Comparing version 0.3.2 to 0.3.3
@@ -8,2 +8,7 @@ (function() { | ||
var objectTypes = { | ||
'function': true, | ||
'object': true | ||
}; | ||
var _nextTick; | ||
@@ -26,8 +31,8 @@ var _setImmediate; | ||
mapLimit: mapLimit, | ||
filter: createFilter(), | ||
filterSeries: createFilter('series'), | ||
filterLimit: createFilter('limit'), | ||
select: createFilter(), | ||
selectSeries: createFilter('series'), | ||
selectLimit: createFilter('limit'), | ||
filter: filter, | ||
filterSeries: filterSeries, | ||
filterLimit: filterLimit, | ||
select: filter, | ||
selectSeries: filterSeries, | ||
selectLimit: filterLimit, | ||
reject: reject, | ||
@@ -97,7 +102,2 @@ rejectSeries: rejectSeries, | ||
var objectTypes = { | ||
'function': true, | ||
'object': true | ||
}; | ||
// Node.js | ||
@@ -293,5 +293,5 @@ if (objectTypes[typeof module] && module && module.exports) { | ||
if (!process || !process.nextTick) { | ||
if (!objectTypes[typeof process] || !process.nextTick) { | ||
if (typeof setImmediate == 'function') { | ||
if (objectTypes[typeof setImmediate]) { | ||
_nextTick = function(func) { | ||
@@ -310,3 +310,3 @@ setImmediate(func); | ||
_nextTick = process.nextTick; | ||
if (typeof setImmediate == 'function') { | ||
if (objectTypes[typeof setImmediate]) { | ||
_setImmediate = function(func) { | ||
@@ -687,39 +687,33 @@ setImmediate(func); | ||
function createFilter(type) { | ||
function filter(collection, iterator, callback, thisArg) { | ||
switch(type) { | ||
case 'series': | ||
return filterSeries; | ||
case 'limit': | ||
return filterLimit; | ||
default: | ||
return filter; | ||
} | ||
pick(collection, iterator, done, thisArg); | ||
function filter(collection, iterator, callback, thisArg) { | ||
function done(result) { | ||
var done = createCallback(collection, callback); | ||
pick(collection, iterator, done, thisArg); | ||
callback = callback || function() {}; | ||
callback(Array.isArray(collection) ? result : _toArray(result)); | ||
} | ||
} | ||
function filterSeries(collection, iterator, callback, thisArg) { | ||
function filterSeries(collection, iterator, callback, thisArg) { | ||
var done = createCallback(collection, callback); | ||
pickSeries(collection, iterator, done, thisArg); | ||
} | ||
pickSeries(collection, iterator, done, thisArg); | ||
function filterLimit(collection, limit, iterator, callback, thisArg) { | ||
function done(result) { | ||
var done = createCallback(collection, callback); | ||
pickLimit(collection, limit, iterator, done, thisArg); | ||
callback = callback || function() {}; | ||
callback(Array.isArray(collection) ? result : _toArray(result)); | ||
} | ||
} | ||
function createCallback(collection, callback) { | ||
function filterLimit(collection, limit, iterator, callback, thisArg) { | ||
return function(result) { | ||
pickLimit(collection, limit, iterator, done, thisArg); | ||
callback(Array.isArray(collection) ? result : _toArray(result)); | ||
}; | ||
function done(result) { | ||
callback = callback || function() {}; | ||
callback(Array.isArray(collection) ? result : _toArray(result)); | ||
} | ||
} | ||
@@ -1372,3 +1366,3 @@ | ||
callback = callback || function() {}; | ||
var size, iterate; | ||
var size, iterate, called; | ||
var isArray = Array.isArray(collection); | ||
@@ -1385,3 +1379,4 @@ var result = isArray ? [] : {}; | ||
iterate = function() { | ||
_iterator(result, collection[completed], completed, once(done)); | ||
called = false; | ||
_iterator(result, collection[completed], completed, done); | ||
}; | ||
@@ -1395,4 +1390,5 @@ } else { | ||
iterate = function() { | ||
called = false; | ||
var key = keys[completed]; | ||
_iterator(result, collection[key], key, once(done)); | ||
_iterator(result, collection[key], key, done); | ||
}; | ||
@@ -1405,2 +1401,6 @@ } | ||
if (called) { | ||
throw new Error('Callback was already called.'); | ||
} | ||
called = true; | ||
if (err) { | ||
@@ -1583,2 +1583,4 @@ return callback(err, result); | ||
function done(res) { | ||
callback = callback || function() {}; | ||
callback(!res); | ||
@@ -1593,2 +1595,4 @@ } | ||
function done(res) { | ||
callback = callback || function() {}; | ||
callback(!res); | ||
@@ -1603,2 +1607,4 @@ } | ||
function done(res) { | ||
callback = callback || function() {}; | ||
callback(!res); | ||
@@ -1605,0 +1611,0 @@ } |
{ | ||
"name": "neo-async", | ||
"version": "0.3.2", | ||
"version": "0.3.3", | ||
"description": "Neo-Async is compatible with Async.js, it is faster and has more feature.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -456,2 +456,2 @@ # Neo-Async | ||
|parallelLimit|10|1000|196.36| | ||
|series|10|500|111.44| | ||
|series|10|500|140.98| |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92187
2288