npm.io
1.0.0 • Published 8 years ago

iterify

Licence
MIT
Version
1.0.0
Deps
3
Size
2 kB
Vulns
0
Weekly
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, returns x as-is.
  • If x is undefined or null, 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) // []

Keywords