Skip to content

Converts the input into an array or returns it if it is already an array.

License

Notifications You must be signed in to change notification settings

Jaid/sure-array

Repository files navigation

sure-array

License Sponsor sure-array
Build status Commits since v1.0.0 Last commit Issues
Latest version on npm Dependents Downloads

Converts the input into an array or returns it if it is already an array.

Installation

sure-array on npm

npm install --save sure-array@^1.0.0

sure-array on Yarn

yarn add sure-array@^1.0.0

@jaid/sure-array on GitHub Packages
(if configured properly)

npm install --save @jaid/sure-array@^1.0.0

Example

import sureArray from "sure-array"

const result = sureArray(123)
const result2 = sureArray([123])
const result3 = sureArray()
const result4 = sureArray(undefined)
const result5 = sureArray(null)
const result6 = sureArray([[123]])

Variable result will be:

[123]

Variable result2 will be:

[123]

Variable result3 will be:

[]

Variable result4 will be:

[]

Variable result5 will be:

[null]

Variable result6 will be:

[[123]]

Development

Setting up:

git clone git@github.com:jaid/sure-array.git
cd sure-array
npm install

Testing:

npm run test:dev

Testing in production environment:

npm run test

License

MIT License
Copyright © 2020, Jaid <jaid.jsx@gmail.com> (https://github.com/jaid)