Don't import util

We don't really need its full power. Not worth the bloat.
This commit is contained in:
Sindre Sorhus 2018-09-28 13:30:19 +07:00
parent 6e07df5896
commit 45c976071a
4 changed files with 6 additions and 7 deletions

3
.gitattributes vendored
View file

@ -1,2 +1 @@
* text=auto
*.js text eol=lf
* text=auto eol=lf

View file

@ -1,4 +1,5 @@
language: node_js
node_js:
- '10'
- '8'
- '6'

View file

@ -184,7 +184,7 @@ Returns `true` if the value is an `Array` and the `.length` is more than 0.
##### .emptyObject(value)
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
Returns `true` if the value is an `Object` and `Object.keys(value).length` is 0.
Please note that `Object.keys` returns only own enumerable properties. Hence something like this can happen:
@ -202,7 +202,7 @@ is.emptyObject(object1);
// => true
```
##### .nonEmptyObject(value)
##### .nonEmptyObject(value)
Returns `true` if the value is an `Object` and `Object.keys(value).length` is more than 0.

View file

@ -2,7 +2,6 @@
/// <reference lib="es2017.sharedmemory"/>
/// <reference lib="esnext.asynciterable"/>
/// <reference lib="dom"/>
import util from 'util';
import symbolObservable from 'symbol-observable';
type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array;
@ -245,7 +244,7 @@ namespace is { // tslint:disable-line:no-namespace
return value >= Math.min(...range) && value <= Math.max(...range);
}
throw new TypeError(`Invalid range: ${util.inspect(range)}`);
throw new TypeError(`Invalid range: ${JSON.stringify(range)}`);
};
const NODE_TYPE_ELEMENT = 1;
@ -290,7 +289,7 @@ namespace is { // tslint:disable-line:no-namespace
type ArrayMethod = (fn: (value: any, index: number, array: any[]) => boolean, thisArg?: any) => boolean;
const predicateOnArray = (method: ArrayMethod, predicate: any, values: any[]) => {
if (function_(predicate) === false) {
throw new TypeError(`Invalid predicate: ${util.inspect(predicate)}`);
throw new TypeError(`Invalid predicate: ${JSON.stringify(predicate)}`);
}
if (values.length === 0) {