update
This commit is contained in:
parent
d9becc67b6
commit
9308795b8b
964 changed files with 104265 additions and 16 deletions
60
node_modules/ramda/src/internal/_xreduceBy.js
generated
vendored
Normal file
60
node_modules/ramda/src/internal/_xreduceBy.js
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
var _curryN =
|
||||
/*#__PURE__*/
|
||||
require("./_curryN");
|
||||
|
||||
var _has =
|
||||
/*#__PURE__*/
|
||||
require("./_has");
|
||||
|
||||
var _xfBase =
|
||||
/*#__PURE__*/
|
||||
require("./_xfBase");
|
||||
|
||||
var XReduceBy =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function XReduceBy(valueFn, valueAcc, keyFn, xf) {
|
||||
this.valueFn = valueFn;
|
||||
this.valueAcc = valueAcc;
|
||||
this.keyFn = keyFn;
|
||||
this.xf = xf;
|
||||
this.inputs = {};
|
||||
}
|
||||
|
||||
XReduceBy.prototype['@@transducer/init'] = _xfBase.init;
|
||||
|
||||
XReduceBy.prototype['@@transducer/result'] = function (result) {
|
||||
var key;
|
||||
|
||||
for (key in this.inputs) {
|
||||
if (_has(key, this.inputs)) {
|
||||
result = this.xf['@@transducer/step'](result, this.inputs[key]);
|
||||
|
||||
if (result['@@transducer/reduced']) {
|
||||
result = result['@@transducer/value'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.inputs = null;
|
||||
return this.xf['@@transducer/result'](result);
|
||||
};
|
||||
|
||||
XReduceBy.prototype['@@transducer/step'] = function (result, input) {
|
||||
var key = this.keyFn(input);
|
||||
this.inputs[key] = this.inputs[key] || [key, this.valueAcc];
|
||||
this.inputs[key][1] = this.valueFn(this.inputs[key][1], input);
|
||||
return result;
|
||||
};
|
||||
|
||||
return XReduceBy;
|
||||
}();
|
||||
|
||||
var _xreduceBy =
|
||||
/*#__PURE__*/
|
||||
_curryN(4, [], function _xreduceBy(valueFn, valueAcc, keyFn, xf) {
|
||||
return new XReduceBy(valueFn, valueAcc, keyFn, xf);
|
||||
});
|
||||
|
||||
module.exports = _xreduceBy;
|
||||
Loading…
Add table
Add a link
Reference in a new issue