arraywrap
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

arraywrap.js

If it's not an array, make it one:

const arraywrap = require("arraywrap");

arraywrap(123); // => [123]
arraywrap("yo"); // => ['yo']
arraywrap(null); // => [null]
arraywrap(undefined); // => [undefined]
arraywrap(); // => []

If it's already an array, do nothing:

arraywrap([1, 2, 3]); // => [1, 2, 3]
arraywrap([]); // => []

const arr = [1, 2];
arrayWrap(arr) === arr; // true

This supports environments that don't have Array.isArray (like IE8 and below).

/arraywrap/

    Package Sidebar

    Install

    npm i arraywrap

    Weekly Downloads

    1,968

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    2.94 kB

    Total Files

    5

    Last publish

    Collaborators

    • evanhahn