source: node_modules/ramda/src/internal/_xfindIndex.js

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