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:
816 bytes
|
Line | |
---|
1 | import _curry3 from "./_curry3.js";
|
---|
2 | import _xfBase from "./_xfBase.js";
|
---|
3 | var tInit = '@@transducer/init';
|
---|
4 | var tStep = '@@transducer/step';
|
---|
5 |
|
---|
6 | var XScan =
|
---|
7 | /*#__PURE__*/
|
---|
8 | function () {
|
---|
9 | function XScan(reducer, acc, xf) {
|
---|
10 | this.xf = xf;
|
---|
11 | this.f = reducer;
|
---|
12 | this.acc = acc;
|
---|
13 | }
|
---|
14 |
|
---|
15 | XScan.prototype[tInit] = function () {
|
---|
16 | return this.xf[tStep](this.xf[tInit](), this.acc);
|
---|
17 | };
|
---|
18 |
|
---|
19 | XScan.prototype['@@transducer/result'] = _xfBase.result;
|
---|
20 |
|
---|
21 | XScan.prototype[tStep] = function (result, input) {
|
---|
22 | if (result['@@transducer/reduced']) {
|
---|
23 | return result;
|
---|
24 | }
|
---|
25 |
|
---|
26 | this.acc = this.f(this.acc, input);
|
---|
27 | return this.xf[tStep](result, this.acc);
|
---|
28 | };
|
---|
29 |
|
---|
30 | return XScan;
|
---|
31 | }();
|
---|
32 |
|
---|
33 | var _xscan =
|
---|
34 | /*#__PURE__*/
|
---|
35 | _curry3(function _xscan(reducer, acc, xf) {
|
---|
36 | return new XScan(reducer, acc, xf);
|
---|
37 | });
|
---|
38 |
|
---|
39 | export default _xscan; |
---|
Note:
See
TracBrowser
for help on using the repository browser.