lazy-assert
Advanced tools
Comparing version 0.1.6 to 0.1.7
{ | ||
"name": "lazy-assert", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "An way of doing assertion for lazy people ...", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -42,3 +42,3 @@ var utils = require('./utils'); | ||
// 只能是 object 了 | ||
result.push(inner.patternObject(array[i], pattern)); | ||
result.push(inner.patternObject(array[i], pattern)); | ||
} | ||
@@ -74,3 +74,3 @@ } | ||
var lazyUtils = { | ||
pick: function (value, configArray) { | ||
pick: function (value, configArrayOrFunc) { | ||
if (value instanceof Array) { | ||
@@ -80,3 +80,3 @@ var result = []; | ||
for (var i = 0; i < value.length; i++) { | ||
result.push(lazyAssert.pick(value[i], configArray)); | ||
result.push(lazyAssert.pick(value[i], configArrayOrFunc)); | ||
} | ||
@@ -87,7 +87,17 @@ return result; | ||
var result = {}; | ||
configArray.forEach(function (key) { | ||
if (key in value) { | ||
result[key] = value[key]; | ||
if (typeof configArrayOrFunc === 'function') { | ||
for (var key in value) { | ||
if (configArrayOrFunc(key, value[key])) { | ||
result[key] = value[key] | ||
} | ||
} | ||
}); | ||
} | ||
else { | ||
configArrayOrFunc.forEach(function (key) { | ||
if (key in value) { | ||
result[key] = value[key]; | ||
} | ||
}); | ||
} | ||
return result; | ||
@@ -100,3 +110,3 @@ } | ||
unpick: function (value, configArray) { | ||
unpick: function (value, configArrayOrFunc) { | ||
if (value instanceof Array) { | ||
@@ -106,3 +116,3 @@ var result = []; | ||
for (var i = 0; i < value.length; i++) { | ||
result.push(lazyAssert.unpick(value[i], configArray)); | ||
result.push(lazyAssert.unpick(value[i], configArrayOrFunc)); | ||
} | ||
@@ -116,5 +126,14 @@ return result; | ||
} | ||
configArray.forEach(function (key) { | ||
delete result[key]; | ||
}); | ||
if (typeof configArrayOrFunc === 'function') { | ||
for (var key in value) { | ||
if (configArrayOrFunc(key, value[key])) { | ||
delete result[key]; | ||
} | ||
} | ||
} | ||
else { | ||
configArrayOrFunc.forEach(function (key) { | ||
delete result[key]; | ||
}); | ||
} | ||
return result; | ||
@@ -121,0 +140,0 @@ } |
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
386895
2318