Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Always Array

Build Status bundle size install size npm version

Ensures you are always dealing with an array. It uses Array.isArray.

Installation

yarn add always-array
# or with npm
npm i always-array

Usage

Very simple.

import alwaysArray from 'always-array';

alwaysArray('foo'); // ['foo']
alwaysArray(['foo']); // ['foo']

const set = new Set([1, 2, 3]);
alwaysArray(set); // [ Set { 1, 2, 3 } ]
alwaysArray.convertIterables(set); // [1, 2, 3]
alwaysArray.convertIterables('foo'); // ['foo'] - albeit being an iterable, strings won't be spread into an array

About

Ensures you are always dealing with an array.

Resources

License

Stars

Watchers

Forks

Packages

No packages published