source: trip-planner-front/node_modules/async/internal/createTester.js@ fa375fe

Last change on this file since fa375fe 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
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = _createTester;
7
8var _noop = require('lodash/noop');
9
10var _noop2 = _interopRequireDefault(_noop);
11
12var _breakLoop = require('./breakLoop');
13
14var _breakLoop2 = _interopRequireDefault(_breakLoop);
15
16function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
18function _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}
44module.exports = exports['default'];
Note: See TracBrowser for help on using the repository browser.