Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

util-io

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

util-io - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

84

lib/util.js

@@ -145,5 +145,23 @@ (function(scope) {

}
return this;
};
/**
* Check is type of arg with name is equal to type
*
* @param name
* @param arg
* @param type
*/
this.checkType = function(name, arg, type) {
var is = Util.getType(arg) === type;
if (!is)
throw(Error(name + ' should be ' + type));
return this;
};
/**
* Check is Properties exists and they are true if neaded

@@ -827,32 +845,60 @@ *

exec.parallel = function(funcs, callback) {
var errorWas,
var keys = [],
callbackWas = false,
arr = [],
obj = {},
count = 0,
allData = [null],
func = exec.ret(callback),
funcsCount = funcs.length;
countFuncs = 0,
type = Util.getType(funcs);
Util.checkArgs(arguments, ['funcs', 'callback']);
switch(type) {
case 'array':
countFuncs = funcs.length;
funcs.forEach(function(func, num) {
exec(func, function() {
checkFunc(num + 1, arguments);
funcs.forEach(function(func, num) {
exec(func, function() {
checkFunc(num, arguments, arr);
});
});
});
break;
function checkFunc(num, data) {
case 'object':
keys = Object.keys(funcs);
countFuncs = keys.length;
keys.forEach(function(name) {
var func = funcs[name];
exec(func, function() {
checkFunc(name, arguments, obj);
});
});
break;
}
function checkFunc(num, data, all) {
var args = Util.slice(data, 1),
isLast = false,
error = data[0],
length = args.length;
if (error) {
errorWas = true;
func(error);
} else if (!errorWas) {
++count;
++count;
isLast = count === countFuncs;
if (!error)
if (length >= 2)
allData[num] = args;
all[num] = args;
else
allData[num] = args[0];
all[num] = args[0];
if (!callbackWas && error || isLast) {
callbackWas = true;
if (count === funcsCount)
func.apply(null, allData);
if (type === 'array')
callback.apply(null, [error].concat(all));
else
callback(error, all);
}

@@ -859,0 +905,0 @@ }

{
"name": "util-io",
"version": "1.2.1",
"version": "1.2.2",
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",

@@ -5,0 +5,0 @@ "description": "Util.io - utilites for vanila js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc