main
Last change
on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 1 | import _xfBase from "./_xfBase.js";
|
---|
| 2 | import _xReduce from "./_xReduce.js";
|
---|
| 3 |
|
---|
| 4 | var XDropLastWhile =
|
---|
| 5 | /*#__PURE__*/
|
---|
| 6 | function () {
|
---|
| 7 | function XDropLastWhile(fn, xf) {
|
---|
| 8 | this.f = fn;
|
---|
| 9 | this.retained = [];
|
---|
| 10 | this.xf = xf;
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init;
|
---|
| 14 |
|
---|
| 15 | XDropLastWhile.prototype['@@transducer/result'] = function (result) {
|
---|
| 16 | this.retained = null;
|
---|
| 17 | return this.xf['@@transducer/result'](result);
|
---|
| 18 | };
|
---|
| 19 |
|
---|
| 20 | XDropLastWhile.prototype['@@transducer/step'] = function (result, input) {
|
---|
| 21 | return this.f(input) ? this.retain(result, input) : this.flush(result, input);
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | XDropLastWhile.prototype.flush = function (result, input) {
|
---|
| 25 | result = _xReduce(this.xf, result, this.retained);
|
---|
| 26 | this.retained = [];
|
---|
| 27 | return this.xf['@@transducer/step'](result, input);
|
---|
| 28 | };
|
---|
| 29 |
|
---|
| 30 | XDropLastWhile.prototype.retain = function (result, input) {
|
---|
| 31 | this.retained.push(input);
|
---|
| 32 | return result;
|
---|
| 33 | };
|
---|
| 34 |
|
---|
| 35 | return XDropLastWhile;
|
---|
| 36 | }();
|
---|
| 37 |
|
---|
| 38 | export default function _xdropLastWhile(fn) {
|
---|
| 39 | return function (xf) {
|
---|
| 40 | return new XDropLastWhile(fn, xf);
|
---|
| 41 | };
|
---|
| 42 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.