wirecheck
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Bootstrap logo

WireCheck

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.

/wirecheck/

    Package Sidebar

    Install

    npm i wirecheck

    Weekly Downloads

    0

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    18.3 kB

    Total Files

    6

    Last publish

    Collaborators

    • dgrosch