async-rails 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async-rails/version.rb +1 -1
- data/vendor/assets/javascripts/async.js +42 -39
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a30d7f145cc38f1a7e9c0f6a0d3f1c64efe9f79
|
4
|
+
data.tar.gz: 39cc938b5f03511c54e29c7a3f59a8cb21d9b02b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16d787632b9edb8eac0c524c969e7bd0aea6ae5dce34441b31eba011eb5ea5552dc30cb0522e392e9bab4c536f5162630f099b763a41848dd1ad7cd17d8acb69
|
7
|
+
data.tar.gz: b844c7f70252045afe71e599c0566926784478c9acfe92bfdb9bd81e693909c35782fba43b05d43c009870f05b25d03d620ec172700dec353a4a50d4be61e316
|
data/lib/async-rails/version.rb
CHANGED
@@ -93,6 +93,10 @@
|
|
93
93
|
return result;
|
94
94
|
}
|
95
95
|
|
96
|
+
function _range(count) {
|
97
|
+
return _map(Array(count), function (v, i) { return i; });
|
98
|
+
}
|
99
|
+
|
96
100
|
function _reduce(arr, iterator, memo) {
|
97
101
|
_arrayEach(arr, function (x, i, a) {
|
98
102
|
memo = iterator(memo, x, i, a);
|
@@ -217,7 +221,7 @@
|
|
217
221
|
async.eachOf = function (object, iterator, callback) {
|
218
222
|
callback = _once(callback || noop);
|
219
223
|
object = object || [];
|
220
|
-
var size = object.length
|
224
|
+
var size = _isArrayLike(object) ? object.length : _keys(object).length;
|
221
225
|
var completed = 0;
|
222
226
|
if (!size) {
|
223
227
|
return callback(null);
|
@@ -834,8 +838,21 @@
|
|
834
838
|
if (q.tasks.length === q.concurrency) {
|
835
839
|
q.saturated();
|
836
840
|
}
|
837
|
-
async.setImmediate(q.process);
|
838
841
|
});
|
842
|
+
async.setImmediate(q.process);
|
843
|
+
}
|
844
|
+
function _next(q, tasks) {
|
845
|
+
return function(){
|
846
|
+
workers -= 1;
|
847
|
+
var args = arguments;
|
848
|
+
_arrayEach(tasks, function (task) {
|
849
|
+
task.callback.apply(task, args);
|
850
|
+
});
|
851
|
+
if (q.tasks.length + workers === 0) {
|
852
|
+
q.drain();
|
853
|
+
}
|
854
|
+
q.process();
|
855
|
+
};
|
839
856
|
}
|
840
857
|
|
841
858
|
var workers = 0;
|
@@ -859,32 +876,22 @@
|
|
859
876
|
},
|
860
877
|
process: function () {
|
861
878
|
if (!q.paused && workers < q.concurrency && q.tasks.length) {
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
var data = _map(tasks, function (task) {
|
867
|
-
return task.data;
|
868
|
-
});
|
879
|
+
while(workers < q.concurrency && q.tasks.length){
|
880
|
+
var tasks = payload ?
|
881
|
+
q.tasks.splice(0, payload) :
|
882
|
+
q.tasks.splice(0, q.tasks.length);
|
869
883
|
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
workers += 1;
|
874
|
-
var cb = only_once(next);
|
875
|
-
worker(data, cb);
|
876
|
-
}
|
884
|
+
var data = _map(tasks, function (task) {
|
885
|
+
return task.data;
|
886
|
+
});
|
877
887
|
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
if (q.tasks.length + workers === 0) {
|
885
|
-
q.drain();
|
888
|
+
if (q.tasks.length === 0) {
|
889
|
+
q.empty();
|
890
|
+
}
|
891
|
+
workers += 1;
|
892
|
+
var cb = only_once(_next(q, tasks));
|
893
|
+
worker(data, cb);
|
886
894
|
}
|
887
|
-
q.process();
|
888
895
|
}
|
889
896
|
},
|
890
897
|
length: function () {
|
@@ -1056,20 +1063,16 @@
|
|
1056
1063
|
};
|
1057
1064
|
};
|
1058
1065
|
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
return async.map(counter, iterator, callback);
|
1065
|
-
};
|
1066
|
+
function _times(mapper) {
|
1067
|
+
return function (count, iterator, callback) {
|
1068
|
+
mapper(_range(count), iterator, callback);
|
1069
|
+
};
|
1070
|
+
}
|
1066
1071
|
|
1067
|
-
async.
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
}
|
1072
|
-
return async.mapSeries(counter, iterator, callback);
|
1072
|
+
async.times = _times(async.map);
|
1073
|
+
async.timesSeries = _times(async.mapSeries);
|
1074
|
+
async.timesLimit = function (count, limit, iterator, callback) {
|
1075
|
+
return async.mapLimit(_range(count), limit, iterator, callback);
|
1073
1076
|
};
|
1074
1077
|
|
1075
1078
|
async.seq = function (/* functions... */) {
|
@@ -1181,4 +1184,4 @@
|
|
1181
1184
|
root.async = async;
|
1182
1185
|
}
|
1183
1186
|
|
1184
|
-
}());
|
1187
|
+
}());
|
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: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Chen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|