Last change
on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = _createTester;
|
---|
7 |
|
---|
8 | var _noop = require('lodash/noop');
|
---|
9 |
|
---|
10 | var _noop2 = _interopRequireDefault(_noop);
|
---|
11 |
|
---|
12 | var _breakLoop = require('./breakLoop');
|
---|
13 |
|
---|
14 | var _breakLoop2 = _interopRequireDefault(_breakLoop);
|
---|
15 |
|
---|
16 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
---|
17 |
|
---|
18 | function _createTester(check, getResult) {
|
---|
19 | return function (eachfn, arr, iteratee, cb) {
|
---|
20 | cb = cb || _noop2.default;
|
---|
21 | var testPassed = false;
|
---|
22 | var testResult;
|
---|
23 | eachfn(arr, function (value, _, callback) {
|
---|
24 | iteratee(value, function (err, result) {
|
---|
25 | if (err) {
|
---|
26 | callback(err);
|
---|
27 | } else if (check(result) && !testResult) {
|
---|
28 | testPassed = true;
|
---|
29 | testResult = getResult(true, value);
|
---|
30 | callback(null, _breakLoop2.default);
|
---|
31 | } else {
|
---|
32 | callback();
|
---|
33 | }
|
---|
34 | });
|
---|
35 | }, function (err) {
|
---|
36 | if (err) {
|
---|
37 | cb(err);
|
---|
38 | } else {
|
---|
39 | cb(null, testPassed ? testResult : getResult(false));
|
---|
40 | }
|
---|
41 | });
|
---|
42 | };
|
---|
43 | }
|
---|
44 | module.exports = exports['default']; |
---|
Note:
See
TracBrowser
for help on using the repository browser.