youtube.com/watch?v=9i2eZaJsC7g
JavaScript Utilities
> npm install chitu --save
> yarn add chitu
Chitu exports 3 module types:
dist/chitu.min.js
)dist/chitu.js
)dist/chitu.es.js
)A module to check the type of a given value.
import { type } from 'chitu';
type.isArray(['foo', 'bar']); // = true
type.isObject({ foo: 'bar' }); // = true
type.isString('foo'); // = true
type.isDate(new Date()); // = true
type.isRegExp(/foo/g); // = true
type.isFunction(function () {}); // = true
type.isBoolean(false); // = true
type.isNumber(123); // = true
type.isError(new Error()); // = true
type.isNull(null); // = true
type.isUndefined(void 0); // = true
// or for anything else
type.is('Symbol', Symbol('foo')); // = true
type.is('Map', new Map([])); // = true
type.is('Set', new Set([])); // = true
// etc
Check if the value is a function and execute it (with provided parameters) or simply return the value.
import { value } from 'chitu';
const foo = (a, b, c) => a * b * c;
const bar = ['baz'];
const fooVal = value(foo, 2, 2, 2); // = 8
const barVal = value(bar); // = ['baz']
Round a number to a given number of decimal places.
import { round } from 'chitu';
round(123.456); // = 123.46
round(1, 2); // = 1.00
round(1.937); // = 1.94
// etc
Return the ordinal value for a given number.
import { ordinal } from 'chitu';
ordinal(1) // = '1st'
ordinal(2) // = '2nd'
ordinal(3) // = '3rd'
ordinal(4) // = '4th'
ordinal(12) // = '12th'
ordinal(101) // = '101st'
// etc
Generated using TypeDoc