From 906b58cacd11eb57e97937ad091171bbd07f627f Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Sat, 12 Jan 2019 12:23:17 +0700 Subject: [PATCH] Remove byte-range dependency and hard-code ranges --- package.json | 4 +--- source/lib/predicates/number.ts | 8 +++++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index b7eb742..a3d06e0 100644 --- a/package.json +++ b/package.json @@ -83,7 +83,5 @@ "dist/test" ] }, - "dependencies": { - "byte-range": "^1.0.0" - } + "dependencies": {} } diff --git a/source/lib/predicates/number.ts b/source/lib/predicates/number.ts index 3833375..3c4bf25 100644 --- a/source/lib/predicates/number.ts +++ b/source/lib/predicates/number.ts @@ -1,5 +1,4 @@ import is from '@sindresorhus/is'; -import byteRange from 'byte-range'; import {Predicate, Context} from './predicate'; export class NumberPredicate extends Predicate { @@ -147,9 +146,12 @@ export class NumberPredicate extends Predicate { * Test a number to be in a valid range for a uint8. */ get uint8() { + const start = 0; + const end = 255; + return this.addValidator({ - message: (value, label) => `Expected ${label} to be an integer in range [${byteRange.uint8[0]}..${byteRange.uint8[1]}], got ${value}`, - validator: value => is.integer(value) && is.inRange(value, [byteRange.uint8[0], byteRange.uint8[1]]) + message: (value, label) => `Expected ${label} to be an integer in range [${start}..${end}], got ${value}`, + validator: value => is.integer(value) && is.inRange(value, [start, end]) }); } }