is-all-utils
v1.0.7
Published
Is utils functions for validate !
Downloads
825
Readme
Is all utils, +32 functions
Some functions to validate the type, and they are very light; take a look at the documentation!
Installation
npm install --save is-all-utils
# Or
yarn add is-all-utils
Usage
For import with typescript
or ES6+
import { isNil /* ...more functions */ } from 'is-all-utils';
For import with javascript standar or ES5-
const is = require('is-all-utils');
// Use with javascript standar
is.isNil;
// Number
isNumber(546); //=> true
isNumber(76.945); //=> true
isNumber(Number); //=> false
isNumber(Number(7)); //=> true
isNumber(new Date().getTime()); //=> true
isInteger(654); //=> true
isInteger(654.645); //=> false
isFloat(546); //=> false
isFloat(546.9465); //=> true
isFloat(546.0); //=> false
// Object
isObj({}); //=> true
isObj([]); //=> true
isObj(Array(7, 18)); //=> true
isObject([]); //=> false
isObject({}); //=> true
isObject(Object); //=> false
isArray({}); //=> false
isArray([]); //=> true
isArray(Array); //=> false
isArray(Array(7, 18)); //=> true
isString('Hello World !'); //=> true
isString(String('Hello World !')); //=> true
isString(String); //=> false
isRegExp(/7/g); //=> true
isRegExp(RegExp('7', 'g')); //=> true
isRegExp(RegExp); //=> false
isBoolean(true); //=> true
isBoolean(false); //=> true
isBoolean(1); //=> false
isBoolean(Boolean(1)); //=> true
isBool(true); //=> true
isBool(1); //=> true
isBool(0); //=> true
isBool(false); //=> true
// Map
isMap(new Map()); //=> true
isMap(Map); //=> false
isMap(new Map(Object.entries({ twitter: '@yonycalsin' }))); //=> true
// WeakMap
isWeakMap(new WeakMap()); //=> true
isWeakMap(new Map()); //=> false
// Set
isSet(new Set()); //=> true
isSet(Set); //=> false
// WeakSet
isWeakSet(new WeakSet()); //=> true
isWeakSet(new Map()); //=> false
isWeakSet(new Set()); //=> false
// Undefined
isUndefined(undefined); //=> true
isUndefined(null); //=> false
isNull(undefined); //=> false
isNull(null); //=> true
isNil(undefined); //=> true
isNil(null); //=> true
// Function
isFunction(() => {}); //=> true
isFunction(class {}); //=> true
isFunction(async () => {}); //=> false
isFunction(Function); //=> true
isAsyncFunction(async () => {}); //=> true
isAsyncFunction(() => {}); //=> false
isFn(() => {}); //=> true
isFn(async () => {}); //=> true
isFn(class {}); //=> true
isFn(Number); //=> true
isFn(Number); //=> true
isFn(Function); //=> true
isClass(class {}); //=> true
isClass(() => {}); //=> false
isSymbol(Symbol()); //=> true
isSymbol(class {}); //=> false
isSymbol(Symbol); //=> false
// Error, Date
isError(new Error('Hi, Error ❓')); //=> true
isError(Error); //=> false
isDate(new Date()); //=> true
isDate(new Date().getTime()); //=> false
isDate(Date); //=> false
isPromise(new Promise(() => {})); //=> true
isPromise(async () => {}); //=> false
isPromise((async () => {})()); //=> true
isPromise(Promise); //=> false
⭐ Support for
is-all-utils
is an open source project licensed by MIT. You can grow thanks to the sponsors and the support of the amazing sponsors. If you want to join them, contact me here.
🎩 Stay in touch
- Github @yonycalsin
- Twitter @yonycalsin
- Instagram @yony_calsin
- Medium @yonycalsin
- Dev @yonycalsin
Contributors
Thanks to the wonderful people who collaborate with me !
📜 License
is-all-utils
under License MIT.