From 20bc7331ad7af4382e4fe6f7d86658607588643e Mon Sep 17 00:00:00 2001 From: glhrmv Date: Sat, 23 Sep 2017 16:19:02 +0100 Subject: [PATCH] Rename to inRange and reuse the Math module --- index.js | 2 +- test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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)); });