1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import _concat from "./_concat.js";
- import _xfBase from "./_xfBase.js";
- var XAperture =
- /*#__PURE__*/
- function () {
- function XAperture(n, xf) {
- this.xf = xf;
- this.pos = 0;
- this.full = false;
- this.acc = new Array(n);
- }
- XAperture.prototype['@@transducer/init'] = _xfBase.init;
- XAperture.prototype['@@transducer/result'] = function (result) {
- this.acc = null;
- return this.xf['@@transducer/result'](result);
- };
- XAperture.prototype['@@transducer/step'] = function (result, input) {
- this.store(input);
- return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result;
- };
- XAperture.prototype.store = function (input) {
- this.acc[this.pos] = input;
- this.pos += 1;
- if (this.pos === this.acc.length) {
- this.pos = 0;
- this.full = true;
- }
- };
- XAperture.prototype.getCopy = function () {
- return _concat(Array.prototype.slice.call(this.acc, this.pos), Array.prototype.slice.call(this.acc, 0, this.pos));
- };
- return XAperture;
- }();
- export default function _xaperture(n) {
- return function (xf) {
- return new XAperture(n, xf);
- };
- }
|