New functionality we want to add to dusty.js (This list is subject to grow)
All Examples are concepts of use for the function
import is from 'dusty-fns/is';
is(String, 'test'); // => true
is(Number, 10); // => true
is(Array, []); // => true
is(Object, {}); // => true
is(Function, function test(a) { return a; }); // => true
is(RegExp, /[0-9]/g); // => true
is(String, new String()); // => true
is(Object, new String()); // => true
import prepend from 'dusty-fns/prepend';
console.log(prepend(10, [11, 12, 13, 14]); // => [10, 11, 12, 13, 14]
import partition from 'dusty-fns/partition';
partition(({val}) => val === 1, [{ val: 1 }, { val: 2 }]);
// => [{ val: 1}] [{ val: 2 }]
import reject from 'dusty-fns/reject';
reject(num => num % 2 == 0, [1, 2, 3, 4, 5, 6]); // => [1, 3, 5]
reject(num => num % 2 == 0, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
import defaults from 'dusty-fns/defaults';
const data = { thing: 4 };
defaults({ test: 1, thing: 2 }, data); // => { test: 1, thing: 4 }
import juxt from 'dusty-fns/juxt';
const getRange = juxt([Math.min, Math.max]);
getRange(3, 4, 9, -3); // =>[-3, 9]
import contains from 'dusty-fns/contains';
contains(3, [1, 2, 3]); // => true
contains({ val: 1 }, [{ val: 2 }, { val: 1 }]); // => true
import filter from 'dusty-fns/filter';
const isEven = n => n % 2 === 0;
filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
import complement from 'dusty-fns/complement';
import isNull from 'dusty-fns/isNull';
const reverseNull = complement(isNull);
isNull(null); // => true
reverseNull(null); // => false
import pluck from 'dusty-fns/pluck';
pluck('a', [{ a: 1 }, { b: 2 }]); // => { a: 1 }
pluck(0, [[1, 2], [3, 4]]); // => [1, 3]
import prop from 'dusty-fns/prop';
prop('thing', {thing: 'test'}); //=> 'test'
prop('thing', {}); //=> undefined
import every from 'dusty-fns/every';
every(is(String), ['test', 'foo', 'bar']); //=> true
every(is(String), ['test', 1, 2, 'bar']); //=> false
import any from 'dusty-fns/any';
any(is(String), ['test', 'foo', 'bar']); //=> true
any(is(String), ['test', 1, 2, 'bar']); //=> true
import min from 'dusty-fns/min';
import __ from 'dusty-fns/__';
const sqr = n => n * n;
min([-1, -3, 1, 3, 4]); //=> 1
min([0, 1, 2, 3]); //=> 0
min(['a', 'b']); // => 'a'
import max from 'dusty-fns/max';
import __ from 'dusty-fns/__';
const sqr = n => n * n;
max([-1, -3, 1, 3, 4]); //=> 1
max([0, 1, 2, 3]); //=> 3
max(['a', 'b']); // => 'b'
import map from 'dusty-fns/map';
const sqr = n => n * n;
map(sqr, [-1, -3, 1, 3, 4]); //=> [1, 9, 1, 9, 16]