async-rails 2.1.4 → 2.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87fa3fd0f1c73f460ff534125ba7c4635d8106a2
4
- data.tar.gz: d8acf4e0a42ea4f8985f445ed8dbedad358447dd
3
+ metadata.gz: b37af162feb594fd569a51c6ac921efdfdcd67c3
4
+ data.tar.gz: 58b4b49a83a252db8a0233c44412dbe75de6d5c6
5
5
  SHA512:
6
- metadata.gz: 8e3074c0a08b2c7a38f664326047d0edb7d608e7230681378914c78287b481de818e87de05c1eedced4671328f569b3f84ebb5da097f38da3079adc438e47478
7
- data.tar.gz: cfd9b3c87368d000562e011bfcd6ad7f940e457191972e133aa7c1b4ca2a13da7da52c0e5079a730e75d4bc59d14ab2b6cc44f8f0c935d7672b3f7a02e1da28d
6
+ metadata.gz: 5c4e9ca797f8b8a68cc2fb32ffa8f4cfb6c4cd501f94efc31f90ddbce917ddae14e7fc986c10832b7dc309ebaadb7641938dd8c346f78d5abf6474052eb22156
7
+ data.tar.gz: 45f958bb66b6e34aa6fd1b88b71e7a7f436423430d505e4ed3302ee12470751ebdfb73f237d2e66c71fcb7efad69cdce50436532fab1765bf28599878cf633c6
@@ -1,5 +1,5 @@
1
1
  module Async
2
2
  module Rails
3
- VERSION = "2.1.4"
3
+ VERSION = "2.1.5"
4
4
  end
5
5
  end
