UNPKG

909 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./_curry2");
4
5var _reduced =
6/*#__PURE__*/
7require("./_reduced");
8
9var _xfBase =
10/*#__PURE__*/
11require("./_xfBase");
12
13var XFind =
14/*#__PURE__*/
15function () {
16 function XFind(f, xf) {
17 this.xf = xf;
18 this.f = f;
19 this.found = false;
20 }
21
22 XFind.prototype['@@transducer/init'] = _xfBase.init;
23
24 XFind.prototype['@@transducer/result'] = function (result) {
25 if (!this.found) {
26 result = this.xf['@@transducer/step'](result, void 0);
27 }
28
29 return this.xf['@@transducer/result'](result);
30 };
31
32 XFind.prototype['@@transducer/step'] = function (result, input) {
33 if (this.f(input)) {
34 this.found = true;
35 result = _reduced(this.xf['@@transducer/step'](result, input));
36 }
37
38 return result;
39 };
40
41 return XFind;
42}();
43
44var _xfind =
45/*#__PURE__*/
46_curry2(function _xfind(f, xf) {
47 return new XFind(f, xf);
48});
49
50module.exports = _xfind;
\No newline at end of file