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:
669 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _reduced from "./_reduced.js";
|
---|
| 2 | import _xfBase from "./_xfBase.js";
|
---|
| 3 |
|
---|
| 4 | var XTake =
|
---|
| 5 | /*#__PURE__*/
|
---|
| 6 | function () {
|
---|
| 7 | function XTake(n, xf) {
|
---|
| 8 | this.xf = xf;
|
---|
| 9 | this.n = n;
|
---|
| 10 | this.i = 0;
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | XTake.prototype['@@transducer/init'] = _xfBase.init;
|
---|
| 14 | XTake.prototype['@@transducer/result'] = _xfBase.result;
|
---|
| 15 |
|
---|
| 16 | XTake.prototype['@@transducer/step'] = function (result, input) {
|
---|
| 17 | this.i += 1;
|
---|
| 18 | var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input);
|
---|
| 19 | return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret;
|
---|
| 20 | };
|
---|
| 21 |
|
---|
| 22 | return XTake;
|
---|
| 23 | }();
|
---|
| 24 |
|
---|
| 25 | export default function _xtake(n) {
|
---|
| 26 | return function (xf) {
|
---|
| 27 | return new XTake(n, xf);
|
---|
| 28 | };
|
---|
| 29 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.