ensure-type
Ensure runtime type safety and perform type coercion if needed.
Install
$ npm install --save ensure-type
Usage
import { ensureArray } from 'ensure-type';
ensureArray(null);
//=> []
ensureArray('apple');
//=> ['apple']
ensureArray(['apple', 'banana']);
//=> ['apple', 'banana']
API
Array
BigInt
Boolean
Function
Number
ensureNumber
ensureNegativeNumber
ensurePositiveNumber
ensureFiniteNumber
ensureNegativeFiniteNumber
ensurePositiveFiniteNumber
ensureInteger
ensureNegativeInteger
ensurePositiveInteger
ensureNonNegativeInteger
ensureNonPositiveInteger
Object
String
License
MIT