Skip to content
This repository was archived by the owner on Aug 12, 2022. It is now read-only.

EvanHahn/arraywrap.js

Repository files navigation

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).

Packages

No packages published

Contributors 2

  •  
  •