1.0.0 • Published 6 years ago

iterify v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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) // []