mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/internal/_xaperture.js
|
|
|
|
|
|
import _concat from './_concat.js';
|
|
import _curry2 from './_curry2.js';
|
|
import _xfBase from './_xfBase.js';
|
|
|
|
|
|
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)
|
|
);
|
|
};
|
|
|
|
var _xaperture = _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); });
|
|
export default _xaperture;
|