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

1.1.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i always-array

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

4.71 kB

Total Files

7

Last publish

Collaborators

  • krmax44