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:
887 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import _reduced from "./_reduced.js";
|
---|
| 2 | import _xfBase from "./_xfBase.js";
|
---|
| 3 |
|
---|
| 4 | var XFindIndex =
|
---|
| 5 | /*#__PURE__*/
|
---|
| 6 | function () {
|
---|
| 7 | function XFindIndex(f, xf) {
|
---|
| 8 | this.xf = xf;
|
---|
| 9 | this.f = f;
|
---|
| 10 | this.idx = -1;
|
---|
| 11 | this.found = false;
|
---|
| 12 | }
|
---|
| 13 |
|
---|
| 14 | XFindIndex.prototype['@@transducer/init'] = _xfBase.init;
|
---|
| 15 |
|
---|
| 16 | XFindIndex.prototype['@@transducer/result'] = function (result) {
|
---|
| 17 | if (!this.found) {
|
---|
| 18 | result = this.xf['@@transducer/step'](result, -1);
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | return this.xf['@@transducer/result'](result);
|
---|
| 22 | };
|
---|
| 23 |
|
---|
| 24 | XFindIndex.prototype['@@transducer/step'] = function (result, input) {
|
---|
| 25 | this.idx += 1;
|
---|
| 26 |
|
---|
| 27 | if (this.f(input)) {
|
---|
| 28 | this.found = true;
|
---|
| 29 | result = _reduced(this.xf['@@transducer/step'](result, this.idx));
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | return result;
|
---|
| 33 | };
|
---|
| 34 |
|
---|
| 35 | return XFindIndex;
|
---|
| 36 | }();
|
---|
| 37 |
|
---|
| 38 | export default function _xfindIndex(f) {
|
---|
| 39 | return function (xf) {
|
---|
| 40 | return new XFindIndex(f, xf);
|
---|
| 41 | };
|
---|
| 42 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.