Simple and useful utility extensions for Lodash.
npm install @outofsync/lodash-ex
lodash-ex replaces and extends lodash, so it only the lodash-ex module needs to be included in your code:
const _ = require('@outofsync/lodash-ex');
const data = { a: 'a', b: 'b' };
// Use lodash as you normally would
console.log(_.pick(data, ['a']);
Tests if the value provided is null
or undefined
_.isUnset(null);
_.isUnset(undefined);
_.isUnset(false);
Results:
true
true
false
Tests if the value provided is not null
or undefined
_.hasValue(null);
_.hasValue(undefined);
_.hasValue(false);
Results:
false
false
true
Test the logic imply operation a => b, providing the following truth table:
A | B | Result |
---|---|---|
T | T | T |
T | F | F |
F | T | T |
F | F | T |
Coerces the value
provided to a boolean value.
_.bool(false);
_.bool(0);
_.bool(0.0);
_.bool('');
_.bool(null);
_.bool(undefined);
_.bool(true);
_.bool(1);
_.bool(3.14);
_.bool('abcd');
_.bool([]);
_.bool({});
_.bool(() => {}));
Results:
false
false
false
false
false
false
true
true
true
true
true
true
true
Copyright (c) 2018,2019 Out of Sync Studios LLC -- Licensed under the MIT license.