1.0.1 • Published 2 years ago

type-utils-js v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

type-utils-js

Type-utils-js is an npm package providing type checking helpers for javascript.

Table Of Content

Installation

Install with npm

  npm install type-utils-js

Usage/Examples

isString

const { isString } = require('type-utils-js');

isString('Hello World'); // -> true
isString(String('Hello World')); // -> true

isNumber

const { isNumber } = require('type-utils-js');

isNumber(123); // -> true
isNumber(Number(123)); // -> true

isBoolean

const { isBoolean } = require('type-utils-js');

isBoolean(true); // -> true
isBoolean(Boolean(1)); // -> true

isNull

const { isNull } = require('type-utils-js');

isNull(null); // -> true

isUndefined

const { isUndefined } = require('type-utils-js');

isUndefined(undefined); // -> true

isObject

const { isObject } = require('type-utils-js');

isObject({ foo: true }); // -> true
isObject(new Object()); // -> true

isFunction

const { isFunction } = require('type-utils-js');

isFunction(() => { console.log('Function'); }); // -> true

isArray

const { isArray } = require('type-utils-js');

isArray(['foo', 'bar', 'baz']); // -> true
isArray(Array('foo', 'bar', 'baz')); // -> true
isArray(Array(6)); // -> true

isDate

const { isDate } = require('type-utils-js');

isDate(new Date()); // -> true
isDate(new Date('10/01/2022')); // -> true
isDate(new Date(2022, 2, 29)); // -> true

Running Tests

To run tests, run the following command

  npm run test:unit

Authors

License

MIT

Tech Stack

  • JavaScript
  • Mocha
  • Chai
  • Eslint

Support

For support, email mohamed.rouabehi.code@gmail.com

Feedback

If you have any feedback, please reach out to us at mohamed.rouabehi.code@gmail.com