main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
718 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _createReduce from "./_createReduce.js";
|
---|
| 2 | import _xArrayReduce from "./_xArrayReduce.js";
|
---|
| 3 | import bind from "../bind.js";
|
---|
| 4 |
|
---|
| 5 | function _xIterableReduce(xf, acc, iter) {
|
---|
| 6 | var step = iter.next();
|
---|
| 7 |
|
---|
| 8 | while (!step.done) {
|
---|
| 9 | acc = xf['@@transducer/step'](acc, step.value);
|
---|
| 10 |
|
---|
| 11 | if (acc && acc['@@transducer/reduced']) {
|
---|
| 12 | acc = acc['@@transducer/value'];
|
---|
| 13 | break;
|
---|
| 14 | }
|
---|
| 15 |
|
---|
| 16 | step = iter.next();
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | return xf['@@transducer/result'](acc);
|
---|
| 20 | }
|
---|
| 21 |
|
---|
| 22 | function _xMethodReduce(xf, acc, obj, methodName) {
|
---|
| 23 | return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc));
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | var _xReduce =
|
---|
| 27 | /*#__PURE__*/
|
---|
| 28 | _createReduce(_xArrayReduce, _xMethodReduce, _xIterableReduce);
|
---|
| 29 |
|
---|
| 30 | export default _xReduce; |
---|
Note:
See
TracBrowser
for help on using the repository browser.