sanitize-arguments
Advanced tools
Comparing version 2.0.2 to 2.0.3
@@ -28,15 +28,19 @@ // Module dependencies | ||
order.some(function(type, newIndex) { | ||
var _type = Array.isArray(type) ? type[0] : type | ||
, found = false; | ||
if (typeOf(_type) == "Function" && typeOf(arg) == nameOf(_type)) { | ||
found = true; | ||
} else if (Array.isArray(type) && type.length == 1 && typeOf(type[0]) == typeOf(arg)) { | ||
found = true; | ||
var found = false; | ||
if (Array.isArray(type)) { | ||
if (type.length == 1 && typeOf(type[0]) == typeOf(arg)) found = true; | ||
else { | ||
type.forEach(function(type) { | ||
if (typeOf(type) == "Function" && typeOf(arg) == nameOf(type)) found = true; | ||
}); | ||
} | ||
} else if (typeOf(type) == "Function" && typeOf(arg) == nameOf(type)) { | ||
found = true; | ||
} | ||
if (found) { | ||
_args[newIndex] = arg; | ||
if(caller) sanitized[argNames[newIndex]] = arg; | ||
delete order[newIndex]; | ||
_args[newIndex] = arg; | ||
if(caller) sanitized[argNames[newIndex]] = arg; | ||
delete order[newIndex]; | ||
} | ||
@@ -52,3 +56,3 @@ | ||
if (Array.isArray(type)) { | ||
def = type.length > 1 ? type[1] : type[0]; | ||
def = type[type.length - 1]; | ||
_args[newIndex] = def; | ||
@@ -55,0 +59,0 @@ if(caller) sanitized[argNames[newIndex]] = def; |
{ | ||
"name": "sanitize-arguments", | ||
"description": "Easily check function arguments", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"author": "Jan Buschtöns <buschtoens@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -0,0 +0,0 @@ ![sanitize-arguments — Order arguments with ease!](http://i.imgur.com/SAhDs.png) |
8434
89