wirecheck
v1.1.0
Published
A JavaScript/Typescript library for fast type checking. Check if a given value is a string, number, object, ...
Downloads
4
Maintainers
Readme
Fast and easy JavaScript type checking for Strings, Numbers, Objects and Arrays.
Install
Install with npm:
$ npm install --save wirecheck
Usage
isString
import { isString } from 'wirecheck';
// True
isString('');
isString('hello');
isString(`number ${1}`);
isString([1, 2, 3].join('-'));
// False
isString(1);
isString(null);
isString(undefined);
isString(true);
isNumber
import { isNumber } from 'wirecheck';
// True
isNumber(1);
isNumber(1.1);
isNumber(0x88ffff);
isNumber('-10');
// False
isNumber(true);
isNumber(Infinity);
isNumber('hello');
isNumber([1, 2, 4]);
isObject
import { isObject } from 'wirecheck';
// True
isObject({});
isObject({ hello: 'world' });
isObject('{"array":[1,2,3]}');
isObject('{"nested":{"nestedChild":{"hello":"world"}}}');
// False
isObject(1);
isObject(null);
isObject('{"hello":"world"}}');
isObject([1, 2, 4]);
isArray
import { isArray } from 'wirecheck';
// True
isArray([]);
isArray([1, 2, 3]);
isArray([undefined, null, undefined]);
isArray([[[[[]], [[]]], [[[], [[[[[[], [[[]]]]]]]]]]]]);
// False
isArray(1);
isArray(null);
isArray({ hello: 'world' });
isArray('[[]');
Contributing
Issues, Pull Requests and Stars are welcome. For feature requests or bugs please open a new issue
License
Copyright © 2022, WireCore. Released under the MIT License.