main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | var _concat =
|
---|
2 | /*#__PURE__*/
|
---|
3 | require("./_concat.js");
|
---|
4 |
|
---|
5 | var _xfBase =
|
---|
6 | /*#__PURE__*/
|
---|
7 | require("./_xfBase.js");
|
---|
8 |
|
---|
9 | var XAperture =
|
---|
10 | /*#__PURE__*/
|
---|
11 | function () {
|
---|
12 | function XAperture(n, xf) {
|
---|
13 | this.xf = xf;
|
---|
14 | this.pos = 0;
|
---|
15 | this.full = false;
|
---|
16 | this.acc = new Array(n);
|
---|
17 | }
|
---|
18 |
|
---|
19 | XAperture.prototype['@@transducer/init'] = _xfBase.init;
|
---|
20 |
|
---|
21 | XAperture.prototype['@@transducer/result'] = function (result) {
|
---|
22 | this.acc = null;
|
---|
23 | return this.xf['@@transducer/result'](result);
|
---|
24 | };
|
---|
25 |
|
---|
26 | XAperture.prototype['@@transducer/step'] = function (result, input) {
|
---|
27 | this.store(input);
|
---|
28 | return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result;
|
---|
29 | };
|
---|
30 |
|
---|
31 | XAperture.prototype.store = function (input) {
|
---|
32 | this.acc[this.pos] = input;
|
---|
33 | this.pos += 1;
|
---|
34 |
|
---|
35 | if (this.pos === this.acc.length) {
|
---|
36 | this.pos = 0;
|
---|
37 | this.full = true;
|
---|
38 | }
|
---|
39 | };
|
---|
40 |
|
---|
41 | XAperture.prototype.getCopy = function () {
|
---|
42 | return _concat(Array.prototype.slice.call(this.acc, this.pos), Array.prototype.slice.call(this.acc, 0, this.pos));
|
---|
43 | };
|
---|
44 |
|
---|
45 | return XAperture;
|
---|
46 | }();
|
---|
47 |
|
---|
48 | function _xaperture(n) {
|
---|
49 | return function (xf) {
|
---|
50 | return new XAperture(n, xf);
|
---|
51 | };
|
---|
52 | }
|
---|
53 |
|
---|
54 | module.exports = _xaperture; |
---|
Note:
See
TracBrowser
for help on using the repository browser.