diff --git a/index.js b/index.js index ee3d6a8..330d91d 100644 --- a/index.js +++ b/index.js @@ -148,6 +148,6 @@ const typedArrayTypes = new Set([ ]); is.typedArray = x => typedArrayTypes.has(getObjectType(x)); -is.withinRange = (x, [min, max]) => x >= min && x <= max; +is.inRange = (x, arr) => is.array(arr) && (x >= Math.min.apply(Math, arr)) && (x <= Math.max.apply(Math, arr)); module.exports = is; diff --git a/test.js b/test.js index 99917ba..5aa34a5 100644 --- a/test.js +++ b/test.js @@ -294,9 +294,9 @@ test('is.typedArray', t => { t.false(m.typedArray({})); }); -test('is.withinRange', t => { +test('is.inRange', t => { const x = 3; const arr = [0, 5]; - t.true(m.withinRange(x, arr)); + t.true(m.inRange(x, arr)); });