sjwilliams / bestfitwidth

Given an array of widths, find the closest fit for a given number.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bestfitwidth

Useful for determining best image widths in responsive applications, for node or the browser.

Given a width integer and an array of possible values, like pre-cut image file widths, find the best fit, opting for a larger file over smaller one.

Install

npm install bestfitwidth

Useage

var bestFitWidth = require('bestfitwidth');
console.log(bestFitWidth(500, [320, 600, 900, 1200])))
// 600

About

Given an array of widths, find the closest fit for a given number.

License:MIT License


Languages

Language:JavaScript 100.0%