ensure-type
v1.5.1
Published
Ensure runtime type safety and perform type coercion if needed.
Downloads
362,016
Maintainers
Readme
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