arrify
- Version 3.0.0
- Published
- 3.5 kB
- No dependencies
- MIT license
Install
npm i arrify
yarn add arrify
pnpm add arrify
Overview
Convert a value to an array
Index
Functions
Functions
function arrify
arrify: <ValueType>( value: ValueType) => ValueType extends null ? [] : ValueType extends string ? [string] : ValueType extends readonly unknown[] ? ValueType : ValueType extends Iterable<infer T> ? T[] : [ValueType];
Convert a value to an array.
_Specifying
null
orundefined
results in an empty array._Example 1
import arrify from 'arrify';arrify('🦄');//=> ['🦄']arrify(['🦄']);//=> ['🦄']arrify(new Set(['🦄']));//=> ['🦄']arrify(null);//=> []arrify(undefined);//=> []
Package Files (1)
Dependencies (0)
No dependencies.
Dev Dependencies (3)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/arrify
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/arrify)
- HTML<a href="https://www.jsdocs.io/package/arrify"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1878 ms. - Missing or incorrect documentation? Open an issue for this package.