iterify

1.0.0 • Public • Published

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

/iterify/

    Package Sidebar

    Install

    npm i iterify

    Weekly Downloads

    2

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    2.55 kB

    Total Files

    4

    Last publish

    Collaborators

    • lamansky