A Set of is
and isNot
functions in JavaScript checking and testing on objects and types
$ yarn add is-or-not
or
$ npm install is-or-not
const utils = require("is-or-not");
utils.isNull(null); // type is null => true
utils.isNull(undefined); // type is undefined => false
utils.isNotNull(undefined); // correct it's undefined => true
utils.isNotEmpty(["🦄", "🐶", "🐼"]); // array contain values => true
utils.isNotEmpty([]); // array is empty => false
/** ... */
utils.isString("Hello World!"); // Type is String => true
utils.isNotString(["🐶", "🦄"]); // true because type is array => true
/** ... */
utils.isPrimitive("Primitive type?"); // String is a Primitive type => true
utils.isNotPrimitive("Not primitive type?"); // False because it's a string, primitive => false
/** ... */
utils.isNullOrUndefined("Hello!"); // String is not null or undefined => false
utils.isNullOrUndefined(undefined); // => true
utils.isNotNullOrUndefined("Not primitive type?"); // true it's a string => true
utils.isNotNullOrUndefined(null); // it is null => false
.
.
.
- isArray
- isBoolean
- isDate
- isEmpty
- isError
- isFunction
- isNotArray
- isNotBoolean
- isNotDate
- isNotEmpty
- isNotError
- isNotFunction
- isNotNull
- isNotNullOrUndefined
- isNotNumber
- isNotObject
- isNotPrimitive
- isNotRegExp
- isNotString
- isNotSymbol
- isNotUndefined
- isNull
- isNullOrUndefined
- isNumber
- isObject
- isPrimitive
- isRegExp
- isString
- isSymbol
- isUndefined
Clone the Github Repository
$ git clone [email protected]:AlaeddineMessadi/utils-is.git
All functions' implementations are in the index.js
file.
Tests are defined in the test.js
file
$ yarn test
// or
$ yarn test:watch
or with npm
$ npm run test
or
$ npm run test:watch