1.0.0 • Published 6 years ago
iterify v1.0.0
iterify
Makes a value iterable if it isn’t already.
Installation
Requires Node.js 4.0.0 or above.
npm i iterify
API
The module exports a single function.
Parameter
Bindable: x
(any): The value to make iterable.
Return Values
- If
x
is iterable, returnsx
as-is. - If
x
isundefined
ornull
, returns an empty array. - Otherwise, returns a one-element array containing
x
.
Example
const iterify = require('iterify')
iterify([123]) // [123]
iterify(123) // [123]
iterify(null) // []
1.0.0
6 years ago