Fallback when a value is not Object.
Via NPM:
npm install obvl
Via Yarn:
yarn add obvl
const obvl = require('obvl');
// When a value is not Object, it will return fallback value.
let a = obvl(null, 0); // a = 0
let b = obvl([1, 2, 3], 'x'); // b = 'x'
// When a value is Object, it will return that value.
let c = obvl({ a: 1, b: 2, c: 3 }, 1); // c = { a: 1, b: 2, c: 3 }
let d = obvl(new Object(), [1, 2, 3]); // d = Object { }
A main value.
A fallback value.