forked from 0x2620/oxjs
use native ''.trim; rename vars
This commit is contained in:
parent
e480d87b34
commit
68ff06af2a
5 changed files with 138 additions and 157 deletions
|
|
@ -189,23 +189,23 @@ Ox.loadAsync <f> Runs an asynchonous function on array elements
|
|||
callback <f> Callback function
|
||||
results <o> Results
|
||||
@*/
|
||||
Ox.loadAsync = function(arr, map, callback) {
|
||||
arr = Ox.makeArray(arr);
|
||||
var i = 0, n = arr.length, results = {};
|
||||
if (arr.some(Ox.isArray)) {
|
||||
Ox.loadAsync = function(array, map, callback) {
|
||||
array = Ox.makeArray(array);
|
||||
var i = 0, n = array.length, results = {};
|
||||
if (array.some(Ox.isArray)) {
|
||||
iterate();
|
||||
} else {
|
||||
arr.forEach(function(item) {
|
||||
map(item, function(result) {
|
||||
array.forEach(function(value) {
|
||||
map(value, function(result) {
|
||||
Ox.extend(results, result);
|
||||
++i == n && callback(results);
|
||||
});
|
||||
});
|
||||
}
|
||||
function iterate() {
|
||||
Ox.loadAsync(arr.shift(), function(result) {
|
||||
Ox.loadAsync(array.shift(), function(result) {
|
||||
Ox.extend(results, result);
|
||||
arr.length ? iterate() : callback(results);
|
||||
array.length ? iterate() : callback(results);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue