action-debian-package/node_modules/ramda/src/internal/_xaperture.js
Dawid Dziurla 9308795b8b
update
2020-03-26 15:37:35 +01:00

58 lines
No EOL
1.2 KiB
JavaScript

var _concat =
/*#__PURE__*/
require("./_concat");
var _curry2 =
/*#__PURE__*/
require("./_curry2");
var _xfBase =
/*#__PURE__*/
require("./_xfBase");
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;
}();
var _xaperture =
/*#__PURE__*/
_curry2(function _xaperture(n, xf) {
return new XAperture(n, xf);
});
module.exports = _xaperture;