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:
1.1 KB
|
Line | |
---|
1 | import _concat from "./_concat.js";
|
---|
2 | import _xfBase from "./_xfBase.js";
|
---|
3 |
|
---|
4 | var XAperture =
|
---|
5 | /*#__PURE__*/
|
---|
6 | function () {
|
---|
7 | function XAperture(n, xf) {
|
---|
8 | this.xf = xf;
|
---|
9 | this.pos = 0;
|
---|
10 | this.full = false;
|
---|
11 | this.acc = new Array(n);
|
---|
12 | }
|
---|
13 |
|
---|
14 | XAperture.prototype['@@transducer/init'] = _xfBase.init;
|
---|
15 |
|
---|
16 | XAperture.prototype['@@transducer/result'] = function (result) {
|
---|
17 | this.acc = null;
|
---|
18 | return this.xf['@@transducer/result'](result);
|
---|
19 | };
|
---|
20 |
|
---|
21 | XAperture.prototype['@@transducer/step'] = function (result, input) {
|
---|
22 | this.store(input);
|
---|
23 | return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result;
|
---|
24 | };
|
---|
25 |
|
---|
26 | XAperture.prototype.store = function (input) {
|
---|
27 | this.acc[this.pos] = input;
|
---|
28 | this.pos += 1;
|
---|
29 |
|
---|
30 | if (this.pos === this.acc.length) {
|
---|
31 | this.pos = 0;
|
---|
32 | this.full = true;
|
---|
33 | }
|
---|
34 | };
|
---|
35 |
|
---|
36 | XAperture.prototype.getCopy = function () {
|
---|
37 | return _concat(Array.prototype.slice.call(this.acc, this.pos), Array.prototype.slice.call(this.acc, 0, this.pos));
|
---|
38 | };
|
---|
39 |
|
---|
40 | return XAperture;
|
---|
41 | }();
|
---|
42 |
|
---|
43 | export default function _xaperture(n) {
|
---|
44 | return function (xf) {
|
---|
45 | return new XAperture(n, xf);
|
---|
46 | };
|
---|
47 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.