Initial commit - full huishou project

This commit is contained in:
jiapengyu
2026-07-27 14:07:26 +08:00
commit 60790ad1b3
39127 changed files with 5989265 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
var always = /*#__PURE__*/require('./always');
/**
* A function that always returns `false`. Any passed in parameters are ignored.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Function
* @sig * -> Boolean
* @param {*}
* @return {Boolean}
* @see R.always, R.T
* @example
*
* R.F(); //=> false
*/
var F = /*#__PURE__*/always(false);
module.exports = F;
+21
View File
@@ -0,0 +1,21 @@
var always = /*#__PURE__*/require('./always');
/**
* A function that always returns `true`. Any passed in parameters are ignored.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Function
* @sig * -> Boolean
* @param {*}
* @return {Boolean}
* @see R.always, R.F
* @example
*
* R.T(); //=> true
*/
var T = /*#__PURE__*/always(true);
module.exports = T;
+27
View File
@@ -0,0 +1,27 @@
/**
* A special placeholder value used to specify "gaps" within curried functions,
* allowing partial application of any combination of arguments, regardless of
* their positions.
*
* If `g` is a curried ternary function and `_` is `R.__`, the following are
* equivalent:
*
* - `g(1, 2, 3)`
* - `g(_, 2, 3)(1)`
* - `g(_, _, 3)(1)(2)`
* - `g(_, _, 3)(1, 2)`
* - `g(_, 2, _)(1, 3)`
* - `g(_, 2)(1)(3)`
* - `g(_, 2)(1, 3)`
* - `g(_, 2)(_, 3)(1)`
*
* @constant
* @memberOf R
* @since v0.6.0
* @category Function
* @example
*
* var greet = R.replace('{name}', R.__, 'Hello, {name}!');
* greet('Alice'); //=> 'Hello, Alice!'
*/
module.exports = { '@@functional/placeholder': true };
+25
View File
@@ -0,0 +1,25 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Adds two values.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Math
* @sig Number -> Number -> Number
* @param {Number} a
* @param {Number} b
* @return {Number}
* @see R.subtract
* @example
*
* R.add(2, 3); //=> 5
* R.add(7)(10); //=> 17
*/
var add = /*#__PURE__*/_curry2(function add(a, b) {
return Number(a) + Number(b);
});
module.exports = add;
+47
View File
@@ -0,0 +1,47 @@
var _concat = /*#__PURE__*/require('./internal/_concat');
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var curryN = /*#__PURE__*/require('./curryN');
/**
* Creates a new list iteration function from an existing one by adding two new
* parameters to its callback function: the current index, and the entire list.
*
* This would turn, for instance, [`R.map`](#map) function into one that
* more closely resembles `Array.prototype.map`. Note that this will only work
* for functions in which the iteration callback function is the first
* parameter, and where the list is the last parameter. (This latter might be
* unimportant if the list parameter is not used.)
*
* @func
* @memberOf R
* @since v0.15.0
* @category Function
* @category List
* @sig ((a ... -> b) ... -> [a] -> *) -> (a ..., Int, [a] -> b) ... -> [a] -> *)
* @param {Function} fn A list iteration function that does not pass index or list to its callback
* @return {Function} An altered list iteration function that passes (item, index, list) to its callback
* @example
*
* var mapIndexed = R.addIndex(R.map);
* mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']);
* //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']
*/
var addIndex = /*#__PURE__*/_curry1(function addIndex(fn) {
return curryN(fn.length, function () {
var idx = 0;
var origFn = arguments[0];
var list = arguments[arguments.length - 1];
var args = Array.prototype.slice.call(arguments, 0);
args[0] = function () {
var result = origFn.apply(this, _concat(arguments, [idx, list]));
idx += 1;
return result;
};
return fn.apply(this, args);
});
});
module.exports = addIndex;
+42
View File
@@ -0,0 +1,42 @@
var _concat = /*#__PURE__*/require('./internal/_concat');
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Applies a function to the value at the given index of an array, returning a
* new copy of the array with the element at the given index replaced with the
* result of the function application.
*
* @func
* @memberOf R
* @since v0.14.0
* @category List
* @sig (a -> a) -> Number -> [a] -> [a]
* @param {Function} fn The function to apply.
* @param {Number} idx The index.
* @param {Array|Arguments} list An array-like object whose value
* at the supplied index will be replaced.
* @return {Array} A copy of the supplied array-like object with
* the element at index `idx` replaced with the value
* returned by applying `fn` to the existing element.
* @see R.update
* @example
*
* R.adjust(R.add(10), 1, [1, 2, 3]); //=> [1, 12, 3]
* R.adjust(R.add(10))(1)([1, 2, 3]); //=> [1, 12, 3]
* @symb R.adjust(f, -1, [a, b]) = [a, f(b)]
* @symb R.adjust(f, 0, [a, b]) = [f(a), b]
*/
var adjust = /*#__PURE__*/_curry3(function adjust(fn, idx, list) {
if (idx >= list.length || idx < -list.length) {
return list;
}
var start = idx < 0 ? list.length : 0;
var _idx = start + idx;
var _list = _concat(list);
_list[_idx] = fn(list[_idx]);
return _list;
});
module.exports = adjust;
+43
View File
@@ -0,0 +1,43 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xall = /*#__PURE__*/require('./internal/_xall');
/**
* Returns `true` if all elements of the list match the predicate, `false` if
* there are any that don't.
*
* Dispatches to the `all` method of the second argument, if present.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig (a -> Boolean) -> [a] -> Boolean
* @param {Function} fn The predicate function.
* @param {Array} list The array to consider.
* @return {Boolean} `true` if the predicate is satisfied by every element, `false`
* otherwise.
* @see R.any, R.none, R.transduce
* @example
*
* var equals3 = R.equals(3);
* R.all(equals3)([3, 3, 3, 3]); //=> true
* R.all(equals3)([3, 3, 1, 3]); //=> false
*/
var all = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['all'], _xall, function all(fn, list) {
var idx = 0;
while (idx < list.length) {
if (!fn(list[idx])) {
return false;
}
idx += 1;
}
return true;
}));
module.exports = all;
+51
View File
@@ -0,0 +1,51 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var curryN = /*#__PURE__*/require('./curryN');
var max = /*#__PURE__*/require('./max');
var pluck = /*#__PURE__*/require('./pluck');
var reduce = /*#__PURE__*/require('./reduce');
/**
* Takes a list of predicates and returns a predicate that returns true for a
* given list of arguments if every one of the provided predicates is satisfied
* by those arguments.
*
* The function returned is a curried function whose arity matches that of the
* highest-arity predicate.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Logic
* @sig [(*... -> Boolean)] -> (*... -> Boolean)
* @param {Array} predicates An array of predicates to check
* @return {Function} The combined predicate
* @see R.anyPass
* @example
*
* var isQueen = R.propEq('rank', 'Q');
* var isSpade = R.propEq('suit', '♠︎');
* var isQueenOfSpades = R.allPass([isQueen, isSpade]);
*
* isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false
* isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true
*/
var allPass = /*#__PURE__*/_curry1(function allPass(preds) {
return curryN(reduce(max, 0, pluck('length', preds)), function () {
var idx = 0;
var len = preds.length;
while (idx < len) {
if (!preds[idx].apply(this, arguments)) {
return false;
}
idx += 1;
}
return true;
});
});
module.exports = allPass;
+29
View File
@@ -0,0 +1,29 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
/**
* Returns a function that always returns the given value. Note that for
* non-primitives the value returned is a reference to the original value.
*
* This function is known as `const`, `constant`, or `K` (for K combinator) in
* other languages and libraries.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig a -> (* -> a)
* @param {*} val The value to wrap in a function
* @return {Function} A Function :: * -> val.
* @example
*
* var t = R.always('Tee');
* t(); //=> 'Tee'
*/
var always = /*#__PURE__*/_curry1(function always(val) {
return function () {
return val;
};
});
module.exports = always;
+27
View File
@@ -0,0 +1,27 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns `true` if both arguments are `true`; `false` otherwise.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Logic
* @sig a -> b -> a | b
* @param {Any} a
* @param {Any} b
* @return {Any} the first argument if it is falsy, otherwise the second argument.
* @see R.both
* @example
*
* R.and(true, true); //=> true
* R.and(true, false); //=> false
* R.and(false, true); //=> false
* R.and(false, false); //=> false
*/
var and = /*#__PURE__*/_curry2(function and(a, b) {
return a && b;
});
module.exports = and;
+44
View File
@@ -0,0 +1,44 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xany = /*#__PURE__*/require('./internal/_xany');
/**
* Returns `true` if at least one of elements of the list match the predicate,
* `false` otherwise.
*
* Dispatches to the `any` method of the second argument, if present.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig (a -> Boolean) -> [a] -> Boolean
* @param {Function} fn The predicate function.
* @param {Array} list The array to consider.
* @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
* otherwise.
* @see R.all, R.none, R.transduce
* @example
*
* var lessThan0 = R.flip(R.lt)(0);
* var lessThan2 = R.flip(R.lt)(2);
* R.any(lessThan0)([1, 2]); //=> false
* R.any(lessThan2)([1, 2]); //=> true
*/
var any = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['any'], _xany, function any(fn, list) {
var idx = 0;
while (idx < list.length) {
if (fn(list[idx])) {
return true;
}
idx += 1;
}
return false;
}));
module.exports = any;
+52
View File
@@ -0,0 +1,52 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var curryN = /*#__PURE__*/require('./curryN');
var max = /*#__PURE__*/require('./max');
var pluck = /*#__PURE__*/require('./pluck');
var reduce = /*#__PURE__*/require('./reduce');
/**
* Takes a list of predicates and returns a predicate that returns true for a
* given list of arguments if at least one of the provided predicates is
* satisfied by those arguments.
*
* The function returned is a curried function whose arity matches that of the
* highest-arity predicate.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Logic
* @sig [(*... -> Boolean)] -> (*... -> Boolean)
* @param {Array} predicates An array of predicates to check
* @return {Function} The combined predicate
* @see R.allPass
* @example
*
* var isClub = R.propEq('suit', '♣');
* var isSpade = R.propEq('suit', '♠');
* var isBlackCard = R.anyPass([isClub, isSpade]);
*
* isBlackCard({rank: '10', suit: '♣'}); //=> true
* isBlackCard({rank: 'Q', suit: '♠'}); //=> true
* isBlackCard({rank: 'Q', suit: '♦'}); //=> false
*/
var anyPass = /*#__PURE__*/_curry1(function anyPass(preds) {
return curryN(reduce(max, 0, pluck('length', preds)), function () {
var idx = 0;
var len = preds.length;
while (idx < len) {
if (preds[idx].apply(this, arguments)) {
return true;
}
idx += 1;
}
return false;
});
});
module.exports = anyPass;
+46
View File
@@ -0,0 +1,46 @@
var _concat = /*#__PURE__*/require('./internal/_concat');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _reduce = /*#__PURE__*/require('./internal/_reduce');
var map = /*#__PURE__*/require('./map');
/**
* ap applies a list of functions to a list of values.
*
* Dispatches to the `ap` method of the second argument, if present. Also
* treats curried functions as applicatives.
*
* @func
* @memberOf R
* @since v0.3.0
* @category Function
* @sig [a -> b] -> [a] -> [b]
* @sig Apply f => f (a -> b) -> f a -> f b
* @sig (a -> b -> c) -> (a -> b) -> (a -> c)
* @param {*} applyF
* @param {*} applyX
* @return {*}
* @example
*
* R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6]
* R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"]
*
* // R.ap can also be used as S combinator
* // when only two functions are passed
* R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA'
* @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)]
*/
var ap = /*#__PURE__*/_curry2(function ap(applyF, applyX) {
return typeof applyX['fantasy-land/ap'] === 'function' ? applyX['fantasy-land/ap'](applyF) : typeof applyF.ap === 'function' ? applyF.ap(applyX) : typeof applyF === 'function' ? function (x) {
return applyF(x)(applyX(x));
} :
// else
_reduce(function (acc, f) {
return _concat(acc, map(f, applyX));
}, [], applyF);
});
module.exports = ap;
+33
View File
@@ -0,0 +1,33 @@
var _aperture = /*#__PURE__*/require('./internal/_aperture');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xaperture = /*#__PURE__*/require('./internal/_xaperture');
/**
* Returns a new list, composed of n-tuples of consecutive elements. If `n` is
* greater than the length of the list, an empty list is returned.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.12.0
* @category List
* @sig Number -> [a] -> [[a]]
* @param {Number} n The size of the tuples to create
* @param {Array} list The list to split into `n`-length tuples
* @return {Array} The resulting list of `n`-length tuples
* @see R.transduce
* @example
*
* R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]]
* R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
* R.aperture(7, [1, 2, 3, 4, 5]); //=> []
*/
var aperture = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xaperture, _aperture));
module.exports = aperture;
+30
View File
@@ -0,0 +1,30 @@
var _concat = /*#__PURE__*/require('./internal/_concat');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns a new list containing the contents of the given list, followed by
* the given element.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig a -> [a] -> [a]
* @param {*} el The element to add to the end of the new list.
* @param {Array} list The list of elements to add a new item to.
* list.
* @return {Array} A new list containing the elements of the old list followed by `el`.
* @see R.prepend
* @example
*
* R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests']
* R.append('tests', []); //=> ['tests']
* R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']]
*/
var append = /*#__PURE__*/_curry2(function append(el, list) {
return _concat(list, [el]);
});
module.exports = append;
+28
View File
@@ -0,0 +1,28 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Applies function `fn` to the argument list `args`. This is useful for
* creating a fixed-arity function from a variadic function. `fn` should be a
* bound function if context is significant.
*
* @func
* @memberOf R
* @since v0.7.0
* @category Function
* @sig (*... -> a) -> [*] -> a
* @param {Function} fn The function which will be called with `args`
* @param {Array} args The arguments to call `fn` with
* @return {*} result The result, equivalent to `fn(...args)`
* @see R.call, R.unapply
* @example
*
* var nums = [1, 2, 3, -99, 42, 6, 7];
* R.apply(Math.max, nums); //=> 42
* @symb R.apply(f, [a, b, c]) = f(a, b, c)
*/
var apply = /*#__PURE__*/_curry2(function apply(fn, args) {
return fn.apply(this, args);
});
module.exports = apply;
+55
View File
@@ -0,0 +1,55 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var apply = /*#__PURE__*/require('./apply');
var curryN = /*#__PURE__*/require('./curryN');
var map = /*#__PURE__*/require('./map');
var max = /*#__PURE__*/require('./max');
var pluck = /*#__PURE__*/require('./pluck');
var reduce = /*#__PURE__*/require('./reduce');
var values = /*#__PURE__*/require('./values');
/**
* Given a spec object recursively mapping properties to functions, creates a
* function producing an object of the same structure, by mapping each property
* to the result of calling its associated function with the supplied arguments.
*
* @func
* @memberOf R
* @since v0.20.0
* @category Function
* @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v})
* @param {Object} spec an object recursively mapping properties to functions for
* producing the values for these properties.
* @return {Function} A function that returns an object of the same structure
* as `spec', with each property set to the value returned by calling its
* associated function with the supplied arguments.
* @see R.converge, R.juxt
* @example
*
* var getMetrics = R.applySpec({
* sum: R.add,
* nested: { mul: R.multiply }
* });
* getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }
* @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } }
*/
var applySpec = /*#__PURE__*/_curry1(function applySpec(spec) {
spec = map(function (v) {
return typeof v == 'function' ? v : applySpec(v);
}, spec);
return curryN(reduce(max, 0, pluck('length', values(spec))), function () {
var args = arguments;
return map(function (f) {
return apply(f, args);
}, spec);
});
});
module.exports = applySpec;
+27
View File
@@ -0,0 +1,27 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Takes a value and applies a function to it.
*
* This function is also known as the `thrush` combinator.
*
* @func
* @memberOf R
* @since v0.25.0
* @category Function
* @sig a -> (a -> b) -> b
* @param {*} x The value
* @param {Function} f The function to apply
* @return {*} The result of applying `f` to `x`
* @example
*
* var t42 = R.applyTo(42);
* t42(R.identity); //=> 42
* t42(R.add(1)); //=> 43
*/
var applyTo = /*#__PURE__*/_curry2(function applyTo(x, f) {
return f(x);
});
module.exports = applyTo;
+32
View File
@@ -0,0 +1,32 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Makes an ascending comparator function out of a function that returns a value
* that can be compared with `<` and `>`.
*
* @func
* @memberOf R
* @since v0.23.0
* @category Function
* @sig Ord b => (a -> b) -> a -> a -> Number
* @param {Function} fn A function of arity one that returns a value that can be compared
* @param {*} a The first item to be compared.
* @param {*} b The second item to be compared.
* @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0`
* @see R.descend
* @example
*
* var byAge = R.ascend(R.prop('age'));
* var people = [
* // ...
* ];
* var peopleByYoungestFirst = R.sort(byAge, people);
*/
var ascend = /*#__PURE__*/_curry3(function ascend(fn, a, b) {
var aa = fn(a);
var bb = fn(b);
return aa < bb ? -1 : aa > bb ? 1 : 0;
});
module.exports = ascend;
+33
View File
@@ -0,0 +1,33 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Makes a shallow clone of an object, setting or overriding the specified
* property with the given value. Note that this copies and flattens prototype
* properties onto the new object as well. All non-primitive properties are
* copied by reference.
*
* @func
* @memberOf R
* @since v0.8.0
* @category Object
* @sig String -> a -> {k: v} -> {k: v}
* @param {String} prop The property name to set
* @param {*} val The new value
* @param {Object} obj The object to clone
* @return {Object} A new object equivalent to the original except for the changed property.
* @see R.dissoc
* @example
*
* R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3}
*/
var assoc = /*#__PURE__*/_curry3(function assoc(prop, val, obj) {
var result = {};
for (var p in obj) {
result[p] = obj[p];
}
result[prop] = val;
return result;
});
module.exports = assoc;
+56
View File
@@ -0,0 +1,56 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
var _has = /*#__PURE__*/require('./internal/_has');
var _isArray = /*#__PURE__*/require('./internal/_isArray');
var _isInteger = /*#__PURE__*/require('./internal/_isInteger');
var assoc = /*#__PURE__*/require('./assoc');
var isNil = /*#__PURE__*/require('./isNil');
/**
* Makes a shallow clone of an object, setting or overriding the nodes required
* to create the given path, and placing the specific value at the tail end of
* that path. Note that this copies and flattens prototype properties onto the
* new object as well. All non-primitive properties are copied by reference.
*
* @func
* @memberOf R
* @since v0.8.0
* @category Object
* @typedefn Idx = String | Int
* @sig [Idx] -> a -> {a} -> {a}
* @param {Array} path the path to set
* @param {*} val The new value
* @param {Object} obj The object to clone
* @return {Object} A new object equivalent to the original except along the specified path.
* @see R.dissocPath
* @example
*
* R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}}
*
* // Any missing or non-object keys in path will be overridden
* R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}}
*/
var assocPath = /*#__PURE__*/_curry3(function assocPath(path, val, obj) {
if (path.length === 0) {
return val;
}
var idx = path[0];
if (path.length > 1) {
var nextObj = !isNil(obj) && _has(idx, obj) ? obj[idx] : _isInteger(path[1]) ? [] : {};
val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj);
}
if (_isInteger(idx) && _isArray(obj)) {
var arr = [].concat(obj);
arr[idx] = val;
return arr;
} else {
return assoc(idx, val, obj);
}
});
module.exports = assocPath;
+38
View File
@@ -0,0 +1,38 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var nAry = /*#__PURE__*/require('./nAry');
/**
* Wraps a function of any arity (including nullary) in a function that accepts
* exactly 2 parameters. Any extraneous parameters will not be passed to the
* supplied function.
*
* @func
* @memberOf R
* @since v0.2.0
* @category Function
* @sig (* -> c) -> (a, b -> c)
* @param {Function} fn The function to wrap.
* @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
* arity 2.
* @see R.nAry, R.unary
* @example
*
* var takesThreeArgs = function(a, b, c) {
* return [a, b, c];
* };
* takesThreeArgs.length; //=> 3
* takesThreeArgs(1, 2, 3); //=> [1, 2, 3]
*
* var takesTwoArgs = R.binary(takesThreeArgs);
* takesTwoArgs.length; //=> 2
* // Only 2 arguments are passed to the wrapped function
* takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]
* @symb R.binary(f)(a, b, c) = f(a, b)
*/
var binary = /*#__PURE__*/_curry1(function binary(fn) {
return nAry(2, fn);
});
module.exports = binary;
+34
View File
@@ -0,0 +1,34 @@
var _arity = /*#__PURE__*/require('./internal/_arity');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Creates a function that is bound to a context.
* Note: `R.bind` does not provide the additional argument-binding capabilities of
* [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
*
* @func
* @memberOf R
* @since v0.6.0
* @category Function
* @category Object
* @sig (* -> *) -> {*} -> (* -> *)
* @param {Function} fn The function to bind to context
* @param {Object} thisObj The context to bind `fn` to
* @return {Function} A function that will execute in the context of `thisObj`.
* @see R.partial
* @example
*
* var log = R.bind(console.log, console);
* R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
* // logs {a: 2}
* @symb R.bind(f, o)(a, b) = f.call(o, a, b)
*/
var bind = /*#__PURE__*/_curry2(function bind(fn, thisObj) {
return _arity(fn.length, function () {
return fn.apply(thisObj, arguments);
});
});
module.exports = bind;
+44
View File
@@ -0,0 +1,44 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _isFunction = /*#__PURE__*/require('./internal/_isFunction');
var and = /*#__PURE__*/require('./and');
var lift = /*#__PURE__*/require('./lift');
/**
* A function which calls the two provided functions and returns the `&&`
* of the results.
* It returns the result of the first function if it is false-y and the result
* of the second function otherwise. Note that this is short-circuited,
* meaning that the second function will not be invoked if the first returns a
* false-y value.
*
* In addition to functions, `R.both` also accepts any fantasy-land compatible
* applicative functor.
*
* @func
* @memberOf R
* @since v0.12.0
* @category Logic
* @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
* @param {Function} f A predicate
* @param {Function} g Another predicate
* @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together.
* @see R.and
* @example
*
* var gt10 = R.gt(R.__, 10)
* var lt20 = R.lt(R.__, 20)
* var f = R.both(gt10, lt20);
* f(15); //=> true
* f(30); //=> false
*/
var both = /*#__PURE__*/_curry2(function both(f, g) {
return _isFunction(f) ? function _both() {
return f.apply(this, arguments) && g.apply(this, arguments);
} : lift(and)(f, g);
});
module.exports = both;
+40
View File
@@ -0,0 +1,40 @@
var curry = /*#__PURE__*/require('./curry');
/**
* Returns the result of calling its first argument with the remaining
* arguments. This is occasionally useful as a converging function for
* [`R.converge`](#converge): the first branch can produce a function while the
* remaining branches produce values to be passed to that function as its
* arguments.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Function
* @sig (*... -> a),*... -> a
* @param {Function} fn The function to apply to the remaining arguments.
* @param {...*} args Any number of positional arguments.
* @return {*}
* @see R.apply
* @example
*
* R.call(R.add, 1, 2); //=> 3
*
* var indentN = R.pipe(R.repeat(' '),
* R.join(''),
* R.replace(/^(?!$)/gm));
*
* var format = R.converge(R.call, [
* R.pipe(R.prop('indent'), indentN),
* R.prop('value')
* ]);
*
* format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n'
* @symb R.call(f, a, b) = f(a, b)
*/
var call = /*#__PURE__*/curry(function call(fn) {
return fn.apply(this, Array.prototype.slice.call(arguments, 1));
});
module.exports = call;
+43
View File
@@ -0,0 +1,43 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _makeFlat = /*#__PURE__*/require('./internal/_makeFlat');
var _xchain = /*#__PURE__*/require('./internal/_xchain');
var map = /*#__PURE__*/require('./map');
/**
* `chain` maps a function over a list and concatenates the results. `chain`
* is also known as `flatMap` in some libraries
*
* Dispatches to the `chain` method of the second argument, if present,
* according to the [FantasyLand Chain spec](https://github.com/fantasyland/fantasy-land#chain).
*
* @func
* @memberOf R
* @since v0.3.0
* @category List
* @sig Chain m => (a -> m b) -> m a -> m b
* @param {Function} fn The function to map with
* @param {Array} list The list to map over
* @return {Array} The result of flat-mapping `list` with `fn`
* @example
*
* var duplicate = n => [n, n];
* R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3]
*
* R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1]
*/
var chain = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) {
if (typeof monad === 'function') {
return function (x) {
return fn(monad(x))(x);
};
}
return _makeFlat(false)(map(fn, monad));
}));
module.exports = chain;
+31
View File
@@ -0,0 +1,31 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Restricts a number to be within a range.
*
* Also works for other ordered types such as Strings and Dates.
*
* @func
* @memberOf R
* @since v0.20.0
* @category Relation
* @sig Ord a => a -> a -> a -> a
* @param {Number} minimum The lower limit of the clamp (inclusive)
* @param {Number} maximum The upper limit of the clamp (inclusive)
* @param {Number} value Value to be clamped
* @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise
* @example
*
* R.clamp(1, 10, -5) // => 1
* R.clamp(1, 10, 15) // => 10
* R.clamp(1, 10, 4) // => 4
*/
var clamp = /*#__PURE__*/_curry3(function clamp(min, max, value) {
if (min > max) {
throw new Error('min must not be greater than max in clamp(min, max, value)');
}
return value < min ? min : value > max ? max : value;
});
module.exports = clamp;
+31
View File
@@ -0,0 +1,31 @@
var _clone = /*#__PURE__*/require('./internal/_clone');
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
/**
* Creates a deep copy of the value which may contain (nested) `Array`s and
* `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are
* assigned by reference rather than copied
*
* Dispatches to a `clone` method if present.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Object
* @sig {*} -> {*}
* @param {*} value The object or array to clone
* @return {*} A deeply cloned copy of `val`
* @example
*
* var objects = [{}, {}, {}];
* var objectsClone = R.clone(objects);
* objects === objectsClone; //=> false
* objects[0] === objectsClone[0]; //=> false
*/
var clone = /*#__PURE__*/_curry1(function clone(value) {
return value != null && typeof value.clone === 'function' ? value.clone() : _clone(value, [], [], true);
});
module.exports = clone;
+30
View File
@@ -0,0 +1,30 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
/**
* Makes a comparator function out of a function that reports whether the first
* element is less than the second.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig ((a, b) -> Boolean) -> ((a, b) -> Number)
* @param {Function} pred A predicate function of arity two which will return `true` if the first argument
* is less than the second, `false` otherwise
* @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0`
* @example
*
* var byAge = R.comparator((a, b) => a.age < b.age);
* var people = [
* // ...
* ];
* var peopleByIncreasingAge = R.sort(byAge, people);
*/
var comparator = /*#__PURE__*/_curry1(function comparator(pred) {
return function (a, b) {
return pred(a, b) ? -1 : pred(b, a) ? 1 : 0;
};
});
module.exports = comparator;
+30
View File
@@ -0,0 +1,30 @@
var lift = /*#__PURE__*/require('./lift');
var not = /*#__PURE__*/require('./not');
/**
* Takes a function `f` and returns a function `g` such that if called with the same arguments
* when `f` returns a "truthy" value, `g` returns `false` and when `f` returns a "falsy" value `g` returns `true`.
*
* `R.complement` may be applied to any functor
*
* @func
* @memberOf R
* @since v0.12.0
* @category Logic
* @sig (*... -> *) -> (*... -> Boolean)
* @param {Function} f
* @return {Function}
* @see R.not
* @example
*
* var isNotNil = R.complement(R.isNil);
* isNil(null); //=> true
* isNotNil(null); //=> false
* isNil(7); //=> false
* isNotNil(7); //=> true
*/
var complement = /*#__PURE__*/lift(not);
module.exports = complement;
+37
View File
@@ -0,0 +1,37 @@
var pipe = /*#__PURE__*/require('./pipe');
var reverse = /*#__PURE__*/require('./reverse');
/**
* Performs right-to-left function composition. The rightmost function may have
* any arity; the remaining functions must be unary.
*
* **Note:** The result of compose is not automatically curried.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z)
* @param {...Function} ...functions The functions to compose
* @return {Function}
* @see R.pipe
* @example
*
* var classyGreeting = (firstName, lastName) => "The name's " + lastName + ", " + firstName + " " + lastName
* var yellGreeting = R.compose(R.toUpper, classyGreeting);
* yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND"
*
* R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7
*
* @symb R.compose(f, g, h)(a, b) = f(g(h(a, b)))
*/
function compose() {
if (arguments.length === 0) {
throw new Error('compose requires at least one argument');
}
return pipe.apply(this, reverse(arguments));
}
module.exports = compose;
+47
View File
@@ -0,0 +1,47 @@
var chain = /*#__PURE__*/require('./chain');
var compose = /*#__PURE__*/require('./compose');
var map = /*#__PURE__*/require('./map');
/**
* Returns the right-to-left Kleisli composition of the provided functions,
* each of which must return a value of a type supported by [`chain`](#chain).
*
* `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`.
*
* @func
* @memberOf R
* @since v0.16.0
* @category Function
* @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z)
* @param {...Function} ...functions The functions to compose
* @return {Function}
* @see R.pipeK
* @example
*
* // get :: String -> Object -> Maybe *
* var get = R.curry((propName, obj) => Maybe(obj[propName]))
*
* // getStateCode :: Maybe String -> Maybe String
* var getStateCode = R.composeK(
* R.compose(Maybe.of, R.toUpper),
* get('state'),
* get('address'),
* get('user'),
* );
* getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY")
* getStateCode({}); //=> Maybe.Nothing()
* @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a)))
*/
function composeK() {
if (arguments.length === 0) {
throw new Error('composeK requires at least one argument');
}
var init = Array.prototype.slice.call(arguments);
var last = init.pop();
return compose(compose.apply(this, map(chain, init)), last);
}
module.exports = composeK;
+47
View File
@@ -0,0 +1,47 @@
var pipeP = /*#__PURE__*/require('./pipeP');
var reverse = /*#__PURE__*/require('./reverse');
/**
* Performs right-to-left composition of one or more Promise-returning
* functions. The rightmost function may have any arity; the remaining
* functions must be unary.
*
* @func
* @memberOf R
* @since v0.10.0
* @category Function
* @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z)
* @param {...Function} functions The functions to compose
* @return {Function}
* @see R.pipeP
* @example
*
* var db = {
* users: {
* JOE: {
* name: 'Joe',
* followers: ['STEVE', 'SUZY']
* }
* }
* }
*
* // We'll pretend to do a db lookup which returns a promise
* var lookupUser = (userId) => Promise.resolve(db.users[userId])
* var lookupFollowers = (user) => Promise.resolve(user.followers)
* lookupUser('JOE').then(lookupFollowers)
*
* // followersForUser :: String -> Promise [UserId]
* var followersForUser = R.composeP(lookupFollowers, lookupUser);
* followersForUser('JOE').then(followers => console.log('Followers:', followers))
* // Followers: ["STEVE","SUZY"]
*/
function composeP() {
if (arguments.length === 0) {
throw new Error('composeP requires at least one argument');
}
return pipeP.apply(this, reverse(arguments));
}
module.exports = composeP;
+62
View File
@@ -0,0 +1,62 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _isArray = /*#__PURE__*/require('./internal/_isArray');
var _isFunction = /*#__PURE__*/require('./internal/_isFunction');
var _isString = /*#__PURE__*/require('./internal/_isString');
var toString = /*#__PURE__*/require('./toString');
/**
* Returns the result of concatenating the given lists or strings.
*
* Note: `R.concat` expects both arguments to be of the same type,
* unlike the native `Array.prototype.concat` method. It will throw
* an error if you `concat` an Array with a non-Array value.
*
* Dispatches to the `concat` method of the first argument, if present.
* Can also concatenate two members of a [fantasy-land
* compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup).
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig [a] -> [a] -> [a]
* @sig String -> String -> String
* @param {Array|String} firstList The first list
* @param {Array|String} secondList The second list
* @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of
* `secondList`.
*
* @example
*
* R.concat('ABC', 'DEF'); // 'ABCDEF'
* R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
* R.concat([], []); //=> []
*/
var concat = /*#__PURE__*/_curry2(function concat(a, b) {
if (_isArray(a)) {
if (_isArray(b)) {
return a.concat(b);
}
throw new TypeError(toString(b) + ' is not an array');
}
if (_isString(a)) {
if (_isString(b)) {
return a + b;
}
throw new TypeError(toString(b) + ' is not a string');
}
if (a != null && _isFunction(a['fantasy-land/concat'])) {
return a['fantasy-land/concat'](b);
}
if (a != null && _isFunction(a.concat)) {
return a.concat(b);
}
throw new TypeError(toString(a) + ' does not have a method named "concat" or "fantasy-land/concat"');
});
module.exports = concat;
+53
View File
@@ -0,0 +1,53 @@
var _arity = /*#__PURE__*/require('./internal/_arity');
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var map = /*#__PURE__*/require('./map');
var max = /*#__PURE__*/require('./max');
var reduce = /*#__PURE__*/require('./reduce');
/**
* Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic.
* `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments
* to `fn` are applied to each of the predicates in turn until one returns a
* "truthy" value, at which point `fn` returns the result of applying its
* arguments to the corresponding transformer. If none of the predicates
* matches, `fn` returns undefined.
*
* @func
* @memberOf R
* @since v0.6.0
* @category Logic
* @sig [[(*... -> Boolean),(*... -> *)]] -> (*... -> *)
* @param {Array} pairs A list of [predicate, transformer]
* @return {Function}
* @example
*
* var fn = R.cond([
* [R.equals(0), R.always('water freezes at 0°C')],
* [R.equals(100), R.always('water boils at 100°C')],
* [R.T, temp => 'nothing special happens at ' + temp + '°C']
* ]);
* fn(0); //=> 'water freezes at 0°C'
* fn(50); //=> 'nothing special happens at 50°C'
* fn(100); //=> 'water boils at 100°C'
*/
var cond = /*#__PURE__*/_curry1(function cond(pairs) {
var arity = reduce(max, 0, map(function (pair) {
return pair[0].length;
}, pairs));
return _arity(arity, function () {
var idx = 0;
while (idx < pairs.length) {
if (pairs[idx][0].apply(this, arguments)) {
return pairs[idx][1].apply(this, arguments);
}
idx += 1;
}
});
});
module.exports = cond;
+42
View File
@@ -0,0 +1,42 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var constructN = /*#__PURE__*/require('./constructN');
/**
* Wraps a constructor function inside a curried function that can be called
* with the same arguments and returns the same type.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig (* -> {*}) -> (* -> {*})
* @param {Function} fn The constructor function to wrap.
* @return {Function} A wrapped, curried constructor function.
* @see R.invoker
* @example
*
* // Constructor function
* function Animal(kind) {
* this.kind = kind;
* };
* Animal.prototype.sighting = function() {
* return "It's a " + this.kind + "!";
* }
*
* var AnimalConstructor = R.construct(Animal)
*
* // Notice we no longer need the 'new' keyword:
* AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}};
*
* var animalTypes = ["Lion", "Tiger", "Bear"];
* var animalSighting = R.invoker(0, 'sighting');
* var sightNewAnimal = R.compose(animalSighting, AnimalConstructor);
* R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"]
*/
var construct = /*#__PURE__*/_curry1(function construct(Fn) {
return constructN(Fn.length, Fn);
});
module.exports = construct;
+78
View File
@@ -0,0 +1,78 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var curry = /*#__PURE__*/require('./curry');
var nAry = /*#__PURE__*/require('./nAry');
/**
* Wraps a constructor function inside a curried function that can be called
* with the same arguments and returns the same type. The arity of the function
* returned is specified to allow using variadic constructor functions.
*
* @func
* @memberOf R
* @since v0.4.0
* @category Function
* @sig Number -> (* -> {*}) -> (* -> {*})
* @param {Number} n The arity of the constructor function.
* @param {Function} Fn The constructor function to wrap.
* @return {Function} A wrapped, curried constructor function.
* @example
*
* // Variadic Constructor function
* function Salad() {
* this.ingredients = arguments;
* }
*
* Salad.prototype.recipe = function() {
* var instructions = R.map(ingredient => 'Add a dollop of ' + ingredient, this.ingredients);
* return R.join('\n', instructions);
* };
*
* var ThreeLayerSalad = R.constructN(3, Salad);
*
* // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments.
* var salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup');
*
* console.log(salad.recipe());
* // Add a dollop of Mayonnaise
* // Add a dollop of Potato Chips
* // Add a dollop of Ketchup
*/
var constructN = /*#__PURE__*/_curry2(function constructN(n, Fn) {
if (n > 10) {
throw new Error('Constructor with greater than ten arguments');
}
if (n === 0) {
return function () {
return new Fn();
};
}
return curry(nAry(n, function ($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
switch (arguments.length) {
case 1:
return new Fn($0);
case 2:
return new Fn($0, $1);
case 3:
return new Fn($0, $1, $2);
case 4:
return new Fn($0, $1, $2, $3);
case 5:
return new Fn($0, $1, $2, $3, $4);
case 6:
return new Fn($0, $1, $2, $3, $4, $5);
case 7:
return new Fn($0, $1, $2, $3, $4, $5, $6);
case 8:
return new Fn($0, $1, $2, $3, $4, $5, $6, $7);
case 9:
return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8);
case 10:
return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9);
}
}));
});
module.exports = constructN;
+28
View File
@@ -0,0 +1,28 @@
var _contains = /*#__PURE__*/require('./internal/_contains');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns `true` if the specified value is equal, in [`R.equals`](#equals)
* terms, to at least one element of the given list; `false` otherwise.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig a -> [a] -> Boolean
* @param {Object} a The item to compare against.
* @param {Array} list The array to consider.
* @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise.
* @see R.any
* @example
*
* R.contains(3, [1, 2, 3]); //=> true
* R.contains(4, [1, 2, 3]); //=> false
* R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true
* R.contains([42], [[42]]); //=> true
*/
var contains = /*#__PURE__*/_curry2(_contains);
module.exports = contains;
+51
View File
@@ -0,0 +1,51 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _map = /*#__PURE__*/require('./internal/_map');
var curryN = /*#__PURE__*/require('./curryN');
var max = /*#__PURE__*/require('./max');
var pluck = /*#__PURE__*/require('./pluck');
var reduce = /*#__PURE__*/require('./reduce');
/**
* Accepts a converging function and a list of branching functions and returns
* a new function. When invoked, this new function is applied to some
* arguments, each branching function is applied to those same arguments. The
* results of each branching function are passed as arguments to the converging
* function to produce the return value.
*
* @func
* @memberOf R
* @since v0.4.2
* @category Function
* @sig ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z)
* @param {Function} after A function. `after` will be invoked with the return values of
* `fn1` and `fn2` as its arguments.
* @param {Array} functions A list of functions.
* @return {Function} A new function.
* @see R.useWith
* @example
*
* var average = R.converge(R.divide, [R.sum, R.length])
* average([1, 2, 3, 4, 5, 6, 7]) //=> 4
*
* var strangeConcat = R.converge(R.concat, [R.toUpper, R.toLower])
* strangeConcat("Yodel") //=> "YODELyodel"
*
* @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b))
*/
var converge = /*#__PURE__*/_curry2(function converge(after, fns) {
return curryN(reduce(max, 0, pluck('length', fns)), function () {
var args = arguments;
var context = this;
return after.apply(context, _map(function (fn) {
return fn.apply(context, args);
}, fns));
});
});
module.exports = converge;
+32
View File
@@ -0,0 +1,32 @@
var reduceBy = /*#__PURE__*/require('./reduceBy');
/**
* Counts the elements of a list according to how many match each value of a
* key generated by the supplied function. Returns an object mapping the keys
* produced by `fn` to the number of occurrences in the list. Note that all
* keys are coerced to strings because of how JavaScript objects work.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Relation
* @sig (a -> String) -> [a] -> {*}
* @param {Function} fn The function used to map values to keys.
* @param {Array} list The list to count elements from.
* @return {Object} An object mapping keys to number of occurrences in the list.
* @example
*
* var numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2];
* R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1}
*
* var letters = ['a', 'b', 'A', 'a', 'B', 'c'];
* R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1}
*/
var countBy = /*#__PURE__*/reduceBy(function (acc, elem) {
return acc + 1;
}, 0);
module.exports = countBy;
+51
View File
@@ -0,0 +1,51 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var curryN = /*#__PURE__*/require('./curryN');
/**
* Returns a curried equivalent of the provided function. The curried function
* has two unusual capabilities. First, its arguments needn't be provided one
* at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the
* following are equivalent:
*
* - `g(1)(2)(3)`
* - `g(1)(2, 3)`
* - `g(1, 2)(3)`
* - `g(1, 2, 3)`
*
* Secondly, the special placeholder value [`R.__`](#__) may be used to specify
* "gaps", allowing partial application of any combination of arguments,
* regardless of their positions. If `g` is as above and `_` is [`R.__`](#__),
* the following are equivalent:
*
* - `g(1, 2, 3)`
* - `g(_, 2, 3)(1)`
* - `g(_, _, 3)(1)(2)`
* - `g(_, _, 3)(1, 2)`
* - `g(_, 2)(1)(3)`
* - `g(_, 2)(1, 3)`
* - `g(_, 2)(_, 3)(1)`
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig (* -> a) -> (* -> a)
* @param {Function} fn The function to curry.
* @return {Function} A new, curried function.
* @see R.curryN
* @example
*
* var addFourNumbers = (a, b, c, d) => a + b + c + d;
*
* var curriedAddFourNumbers = R.curry(addFourNumbers);
* var f = curriedAddFourNumbers(1, 2);
* var g = f(3);
* g(4); //=> 10
*/
var curry = /*#__PURE__*/_curry1(function curry(fn) {
return curryN(fn.length, fn);
});
module.exports = curry;
+59
View File
@@ -0,0 +1,59 @@
var _arity = /*#__PURE__*/require('./internal/_arity');
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _curryN = /*#__PURE__*/require('./internal/_curryN');
/**
* Returns a curried equivalent of the provided function, with the specified
* arity. The curried function has two unusual capabilities. First, its
* arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the
* following are equivalent:
*
* - `g(1)(2)(3)`
* - `g(1)(2, 3)`
* - `g(1, 2)(3)`
* - `g(1, 2, 3)`
*
* Secondly, the special placeholder value [`R.__`](#__) may be used to specify
* "gaps", allowing partial application of any combination of arguments,
* regardless of their positions. If `g` is as above and `_` is [`R.__`](#__),
* the following are equivalent:
*
* - `g(1, 2, 3)`
* - `g(_, 2, 3)(1)`
* - `g(_, _, 3)(1)(2)`
* - `g(_, _, 3)(1, 2)`
* - `g(_, 2)(1)(3)`
* - `g(_, 2)(1, 3)`
* - `g(_, 2)(_, 3)(1)`
*
* @func
* @memberOf R
* @since v0.5.0
* @category Function
* @sig Number -> (* -> a) -> (* -> a)
* @param {Number} length The arity for the returned function.
* @param {Function} fn The function to curry.
* @return {Function} A new, curried function.
* @see R.curry
* @example
*
* var sumArgs = (...args) => R.sum(args);
*
* var curriedAddFourNumbers = R.curryN(4, sumArgs);
* var f = curriedAddFourNumbers(1, 2);
* var g = f(3);
* g(4); //=> 10
*/
var curryN = /*#__PURE__*/_curry2(function curryN(length, fn) {
if (length === 1) {
return _curry1(fn);
}
return _arity(length, _curryN(length, [], fn));
});
module.exports = curryN;
+21
View File
@@ -0,0 +1,21 @@
var add = /*#__PURE__*/require('./add');
/**
* Decrements its argument.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Math
* @sig Number -> Number
* @param {Number} n
* @return {Number} n - 1
* @see R.inc
* @example
*
* R.dec(42); //=> 41
*/
var dec = /*#__PURE__*/add(-1);
module.exports = dec;
+30
View File
@@ -0,0 +1,30 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns the second argument if it is not `null`, `undefined` or `NaN`;
* otherwise the first argument is returned.
*
* @func
* @memberOf R
* @since v0.10.0
* @category Logic
* @sig a -> b -> a | b
* @param {a} default The default value.
* @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`.
* @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value
* @example
*
* var defaultTo42 = R.defaultTo(42);
*
* defaultTo42(null); //=> 42
* defaultTo42(undefined); //=> 42
* defaultTo42('Ramda'); //=> 'Ramda'
* // parseInt('string') results in NaN
* defaultTo42(parseInt('string')); //=> 42
*/
var defaultTo = /*#__PURE__*/_curry2(function defaultTo(d, v) {
return v == null || v !== v ? d : v;
});
module.exports = defaultTo;
+32
View File
@@ -0,0 +1,32 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Makes a descending comparator function out of a function that returns a value
* that can be compared with `<` and `>`.
*
* @func
* @memberOf R
* @since v0.23.0
* @category Function
* @sig Ord b => (a -> b) -> a -> a -> Number
* @param {Function} fn A function of arity one that returns a value that can be compared
* @param {*} a The first item to be compared.
* @param {*} b The second item to be compared.
* @return {Number} `-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0`
* @see R.ascend
* @example
*
* var byAge = R.descend(R.prop('age'));
* var people = [
* // ...
* ];
* var peopleByOldestFirst = R.sort(byAge, people);
*/
var descend = /*#__PURE__*/_curry3(function descend(fn, a, b) {
var aa = fn(a);
var bb = fn(b);
return aa > bb ? -1 : aa < bb ? 1 : 0;
});
module.exports = descend;
+39
View File
@@ -0,0 +1,39 @@
var _contains = /*#__PURE__*/require('./internal/_contains');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Finds the set (i.e. no duplicates) of all elements in the first list not
* contained in the second list. Objects and Arrays are compared in terms of
* value equality, not reference equality.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Relation
* @sig [*] -> [*] -> [*]
* @param {Array} list1 The first list.
* @param {Array} list2 The second list.
* @return {Array} The elements in `list1` that are not in `list2`.
* @see R.differenceWith, R.symmetricDifference, R.symmetricDifferenceWith, R.without
* @example
*
* R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2]
* R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5]
* R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}]
*/
var difference = /*#__PURE__*/_curry2(function difference(first, second) {
var out = [];
var idx = 0;
var firstLen = first.length;
while (idx < firstLen) {
if (!_contains(first[idx], second) && !_contains(first[idx], out)) {
out[out.length] = first[idx];
}
idx += 1;
}
return out;
});
module.exports = difference;
+41
View File
@@ -0,0 +1,41 @@
var _containsWith = /*#__PURE__*/require('./internal/_containsWith');
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Finds the set (i.e. no duplicates) of all elements in the first list not
* contained in the second list. Duplication is determined according to the
* value returned by applying the supplied predicate to two list elements.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Relation
* @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
* @param {Function} pred A predicate used to test whether two items are equal.
* @param {Array} list1 The first list.
* @param {Array} list2 The second list.
* @return {Array} The elements in `list1` that are not in `list2`.
* @see R.difference, R.symmetricDifference, R.symmetricDifferenceWith
* @example
*
* var cmp = (x, y) => x.a === y.a;
* var l1 = [{a: 1}, {a: 2}, {a: 3}];
* var l2 = [{a: 3}, {a: 4}];
* R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}]
*/
var differenceWith = /*#__PURE__*/_curry3(function differenceWith(pred, first, second) {
var out = [];
var idx = 0;
var firstLen = first.length;
while (idx < firstLen) {
if (!_containsWith(pred, first[idx], second) && !_containsWith(pred, first[idx], out)) {
out.push(first[idx]);
}
idx += 1;
}
return out;
});
module.exports = differenceWith;
+29
View File
@@ -0,0 +1,29 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns a new object that does not contain a `prop` property.
*
* @func
* @memberOf R
* @since v0.10.0
* @category Object
* @sig String -> {k: v} -> {k: v}
* @param {String} prop The name of the property to dissociate
* @param {Object} obj The object to clone
* @return {Object} A new object equivalent to the original but without the specified property
* @see R.assoc
* @example
*
* R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3}
*/
var dissoc = /*#__PURE__*/_curry2(function dissoc(prop, obj) {
var result = {};
for (var p in obj) {
result[p] = obj[p];
}
delete result[prop];
return result;
});
module.exports = dissoc;
+52
View File
@@ -0,0 +1,52 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _isInteger = /*#__PURE__*/require('./internal/_isInteger');
var assoc = /*#__PURE__*/require('./assoc');
var dissoc = /*#__PURE__*/require('./dissoc');
var remove = /*#__PURE__*/require('./remove');
var update = /*#__PURE__*/require('./update');
/**
* Makes a shallow clone of an object, omitting the property at the given path.
* Note that this copies and flattens prototype properties onto the new object
* as well. All non-primitive properties are copied by reference.
*
* @func
* @memberOf R
* @since v0.11.0
* @category Object
* @typedefn Idx = String | Int
* @sig [Idx] -> {k: v} -> {k: v}
* @param {Array} path The path to the value to omit
* @param {Object} obj The object to clone
* @return {Object} A new object without the property at path
* @see R.assocPath
* @example
*
* R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}}
*/
var dissocPath = /*#__PURE__*/_curry2(function dissocPath(path, obj) {
switch (path.length) {
case 0:
return obj;
case 1:
return _isInteger(path[0]) ? remove(path[0], 1, obj) : dissoc(path[0], obj);
default:
var head = path[0];
var tail = Array.prototype.slice.call(path, 1);
if (obj[head] == null) {
return obj;
} else if (_isInteger(path[0])) {
return update(head, dissocPath(tail, obj[head]), obj);
} else {
return assoc(head, dissocPath(tail, obj[head]), obj);
}
}
});
module.exports = dissocPath;
+30
View File
@@ -0,0 +1,30 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Divides two numbers. Equivalent to `a / b`.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Math
* @sig Number -> Number -> Number
* @param {Number} a The first value.
* @param {Number} b The second value.
* @return {Number} The result of `a / b`.
* @see R.multiply
* @example
*
* R.divide(71, 100); //=> 0.71
*
* var half = R.divide(R.__, 2);
* half(42); //=> 21
*
* var reciprocal = R.divide(1);
* reciprocal(4); //=> 0.25
*/
var divide = /*#__PURE__*/_curry2(function divide(a, b) {
return a / b;
});
module.exports = divide;
+38
View File
@@ -0,0 +1,38 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xdrop = /*#__PURE__*/require('./internal/_xdrop');
var slice = /*#__PURE__*/require('./slice');
/**
* Returns all but the first `n` elements of the given list, string, or
* transducer/transformer (or object with a `drop` method).
*
* Dispatches to the `drop` method of the second argument, if present.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig Number -> [a] -> [a]
* @sig Number -> String -> String
* @param {Number} n
* @param {*} list
* @return {*} A copy of list without the first `n` elements
* @see R.take, R.transduce, R.dropLast, R.dropWhile
* @example
*
* R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
* R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz']
* R.drop(3, ['foo', 'bar', 'baz']); //=> []
* R.drop(4, ['foo', 'bar', 'baz']); //=> []
* R.drop(3, 'ramda'); //=> 'da'
*/
var drop = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['drop'], _xdrop, function drop(n, xs) {
return slice(Math.max(0, n), Infinity, xs);
}));
module.exports = drop;
+33
View File
@@ -0,0 +1,33 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _dropLast = /*#__PURE__*/require('./internal/_dropLast');
var _xdropLast = /*#__PURE__*/require('./internal/_xdropLast');
/**
* Returns a list containing all but the last `n` elements of the given `list`.
*
* @func
* @memberOf R
* @since v0.16.0
* @category List
* @sig Number -> [a] -> [a]
* @sig Number -> String -> String
* @param {Number} n The number of elements of `list` to skip.
* @param {Array} list The list of elements to consider.
* @return {Array} A copy of the list with only the first `list.length - n` elements
* @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile
* @example
*
* R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
* R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo']
* R.dropLast(3, ['foo', 'bar', 'baz']); //=> []
* R.dropLast(4, ['foo', 'bar', 'baz']); //=> []
* R.dropLast(3, 'ramda'); //=> 'ra'
*/
var dropLast = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xdropLast, _dropLast));
module.exports = dropLast;
+37
View File
@@ -0,0 +1,37 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _dropLastWhile = /*#__PURE__*/require('./internal/_dropLastWhile');
var _xdropLastWhile = /*#__PURE__*/require('./internal/_xdropLastWhile');
/**
* Returns a new list excluding all the tailing elements of a given list which
* satisfy the supplied predicate function. It passes each value from the right
* to the supplied predicate function, skipping elements until the predicate
* function returns a `falsy` value. The predicate function is applied to one argument:
* *(value)*.
*
* @func
* @memberOf R
* @since v0.16.0
* @category List
* @sig (a -> Boolean) -> [a] -> [a]
* @sig (a -> Boolean) -> String -> String
* @param {Function} predicate The function to be called on each element
* @param {Array} xs The collection to iterate over.
* @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`.
* @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile
* @example
*
* var lteThree = x => x <= 3;
*
* R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4]
*
* R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd'
*/
var dropLastWhile = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xdropLastWhile, _dropLastWhile));
module.exports = dropLastWhile;
+32
View File
@@ -0,0 +1,32 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xdropRepeatsWith = /*#__PURE__*/require('./internal/_xdropRepeatsWith');
var dropRepeatsWith = /*#__PURE__*/require('./dropRepeatsWith');
var equals = /*#__PURE__*/require('./equals');
/**
* Returns a new list without any consecutively repeating elements.
* [`R.equals`](#equals) is used to determine equality.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.14.0
* @category List
* @sig [a] -> [a]
* @param {Array} list The array to consider.
* @return {Array} `list` without repeating elements.
* @see R.transduce
* @example
*
* R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2]
*/
var dropRepeats = /*#__PURE__*/_curry1( /*#__PURE__*/_dispatchable([], /*#__PURE__*/_xdropRepeatsWith(equals), /*#__PURE__*/dropRepeatsWith(equals)));
module.exports = dropRepeats;
+47
View File
@@ -0,0 +1,47 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xdropRepeatsWith = /*#__PURE__*/require('./internal/_xdropRepeatsWith');
var last = /*#__PURE__*/require('./last');
/**
* Returns a new list without any consecutively repeating elements. Equality is
* determined by applying the supplied predicate to each pair of consecutive elements. The
* first element in a series of equal elements will be preserved.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.14.0
* @category List
* @sig ((a, a) -> Boolean) -> [a] -> [a]
* @param {Function} pred A predicate used to test whether two items are equal.
* @param {Array} list The array to consider.
* @return {Array} `list` without repeating elements.
* @see R.transduce
* @example
*
* var l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3];
* R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3]
*/
var dropRepeatsWith = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) {
var result = [];
var idx = 1;
var len = list.length;
if (len !== 0) {
result[0] = list[0];
while (idx < len) {
if (!pred(last(result), list[idx])) {
result[result.length] = list[idx];
}
idx += 1;
}
}
return result;
}));
module.exports = dropRepeatsWith;
+47
View File
@@ -0,0 +1,47 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xdropWhile = /*#__PURE__*/require('./internal/_xdropWhile');
var slice = /*#__PURE__*/require('./slice');
/**
* Returns a new list excluding the leading elements of a given list which
* satisfy the supplied predicate function. It passes each value to the supplied
* predicate function, skipping elements while the predicate function returns
* `true`. The predicate function is applied to one argument: *(value)*.
*
* Dispatches to the `dropWhile` method of the second argument, if present.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.9.0
* @category List
* @sig (a -> Boolean) -> [a] -> [a]
* @sig (a -> Boolean) -> String -> String
* @param {Function} fn The function called per iteration.
* @param {Array} xs The collection to iterate over.
* @return {Array} A new array.
* @see R.takeWhile, R.transduce, R.addIndex
* @example
*
* var lteTwo = x => x <= 2;
*
* R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1]
*
* R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da'
*/
var dropWhile = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) {
var idx = 0;
var len = xs.length;
while (idx < len && pred(xs[idx])) {
idx += 1;
}
return slice(idx, Infinity, xs);
}));
module.exports = dropWhile;
+43
View File
@@ -0,0 +1,43 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _isFunction = /*#__PURE__*/require('./internal/_isFunction');
var lift = /*#__PURE__*/require('./lift');
var or = /*#__PURE__*/require('./or');
/**
* A function wrapping calls to the two functions in an `||` operation,
* returning the result of the first function if it is truth-y and the result
* of the second function otherwise. Note that this is short-circuited,
* meaning that the second function will not be invoked if the first returns a
* truth-y value.
*
* In addition to functions, `R.either` also accepts any fantasy-land compatible
* applicative functor.
*
* @func
* @memberOf R
* @since v0.12.0
* @category Logic
* @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
* @param {Function} f a predicate
* @param {Function} g another predicate
* @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together.
* @see R.or
* @example
*
* var gt10 = x => x > 10;
* var even = x => x % 2 === 0;
* var f = R.either(gt10, even);
* f(101); //=> true
* f(8); //=> true
*/
var either = /*#__PURE__*/_curry2(function either(f, g) {
return _isFunction(f) ? function _either() {
return f.apply(this, arguments) || g.apply(this, arguments);
} : lift(or)(f, g);
});
module.exports = either;
+43
View File
@@ -0,0 +1,43 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var _isArguments = /*#__PURE__*/require('./internal/_isArguments');
var _isArray = /*#__PURE__*/require('./internal/_isArray');
var _isObject = /*#__PURE__*/require('./internal/_isObject');
var _isString = /*#__PURE__*/require('./internal/_isString');
/**
* Returns the empty value of its argument's type. Ramda defines the empty
* value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other
* types are supported if they define `<Type>.empty`,
* `<Type>.prototype.empty` or implement the
* [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
*
* Dispatches to the `empty` method of the first argument, if present.
*
* @func
* @memberOf R
* @since v0.3.0
* @category Function
* @sig a -> a
* @param {*} x
* @return {*}
* @example
*
* R.empty(Just(42)); //=> Nothing()
* R.empty([1, 2, 3]); //=> []
* R.empty('unicorns'); //=> ''
* R.empty({x: 1, y: 2}); //=> {}
*/
var empty = /*#__PURE__*/_curry1(function empty(x) {
return x != null && typeof x['fantasy-land/empty'] === 'function' ? x['fantasy-land/empty']() : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function' ? x.constructor['fantasy-land/empty']() : x != null && typeof x.empty === 'function' ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === 'function' ? x.constructor.empty() : _isArray(x) ? [] : _isString(x) ? '' : _isObject(x) ? {} : _isArguments(x) ? function () {
return arguments;
}() :
// else
void 0;
});
module.exports = empty;
+31
View File
@@ -0,0 +1,31 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var equals = /*#__PURE__*/require('./equals');
var takeLast = /*#__PURE__*/require('./takeLast');
/**
* Checks if a list ends with the provided values
*
* @func
* @memberOf R
* @since v0.24.0
* @category List
* @sig [a] -> Boolean
* @sig String -> Boolean
* @param {*} suffix
* @param {*} list
* @return {Boolean}
* @example
*
* R.endsWith('c', 'abc') //=> true
* R.endsWith('b', 'abc') //=> false
* R.endsWith(['c'], ['a', 'b', 'c']) //=> true
* R.endsWith(['b'], ['a', 'b', 'c']) //=> false
*/
var endsWith = /*#__PURE__*/_curry2(function (suffix, list) {
return equals(takeLast(suffix.length, list), suffix);
});
module.exports = endsWith;
+27
View File
@@ -0,0 +1,27 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
var equals = /*#__PURE__*/require('./equals');
/**
* Takes a function and two values in its domain and returns `true` if the
* values map to the same value in the codomain; `false` otherwise.
*
* @func
* @memberOf R
* @since v0.18.0
* @category Relation
* @sig (a -> b) -> a -> a -> Boolean
* @param {Function} f
* @param {*} x
* @param {*} y
* @return {Boolean}
* @example
*
* R.eqBy(Math.abs, 5, -5); //=> true
*/
var eqBy = /*#__PURE__*/_curry3(function eqBy(f, x, y) {
return equals(f(x), f(y));
});
module.exports = eqBy;
+31
View File
@@ -0,0 +1,31 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
var equals = /*#__PURE__*/require('./equals');
/**
* Reports whether two objects have the same value, in [`R.equals`](#equals)
* terms, for the specified property. Useful as a curried predicate.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Object
* @sig k -> {k: v} -> {k: v} -> Boolean
* @param {String} prop The name of the property to compare
* @param {Object} obj1
* @param {Object} obj2
* @return {Boolean}
*
* @example
*
* var o1 = { a: 1, b: 2, c: 3, d: 4 };
* var o2 = { a: 10, b: 20, c: 3, d: 40 };
* R.eqProps('a', o1, o2); //=> false
* R.eqProps('c', o1, o2); //=> true
*/
var eqProps = /*#__PURE__*/_curry3(function eqProps(prop, obj1, obj2) {
return equals(obj1[prop], obj2[prop]);
});
module.exports = eqProps;
+35
View File
@@ -0,0 +1,35 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _equals = /*#__PURE__*/require('./internal/_equals');
/**
* Returns `true` if its arguments are equivalent, `false` otherwise. Handles
* cyclical data structures.
*
* Dispatches symmetrically to the `equals` methods of both arguments, if
* present.
*
* @func
* @memberOf R
* @since v0.15.0
* @category Relation
* @sig a -> b -> Boolean
* @param {*} a
* @param {*} b
* @return {Boolean}
* @example
*
* R.equals(1, 1); //=> true
* R.equals(1, '1'); //=> false
* R.equals([1, 2, 3], [1, 2, 3]); //=> true
*
* var a = {}; a.v = a;
* var b = {}; b.v = b;
* R.equals(a, b); //=> true
*/
var equals = /*#__PURE__*/_curry2(function equals(a, b) {
return _equals(a, b, [], []);
});
module.exports = equals;
+42
View File
@@ -0,0 +1,42 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Creates a new object by recursively evolving a shallow copy of `object`,
* according to the `transformation` functions. All non-primitive properties
* are copied by reference.
*
* A `transformation` function will not be invoked if its corresponding key
* does not exist in the evolved object.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Object
* @sig {k: (v -> v)} -> {k: v} -> {k: v}
* @param {Object} transformations The object specifying transformation functions to apply
* to the object.
* @param {Object} object The object to be transformed.
* @return {Object} The transformed object.
* @example
*
* var tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123};
* var transformations = {
* firstName: R.trim,
* lastName: R.trim, // Will not get invoked.
* data: {elapsed: R.add(1), remaining: R.add(-1)}
* };
* R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123}
*/
var evolve = /*#__PURE__*/_curry2(function evolve(transformations, object) {
var result = {};
var transformation, key, type;
for (key in object) {
transformation = transformations[key];
type = typeof transformation;
result[key] = type === 'function' ? transformation(object[key]) : transformation && type === 'object' ? evolve(transformation, object[key]) : object[key];
}
return result;
});
module.exports = evolve;
+54
View File
@@ -0,0 +1,54 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _filter = /*#__PURE__*/require('./internal/_filter');
var _isObject = /*#__PURE__*/require('./internal/_isObject');
var _reduce = /*#__PURE__*/require('./internal/_reduce');
var _xfilter = /*#__PURE__*/require('./internal/_xfilter');
var keys = /*#__PURE__*/require('./keys');
/**
* Takes a predicate and a `Filterable`, and returns a new filterable of the
* same type containing the members of the given filterable which satisfy the
* given predicate. Filterable objects include plain objects or any object
* that has a filter method such as `Array`.
*
* Dispatches to the `filter` method of the second argument, if present.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig Filterable f => (a -> Boolean) -> f a -> f a
* @param {Function} pred
* @param {Array} filterable
* @return {Array} Filterable
* @see R.reject, R.transduce, R.addIndex
* @example
*
* var isEven = n => n % 2 === 0;
*
* R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
*
* R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
*/
var filter = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['filter'], _xfilter, function (pred, filterable) {
return _isObject(filterable) ? _reduce(function (acc, key) {
if (pred(filterable[key])) {
acc[key] = filterable[key];
}
return acc;
}, {}, keys(filterable)) :
// else
_filter(pred, filterable);
}));
module.exports = filter;
+43
View File
@@ -0,0 +1,43 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xfind = /*#__PURE__*/require('./internal/_xfind');
/**
* Returns the first element of the list which matches the predicate, or
* `undefined` if no element matches.
*
* Dispatches to the `find` method of the second argument, if present.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig (a -> Boolean) -> [a] -> a | undefined
* @param {Function} fn The predicate function used to determine if the element is the
* desired one.
* @param {Array} list The array to consider.
* @return {Object} The element found, or `undefined`.
* @see R.transduce
* @example
*
* var xs = [{a: 1}, {a: 2}, {a: 3}];
* R.find(R.propEq('a', 2))(xs); //=> {a: 2}
* R.find(R.propEq('a', 4))(xs); //=> undefined
*/
var find = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable(['find'], _xfind, function find(fn, list) {
var idx = 0;
var len = list.length;
while (idx < len) {
if (fn(list[idx])) {
return list[idx];
}
idx += 1;
}
}));
module.exports = find;
+42
View File
@@ -0,0 +1,42 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xfindIndex = /*#__PURE__*/require('./internal/_xfindIndex');
/**
* Returns the index of the first element of the list which matches the
* predicate, or `-1` if no element matches.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.1
* @category List
* @sig (a -> Boolean) -> [a] -> Number
* @param {Function} fn The predicate function used to determine if the element is the
* desired one.
* @param {Array} list The array to consider.
* @return {Number} The index of the element found, or `-1`.
* @see R.transduce
* @example
*
* var xs = [{a: 1}, {a: 2}, {a: 3}];
* R.findIndex(R.propEq('a', 2))(xs); //=> 1
* R.findIndex(R.propEq('a', 4))(xs); //=> -1
*/
var findIndex = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xfindIndex, function findIndex(fn, list) {
var idx = 0;
var len = list.length;
while (idx < len) {
if (fn(list[idx])) {
return idx;
}
idx += 1;
}
return -1;
}));
module.exports = findIndex;
+40
View File
@@ -0,0 +1,40 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xfindLast = /*#__PURE__*/require('./internal/_xfindLast');
/**
* Returns the last element of the list which matches the predicate, or
* `undefined` if no element matches.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.1
* @category List
* @sig (a -> Boolean) -> [a] -> a | undefined
* @param {Function} fn The predicate function used to determine if the element is the
* desired one.
* @param {Array} list The array to consider.
* @return {Object} The element found, or `undefined`.
* @see R.transduce
* @example
*
* var xs = [{a: 1, b: 0}, {a:1, b: 1}];
* R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1}
* R.findLast(R.propEq('a', 4))(xs); //=> undefined
*/
var findLast = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xfindLast, function findLast(fn, list) {
var idx = list.length - 1;
while (idx >= 0) {
if (fn(list[idx])) {
return list[idx];
}
idx -= 1;
}
}));
module.exports = findLast;
+41
View File
@@ -0,0 +1,41 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _dispatchable = /*#__PURE__*/require('./internal/_dispatchable');
var _xfindLastIndex = /*#__PURE__*/require('./internal/_xfindLastIndex');
/**
* Returns the index of the last element of the list which matches the
* predicate, or `-1` if no element matches.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.1
* @category List
* @sig (a -> Boolean) -> [a] -> Number
* @param {Function} fn The predicate function used to determine if the element is the
* desired one.
* @param {Array} list The array to consider.
* @return {Number} The index of the element found, or `-1`.
* @see R.transduce
* @example
*
* var xs = [{a: 1, b: 0}, {a:1, b: 1}];
* R.findLastIndex(R.propEq('a', 1))(xs); //=> 1
* R.findLastIndex(R.propEq('a', 4))(xs); //=> -1
*/
var findLastIndex = /*#__PURE__*/_curry2( /*#__PURE__*/_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) {
var idx = list.length - 1;
while (idx >= 0) {
if (fn(list[idx])) {
return idx;
}
idx -= 1;
}
return -1;
}));
module.exports = findLastIndex;
+25
View File
@@ -0,0 +1,25 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var _makeFlat = /*#__PURE__*/require('./internal/_makeFlat');
/**
* Returns a new list by pulling every item out of it (and all its sub-arrays)
* and putting them in a new array, depth-first.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig [a] -> [b]
* @param {Array} list The array to consider.
* @return {Array} The flattened list.
* @see R.unnest
* @example
*
* R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]);
* //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
*/
var flatten = /*#__PURE__*/_curry1( /*#__PURE__*/_makeFlat(true));
module.exports = flatten;
+35
View File
@@ -0,0 +1,35 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var curryN = /*#__PURE__*/require('./curryN');
/**
* Returns a new function much like the supplied one, except that the first two
* arguments' order is reversed.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z)
* @param {Function} fn The function to invoke with its first two parameters reversed.
* @return {*} The result of invoking `fn` with its first two parameters' order reversed.
* @example
*
* var mergeThree = (a, b, c) => [].concat(a, b, c);
*
* mergeThree(1, 2, 3); //=> [1, 2, 3]
*
* R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3]
* @symb R.flip(f)(a, b, c) = f(b, a, c)
*/
var flip = /*#__PURE__*/_curry1(function flip(fn) {
return curryN(fn.length, function (a, b) {
var args = Array.prototype.slice.call(arguments, 0);
args[0] = b;
args[1] = a;
return fn.apply(this, args);
});
});
module.exports = flip;
+50
View File
@@ -0,0 +1,50 @@
var _checkForMethod = /*#__PURE__*/require('./internal/_checkForMethod');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Iterate over an input `list`, calling a provided function `fn` for each
* element in the list.
*
* `fn` receives one argument: *(value)*.
*
* Note: `R.forEach` does not skip deleted or unassigned indices (sparse
* arrays), unlike the native `Array.prototype.forEach` method. For more
* details on this behavior, see:
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description
*
* Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns
* the original array. In some libraries this function is named `each`.
*
* Dispatches to the `forEach` method of the second argument, if present.
*
* @func
* @memberOf R
* @since v0.1.1
* @category List
* @sig (a -> *) -> [a] -> [a]
* @param {Function} fn The function to invoke. Receives one argument, `value`.
* @param {Array} list The list to iterate over.
* @return {Array} The original list.
* @see R.addIndex
* @example
*
* var printXPlusFive = x => console.log(x + 5);
* R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3]
* // logs 6
* // logs 7
* // logs 8
* @symb R.forEach(f, [a, b, c]) = [a, b, c]
*/
var forEach = /*#__PURE__*/_curry2( /*#__PURE__*/_checkForMethod('forEach', function forEach(fn, list) {
var len = list.length;
var idx = 0;
while (idx < len) {
fn(list[idx]);
idx += 1;
}
return list;
}));
module.exports = forEach;
+39
View File
@@ -0,0 +1,39 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var keys = /*#__PURE__*/require('./keys');
/**
* Iterate over an input `object`, calling a provided function `fn` for each
* key and value in the object.
*
* `fn` receives three argument: *(value, key, obj)*.
*
* @func
* @memberOf R
* @since v0.23.0
* @category Object
* @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a
* @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`.
* @param {Object} obj The object to iterate over.
* @return {Object} The original object.
* @example
*
* var printKeyConcatValue = (value, key) => console.log(key + ':' + value);
* R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2}
* // logs x:1
* // logs y:2
* @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b}
*/
var forEachObjIndexed = /*#__PURE__*/_curry2(function forEachObjIndexed(fn, obj) {
var keyList = keys(obj);
var idx = 0;
while (idx < keyList.length) {
var key = keyList[idx];
fn(obj[key], key, obj);
idx += 1;
}
return obj;
});
module.exports = forEachObjIndexed;
+30
View File
@@ -0,0 +1,30 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
/**
* Creates a new object from a list key-value pairs. If a key appears in
* multiple pairs, the rightmost pair is included in the object.
*
* @func
* @memberOf R
* @since v0.3.0
* @category List
* @sig [[k,v]] -> {k: v}
* @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object.
* @return {Object} The object made by pairing up `keys` and `values`.
* @see R.toPairs, R.pair
* @example
*
* R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
*/
var fromPairs = /*#__PURE__*/_curry1(function fromPairs(pairs) {
var result = {};
var idx = 0;
while (idx < pairs.length) {
result[pairs[idx][0]] = pairs[idx][1];
idx += 1;
}
return result;
});
module.exports = fromPairs;
+56
View File
@@ -0,0 +1,56 @@
var _checkForMethod = /*#__PURE__*/require('./internal/_checkForMethod');
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var reduceBy = /*#__PURE__*/require('./reduceBy');
/**
* Splits a list into sub-lists stored in an object, based on the result of
* calling a String-returning function on each element, and grouping the
* results according to values returned.
*
* Dispatches to the `groupBy` method of the second argument, if present.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig (a -> String) -> [a] -> {String: [a]}
* @param {Function} fn Function :: a -> String
* @param {Array} list The array to group
* @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements
* that produced that key when passed to `fn`.
* @see R.transduce
* @example
*
* var byGrade = R.groupBy(function(student) {
* var score = student.score;
* return score < 65 ? 'F' :
* score < 70 ? 'D' :
* score < 80 ? 'C' :
* score < 90 ? 'B' : 'A';
* });
* var students = [{name: 'Abby', score: 84},
* {name: 'Eddy', score: 58},
* // ...
* {name: 'Jack', score: 69}];
* byGrade(students);
* // {
* // 'A': [{name: 'Dianne', score: 99}],
* // 'B': [{name: 'Abby', score: 84}]
* // // ...,
* // 'F': [{name: 'Eddy', score: 58}]
* // }
*/
var groupBy = /*#__PURE__*/_curry2( /*#__PURE__*/_checkForMethod('groupBy', /*#__PURE__*/reduceBy(function (acc, item) {
if (acc == null) {
acc = [];
}
acc.push(item);
return acc;
}, null)));
module.exports = groupBy;
+49
View File
@@ -0,0 +1,49 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Takes a list and returns a list of lists where each sublist's elements are
* all satisfied pairwise comparison according to the provided function.
* Only adjacent elements are passed to the comparison function.
*
* @func
* @memberOf R
* @since v0.21.0
* @category List
* @sig ((a, a) → Boolean) → [a] → [[a]]
* @param {Function} fn Function for determining whether two given (adjacent)
* elements should be in the same group
* @param {Array} list The array to group. Also accepts a string, which will be
* treated as a list of characters.
* @return {List} A list that contains sublists of elements,
* whose concatenations are equal to the original list.
* @example
*
* R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21])
* //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]]
*
* R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21])
* //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]]
*
* R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21])
* //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]]
*
* R.groupWith(R.eqBy(isVowel), 'aestiou')
* //=> ['ae', 'st', 'iou']
*/
var groupWith = /*#__PURE__*/_curry2(function (fn, list) {
var res = [];
var idx = 0;
var len = list.length;
while (idx < len) {
var nextidx = idx + 1;
while (nextidx < len && fn(list[nextidx - 1], list[nextidx])) {
nextidx += 1;
}
res.push(list.slice(idx, nextidx));
idx = nextidx;
}
return res;
});
module.exports = groupWith;
+29
View File
@@ -0,0 +1,29 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns `true` if the first argument is greater than the second; `false`
* otherwise.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Relation
* @sig Ord a => a -> a -> Boolean
* @param {*} a
* @param {*} b
* @return {Boolean}
* @see R.lt
* @example
*
* R.gt(2, 1); //=> true
* R.gt(2, 2); //=> false
* R.gt(2, 3); //=> false
* R.gt('a', 'z'); //=> false
* R.gt('z', 'a'); //=> true
*/
var gt = /*#__PURE__*/_curry2(function gt(a, b) {
return a > b;
});
module.exports = gt;
+29
View File
@@ -0,0 +1,29 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns `true` if the first argument is greater than or equal to the second;
* `false` otherwise.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Relation
* @sig Ord a => a -> a -> Boolean
* @param {Number} a
* @param {Number} b
* @return {Boolean}
* @see R.lte
* @example
*
* R.gte(2, 1); //=> true
* R.gte(2, 2); //=> true
* R.gte(2, 3); //=> false
* R.gte('a', 'z'); //=> false
* R.gte('z', 'a'); //=> true
*/
var gte = /*#__PURE__*/_curry2(function gte(a, b) {
return a >= b;
});
module.exports = gte;
+32
View File
@@ -0,0 +1,32 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _has = /*#__PURE__*/require('./internal/_has');
/**
* Returns whether or not an object has an own property with the specified name
*
* @func
* @memberOf R
* @since v0.7.0
* @category Object
* @sig s -> {s: x} -> Boolean
* @param {String} prop The name of the property to check for.
* @param {Object} obj The object to query.
* @return {Boolean} Whether the property exists.
* @example
*
* var hasName = R.has('name');
* hasName({name: 'alice'}); //=> true
* hasName({name: 'bob'}); //=> true
* hasName({}); //=> false
*
* var point = {x: 0, y: 0};
* var pointHas = R.has(R.__, point);
* pointHas('x'); //=> true
* pointHas('y'); //=> true
* pointHas('z'); //=> false
*/
var has = /*#__PURE__*/_curry2(_has);
module.exports = has;
+34
View File
@@ -0,0 +1,34 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns whether or not an object or its prototype chain has a property with
* the specified name
*
* @func
* @memberOf R
* @since v0.7.0
* @category Object
* @sig s -> {s: x} -> Boolean
* @param {String} prop The name of the property to check for.
* @param {Object} obj The object to query.
* @return {Boolean} Whether the property exists.
* @example
*
* function Rectangle(width, height) {
* this.width = width;
* this.height = height;
* }
* Rectangle.prototype.area = function() {
* return this.width * this.height;
* };
*
* var square = new Rectangle(2, 2);
* R.hasIn('width', square); //=> true
* R.hasIn('area', square); //=> true
*/
var hasIn = /*#__PURE__*/_curry2(function hasIn(prop, obj) {
return prop in obj;
});
module.exports = hasIn;
+27
View File
@@ -0,0 +1,27 @@
var nth = /*#__PURE__*/require('./nth');
/**
* Returns the first element of the given list or string. In some libraries
* this function is named `first`.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig [a] -> a | Undefined
* @sig String -> String
* @param {Array|String} list
* @return {*}
* @see R.tail, R.init, R.last
* @example
*
* R.head(['fi', 'fo', 'fum']); //=> 'fi'
* R.head([]); //=> undefined
*
* R.head('abc'); //=> 'a'
* R.head(''); //=> ''
*/
var head = /*#__PURE__*/nth(0);
module.exports = head;
+39
View File
@@ -0,0 +1,39 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
/**
* Returns true if its arguments are identical, false otherwise. Values are
* identical if they reference the same memory. `NaN` is identical to `NaN`;
* `0` and `-0` are not identical.
*
* @func
* @memberOf R
* @since v0.15.0
* @category Relation
* @sig a -> a -> Boolean
* @param {*} a
* @param {*} b
* @return {Boolean}
* @example
*
* var o = {};
* R.identical(o, o); //=> true
* R.identical(1, 1); //=> true
* R.identical(1, '1'); //=> false
* R.identical([], []); //=> false
* R.identical(0, -0); //=> false
* R.identical(NaN, NaN); //=> true
*/
var identical = /*#__PURE__*/_curry2(function identical(a, b) {
// SameValue algorithm
if (a === b) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
return a !== 0 || 1 / a === 1 / b;
} else {
// Step 6.a: NaN == NaN
return a !== a && b !== b;
}
});
module.exports = identical;
+27
View File
@@ -0,0 +1,27 @@
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
var _identity = /*#__PURE__*/require('./internal/_identity');
/**
* A function that does nothing but return the parameter supplied to it. Good
* as a default or placeholder function.
*
* @func
* @memberOf R
* @since v0.1.0
* @category Function
* @sig a -> a
* @param {*} x The value to return.
* @return {*} The input value, `x`.
* @example
*
* R.identity(1); //=> 1
*
* var obj = {};
* R.identity(obj) === obj; //=> true
* @symb R.identity(a) = a
*/
var identity = /*#__PURE__*/_curry1(_identity);
module.exports = identity;
+37
View File
@@ -0,0 +1,37 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
var curryN = /*#__PURE__*/require('./curryN');
/**
* Creates a function that will process either the `onTrue` or the `onFalse`
* function depending upon the result of the `condition` predicate.
*
* @func
* @memberOf R
* @since v0.8.0
* @category Logic
* @sig (*... -> Boolean) -> (*... -> *) -> (*... -> *) -> (*... -> *)
* @param {Function} condition A predicate function
* @param {Function} onTrue A function to invoke when the `condition` evaluates to a truthy value.
* @param {Function} onFalse A function to invoke when the `condition` evaluates to a falsy value.
* @return {Function} A new unary function that will process either the `onTrue` or the `onFalse`
* function depending upon the result of the `condition` predicate.
* @see R.unless, R.when
* @example
*
* var incCount = R.ifElse(
* R.has('count'),
* R.over(R.lensProp('count'), R.inc),
* R.assoc('count', 1)
* );
* incCount({}); //=> { count: 1 }
* incCount({ count: 1 }); //=> { count: 2 }
*/
var ifElse = /*#__PURE__*/_curry3(function ifElse(condition, onTrue, onFalse) {
return curryN(Math.max(condition.length, onTrue.length, onFalse.length), function _ifElse() {
return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments);
});
});
module.exports = ifElse;
+21
View File
@@ -0,0 +1,21 @@
var add = /*#__PURE__*/require('./add');
/**
* Increments its argument.
*
* @func
* @memberOf R
* @since v0.9.0
* @category Math
* @sig Number -> Number
* @param {Number} n
* @return {Number} n + 1
* @see R.dec
* @example
*
* R.inc(42); //=> 43
*/
var inc = /*#__PURE__*/add(1);
module.exports = inc;
+247
View File
@@ -0,0 +1,247 @@
module.exports = {};
module.exports.F = /*#__PURE__*/require('./F');
module.exports.T = /*#__PURE__*/require('./T');
module.exports.__ = /*#__PURE__*/require('./__');
module.exports.add = /*#__PURE__*/require('./add');
module.exports.addIndex = /*#__PURE__*/require('./addIndex');
module.exports.adjust = /*#__PURE__*/require('./adjust');
module.exports.all = /*#__PURE__*/require('./all');
module.exports.allPass = /*#__PURE__*/require('./allPass');
module.exports.always = /*#__PURE__*/require('./always');
module.exports.and = /*#__PURE__*/require('./and');
module.exports.any = /*#__PURE__*/require('./any');
module.exports.anyPass = /*#__PURE__*/require('./anyPass');
module.exports.ap = /*#__PURE__*/require('./ap');
module.exports.aperture = /*#__PURE__*/require('./aperture');
module.exports.append = /*#__PURE__*/require('./append');
module.exports.apply = /*#__PURE__*/require('./apply');
module.exports.applySpec = /*#__PURE__*/require('./applySpec');
module.exports.applyTo = /*#__PURE__*/require('./applyTo');
module.exports.ascend = /*#__PURE__*/require('./ascend');
module.exports.assoc = /*#__PURE__*/require('./assoc');
module.exports.assocPath = /*#__PURE__*/require('./assocPath');
module.exports.binary = /*#__PURE__*/require('./binary');
module.exports.bind = /*#__PURE__*/require('./bind');
module.exports.both = /*#__PURE__*/require('./both');
module.exports.call = /*#__PURE__*/require('./call');
module.exports.chain = /*#__PURE__*/require('./chain');
module.exports.clamp = /*#__PURE__*/require('./clamp');
module.exports.clone = /*#__PURE__*/require('./clone');
module.exports.comparator = /*#__PURE__*/require('./comparator');
module.exports.complement = /*#__PURE__*/require('./complement');
module.exports.compose = /*#__PURE__*/require('./compose');
module.exports.composeK = /*#__PURE__*/require('./composeK');
module.exports.composeP = /*#__PURE__*/require('./composeP');
module.exports.concat = /*#__PURE__*/require('./concat');
module.exports.cond = /*#__PURE__*/require('./cond');
module.exports.construct = /*#__PURE__*/require('./construct');
module.exports.constructN = /*#__PURE__*/require('./constructN');
module.exports.contains = /*#__PURE__*/require('./contains');
module.exports.converge = /*#__PURE__*/require('./converge');
module.exports.countBy = /*#__PURE__*/require('./countBy');
module.exports.curry = /*#__PURE__*/require('./curry');
module.exports.curryN = /*#__PURE__*/require('./curryN');
module.exports.dec = /*#__PURE__*/require('./dec');
module.exports.defaultTo = /*#__PURE__*/require('./defaultTo');
module.exports.descend = /*#__PURE__*/require('./descend');
module.exports.difference = /*#__PURE__*/require('./difference');
module.exports.differenceWith = /*#__PURE__*/require('./differenceWith');
module.exports.dissoc = /*#__PURE__*/require('./dissoc');
module.exports.dissocPath = /*#__PURE__*/require('./dissocPath');
module.exports.divide = /*#__PURE__*/require('./divide');
module.exports.drop = /*#__PURE__*/require('./drop');
module.exports.dropLast = /*#__PURE__*/require('./dropLast');
module.exports.dropLastWhile = /*#__PURE__*/require('./dropLastWhile');
module.exports.dropRepeats = /*#__PURE__*/require('./dropRepeats');
module.exports.dropRepeatsWith = /*#__PURE__*/require('./dropRepeatsWith');
module.exports.dropWhile = /*#__PURE__*/require('./dropWhile');
module.exports.either = /*#__PURE__*/require('./either');
module.exports.empty = /*#__PURE__*/require('./empty');
module.exports.endsWith = /*#__PURE__*/require('./endsWith');
module.exports.eqBy = /*#__PURE__*/require('./eqBy');
module.exports.eqProps = /*#__PURE__*/require('./eqProps');
module.exports.equals = /*#__PURE__*/require('./equals');
module.exports.evolve = /*#__PURE__*/require('./evolve');
module.exports.filter = /*#__PURE__*/require('./filter');
module.exports.find = /*#__PURE__*/require('./find');
module.exports.findIndex = /*#__PURE__*/require('./findIndex');
module.exports.findLast = /*#__PURE__*/require('./findLast');
module.exports.findLastIndex = /*#__PURE__*/require('./findLastIndex');
module.exports.flatten = /*#__PURE__*/require('./flatten');
module.exports.flip = /*#__PURE__*/require('./flip');
module.exports.forEach = /*#__PURE__*/require('./forEach');
module.exports.forEachObjIndexed = /*#__PURE__*/require('./forEachObjIndexed');
module.exports.fromPairs = /*#__PURE__*/require('./fromPairs');
module.exports.groupBy = /*#__PURE__*/require('./groupBy');
module.exports.groupWith = /*#__PURE__*/require('./groupWith');
module.exports.gt = /*#__PURE__*/require('./gt');
module.exports.gte = /*#__PURE__*/require('./gte');
module.exports.has = /*#__PURE__*/require('./has');
module.exports.hasIn = /*#__PURE__*/require('./hasIn');
module.exports.head = /*#__PURE__*/require('./head');
module.exports.identical = /*#__PURE__*/require('./identical');
module.exports.identity = /*#__PURE__*/require('./identity');
module.exports.ifElse = /*#__PURE__*/require('./ifElse');
module.exports.inc = /*#__PURE__*/require('./inc');
module.exports.indexBy = /*#__PURE__*/require('./indexBy');
module.exports.indexOf = /*#__PURE__*/require('./indexOf');
module.exports.init = /*#__PURE__*/require('./init');
module.exports.innerJoin = /*#__PURE__*/require('./innerJoin');
module.exports.insert = /*#__PURE__*/require('./insert');
module.exports.insertAll = /*#__PURE__*/require('./insertAll');
module.exports.intersection = /*#__PURE__*/require('./intersection');
module.exports.intersperse = /*#__PURE__*/require('./intersperse');
module.exports.into = /*#__PURE__*/require('./into');
module.exports.invert = /*#__PURE__*/require('./invert');
module.exports.invertObj = /*#__PURE__*/require('./invertObj');
module.exports.invoker = /*#__PURE__*/require('./invoker');
module.exports.is = /*#__PURE__*/require('./is');
module.exports.isEmpty = /*#__PURE__*/require('./isEmpty');
module.exports.isNil = /*#__PURE__*/require('./isNil');
module.exports.join = /*#__PURE__*/require('./join');
module.exports.juxt = /*#__PURE__*/require('./juxt');
module.exports.keys = /*#__PURE__*/require('./keys');
module.exports.keysIn = /*#__PURE__*/require('./keysIn');
module.exports.last = /*#__PURE__*/require('./last');
module.exports.lastIndexOf = /*#__PURE__*/require('./lastIndexOf');
module.exports.length = /*#__PURE__*/require('./length');
module.exports.lens = /*#__PURE__*/require('./lens');
module.exports.lensIndex = /*#__PURE__*/require('./lensIndex');
module.exports.lensPath = /*#__PURE__*/require('./lensPath');
module.exports.lensProp = /*#__PURE__*/require('./lensProp');
module.exports.lift = /*#__PURE__*/require('./lift');
module.exports.liftN = /*#__PURE__*/require('./liftN');
module.exports.lt = /*#__PURE__*/require('./lt');
module.exports.lte = /*#__PURE__*/require('./lte');
module.exports.map = /*#__PURE__*/require('./map');
module.exports.mapAccum = /*#__PURE__*/require('./mapAccum');
module.exports.mapAccumRight = /*#__PURE__*/require('./mapAccumRight');
module.exports.mapObjIndexed = /*#__PURE__*/require('./mapObjIndexed');
module.exports.match = /*#__PURE__*/require('./match');
module.exports.mathMod = /*#__PURE__*/require('./mathMod');
module.exports.max = /*#__PURE__*/require('./max');
module.exports.maxBy = /*#__PURE__*/require('./maxBy');
module.exports.mean = /*#__PURE__*/require('./mean');
module.exports.median = /*#__PURE__*/require('./median');
module.exports.memoize = /*#__PURE__*/require('./memoize');
module.exports.memoizeWith = /*#__PURE__*/require('./memoizeWith');
module.exports.merge = /*#__PURE__*/require('./merge');
module.exports.mergeAll = /*#__PURE__*/require('./mergeAll');
module.exports.mergeDeepLeft = /*#__PURE__*/require('./mergeDeepLeft');
module.exports.mergeDeepRight = /*#__PURE__*/require('./mergeDeepRight');
module.exports.mergeDeepWith = /*#__PURE__*/require('./mergeDeepWith');
module.exports.mergeDeepWithKey = /*#__PURE__*/require('./mergeDeepWithKey');
module.exports.mergeWith = /*#__PURE__*/require('./mergeWith');
module.exports.mergeWithKey = /*#__PURE__*/require('./mergeWithKey');
module.exports.min = /*#__PURE__*/require('./min');
module.exports.minBy = /*#__PURE__*/require('./minBy');
module.exports.modulo = /*#__PURE__*/require('./modulo');
module.exports.multiply = /*#__PURE__*/require('./multiply');
module.exports.nAry = /*#__PURE__*/require('./nAry');
module.exports.negate = /*#__PURE__*/require('./negate');
module.exports.none = /*#__PURE__*/require('./none');
module.exports.not = /*#__PURE__*/require('./not');
module.exports.nth = /*#__PURE__*/require('./nth');
module.exports.nthArg = /*#__PURE__*/require('./nthArg');
module.exports.o = /*#__PURE__*/require('./o');
module.exports.objOf = /*#__PURE__*/require('./objOf');
module.exports.of = /*#__PURE__*/require('./of');
module.exports.omit = /*#__PURE__*/require('./omit');
module.exports.once = /*#__PURE__*/require('./once');
module.exports.or = /*#__PURE__*/require('./or');
module.exports.over = /*#__PURE__*/require('./over');
module.exports.pair = /*#__PURE__*/require('./pair');
module.exports.partial = /*#__PURE__*/require('./partial');
module.exports.partialRight = /*#__PURE__*/require('./partialRight');
module.exports.partition = /*#__PURE__*/require('./partition');
module.exports.path = /*#__PURE__*/require('./path');
module.exports.pathEq = /*#__PURE__*/require('./pathEq');
module.exports.pathOr = /*#__PURE__*/require('./pathOr');
module.exports.pathSatisfies = /*#__PURE__*/require('./pathSatisfies');
module.exports.pick = /*#__PURE__*/require('./pick');
module.exports.pickAll = /*#__PURE__*/require('./pickAll');
module.exports.pickBy = /*#__PURE__*/require('./pickBy');
module.exports.pipe = /*#__PURE__*/require('./pipe');
module.exports.pipeK = /*#__PURE__*/require('./pipeK');
module.exports.pipeP = /*#__PURE__*/require('./pipeP');
module.exports.pluck = /*#__PURE__*/require('./pluck');
module.exports.prepend = /*#__PURE__*/require('./prepend');
module.exports.product = /*#__PURE__*/require('./product');
module.exports.project = /*#__PURE__*/require('./project');
module.exports.prop = /*#__PURE__*/require('./prop');
module.exports.propEq = /*#__PURE__*/require('./propEq');
module.exports.propIs = /*#__PURE__*/require('./propIs');
module.exports.propOr = /*#__PURE__*/require('./propOr');
module.exports.propSatisfies = /*#__PURE__*/require('./propSatisfies');
module.exports.props = /*#__PURE__*/require('./props');
module.exports.range = /*#__PURE__*/require('./range');
module.exports.reduce = /*#__PURE__*/require('./reduce');
module.exports.reduceBy = /*#__PURE__*/require('./reduceBy');
module.exports.reduceRight = /*#__PURE__*/require('./reduceRight');
module.exports.reduceWhile = /*#__PURE__*/require('./reduceWhile');
module.exports.reduced = /*#__PURE__*/require('./reduced');
module.exports.reject = /*#__PURE__*/require('./reject');
module.exports.remove = /*#__PURE__*/require('./remove');
module.exports.repeat = /*#__PURE__*/require('./repeat');
module.exports.replace = /*#__PURE__*/require('./replace');
module.exports.reverse = /*#__PURE__*/require('./reverse');
module.exports.scan = /*#__PURE__*/require('./scan');
module.exports.sequence = /*#__PURE__*/require('./sequence');
module.exports.set = /*#__PURE__*/require('./set');
module.exports.slice = /*#__PURE__*/require('./slice');
module.exports.sort = /*#__PURE__*/require('./sort');
module.exports.sortBy = /*#__PURE__*/require('./sortBy');
module.exports.sortWith = /*#__PURE__*/require('./sortWith');
module.exports.split = /*#__PURE__*/require('./split');
module.exports.splitAt = /*#__PURE__*/require('./splitAt');
module.exports.splitEvery = /*#__PURE__*/require('./splitEvery');
module.exports.splitWhen = /*#__PURE__*/require('./splitWhen');
module.exports.startsWith = /*#__PURE__*/require('./startsWith');
module.exports.subtract = /*#__PURE__*/require('./subtract');
module.exports.sum = /*#__PURE__*/require('./sum');
module.exports.symmetricDifference = /*#__PURE__*/require('./symmetricDifference');
module.exports.symmetricDifferenceWith = /*#__PURE__*/require('./symmetricDifferenceWith');
module.exports.tail = /*#__PURE__*/require('./tail');
module.exports.take = /*#__PURE__*/require('./take');
module.exports.takeLast = /*#__PURE__*/require('./takeLast');
module.exports.takeLastWhile = /*#__PURE__*/require('./takeLastWhile');
module.exports.takeWhile = /*#__PURE__*/require('./takeWhile');
module.exports.tap = /*#__PURE__*/require('./tap');
module.exports.test = /*#__PURE__*/require('./test');
module.exports.times = /*#__PURE__*/require('./times');
module.exports.toLower = /*#__PURE__*/require('./toLower');
module.exports.toPairs = /*#__PURE__*/require('./toPairs');
module.exports.toPairsIn = /*#__PURE__*/require('./toPairsIn');
module.exports.toString = /*#__PURE__*/require('./toString');
module.exports.toUpper = /*#__PURE__*/require('./toUpper');
module.exports.transduce = /*#__PURE__*/require('./transduce');
module.exports.transpose = /*#__PURE__*/require('./transpose');
module.exports.traverse = /*#__PURE__*/require('./traverse');
module.exports.trim = /*#__PURE__*/require('./trim');
module.exports.tryCatch = /*#__PURE__*/require('./tryCatch');
module.exports.type = /*#__PURE__*/require('./type');
module.exports.unapply = /*#__PURE__*/require('./unapply');
module.exports.unary = /*#__PURE__*/require('./unary');
module.exports.uncurryN = /*#__PURE__*/require('./uncurryN');
module.exports.unfold = /*#__PURE__*/require('./unfold');
module.exports.union = /*#__PURE__*/require('./union');
module.exports.unionWith = /*#__PURE__*/require('./unionWith');
module.exports.uniq = /*#__PURE__*/require('./uniq');
module.exports.uniqBy = /*#__PURE__*/require('./uniqBy');
module.exports.uniqWith = /*#__PURE__*/require('./uniqWith');
module.exports.unless = /*#__PURE__*/require('./unless');
module.exports.unnest = /*#__PURE__*/require('./unnest');
module.exports.until = /*#__PURE__*/require('./until');
module.exports.update = /*#__PURE__*/require('./update');
module.exports.useWith = /*#__PURE__*/require('./useWith');
module.exports.values = /*#__PURE__*/require('./values');
module.exports.valuesIn = /*#__PURE__*/require('./valuesIn');
module.exports.view = /*#__PURE__*/require('./view');
module.exports.when = /*#__PURE__*/require('./when');
module.exports.where = /*#__PURE__*/require('./where');
module.exports.whereEq = /*#__PURE__*/require('./whereEq');
module.exports.without = /*#__PURE__*/require('./without');
module.exports.xprod = /*#__PURE__*/require('./xprod');
module.exports.zip = /*#__PURE__*/require('./zip');
module.exports.zipObj = /*#__PURE__*/require('./zipObj');
module.exports.zipWith = /*#__PURE__*/require('./zipWith');
+30
View File
@@ -0,0 +1,30 @@
var reduceBy = /*#__PURE__*/require('./reduceBy');
/**
* Given a function that generates a key, turns a list of objects into an
* object indexing the objects by the given key. Note that if multiple
* objects generate the same value for the indexing key only the last value
* will be included in the generated object.
*
* Acts as a transducer if a transformer is given in list position.
*
* @func
* @memberOf R
* @since v0.19.0
* @category List
* @sig (a -> String) -> [{k: v}] -> {k: {k: v}}
* @param {Function} fn Function :: a -> String
* @param {Array} array The array of objects to index
* @return {Object} An object indexing each array element by the given property.
* @example
*
* var list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}];
* R.indexBy(R.prop('id'), list);
* //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}
*/
var indexBy = /*#__PURE__*/reduceBy(function (acc, elem) {
return elem;
}, null);
module.exports = indexBy;
+31
View File
@@ -0,0 +1,31 @@
var _curry2 = /*#__PURE__*/require('./internal/_curry2');
var _indexOf = /*#__PURE__*/require('./internal/_indexOf');
var _isArray = /*#__PURE__*/require('./internal/_isArray');
/**
* Returns the position of the first occurrence of an item in an array, or -1
* if the item is not included in the array. [`R.equals`](#equals) is used to
* determine equality.
*
* @func
* @memberOf R
* @since v0.1.0
* @category List
* @sig a -> [a] -> Number
* @param {*} target The item to find.
* @param {Array} xs The array to search in.
* @return {Number} the index of the target, or -1 if the target is not found.
* @see R.lastIndexOf
* @example
*
* R.indexOf(3, [1,2,3,4]); //=> 2
* R.indexOf(10, [1,2,3,4]); //=> -1
*/
var indexOf = /*#__PURE__*/_curry2(function indexOf(target, xs) {
return typeof xs.indexOf === 'function' && !_isArray(xs) ? xs.indexOf(target) : _indexOf(xs, target, 0);
});
module.exports = indexOf;
+30
View File
@@ -0,0 +1,30 @@
var slice = /*#__PURE__*/require('./slice');
/**
* Returns all but the last element of the given list or string.
*
* @func
* @memberOf R
* @since v0.9.0
* @category List
* @sig [a] -> [a]
* @sig String -> String
* @param {*} list
* @return {*}
* @see R.last, R.head, R.tail
* @example
*
* R.init([1, 2, 3]); //=> [1, 2]
* R.init([1, 2]); //=> [1]
* R.init([1]); //=> []
* R.init([]); //=> []
*
* R.init('abc'); //=> 'ab'
* R.init('ab'); //=> 'a'
* R.init('a'); //=> ''
* R.init(''); //=> ''
*/
var init = /*#__PURE__*/slice(0, -1);
module.exports = init;
+49
View File
@@ -0,0 +1,49 @@
var _containsWith = /*#__PURE__*/require('./internal/_containsWith');
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
var _filter = /*#__PURE__*/require('./internal/_filter');
/**
* Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list
* `xs'` comprising each of the elements of `xs` which is equal to one or more
* elements of `ys` according to `pred`.
*
* `pred` must be a binary function expecting an element from each list.
*
* `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should
* not be significant, but since `xs'` is ordered the implementation guarantees
* that its values are in the same order as they appear in `xs`. Duplicates are
* not removed, so `xs'` may contain duplicates if `xs` contains duplicates.
*
* @func
* @memberOf R
* @since v0.24.0
* @category Relation
* @sig ((a, b) -> Boolean) -> [a] -> [b] -> [a]
* @param {Function} pred
* @param {Array} xs
* @param {Array} ys
* @return {Array}
* @see R.intersection
* @example
*
* R.innerJoin(
* (record, id) => record.id === id,
* [{id: 824, name: 'Richie Furay'},
* {id: 956, name: 'Dewey Martin'},
* {id: 313, name: 'Bruce Palmer'},
* {id: 456, name: 'Stephen Stills'},
* {id: 177, name: 'Neil Young'}],
* [177, 456, 999]
* );
* //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}]
*/
var innerJoin = /*#__PURE__*/_curry3(function innerJoin(pred, xs, ys) {
return _filter(function (x) {
return _containsWith(pred, x, ys);
}, xs);
});
module.exports = innerJoin;
+30
View File
@@ -0,0 +1,30 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Inserts the supplied element into the list, at the specified `index`. _Note that
* this is not destructive_: it returns a copy of the list with the changes.
* <small>No lists have been harmed in the application of this function.</small>
*
* @func
* @memberOf R
* @since v0.2.2
* @category List
* @sig Number -> a -> [a] -> [a]
* @param {Number} index The position to insert the element
* @param {*} elt The element to insert into the Array
* @param {Array} list The list to insert into
* @return {Array} A new Array with `elt` inserted at `index`.
* @example
*
* R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4]
*/
var insert = /*#__PURE__*/_curry3(function insert(idx, elt, list) {
idx = idx < list.length && idx >= 0 ? idx : list.length;
var result = Array.prototype.slice.call(list, 0);
result.splice(idx, 0, elt);
return result;
});
module.exports = insert;
+27
View File
@@ -0,0 +1,27 @@
var _curry3 = /*#__PURE__*/require('./internal/_curry3');
/**
* Inserts the sub-list into the list, at the specified `index`. _Note that this is not
* destructive_: it returns a copy of the list with the changes.
* <small>No lists have been harmed in the application of this function.</small>
*
* @func
* @memberOf R
* @since v0.9.0
* @category List
* @sig Number -> [a] -> [a] -> [a]
* @param {Number} index The position to insert the sub-list
* @param {Array} elts The sub-list to insert into the Array
* @param {Array} list The list to insert the sub-list into
* @return {Array} A new Array with `elts` inserted starting at `index`.
* @example
*
* R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4]
*/
var insertAll = /*#__PURE__*/_curry3(function insertAll(idx, elts, list) {
idx = idx < list.length && idx >= 0 ? idx : list.length;
return [].concat(Array.prototype.slice.call(list, 0, idx), elts, Array.prototype.slice.call(list, idx));
});
module.exports = insertAll;
+174
View File
@@ -0,0 +1,174 @@
var _contains = /*#__PURE__*/require('./_contains');
var _Set = /*#__PURE__*/function () {
function _Set() {
/* globals Set */
this._nativeSet = typeof Set === 'function' ? new Set() : null;
this._items = {};
}
// until we figure out why jsdoc chokes on this
// @param item The item to add to the Set
// @returns {boolean} true if the item did not exist prior, otherwise false
//
_Set.prototype.add = function (item) {
return !hasOrAdd(item, true, this);
};
//
// @param item The item to check for existence in the Set
// @returns {boolean} true if the item exists in the Set, otherwise false
//
_Set.prototype.has = function (item) {
return hasOrAdd(item, false, this);
};
//
// Combines the logic for checking whether an item is a member of the set and
// for adding a new item to the set.
//
// @param item The item to check or add to the Set instance.
// @param shouldAdd If true, the item will be added to the set if it doesn't
// already exist.
// @param set The set instance to check or add to.
// @return {boolean} true if the item already existed, otherwise false.
//
return _Set;
}();
function hasOrAdd(item, shouldAdd, set) {
var type = typeof item;
var prevSize, newSize;
switch (type) {
case 'string':
case 'number':
// distinguish between +0 and -0
if (item === 0 && 1 / item === -Infinity) {
if (set._items['-0']) {
return true;
} else {
if (shouldAdd) {
set._items['-0'] = true;
}
return false;
}
}
// these types can all utilise the native Set
if (set._nativeSet !== null) {
if (shouldAdd) {
prevSize = set._nativeSet.size;
set._nativeSet.add(item);
newSize = set._nativeSet.size;
return newSize === prevSize;
} else {
return set._nativeSet.has(item);
}
} else {
if (!(type in set._items)) {
if (shouldAdd) {
set._items[type] = {};
set._items[type][item] = true;
}
return false;
} else if (item in set._items[type]) {
return true;
} else {
if (shouldAdd) {
set._items[type][item] = true;
}
return false;
}
}
case 'boolean':
// set._items['boolean'] holds a two element array
// representing [ falseExists, trueExists ]
if (type in set._items) {
var bIdx = item ? 1 : 0;
if (set._items[type][bIdx]) {
return true;
} else {
if (shouldAdd) {
set._items[type][bIdx] = true;
}
return false;
}
} else {
if (shouldAdd) {
set._items[type] = item ? [false, true] : [true, false];
}
return false;
}
case 'function':
// compare functions for reference equality
if (set._nativeSet !== null) {
if (shouldAdd) {
prevSize = set._nativeSet.size;
set._nativeSet.add(item);
newSize = set._nativeSet.size;
return newSize === prevSize;
} else {
return set._nativeSet.has(item);
}
} else {
if (!(type in set._items)) {
if (shouldAdd) {
set._items[type] = [item];
}
return false;
}
if (!_contains(item, set._items[type])) {
if (shouldAdd) {
set._items[type].push(item);
}
return false;
}
return true;
}
case 'undefined':
if (set._items[type]) {
return true;
} else {
if (shouldAdd) {
set._items[type] = true;
}
return false;
}
case 'object':
if (item === null) {
if (!set._items['null']) {
if (shouldAdd) {
set._items['null'] = true;
}
return false;
}
return true;
}
/* falls through */
default:
// reduce the search size of heterogeneous sets by creating buckets
// for each type.
type = Object.prototype.toString.call(item);
if (!(type in set._items)) {
if (shouldAdd) {
set._items[type] = [item];
}
return false;
}
// scan through all previously applied items
if (!_contains(item, set._items[type])) {
if (shouldAdd) {
set._items[type].push(item);
}
return false;
}
return true;
}
}
// A simple Set type that honours R.equals semantics
module.exports = _Set;
+11
View File
@@ -0,0 +1,11 @@
function _aperture(n, list) {
var idx = 0;
var limit = list.length - (n - 1);
var acc = new Array(limit >= 0 ? limit : 0);
while (idx < limit) {
acc[idx] = Array.prototype.slice.call(list, idx, idx + n);
idx += 1;
}
return acc;
}
module.exports = _aperture;
+52
View File
@@ -0,0 +1,52 @@
function _arity(n, fn) {
/* eslint-disable no-unused-vars */
switch (n) {
case 0:
return function () {
return fn.apply(this, arguments);
};
case 1:
return function (a0) {
return fn.apply(this, arguments);
};
case 2:
return function (a0, a1) {
return fn.apply(this, arguments);
};
case 3:
return function (a0, a1, a2) {
return fn.apply(this, arguments);
};
case 4:
return function (a0, a1, a2, a3) {
return fn.apply(this, arguments);
};
case 5:
return function (a0, a1, a2, a3, a4) {
return fn.apply(this, arguments);
};
case 6:
return function (a0, a1, a2, a3, a4, a5) {
return fn.apply(this, arguments);
};
case 7:
return function (a0, a1, a2, a3, a4, a5, a6) {
return fn.apply(this, arguments);
};
case 8:
return function (a0, a1, a2, a3, a4, a5, a6, a7) {
return fn.apply(this, arguments);
};
case 9:
return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {
return fn.apply(this, arguments);
};
case 10:
return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
return fn.apply(this, arguments);
};
default:
throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
}
}
module.exports = _arity;
+9
View File
@@ -0,0 +1,9 @@
function _arrayFromIterator(iter) {
var list = [];
var next;
while (!(next = iter.next()).done) {
list.push(next.value);
}
return list;
}
module.exports = _arrayFromIterator;
+3
View File
@@ -0,0 +1,3 @@
var _objectAssign = /*#__PURE__*/require('./_objectAssign');
module.exports = typeof Object.assign === 'function' ? Object.assign : _objectAssign;
+25
View File
@@ -0,0 +1,25 @@
var _isArray = /*#__PURE__*/require('./_isArray');
/**
* This checks whether a function has a [methodname] function. If it isn't an
* array it will execute that function otherwise it will default to the ramda
* implementation.
*
* @private
* @param {Function} fn ramda implemtation
* @param {String} methodname property to check for a custom implementation
* @return {Object} Whatever the return value of the method is.
*/
function _checkForMethod(methodname, fn) {
return function () {
var length = arguments.length;
if (length === 0) {
return fn();
}
var obj = arguments[length - 1];
return _isArray(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
};
}
module.exports = _checkForMethod;
+47
View File
@@ -0,0 +1,47 @@
var _cloneRegExp = /*#__PURE__*/require('./_cloneRegExp');
var type = /*#__PURE__*/require('../type');
/**
* Copies an object.
*
* @private
* @param {*} value The value to be copied
* @param {Array} refFrom Array containing the source references
* @param {Array} refTo Array containing the copied source references
* @param {Boolean} deep Whether or not to perform deep cloning.
* @return {*} The copied value.
*/
function _clone(value, refFrom, refTo, deep) {
var copy = function copy(copiedValue) {
var len = refFrom.length;
var idx = 0;
while (idx < len) {
if (value === refFrom[idx]) {
return refTo[idx];
}
idx += 1;
}
refFrom[idx + 1] = value;
refTo[idx + 1] = copiedValue;
for (var key in value) {
copiedValue[key] = deep ? _clone(value[key], refFrom, refTo, true) : value[key];
}
return copiedValue;
};
switch (type(value)) {
case 'Object':
return copy({});
case 'Array':
return copy([]);
case 'Date':
return new Date(value.valueOf());
case 'RegExp':
return _cloneRegExp(value);
default:
return value;
}
}
module.exports = _clone;
+4
View File
@@ -0,0 +1,4 @@
function _cloneRegExp(pattern) {
return new RegExp(pattern.source, (pattern.global ? 'g' : '') + (pattern.ignoreCase ? 'i' : '') + (pattern.multiline ? 'm' : '') + (pattern.sticky ? 'y' : '') + (pattern.unicode ? 'u' : ''));
}
module.exports = _cloneRegExp;
+6
View File
@@ -0,0 +1,6 @@
function _complement(f) {
return function () {
return !f.apply(this, arguments);
};
}
module.exports = _complement;

Some files were not shown because too many files have changed in this diff Show More