Skip to content

AlaeddineMessadi/is-or-not

Repository files navigation

IsOrNot

Build Status

Description

github

documentation

A Set of is and isNot functions in JavaScript checking and testing on objects and types

Install

$ yarn add is-or-not

or

$ npm install is-or-not

Usage

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

.
.
.

Documentation

documentation

Contribution

Clone the Github Repository

$ git clone git@github.com:AlaeddineMessadi/utils-is.git

All functions' implementations are in the index.js file.

Tests are defined in the test.js file

Running tests

$ yarn test
// or
$ yarn test:watch

or with npm

$ npm run test
or
$ npm run test:watch