arrvl
v1.0.0
Published
Fallback when a value is not Array.
Downloads
19
Maintainers
Readme
ARRVL
Fallback when a value is not Array.
Installation
Via NPM:
npm install arrvl
Via Yarn:
yarn add arrvl
Usage
const arrvl = require('arrvl');
// When a value is not Array, it will return fallback value.
let a = arrvl(null, 0); // a = 0
let b = arrvl({}, 'x'); // b = 'x'
// When a value is Array, it will return that value.
let c = arrvl([], 1); // c = []
let d = arrvl([1, 2, 3], 'abc'); // d = [1, 2, 3]
API
arrvl(value, fallbackValue)
value
A main value.
fallbackValue
A fallback value.