always-array
v1.1.0
Published
[![Build Status](https://travis-ci.com/krmax44/always-array.svg?branch=master)](https://travis-ci.com/krmax44/always-array) [![bundle size](https://img.shields.io/bundlephobia/minzip/always-array)](https://bundlephobia.com/result?p=always-array) [![instal
Downloads
865
Readme
Always Array
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