@@ -95,7 +95,7 @@ function applyEach$1(eachfn) {
95
95
  var go = initialParams(function (args, callback) {
96
96
  var that = this;
97
97
  return eachfn(fns, function (fn, cb) {
98
- fn.apply(that, args.concat([cb]));
98
+ fn.apply(that, args.concat(cb));
99
99
  }, callback);
100
100
  });
101
101
  if (args.length) {
@@ -200,8 +200,7 @@ function baseGetTag(value) {
200
200
  if (value == null) {
201
201
  return value === undefined ? undefinedTag : nullTag;
202
202
  }
203
- value = Object(value);
204
- return (symToStringTag && symToStringTag in value)
203
+ return (symToStringTag && symToStringTag in Object(value))
205
204
  ? getRawTag(value)
206
205
  : objectToString(value);
207
206
  }
@@ -332,6 +331,10 @@ function isArrayLike(value) {
332
331
  return value != null && isLength(value.length) && !isFunction(value);
333
332
  }
334
333
 
334
+ // A temporary value used to identify if the loop should be broken.
335
+ // See #1064, #1293
336
+ var breakLoop = {};
337
+
335
338
  /**
336
339
  * This method returns `undefined`.
337
340
  *
@@ -636,7 +639,7 @@ var freeProcess = moduleExports$1 && freeGlobal.process;
636
639
  /** Used to access faster Node.js helpers. */
637
640
  var nodeUtil = (function() {
638
641
  try {
639
- return freeProcess && freeProcess.binding('util');
642
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
640
643
  } catch (e) {}
641
644
  }());
642
645
 
@@ -841,10 +844,6 @@ function onlyOnce(fn) {
841
844
  };
842
845
  }
843
846
 
844
- // A temporary value used to identify if the loop should be broken.
845
- // See #1064, #1293
846
- var breakLoop = {};
847
-
848
847
  function _eachOfLimit(limit) {
849
848
  return function (obj, iteratee, callback) {
850
849
  callback = once(callback || noop);
@@ -929,10 +928,10 @@ function eachOfArrayLike(coll, iteratee, callback) {
929
928
  callback(null);
930
929
  }
931
930
 
932
- function iteratorCallback(err) {
931
+ function iteratorCallback(err, value) {
933
932
  if (err) {
934
933
  callback(err);
935
- } else if (++completed === length) {
934
+ } else if (++completed === length || value === breakLoop) {
936
935
  callback(null);
937
936
  }
938
937
  }
@@ -1521,7 +1520,7 @@ var auto = function (tasks, concurrency, callback) {
1521
1520
  var runningTasks = 0;
1522
1521
  var hasError = false;
1523
1522
 
1524
- var listeners = {};
1523
+ var listeners = Object.create(null);
1525
1524
 
1526
1525
  var readyTasks = [];
1527
1526
 
@@ -1549,7 +1548,7 @@ var auto = function (tasks, concurrency, callback) {
1549
1548
 
1550
1549
  arrayEach(dependencies, function (dependencyName) {
1551
1550
  if (!tasks[dependencyName]) {
1552
- throw new Error('async.auto task `' + key + '` has a non-existent dependency in ' + dependencies.join(', '));
1551
+ throw new Error('async.auto task `' + key + '` has a non-existent dependency `' + dependencyName + '` in ' + dependencies.join(', '));
1553
1552
  }
1554
1553
  addListener(dependencyName, function () {
1555
1554
  remainingDependencies--;
@@ -1611,7 +1610,7 @@ var auto = function (tasks, concurrency, callback) {
1611
1610
  });
1612
1611
  safeResults[key] = args;
1613
1612
  hasError = true;
1614
- listeners = [];
1613
+ listeners = Object.create(null);
1615
1614
 
1616
1615
  callback(err, safeResults);
1617
1616
  } else {
@@ -1828,15 +1827,17 @@ function asciiToArray(string) {
1828
1827
 
1829
1828
  /** Used to compose unicode character classes. */
1830
1829
  var rsAstralRange = '\\ud800-\\udfff';
1831
- var rsComboMarksRange = '\\u0300-\\u036f\\ufe20-\\ufe23';
1832
- var rsComboSymbolsRange = '\\u20d0-\\u20f0';
1830
+ var rsComboMarksRange = '\\u0300-\\u036f';
1831
+ var reComboHalfMarksRange = '\\ufe20-\\ufe2f';
1832
+ var rsComboSymbolsRange = '\\u20d0-\\u20ff';
1833
+ var rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange;
1833
1834
  var rsVarRange = '\\ufe0e\\ufe0f';
1834
1835
 
1835
1836
  /** Used to compose unicode capture groups. */
1836
1837
  var rsZWJ = '\\u200d';
1837
1838
 
1838
1839
  /** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
1839
- var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboMarksRange + rsComboSymbolsRange + rsVarRange + ']');
1840
+ var reHasUnicode = RegExp('[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']');
1840
1841
 
1841
1842
  /**
1842
1843
  * Checks if `string` contains Unicode symbols.
@@ -1851,13 +1852,15 @@ function hasUnicode(string) {
1851
1852
 
1852
1853
  /** Used to compose unicode character classes. */
1853
1854
  var rsAstralRange$1 = '\\ud800-\\udfff';
1854
- var rsComboMarksRange$1 = '\\u0300-\\u036f\\ufe20-\\ufe23';
1855
- var rsComboSymbolsRange$1 = '\\u20d0-\\u20f0';
1855
+ var rsComboMarksRange$1 = '\\u0300-\\u036f';
1856
+ var reComboHalfMarksRange$1 = '\\ufe20-\\ufe2f';
1857
+ var rsComboSymbolsRange$1 = '\\u20d0-\\u20ff';
1858
+ var rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1;
1856
1859
  var rsVarRange$1 = '\\ufe0e\\ufe0f';
1857
1860
 
1858
1861
  /** Used to compose unicode capture groups. */
1859
1862
  var rsAstral = '[' + rsAstralRange$1 + ']';
1860
- var rsCombo = '[' + rsComboMarksRange$1 + rsComboSymbolsRange$1 + ']';
1863
+ var rsCombo = '[' + rsComboRange$1 + ']';
1861
1864
  var rsFitz = '\\ud83c[\\udffb-\\udfff]';
1862
1865
  var rsModifier = '(?:' + rsCombo + '|' + rsFitz + ')';
1863
1866
  var rsNonAstral = '[^' + rsAstralRange$1 + ']';
@@ -2251,6 +2254,7 @@ function queue(worker, concurrency, payload) {
2251
2254
 
2252
2255
  var workers = 0;
2253
2256
  var workersList = [];
2257
+ var isProcessing = false;
2254
2258
  var q = {
2255
2259
  _tasks: new DLL(),
2256
2260
  concurrency: concurrency,
@@ -2274,6 +2278,12 @@ function queue(worker, concurrency, payload) {
2274
2278
  _insert(data, true, callback);
2275
2279
  },
2276
2280
  process: function () {
2281
+ // Avoid trying to start too many processing operations. This can occur
2282
+ // when callbacks resolve synchronously (#1267).
2283
+ if (isProcessing) {
2284
+ return;
2285
+ }
2286
+ isProcessing = true;
2277
2287
  while (!q.paused && workers < q.concurrency && q._tasks.length) {
2278
2288
  var tasks = [],
2279
2289
  data = [];
@@ -2298,6 +2308,7 @@ function queue(worker, concurrency, payload) {
2298
2308
  var cb = onlyOnce(_next(tasks));
2299
2309
  worker(data, cb);
2300
2310
  }
2311
+ isProcessing = false;
2301
2312
  },
2302
2313
  length: function () {
2303
2314
  return q._tasks.length;
@@ -2319,12 +2330,7 @@ function queue(worker, concurrency, payload) {
2319
2330
  return;
2320
2331
  }
2321
2332
  q.paused = false;
2322
- var resumeCount = Math.min(q.concurrency, q._tasks.length);
2323
- // Need to call q.process once per concurrent
2324
- // worker to preserve full concurrency after pause
2325
- for (var w = 1; w <= resumeCount; w++) {
2326
- setImmediate$1(q.process);
2327
- }
2333
+ setImmediate$1(q.process);
2328
2334
  }
2329
2335
  };
2330
2336
  return q;
@@ -2535,9 +2541,9 @@ var seq$1 = rest(function seq(functions) {
2535
2541
  }
2536
2542
 
2537
2543
  reduce(functions, args, function (newargs, fn, cb) {
2538
- fn.apply(that, newargs.concat([rest(function (err, nextargs) {
2544
+ fn.apply(that, newargs.concat(rest(function (err, nextargs) {
2539
2545
  cb(err, nextargs);
2540
- })]));
2546
+ })));
2541
2547
  }, function (err, results) {
2542
2548
  cb.apply(that, [err].concat(results));
2543
2549
  });
@@ -2700,36 +2706,30 @@ var constant = rest(function (values) {
2700
2706
  });
2701
2707
  });
2702
2708
 
2703
- function _createTester(eachfn, check, getResult) {
2704
- return function (arr, limit, iteratee, cb) {
2705
- function done() {
2706
- if (cb) {
2707
- cb(null, getResult(false));
2708
- }
2709
- }
2710
- function wrappedIteratee(x, _, callback) {
2711
- if (!cb) return callback();
2712
- iteratee(x, function (err, v) {
2713
- // Check cb as another iteratee may have resolved with a
2714
- // value or error since we started this iteratee
2715
- if (cb && (err || check(v))) {
2716
- if (err) cb(err);else cb(err, getResult(true, x));
2717
- cb = iteratee = false;
2718
- callback(err, breakLoop);
2709
+ function _createTester(check, getResult) {
2710
+ return function (eachfn, arr, iteratee, cb) {
2711
+ cb = cb || noop;
2712
+ var testPassed = false;
2713
+ var testResult;
2714
+ eachfn(arr, function (value, _, callback) {
2715
+ iteratee(value, function (err, result) {
2716
+ if (err) {
2717
+ callback(err);
2718
+ } else if (check(result) && !testResult) {
2719
+ testPassed = true;
2720
+ testResult = getResult(true, value);
2721
+ callback(null, breakLoop);
2719
2722
  } else {
2720
2723
  callback();
2721
2724
  }
2722
2725
  });
2723
- }
2724
- if (arguments.length > 3) {
2725
- cb = cb || noop;
2726
- eachfn(arr, limit, wrappedIteratee, done);
2727
- } else {
2728
- cb = iteratee;
2729
- cb = cb || noop;
2730
- iteratee = limit;
2731
- eachfn(arr, wrappedIteratee, done);
2732
- }
2726
+ }, function (err) {
2727
+ if (err) {
2728
+ cb(err);
2729
+ } else {
2730
+ cb(null, testPassed ? testResult : getResult(false));
2731
+ }
2732
+ });
2733
2733
  };
2734
2734
  }
2735
2735
 
@@ -2772,7 +2772,7 @@ function _findGetResult(v, x) {
2772
2772
  * // result now equals the first file in the list that exists
2773
2773
  * });
2774
2774
  */
2775
- var detect = _createTester(eachOf, identity, _findGetResult);
2775
+ var detect = doParallel(_createTester(identity, _findGetResult));
2776
2776
 
2777
2777
  /**
2778
2778
  * The same as [`detect`]{@link module:Collections.detect} but runs a maximum of `limit` async operations at a
@@ -2796,7 +2796,7 @@ var detect = _createTester(eachOf, identity, _findGetResult);
2796
2796
  * (iteratee) or the value `undefined` if none passed. Invoked with
2797
2797
  * (err, result).
2798
2798
  */
2799
- var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
2799
+ var detectLimit = doParallelLimit(_createTester(identity, _findGetResult));
2800
2800
 
2801
2801
  /**
2802
2802
  * The same as [`detect`]{@link module:Collections.detect} but runs only a single async operation at a time.
@@ -2818,11 +2818,11 @@ var detectLimit = _createTester(eachOfLimit, identity, _findGetResult);
2818
2818
  * (iteratee) or the value `undefined` if none passed. Invoked with
2819
2819
  * (err, result).
2820
2820
  */
2821
- var detectSeries = _createTester(eachOfSeries, identity, _findGetResult);
2821
+ var detectSeries = doLimit(detectLimit, 1);
2822
2822
 
2823
2823
  function consoleFunc(name) {
2824
2824
  return rest(function (fn, args) {
2825
- fn.apply(null, args.concat([rest(function (err, args) {
2825
+ fn.apply(null, args.concat(rest(function (err, args) {
2826
2826
  if (typeof console === 'object') {
2827
2827
  if (err) {
2828
2828
  if (console.error) {
@@ -2834,7 +2834,7 @@ function consoleFunc(name) {
2834
2834
  });
2835
2835
  }
2836
2836
  }
2837
- })]));
2837
+ })));
2838
2838
  });
2839
2839
  }
2840
2840
 
@@ -2923,7 +2923,7 @@ function doDuring(fn, test, callback) {
2923
2923
  * passes. The function is passed a `callback(err)`, which must be called once
2924
2924
  * it has completed with an optional `err` argument. Invoked with (callback).
2925
2925
  * @param {Function} test - synchronous truth test to perform after each
2926
- * execution of `iteratee`. Invoked with the non-error callback results of
2926
+ * execution of `iteratee`. Invoked with the non-error callback results of
2927
2927
  * `iteratee`.
2928
2928
  * @param {Function} [callback] - A callback which is called after the test
2929
2929
  * function has failed and repeated execution of `iteratee` has stopped.
@@ -3220,7 +3220,7 @@ function notId(v) {
3220
3220
  * // if result is true then every file exists
3221
3221
  * });
3222
3222
  */
3223
- var every = _createTester(eachOf, notId, notId);
3223
+ var every = doParallel(_createTester(notId, notId));
3224
3224
 
3225
3225
  /**
3226
3226
  * The same as [`every`]{@link module:Collections.every} but runs a maximum of `limit` async operations at a time.
@@ -3242,7 +3242,7 @@ var every = _createTester(eachOf, notId, notId);
3242
3242
  * `iteratee` functions have finished. Result will be either `true` or `false`
3243
3243
  * depending on the values of the async tests. Invoked with (err, result).
3244
3244
  */
3245
- var everyLimit = _createTester(eachOfLimit, notId, notId);
3245
+ var everyLimit = doParallelLimit(_createTester(notId, notId));
3246
3246
 
3247
3247
  /**
3248
3248
  * The same as [`every`]{@link module:Collections.every} but runs only a single async operation at a time.
@@ -3620,14 +3620,14 @@ function memoize(fn, hasher) {
3620
3620
  queues[key].push(callback);
3621
3621
  } else {
3622
3622
  queues[key] = [callback];
3623
- fn.apply(null, args.concat([rest(function (args) {
3623
+ fn.apply(null, args.concat(rest(function (args) {
3624
3624
  memo[key] = args;
3625
3625
  var q = queues[key];
3626
3626
  delete queues[key];
3627
3627
  for (var i = 0, l = q.length; i < l; i++) {
3628
3628
  q[i].apply(null, args);
3629
3629
  }
3630
- })]));
3630
+ })));
3631
3631
  }
3632
3632
  });
3633
3633
  memoized.memo = memo;
@@ -4450,7 +4450,7 @@ var retryable = function (opts, task) {
4450
4450
  }
4451
4451
  return initialParams(function (args, callback) {
4452
4452
  function taskFn(cb) {
4453
- task.apply(null, args.concat([cb]));
4453
+ task.apply(null, args.concat(cb));
4454
4454
  }
4455
4455
 
4456
4456
  if (opts) retry(opts, taskFn, callback);else retry(taskFn, callback);
@@ -4555,7 +4555,7 @@ function series(tasks, callback) {
4555
4555
  * // if result is true then at least one of the files exists
4556
4556
  * });
4557
4557
  */
4558
- var some = _createTester(eachOf, Boolean, identity);
4558
+ var some = doParallel(_createTester(Boolean, identity));
4559
4559
 
4560
4560
  /**
4561
4561
  * The same as [`some`]{@link module:Collections.some} but runs a maximum of `limit` async operations at a time.
@@ -4578,7 +4578,7 @@ var some = _createTester(eachOf, Boolean, identity);
4578
4578
  * Result will be either `true` or `false` depending on the values of the async
4579
4579
  * tests. Invoked with (err, result).
4580
4580
  */
4581
- var someLimit = _createTester(eachOfLimit, Boolean, identity);
4581
+ var someLimit = doParallelLimit(_createTester(Boolean, identity));
4582
4582
 
4583
4583
  /**
4584
4584
  * The same as [`some`]{@link module:Collections.some} but runs only a single async operation at a time.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.4
4
+ version: 2.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Chen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-28 00:00:00.000000000 Z
11
+ date: 2017-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties