async-rails 2.4.1 → 2.5.0

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: '08e5cb75601fccd33a0d462ab6785d14db141f29'
4
- data.tar.gz: eaf38a840d3aceb791c3b932c45a3c402853c00a
3
+ metadata.gz: 3167bb1ccee60605463aaf5db50d0e2fe48edd9a
4
+ data.tar.gz: eae19d4f907e37cb0f58780ecdbfc2754d14f4d7
5
5
  SHA512:
6
- metadata.gz: 0207565ddaee5781e7de430a6c4263a469ee1416b5d450ee6f7d3d9bb5ee9af964e9d191512cfe4c43d794e8f549762d720448f1336eae2c6b80858124582173
7
- data.tar.gz: 95bcac0ca71e890834604b876128d160ae1e879665253e66b0fb91ba21f77cf4415e3872689aa90e50f6416ef005a92d0df0394e7c74200e2304b4b9828257d8
6
+ metadata.gz: bb2775a194cb58601b760323ae7d45b7bece32c5759a08c011817378db86cf16151605370c4679167b687de8bdb3c7ed8bdd8eddf98d25dab52cc3b05217d9bd
7
+ data.tar.gz: af7fbf7fdef0619f84d290185b5cae511cc4a413dcc783dda6369c617714a5f49a6600a1f13914aeb1f54ca4bcd540e4835eae34f9bd7e89d7373afa910cf875
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # async-rails
1
+ # async-rails [![Build Status](https://travis-ci.org/dbackowski/async-rails.svg?branch=master)](https://travis-ci.org/dbackowski/async-rails)
2
2
 
3
3
  Rails asset pipeline wrapper for [async.js](https://github.com/caolan/async).
4
4
 
@@ -1,5 +1,5 @@
1
1
  module Async
2
2
  module Rails
3
- VERSION = "2.4.1"
3
+ VERSION = "2.5.0"
4
4
  end
5
5
  end
@@ -2235,9 +2235,10 @@ function queue(worker, concurrency, payload) {
2235
2235
 
2236
2236
  for (var i = 0, l = tasks.length; i < l; i++) {
2237
2237
  var task = tasks[i];
2238
+
2238
2239
  var index = baseIndexOf(workersList, task, 0);
2239
2240
  if (index >= 0) {
2240
- workersList.splice(index);
2241
+ workersList.splice(index, 1);
2241
2242
  }
2242
2243
 
2243
2244
  task.callback.apply(task, arguments);
@@ -2298,11 +2299,11 @@ function queue(worker, concurrency, payload) {
2298
2299
  for (var i = 0; i < l; i++) {
2299
2300
  var node = q._tasks.shift();
2300
2301
  tasks.push(node);
2302
+ workersList.push(node);
2301
2303
  data.push(node.data);
2302
2304
  }
2303
2305
 
2304
2306
  numRunning += 1;
2305
- workersList.push(tasks[0]);
2306
2307
 
2307
2308
  if (q._tasks.length === 0) {
2308
2309
  q.empty();
@@ -2596,17 +2597,45 @@ var compose = function(/*...args*/) {
2596
2597
  return seq.apply(null, slice(arguments).reverse());
2597
2598
  };
2598
2599
 
2599
- function concat$1(eachfn, arr, fn, callback) {
2600
- var result = [];
2601
- eachfn(arr, function (x, index, cb) {
2602
- fn(x, function (err, y) {
2603
- result = result.concat(y || []);
2604
- cb(err);
2600
+ var _concat = Array.prototype.concat;
2601
+
2602
+ /**
2603
+ * The same as [`concat`]{@link module:Collections.concat} but runs a maximum of `limit` async operations at a time.
2604
+ *
2605
+ * @name concatLimit
2606
+ * @static
2607
+ * @memberOf module:Collections
2608
+ * @method
2609
+ * @see [async.concat]{@link module:Collections.concat}
2610
+ * @category Collection
2611
+ * @param {Array|Iterable|Object} coll - A collection to iterate over.
2612
+ * @param {number} limit - The maximum number of async operations at a time.
2613
+ * @param {AsyncFunction} iteratee - A function to apply to each item in `coll`,
2614
+ * which should use an array as its result. Invoked with (item, callback).
2615
+ * @param {Function} [callback] - A callback which is called after all the
2616
+ * `iteratee` functions have finished, or an error occurs. Results is an array
2617
+ * containing the concatenated results of the `iteratee` function. Invoked with
2618
+ * (err, results).
2619
+ */
2620
+ var concatLimit = function(coll, limit, iteratee, callback) {
2621
+ callback = callback || noop;
2622
+ var _iteratee = wrapAsync(iteratee);
2623
+ mapLimit(coll, limit, function(val, callback) {
2624
+ _iteratee(val, function(err /*, ...args*/) {
2625
+ if (err) return callback(err);
2626
+ return callback(null, slice(arguments, 1));
2605
2627
  });
2606
- }, function (err) {
2607
- callback(err, result);
2628
+ }, function(err, mapResults) {
2629
+ var result = [];
2630
+ for (var i = 0; i < mapResults.length; i++) {
2631
+ if (mapResults[i]) {
2632
+ result = _concat.apply(result, mapResults[i]);
2633
+ }
2634
+ }
2635
+
2636
+ return callback(err, result);
2608
2637
  });
2609
- }
2638
+ };
2610
2639
 
2611
2640
  /**
2612
2641
  * Applies `iteratee` to each item in `coll`, concatenating the results. Returns
@@ -2633,13 +2662,7 @@ function concat$1(eachfn, arr, fn, callback) {
2633
2662
  * // files is now a list of filenames that exist in the 3 directories
2634
2663
  * });
2635
2664
  */
2636
- var concat = doParallel(concat$1);
2637
-
2638
- function doSeries(fn) {
2639
- return function (obj, iteratee, callback) {
2640
- return fn(eachOfSeries, obj, wrapAsync(iteratee), callback);
2641
- };
2642
- }
2665
+ var concat = doLimit(concatLimit, Infinity);
2643
2666
 
2644
2667
  /**
2645
2668
  * The same as [`concat`]{@link module:Collections.concat} but runs only a single async operation at a time.
@@ -2659,7 +2682,7 @@ function doSeries(fn) {
2659
2682
  * containing the concatenated results of the `iteratee` function. Invoked with
2660
2683
  * (err, results).
2661
2684
  */
2662
- var concatSeries = doSeries(concat$1);
2685
+ var concatSeries = doLimit(concatLimit, 1);
2663
2686
 
2664
2687
  /**
2665
2688
  * Returns a function that when called, calls-back with the values provided.
@@ -3985,7 +4008,8 @@ function parallelLimit$1(tasks, limit, callback) {
3985
4008
  * @property {Function} resume - a function that resumes the processing of
3986
4009
  * queued tasks when the queue is paused. Invoke with `queue.resume()`.
3987
4010
  * @property {Function} kill - a function that removes the `drain` callback and
3988
- * empties remaining tasks from the queue forcing it to go idle. Invoke with `queue.kill()`.
4011
+ * empties remaining tasks from the queue forcing it to go idle. No more tasks
4012
+ * should be pushed to the queue after calling this function. Invoke with `queue.kill()`.
3989
4013
  */
3990
4014
 
3991
4015
  /**
@@ -5358,6 +5382,7 @@ var index = {
5358
5382
  cargo: cargo,
5359
5383
  compose: compose,
5360
5384
  concat: concat,
5385
+ concatLimit: concatLimit,
5361
5386
  concatSeries: concatSeries,
5362
5387
  constant: constant,
5363
5388
  detect: detect,
@@ -5454,6 +5479,7 @@ exports.autoInject = autoInject;
5454
5479
  exports.cargo = cargo;
5455
5480
  exports.compose = compose;
5456
5481
  exports.concat = concat;
5482
+ exports.concatLimit = concatLimit;
5457
5483
  exports.concatSeries = concatSeries;
5458
5484
  exports.constant = constant;
5459
5485
  exports.detect = detect;
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Chen
8
+ - Damian Baćkowski
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2017-05-22 00:00:00.000000000 Z
12
+ date: 2017-08-07 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: railties
@@ -24,9 +25,66 @@ dependencies:
24
25
  - - ">="
25
26
  - !ruby/object:Gem::Version
26
27
  version: '3.1'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec-rails
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 3.6.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 3.6.0
42
+ - !ruby/object:Gem::Dependency
43
+ name: capybara
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: 2.14.0
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: 2.14.0
56
+ - !ruby/object:Gem::Dependency
57
+ name: rails
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '='
61
+ - !ruby/object:Gem::Version
62
+ version: 5.1.2
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 5.1.2
70
+ - !ruby/object:Gem::Dependency
71
+ name: sqlite3
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '1.3'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '1.3'
27
84
  description: Rails asset pipeline wrapper for async.js
28
85
  email:
29
86
  - jhchen7@gmail.com
87
+ - damianbackowski@gmail.com
30
88
  executables: []
31
89
  extensions: []
32
90
  extra_rdoc_files: []