Skip to content
/ is Public
generated from fiquu/template

Small value check library for Node.

License

Notifications You must be signed in to change notification settings

fiquu/is

Repository files navigation

@fiquu/is

Build Status GitHub GitHub last commit npm (scoped) npm

Functional, dependency-free check library for Node.js and the browser (transpiled).

Installation

npm i @fiquu/is

Usage

Import by category:

import { isString, isNumber } from '@fiquu/is/type';
import { isIntlPhone } from '@fiquu/is/regexp';

isString('foo'); // true
isString(2); // false

isNumber(1); // true
isNumber('1'); // false

intlPhone('+12015556677'); // true
intlPhone('1234'); // false

Or just what you need:

import { isIntlPhone } from '@fiquu/is/regexp/intl-phone';
import { isString } from '@fiquu/is/type/string';
import { isNumber } from '@fiquu/is/type/number';

isString('foo'); // true
isSstring(2); // false

isNumber(1); // true
isNumber('1'); // false

isIntlPhone('+12015556677'); // true
isIntlPhone('1234'); // false

Multiple Values

If you need to check multiple values, then use the some and every array methods:

import { isString, isNumber } from '@fiquu/is/type';

['foo', 'bar'].every(isString); // true
[1, 2, 'baz'].every(isString); // false

[1, 2, 3, 4].every(isNumber); // true
[1, 2, 'foo'].every(isNumber); // false

['foo', 'bar', true].some(isString); // true
[1, 2, 'baz'].some(isString); // false

[1, null, '3'].some(isNumber); // true
[false, null, 'foo'].some(isNumber); // false

Documentation

Please see the documentation page for more details.