1 | var _curry2 =
|
2 |
|
3 | require("./_curry2");
|
4 |
|
5 | var _xfBase =
|
6 |
|
7 | require("./_xfBase");
|
8 |
|
9 | var XDropLast =
|
10 |
|
11 | function () {
|
12 | function XDropLast(n, xf) {
|
13 | this.xf = xf;
|
14 | this.pos = 0;
|
15 | this.full = false;
|
16 | this.acc = new Array(n);
|
17 | }
|
18 |
|
19 | XDropLast.prototype['@@transducer/init'] = _xfBase.init;
|
20 |
|
21 | XDropLast.prototype['@@transducer/result'] = function (result) {
|
22 | this.acc = null;
|
23 | return this.xf['@@transducer/result'](result);
|
24 | };
|
25 |
|
26 | XDropLast.prototype['@@transducer/step'] = function (result, input) {
|
27 | if (this.full) {
|
28 | result = this.xf['@@transducer/step'](result, this.acc[this.pos]);
|
29 | }
|
30 |
|
31 | this.store(input);
|
32 | return result;
|
33 | };
|
34 |
|
35 | XDropLast.prototype.store = function (input) {
|
36 | this.acc[this.pos] = input;
|
37 | this.pos += 1;
|
38 |
|
39 | if (this.pos === this.acc.length) {
|
40 | this.pos = 0;
|
41 | this.full = true;
|
42 | }
|
43 | };
|
44 |
|
45 | return XDropLast;
|
46 | }();
|
47 |
|
48 | var _xdropLast =
|
49 |
|
50 | _curry2(function _xdropLast(n, xf) {
|
51 | return new XDropLast(n, xf);
|
52 | });
|
53 |
|
54 | module.exports = _xdropLast; |
\ | No newline at end of file |