Skip to content

A JavaScript/Typescript library for fast type checking. Check if a given value is a string, number, object, ...

License

Notifications You must be signed in to change notification settings

WireCore/wirecheck

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

A JavaScript/Typescript library for fast type checking. Check if a given value is a string, number, object, ...

Resources

License

Stars

Watchers

Forks

Packages

No packages published