We are lazy, also lazy-cached and browserify-ready - just arrayify, falsey values returns empty array. In bonus with
.isArray
method.
npm i lazy-arrayify --save
For more use-cases see the tests
const lazyArrayify = require('lazy-arrayify')
Check if value is array using the isarray module.
Params
val
{Mixed}returns
{Boolean}
Example
var isArray = require('lazy-arrayify').isArray
console.log(isArray(1234)) // => false
console.log(isArray('str')) // => false
console.log(isArray(null)) // => false
console.log(isArray()) // => false
console.log(isArray(0)) // => false
console.log(isArray(false)) // => false
console.log(isArray([null, 123])) // => true
console.log(isArray([null])) // => true
console.log(isArray([false])) // => true
Returns empty array on falsey values.
Params
val
{Mixed}returns
{Array}
Example
var arrayify = require('lazy-arrayify').arrayify
console.log(arrayify(1234)) // => [1234]
console.log(arrayify('str')) // => ['str']
console.log(arrayify(null)) // => []
console.log(arrayify()) // => []
console.log(arrayify(0)) // => []
console.log(arrayify(false)) // => []
console.log(arrayify([null, 123])) // => [null, 123]
console.log(arrayify([false])) // => [false]
- arrify: Convert a value to an array | homepage
- isarray: Array#isArray for older browsers | homepage
- lazy-utils: Most of the used mostly everywhere utils: extend-shallow, isobject, is-extendable (used in… more | homepage
- limon: The pluggable JavaScript lexer on per character basis. | homepage
- limon-prev-next: Plugin for limon pluggable lexer that adds
prev
andnext
methods. | homepage - postjson: Transforming JSON with plugins. | homepage
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.