Comparing version 0.10.5 to 0.11.0
196
index.js
@@ -7,6 +7,6 @@ /** | ||
var sanitize = require('validator').sanitize; | ||
var _ = require('lodash'); | ||
/** | ||
@@ -17,3 +17,3 @@ * Public access | ||
module.exports = function (entity) { | ||
return new Anchor(entity); | ||
return new Anchor(entity); | ||
}; | ||
@@ -31,9 +31,11 @@ | ||
function Anchor (entity) { | ||
if (util.isFunction(entity)) { | ||
this.fn = entity; | ||
throw new Error ('Anchor does not support functions yet!'); | ||
} | ||
else this.data = entity; | ||
if (util.isFunction(entity)) { | ||
this.fn = entity; | ||
throw new Error ('Anchor does not support functions yet!'); | ||
} | ||
else { | ||
this.data = entity; | ||
} | ||
return this; | ||
return this; | ||
} | ||
@@ -61,33 +63,63 @@ | ||
var errors = []; | ||
var errors = []; | ||
// If ruleset doesn't contain any explicit rule keys, | ||
// assume that this is a type | ||
// If ruleset doesn't contain any explicit rule keys, | ||
// assume that this is a type | ||
// Look for explicit rules | ||
for (var rule in ruleset) { | ||
// Look for explicit rules | ||
for (var rule in ruleset) { | ||
if (rule === 'type') { | ||
if (rule === 'type') { | ||
// Use deep match to descend into the collection and verify each item and/or key | ||
// Stop at default maxDepth (50) to prevent infinite loops in self-associations | ||
errors = errors.concat(Anchor.match.type.call(context, this.data, ruleset.type)); | ||
} | ||
// Use deep match to descend into the collection and verify each item and/or key | ||
// Stop at default maxDepth (50) to prevent infinite loops in self-associations | ||
errors = errors.concat(Anchor.match.type.call(context, this.data, ruleset['type'])); | ||
} | ||
// Validate a dbType rule | ||
else if (rule === 'dbType') { | ||
// Validate a non-type rule | ||
else { | ||
errors = errors.concat(Anchor.match.rule.call(context, this.data, rule, ruleset[rule])); | ||
} | ||
} | ||
// only if a validation rule exists for it so it doesn't break on an adapter that | ||
// doesn't support the particular dbType | ||
if(Anchor.prototype.rules[ruleset.dbType]) { | ||
errors = errors.concat(Anchor.match.type.call(context, this.data, ruleset.dbType)); | ||
} | ||
} | ||
// If errors exist, return the list of them | ||
if (errors.length) { | ||
return errors; | ||
} | ||
// Validate a non-type rule | ||
else { | ||
// No errors, so return false | ||
else return false; | ||
// Normalize the value if it looks like a boolean | ||
if(ruleset[rule] === 'true') { | ||
ruleset[rule] = true; | ||
} | ||
if(ruleset[rule] === 'false') { | ||
ruleset[rule] = false; | ||
} | ||
// If the value is false, then we shouldn't even run the validation | ||
if(ruleset[rule] === false) { | ||
break; | ||
} | ||
// If the rule value is a boolean we don't need to pass the value along. | ||
// Otherwise we can pass it along so it's options are available in | ||
// the validation. | ||
var ruleVal = _.isBoolean(ruleset[rule]) ? undefined : ruleset[rule]; | ||
errors = errors.concat(Anchor.match.rule.call(context, this.data, rule, ruleVal)); | ||
} | ||
} | ||
// If errors exist, return the list of them | ||
if (errors.length) { | ||
return errors; | ||
} | ||
// No errors, so return false | ||
else { | ||
return false; | ||
} | ||
}; | ||
Anchor.prototype.hasErrors = Anchor.prototype.to; | ||
@@ -110,14 +142,14 @@ | ||
* | ||
{ | ||
// Called before find() receives criteria | ||
// Here, criteria refers to just attributes (the `where`) | ||
// limit, skip, and sort are not included | ||
coerceCriteria: function (criteria) { | ||
return criteria; | ||
}, | ||
{ | ||
// Called before find() receives criteria | ||
// Here, criteria refers to just attributes (the `where`) | ||
// limit, skip, and sort are not included | ||
coerceCriteria: function (criteria) { | ||
return criteria; | ||
}, | ||
// Called before create() or update() receive values | ||
coerceValues: function () {} | ||
// Called before create() or update() receive values | ||
coerceValues: function () {} | ||
} | ||
} | ||
* | ||
@@ -133,3 +165,3 @@ * Adapter developers would be able to use Anchor.prototype.cast() | ||
Anchor.prototype.cast = function (ruleset) { | ||
todo(); | ||
todo(); | ||
}; | ||
@@ -146,22 +178,22 @@ | ||
// Iterate trough given data attributes | ||
// to check if they exist in the ruleset | ||
for (var attr in this.data) { | ||
if (this.data.hasOwnProperty(attr)) { | ||
// Iterate trough given data attributes | ||
// to check if they exist in the ruleset | ||
for (var attr in this.data) { | ||
if (this.data.hasOwnProperty(attr)) { | ||
// If it doesnt... | ||
if (!ruleset[attr]) { | ||
// If it doesnt... | ||
if (!ruleset[attr]) { | ||
// Declaring err here as error helpers live in match.js | ||
var err = new Error('Validation error: Attribute \"' + attr + '\" is not in the ruleset.'); | ||
// Declaring err here as error helpers live in match.js | ||
var err = new Error('Validation error: Attribute \"' + attr + '\" is not in the ruleset.'); | ||
// just throw it | ||
throw err; | ||
} | ||
} | ||
} | ||
// just throw it | ||
throw err; | ||
} | ||
} | ||
} | ||
// Once we make sure that attributes match | ||
// we can just proceed to deepMatch | ||
Anchor.match(this.data, ruleset, this); | ||
// Once we make sure that attributes match | ||
// we can just proceed to deepMatch | ||
Anchor.match(this.data, ruleset, this); | ||
}; | ||
@@ -178,3 +210,3 @@ | ||
Anchor.prototype.defaults = function (ruleset) { | ||
todo(); | ||
todo(); | ||
}; | ||
@@ -198,29 +230,25 @@ | ||
// check to see if we have an dictionary | ||
if ( util.isObject(name) ) { | ||
// check to see if we have an dictionary | ||
if ( util.isObject(name) ) { | ||
// if so all the attributes should be validation functions | ||
for (var attr in name){ | ||
if(!util.isFunction(name[attr])){ | ||
throw new Error('Definition error: \"' + attr + '\" does not have a definition'); | ||
} | ||
} | ||
// if so all the attributes should be validation functions | ||
for (var attr in name) { | ||
if(!util.isFunction(name[attr])){ | ||
throw new Error('Definition error: \"' + attr + '\" does not have a definition'); | ||
} | ||
} | ||
// add the new custom data types | ||
util.extend(Anchor.prototype.rules, name); | ||
// add the new custom data types | ||
util.extend(Anchor.prototype.rules, name); | ||
return this; | ||
return this; | ||
} | ||
} | ||
if ( util.isFunction(definition) && util.isString(name) ) { | ||
// Add a single data type | ||
Anchor.prototype.rules[name] = definition; | ||
return this; | ||
} | ||
if ( util.isFunction(definition) && util.isString(name) ) { | ||
// Add a single data type | ||
Anchor.prototype.rules[name] = definition; | ||
return this; | ||
} | ||
throw new Error('Definition error: \"' + name + '\" is not a valid definition.'); | ||
throw new Error('Definition error: \"' + name + '\" is not a valid definition.'); | ||
}; | ||
@@ -237,3 +265,3 @@ | ||
Anchor.prototype.as = function (ruleset) { | ||
todo(); | ||
todo(); | ||
}; | ||
@@ -249,3 +277,3 @@ | ||
Anchor.prototype.args = function (args) { | ||
todo(); | ||
todo(); | ||
}; | ||
@@ -261,4 +289,4 @@ | ||
Anchor.prototype.usage = function () { | ||
var usages = util.toArray(arguments); | ||
todo(); | ||
var usages = util.toArray(arguments); | ||
todo(); | ||
}; | ||
@@ -290,3 +318,3 @@ | ||
function todo() { | ||
throw new Error('Not implemented yet! If you\'d like to contribute, tweet @mikermcneil.'); | ||
throw new Error('Not implemented yet! If you\'d like to contribute, tweet @mikermcneil.'); | ||
} |
@@ -11,3 +11,3 @@ /** | ||
* `errorFactory()` | ||
* | ||
* | ||
* @param {?} value | ||
@@ -17,5 +17,5 @@ * @param {String} ruleName | ||
* @param {String|Function} customMessage (optional) | ||
* | ||
* | ||
* @return {Object} | ||
* | ||
* | ||
* @api private | ||
@@ -22,0 +22,0 @@ */ |
@@ -35,3 +35,3 @@ /** | ||
* (optional) | ||
* | ||
* | ||
* @returns a list of errors (or an empty list if no errors were found) | ||
@@ -88,3 +88,3 @@ */ | ||
// Note: | ||
// | ||
// | ||
// We take advantage of a couple of preconditions at this point: | ||
@@ -132,7 +132,7 @@ // (a) ruleset must be an Object | ||
} | ||
// Don't treat empty object as a ruleset | ||
@@ -163,3 +163,3 @@ // Instead, treat it as 'object' | ||
* `matchType()` | ||
* | ||
* | ||
* Return whether a piece of data matches a rule | ||
@@ -200,3 +200,3 @@ * | ||
if (!_.isString(x)) { | ||
rule = rules['string']; | ||
rule = rules.string; | ||
} else x.match.call(self, ruleName); | ||
@@ -203,0 +203,0 @@ }; |
@@ -15,106 +15,109 @@ /** | ||
'empty' : _.isEmpty, | ||
'empty' : _.isEmpty, | ||
'required' : function (x) { | ||
// Transform data to work properly with node validator | ||
if(!x && x !== 0 && x !== false) x = ''; | ||
else if(typeof x.toString !== 'undefined') x = x.toString(); | ||
else x = '' + x; | ||
'required' : function (x) { | ||
// Transform data to work properly with node validator | ||
if(!x && x !== 0 && x !== false) x = ''; | ||
else if(typeof x.toString !== 'undefined') x = x.toString(); | ||
else x = '' + x; | ||
return !validator.isNull(x); | ||
}, | ||
return !validator.isNull(x); | ||
}, | ||
'protected' : function () {return true;}, | ||
'protected' : function () {return true;}, | ||
'notEmpty' : function (x) { | ||
'notEmpty' : function (x) { | ||
// Transform data to work properly with node validator | ||
if (!x) x = ''; | ||
else if (typeof x.toString !== 'undefined') x = x.toString(); | ||
else x = '' + x; | ||
// Transform data to work properly with node validator | ||
if (!x) x = ''; | ||
else if (typeof x.toString !== 'undefined') x = x.toString(); | ||
else x = '' + x; | ||
return !validator.isNull(x); | ||
}, | ||
return !validator.isNull(x); | ||
}, | ||
'undefined' : _.isUndefined, | ||
'undefined' : _.isUndefined, | ||
'object' : _.isObject, | ||
'json' : function (x) { | ||
if (_.isUndefined(x)) return false; | ||
try { JSON.stringify(x); } | ||
catch(err) { return false; } | ||
return true; | ||
}, | ||
'geojson' : function (value, opt) { | ||
'object' : _.isObject, | ||
'json' : function (x) { | ||
if (_.isUndefined(x)) return false; | ||
try { JSON.stringify(x); } | ||
catch(err) { return false; } | ||
return true; | ||
}, | ||
'geojson' : function (value, opt) { | ||
var errors = geojsonhint.hint(value); | ||
return errors.length === 0 || !opt; | ||
return errors.length === 0; | ||
}, | ||
'mediumtext' : _.isString, | ||
'longtext' : _.isString, | ||
'text' : _.isString, | ||
'string' : _.isString, | ||
'alpha' : validator.isAlpha, | ||
'alphadashed': function (x) {return (/^[a-zA-Z-_]*$/).test(x); }, | ||
'numeric' : validator.isNumeric, | ||
'alphanumeric': validator.isAlphanumeric, | ||
'alphanumericdashed': function (x) {return (/^[a-zA-Z0-9-_]*$/).test(x); }, | ||
'email' : validator.isEmail, | ||
'url' : function(x, opt) { return validator.isURL(x, opt === true ? undefined : opt); }, | ||
'urlish' : /^\s([^\/]+\.)+.+\s*$/g, | ||
'ip' : validator.isIP, | ||
'ipv4' : validator.isIPv4, | ||
'ipv6' : validator.isIPv6, | ||
'creditcard': validator.isCreditCard, | ||
'uuid' : validator.isUUID, | ||
'uuidv3' : function (x){ return validator.isUUID(x, 3);}, | ||
'uuidv4' : function (x){ return validator.isUUID(x, 4);}, | ||
'geometry': function (value) { | ||
return _.isEmpty(value) || (_.isObject(value) || _.isString(value)); | ||
}, | ||
'mediumtext' : _.isString, | ||
'longtext' : _.isString, | ||
'text' : _.isString, | ||
'string' : _.isString, | ||
'alpha' : validator.isAlpha, | ||
'alphadashed': function (x) {return (/^[a-zA-Z-_]*$/).test(x); }, | ||
'numeric' : validator.isNumeric, | ||
'alphanumeric': validator.isAlphanumeric, | ||
'alphanumericdashed': function (x) {return (/^[a-zA-Z0-9-_]*$/).test(x); }, | ||
'email' : validator.isEmail, | ||
'url' : function(x, opt) { return validator.isURL(x, opt === true ? undefined : opt); }, | ||
'urlish' : /^\s([^\/]+\.)+.+\s*$/g, | ||
'ip' : validator.isIP, | ||
'ipv4' : validator.isIPv4, | ||
'ipv6' : validator.isIPv6, | ||
'creditcard': validator.isCreditCard, | ||
'uuid' : validator.isUUID, | ||
'uuidv3' : function (x){ return validator.isUUID(x, 3);}, | ||
'uuidv4' : function (x){ return validator.isUUID(x, 4);}, | ||
'int' : validator.isInt, | ||
'integer' : validator.isInt, | ||
'number' : _.isNumber, | ||
'finite' : _.isFinite, | ||
'int' : validator.isInt, | ||
'integer' : validator.isInt, | ||
'number' : _.isNumber, | ||
'finite' : _.isFinite, | ||
'decimal' : validator.isFloat, | ||
'float' : validator.isFloat, | ||
'decimal' : validator.isFloat, | ||
'float' : validator.isFloat, | ||
'falsey' : function (x) { return !x; }, | ||
'truthy' : function (x) { return !!x; }, | ||
'null' : _.isNull, | ||
'notNull' : function (x) { return !validator.isNull(x); }, | ||
'falsey' : function (x) { return !x; }, | ||
'truthy' : function (x) { return !!x; }, | ||
'null' : _.isNull, | ||
'notNull' : function (x) { return !validator.isNull(x); }, | ||
'boolean' : _.isBoolean, | ||
'boolean' : _.isBoolean, | ||
'array' : _.isArray, | ||
'array' : _.isArray, | ||
'binary' : function (x) { return Buffer.isBuffer(x) || _.isString(x); }, | ||
'binary' : function (x) { return Buffer.isBuffer(x) || _.isString(x); }, | ||
'date' : validator.isDate, | ||
'datetime': validator.isDate, | ||
'date' : validator.isDate, | ||
'datetime': validator.isDate, | ||
'hexadecimal': validator.isHexadecimal, | ||
'hexColor': validator.isHexColor, | ||
'hexadecimal': validator.isHexadecimal, | ||
'hexColor': validator.isHexColor, | ||
'lowercase': validator.isLowercase, | ||
'uppercase': validator.isUppercase, | ||
'lowercase': validator.isLowercase, | ||
'uppercase': validator.isUppercase, | ||
// Miscellaneous rules | ||
'after' : validator.isAfter, | ||
'before' : validator.isBefore, | ||
// Miscellaneous rules | ||
'after' : validator.isAfter, | ||
'before' : validator.isBefore, | ||
'equals' : validator.equals, | ||
'contains': validator.contains, | ||
'notContains': function (x, str) { return !validator.contains(x, str); }, | ||
'len' : function (x, min, max) { return validator.isLength(x, min, max); }, | ||
'in' : validator.isIn, | ||
'notIn' : function (x, arrayOrString) { return !validator.isIn(x, arrayOrString); }, | ||
'max' : function (x, val) { | ||
var number = parseFloat(x); | ||
return isNaN(number) || number <= val; | ||
}, | ||
'min' : function (x, val) { | ||
var number = parseFloat(x); | ||
return isNaN(number) || number >= val; | ||
}, | ||
'greaterThan' : function (x, val) { | ||
'equals' : validator.equals, | ||
'contains': validator.contains, | ||
'notContains': function (x, str) { return !validator.contains(x, str); }, | ||
'len' : function (x, min, max) { return validator.isLength(x, min, max); }, | ||
'in' : validator.isIn, | ||
'notIn' : function (x, arrayOrString) { return !validator.isIn(x, arrayOrString); }, | ||
'max' : function (x, val) { | ||
var number = parseFloat(x); | ||
return isNaN(number) || number <= val; | ||
}, | ||
'min' : function (x, val) { | ||
var number = parseFloat(x); | ||
return isNaN(number) || number >= val; | ||
}, | ||
'greaterThan' : function (x, val) { | ||
var number = parseFloat(x); | ||
return isNaN(number) || number > val; | ||
@@ -126,8 +129,8 @@ }, | ||
}, | ||
'minLength' : function (x, min) { return validator.isLength(x, min); }, | ||
'maxLength' : function (x, max) { return validator.isLength(x, 0, max); }, | ||
'minLength' : function (x, min) { return validator.isLength(x, min); }, | ||
'maxLength' : function (x, max) { return validator.isLength(x, 0, max); }, | ||
'regex' : function (x, regex) { return validator.matches(x, regex); }, | ||
'notRegex' : function (x, regex) { return !validator.matches(x, regex); } | ||
'regex' : function (x, regex) { return validator.matches(x, regex); }, | ||
'notRegex' : function (x, regex) { return !validator.matches(x, regex); } | ||
}; |
@@ -19,3 +19,3 @@ { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/Marak/colors.js.git" | ||
"url": "http://github.com/Marak/colors.js.git" | ||
}, | ||
@@ -45,4 +45,3 @@ "engines": { | ||
"_shasum": "2423fe6678ac0c5dae8852e5d0e5be08c997abcc", | ||
"_resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz" | ||
} |
@@ -19,3 +19,3 @@ { | ||
"type": "git", | ||
"url": "git://github.com/isaacs/inherits.git" | ||
"url": "git://github.com/isaacs/inherits" | ||
}, | ||
@@ -48,5 +48,3 @@ "license": "ISC", | ||
"_shasum": "b17d08d326b4423e568eff719f91b0b1cbdf69f1", | ||
"_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", | ||
"readme": "ERROR: No README data found!", | ||
"homepage": "https://github.com/isaacs/inherits#readme" | ||
"_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" | ||
} |
@@ -24,4 +24,8 @@ // Copyright Joyent, Inc. and other Node contributors. | ||
// because it is fragile and can be easily faked with `Object.create()`. | ||
function isArray(ar) { | ||
return Array.isArray(ar); | ||
function isArray(arg) { | ||
if (Array.isArray) { | ||
return Array.isArray(arg); | ||
} | ||
return objectToString(arg) === '[object Array]'; | ||
} | ||
@@ -66,3 +70,3 @@ exports.isArray = isArray; | ||
function isRegExp(re) { | ||
return isObject(re) && objectToString(re) === '[object RegExp]'; | ||
return objectToString(re) === '[object RegExp]'; | ||
} | ||
@@ -77,3 +81,3 @@ exports.isRegExp = isRegExp; | ||
function isDate(d) { | ||
return isObject(d) && objectToString(d) === '[object Date]'; | ||
return objectToString(d) === '[object Date]'; | ||
} | ||
@@ -83,4 +87,3 @@ exports.isDate = isDate; | ||
function isError(e) { | ||
return isObject(e) && | ||
(objectToString(e) === '[object Error]' || e instanceof Error); | ||
return (objectToString(e) === '[object Error]' || e instanceof Error); | ||
} | ||
@@ -104,9 +107,6 @@ exports.isError = isError; | ||
function isBuffer(arg) { | ||
return Buffer.isBuffer(arg); | ||
} | ||
exports.isBuffer = isBuffer; | ||
exports.isBuffer = Buffer.isBuffer; | ||
function objectToString(o) { | ||
return Object.prototype.toString.call(o); | ||
} | ||
} |
{ | ||
"name": "core-util-is", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "The `util.is*` functions introduced in Node v0.12.", | ||
@@ -30,12 +30,15 @@ "main": "lib/util.js", | ||
}, | ||
"readme": "# core-util-is\n\nThe `util.is*` functions introduced in Node v0.12.\n", | ||
"readmeFilename": "README.md", | ||
"homepage": "https://github.com/isaacs/core-util-is", | ||
"_id": "core-util-is@1.0.1", | ||
"dist": { | ||
"shasum": "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538", | ||
"tarball": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" | ||
"scripts": { | ||
"test": "tap test.js" | ||
}, | ||
"devDependencies": { | ||
"tap": "^2.3.0" | ||
}, | ||
"gitHead": "a177da234df5638b363ddc15fa324619a38577c8", | ||
"homepage": "https://github.com/isaacs/core-util-is#readme", | ||
"_id": "core-util-is@1.0.2", | ||
"_shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7", | ||
"_from": "core-util-is@>=1.0.0 <1.1.0", | ||
"_npmVersion": "1.3.23", | ||
"_npmVersion": "3.3.2", | ||
"_nodeVersion": "4.0.0", | ||
"_npmUser": { | ||
@@ -45,2 +48,6 @@ "name": "isaacs", | ||
}, | ||
"dist": { | ||
"shasum": "b5fd54220aa2bc5ab57aab7140c940754503c1a7", | ||
"tarball": "http://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" | ||
}, | ||
"maintainers": [ | ||
@@ -53,4 +60,3 @@ { | ||
"directories": {}, | ||
"_shasum": "6b07085aef9a3ccac6ee53bf9d3df0c1521a5538", | ||
"_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" | ||
"_resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" | ||
} |
@@ -48,7 +48,3 @@ { | ||
"_shasum": "8a18acfca9a8f4177e09abfc6038939b05d1eedf", | ||
"_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", | ||
"bugs": { | ||
"url": "https://github.com/juliangruber/isarray/issues" | ||
}, | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" | ||
} |
@@ -52,4 +52,3 @@ { | ||
"directories": {}, | ||
"_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" | ||
} |
@@ -20,3 +20,3 @@ { | ||
"type": "git", | ||
"url": "git://github.com/isaacs/readable-stream.git" | ||
"url": "git://github.com/isaacs/readable-stream" | ||
}, | ||
@@ -69,4 +69,3 @@ "keywords": [ | ||
"directories": {}, | ||
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.13.tgz" | ||
} |
@@ -77,4 +77,3 @@ { | ||
"_shasum": "867ac74e3864187b1d3d47d996a78ec5c8830777", | ||
"_resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz" | ||
} |
@@ -73,4 +73,3 @@ { | ||
"_shasum": "cb102df1c56f5123eab8b67cd7b98027a0279178", | ||
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.0.0.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.0.0.tgz" | ||
} |
@@ -8,3 +8,3 @@ { | ||
"type": "git", | ||
"url": "git://github.com/sindresorhus/has-color.git" | ||
"url": "git://github.com/sindresorhus/has-color" | ||
}, | ||
@@ -70,4 +70,3 @@ "author": { | ||
"_shasum": "67144a5260c34fc3cca677d041daf52fe7b78b2f", | ||
"_resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz" | ||
} |
@@ -11,3 +11,3 @@ { | ||
"type": "git", | ||
"url": "git://github.com/sindresorhus/strip-ansi.git" | ||
"url": "git://github.com/sindresorhus/strip-ansi" | ||
}, | ||
@@ -80,4 +80,3 @@ "author": { | ||
"_shasum": "39e8a98d044d150660abe4a6808acf70bb7bc991", | ||
"_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.1.1.tgz" | ||
} |
@@ -8,3 +8,3 @@ { | ||
"type": "git", | ||
"url": "git://github.com/sindresorhus/chalk.git" | ||
"url": "git://github.com/sindresorhus/chalk" | ||
}, | ||
@@ -77,4 +77,3 @@ "author": { | ||
"_shasum": "5199a3ddcd0c1efe23bc08c1b027b06176e0c64f", | ||
"_resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/chalk/-/chalk-0.4.0.tgz" | ||
} |
@@ -65,4 +65,3 @@ { | ||
"_shasum": "de3f98543dbf96082be48ad1a0c7cda836301dcf", | ||
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz" | ||
} |
@@ -61,4 +61,3 @@ { | ||
], | ||
"_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" | ||
} |
@@ -19,3 +19,3 @@ { | ||
"type": "git", | ||
"url": "git+ssh://git@github.com/substack/node-optimist.git" | ||
"url": "http://github.com/substack/node-optimist.git" | ||
}, | ||
@@ -63,4 +63,3 @@ "keywords": [ | ||
"_shasum": "da3ea74686fa21a19a111c326e90eb15a0196686", | ||
"_resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz" | ||
} |
@@ -47,3 +47,3 @@ { | ||
"_shasum": "dc46c3ce09101f3f9182658ddc3706056fcb4746", | ||
"_from": "geojsonhint@>=1.1.0 <2.0.0", | ||
"_from": "geojsonhint@1.1.0", | ||
"_npmVersion": "1.4.28", | ||
@@ -50,0 +50,0 @@ "_npmUser": { |
var baseSlice = require('../internal/baseSlice'), | ||
isIterateeCall = require('../internal/isIterateeCall'); | ||
/** Native method references. */ | ||
var ceil = Math.ceil; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeMax = Math.max; | ||
var nativeCeil = Math.ceil, | ||
nativeFloor = Math.floor, | ||
nativeMax = Math.max; | ||
@@ -34,3 +33,3 @@ /** | ||
} else { | ||
size = nativeMax(+size || 1, 1); | ||
size = nativeMax(nativeFloor(size) || 1, 1); | ||
} | ||
@@ -40,3 +39,3 @@ var index = 0, | ||
resIndex = -1, | ||
result = Array(ceil(length / size)); | ||
result = Array(nativeCeil(length / size)); | ||
@@ -43,0 +42,0 @@ while (index < length) { |
var baseDifference = require('../internal/baseDifference'), | ||
baseFlatten = require('../internal/baseFlatten'), | ||
isArrayLike = require('../internal/isArrayLike'), | ||
isObjectLike = require('../internal/isObjectLike'), | ||
restParam = require('../function/restParam'); | ||
@@ -8,3 +9,3 @@ | ||
* Creates an array of unique `array` values not included in the other | ||
* provided arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* provided arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons. | ||
@@ -24,3 +25,3 @@ * | ||
var difference = restParam(function(array, values) { | ||
return isArrayLike(array) | ||
return (isObjectLike(array) && isArrayLike(array)) | ||
? baseDifference(array, baseFlatten(values, false, true)) | ||
@@ -27,0 +28,0 @@ : []; |
@@ -6,3 +6,3 @@ var baseFlatten = require('../internal/baseFlatten'), | ||
* Flattens a nested array. If `isDeep` is `true` the array is recursively | ||
* flattened, otherwise it is only flattened a single level. | ||
* flattened, otherwise it's only flattened a single level. | ||
* | ||
@@ -9,0 +9,0 @@ * @static |
@@ -9,4 +9,4 @@ var baseIndexOf = require('../internal/baseIndexOf'), | ||
* Gets the index at which the first occurrence of `value` is found in `array` | ||
* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* for equality comparisons. If `fromIndex` is negative, it is used as the offset | ||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons. If `fromIndex` is negative, it's used as the offset | ||
* from the end of `array`. If `array` is sorted providing `true` for `fromIndex` | ||
@@ -44,6 +44,5 @@ * performs a faster binary search. | ||
} else if (fromIndex) { | ||
var index = binaryIndex(array, value), | ||
other = array[index]; | ||
if (value === value ? (value === other) : (other !== other)) { | ||
var index = binaryIndex(array, value); | ||
if (index < length && | ||
(value === value ? (value === array[index]) : (array[index] !== array[index]))) { | ||
return index; | ||
@@ -50,0 +49,0 @@ } |
@@ -9,3 +9,3 @@ var baseIndexOf = require('../internal/baseIndexOf'), | ||
* Creates an array of unique values that are included in all of the provided | ||
* arrays using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* arrays using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons. | ||
@@ -12,0 +12,0 @@ * |
@@ -11,3 +11,3 @@ var baseIndexOf = require('../internal/baseIndexOf'); | ||
* Removes all provided values from `array` using | ||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons. | ||
@@ -14,0 +14,0 @@ * |
@@ -6,3 +6,3 @@ var createSortedIndex = require('../internal/createSortedIndex'); | ||
* be inserted into `array` in order to maintain its sort order. If an iteratee | ||
* function is provided it is invoked for `value` and each element of `array` | ||
* function is provided it's invoked for `value` and each element of `array` | ||
* to compute their sort ranking. The iteratee is bound to `thisArg` and | ||
@@ -9,0 +9,0 @@ * invoked with one argument; (value). |
@@ -7,3 +7,3 @@ var baseFlatten = require('../internal/baseFlatten'), | ||
* Creates an array of unique values, in order, from all of the provided arrays | ||
* using [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* using [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons. | ||
@@ -10,0 +10,0 @@ * |
@@ -8,6 +8,6 @@ var baseCallback = require('../internal/baseCallback'), | ||
* Creates a duplicate-free version of an array, using | ||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons, in which only the first occurence of each element | ||
* is kept. Providing `true` for `isSorted` performs a faster search algorithm | ||
* for sorted arrays. If an iteratee function is provided it is invoked for | ||
* for sorted arrays. If an iteratee function is provided it's invoked for | ||
* each element in the array to generate the criterion by which uniqueness | ||
@@ -63,3 +63,3 @@ * is computed. The `iteratee` is bound to `thisArg` and invoked with three | ||
thisArg = iteratee; | ||
iteratee = isIterateeCall(array, isSorted, thisArg) ? null : isSorted; | ||
iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted; | ||
isSorted = false; | ||
@@ -66,0 +66,0 @@ } |
@@ -7,3 +7,3 @@ var baseDifference = require('../internal/baseDifference'), | ||
* Creates an array excluding all provided values using | ||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons. | ||
@@ -10,0 +10,0 @@ * |
@@ -1,2 +0,3 @@ | ||
var baseDifference = require('../internal/baseDifference'), | ||
var arrayPush = require('../internal/arrayPush'), | ||
baseDifference = require('../internal/baseDifference'), | ||
baseUniq = require('../internal/baseUniq'), | ||
@@ -27,3 +28,3 @@ isArrayLike = require('../internal/isArrayLike'); | ||
var result = result | ||
? baseDifference(result, array).concat(baseDifference(array, result)) | ||
? arrayPush(baseDifference(result, array), baseDifference(array, result)) | ||
: array; | ||
@@ -30,0 +31,0 @@ } |
module.exports = { | ||
'chain': require('./chain/chain'), | ||
'commit': require('./chain/commit'), | ||
'concat': require('./chain/concat'), | ||
'lodash': require('./chain/lodash'), | ||
@@ -5,0 +6,0 @@ 'plant': require('./chain/plant'), |
@@ -17,11 +17,12 @@ var LazyWrapper = require('../internal/LazyWrapper'), | ||
* Methods that operate on and return arrays, collections, and functions can | ||
* be chained together. Methods that return a boolean or single value will | ||
* automatically end the chain returning the unwrapped value. Explicit chaining | ||
* may be enabled using `_.chain`. The execution of chained methods is lazy, | ||
* that is, execution is deferred until `_#value` is implicitly or explicitly | ||
* called. | ||
* be chained together. Methods that retrieve a single value or may return a | ||
* primitive value will automatically end the chain returning the unwrapped | ||
* value. Explicit chaining may be enabled using `_.chain`. The execution of | ||
* chained methods is lazy, that is, execution is deferred until `_#value` | ||
* is implicitly or explicitly called. | ||
* | ||
* Lazy evaluation allows several methods to support shortcut fusion. Shortcut | ||
* fusion is an optimization that merges iteratees to avoid creating intermediate | ||
* arrays and reduce the number of iteratee executions. | ||
* fusion is an optimization strategy which merge iteratee calls; this can help | ||
* to avoid the creation of intermediate data structures and greatly reduce the | ||
* number of iteratee executions. | ||
* | ||
@@ -49,32 +50,33 @@ * Chaining is supported in custom builds as long as the `_#value` method is | ||
* `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`, | ||
* `countBy`, `create`, `curry`, `debounce`, `defaults`, `defer`, `delay`, | ||
* `difference`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `fill`, | ||
* `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, `forEach`, | ||
* `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, `functions`, | ||
* `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, `invoke`, `keys`, | ||
* `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, `matchesProperty`, | ||
* `memoize`, `merge`, `method`, `methodOf`, `mixin`, `negate`, `omit`, `once`, | ||
* `pairs`, `partial`, `partialRight`, `partition`, `pick`, `plant`, `pluck`, | ||
* `property`, `propertyOf`, `pull`, `pullAt`, `push`, `range`, `rearg`, | ||
* `reject`, `remove`, `rest`, `restParam`, `reverse`, `set`, `shuffle`, | ||
* `slice`, `sort`, `sortBy`, `sortByAll`, `sortByOrder`, `splice`, `spread`, | ||
* `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `tap`, `throttle`, | ||
* `thru`, `times`, `toArray`, `toPlainObject`, `transform`, `union`, `uniq`, | ||
* `unshift`, `unzip`, `unzipWith`, `values`, `valuesIn`, `where`, `without`, | ||
* `wrap`, `xor`, `zip`, `zipObject`, `zipWith` | ||
* `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`, | ||
* `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`, | ||
* `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`, | ||
* `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`, | ||
* `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`, | ||
* `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`, | ||
* `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`, | ||
* `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`, | ||
* `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`, | ||
* `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`, | ||
* `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`, | ||
* `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`, | ||
* `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`, | ||
* `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`, | ||
* `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith` | ||
* | ||
* The wrapper methods that are **not** chainable by default are: | ||
* `add`, `attempt`, `camelCase`, `capitalize`, `clone`, `cloneDeep`, `deburr`, | ||
* `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, `findKey`, | ||
* `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, `get`, | ||
* `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, `inRange`, `isArguments`, | ||
* `isArray`, `isBoolean`, `isDate`, `isElement`, `isEmpty`, `isEqual`, `isError`, | ||
* `isFinite` `isFunction`, `isMatch`, `isNative`, `isNaN`, `isNull`, `isNumber`, | ||
* `isObject`, `isPlainObject`, `isRegExp`, `isString`, `isUndefined`, | ||
* `isTypedArray`, `join`, `kebabCase`, `last`, `lastIndexOf`, `lt`, `lte`, | ||
* `max`, `min`, `noConflict`, `noop`, `now`, `pad`, `padLeft`, `padRight`, | ||
* `parseInt`, `pop`, `random`, `reduce`, `reduceRight`, `repeat`, `result`, | ||
* `runInContext`, `shift`, `size`, `snakeCase`, `some`, `sortedIndex`, | ||
* `sortedLastIndex`, `startCase`, `startsWith`, `sum`, `template`, `trim`, | ||
* `trimLeft`, `trimRight`, `trunc`, `unescape`, `uniqueId`, `value`, and `words` | ||
* `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`, | ||
* `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`, | ||
* `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`, | ||
* `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`, | ||
* `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`, | ||
* `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`, | ||
* `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`, | ||
* `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`, | ||
* `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`, | ||
* `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`, | ||
* `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`, | ||
* `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`, | ||
* `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`, | ||
* `unescape`, `uniqueId`, `value`, and `words` | ||
* | ||
@@ -81,0 +83,0 @@ * The wrapper method `sample` will return a wrapped value when `n` is provided, |
@@ -13,3 +13,3 @@ var LodashWrapper = require('../internal/LodashWrapper'); | ||
* var array = [1, 2]; | ||
* var wrapper = _(array).push(3); | ||
* var wrapped = _(array).push(3); | ||
* | ||
@@ -19,7 +19,7 @@ * console.log(array); | ||
* | ||
* wrapper = wrapper.commit(); | ||
* wrapped = wrapped.commit(); | ||
* console.log(array); | ||
* // => [1, 2, 3] | ||
* | ||
* wrapper.last(); | ||
* wrapped.last(); | ||
* // => 3 | ||
@@ -26,0 +26,0 @@ * |
@@ -14,3 +14,3 @@ var baseLodash = require('../internal/baseLodash'), | ||
* var array = [1, 2]; | ||
* var wrapper = _(array).map(function(value) { | ||
* var wrapped = _(array).map(function(value) { | ||
* return Math.pow(value, 2); | ||
@@ -20,8 +20,8 @@ * }); | ||
* var other = [3, 4]; | ||
* var otherWrapper = wrapper.plant(other); | ||
* var otherWrapped = wrapped.plant(other); | ||
* | ||
* otherWrapper.value(); | ||
* otherWrapped.value(); | ||
* // => [9, 16] | ||
* | ||
* wrapper.value(); | ||
* wrapped.value(); | ||
* // => [1, 4] | ||
@@ -28,0 +28,0 @@ */ |
@@ -27,13 +27,18 @@ var LazyWrapper = require('../internal/LazyWrapper'), | ||
var value = this.__wrapped__; | ||
var interceptor = function(value) { | ||
return value.reverse(); | ||
}; | ||
if (value instanceof LazyWrapper) { | ||
var wrapped = value; | ||
if (this.__actions__.length) { | ||
value = new LazyWrapper(this); | ||
wrapped = new LazyWrapper(this); | ||
} | ||
return new LodashWrapper(value.reverse(), this.__chain__); | ||
wrapped = wrapped.reverse(); | ||
wrapped.__actions__.push({ 'func': thru, 'args': [interceptor], 'thisArg': undefined }); | ||
return new LodashWrapper(wrapped, this.__chain__); | ||
} | ||
return this.thru(function(value) { | ||
return value.reverse(); | ||
}); | ||
return this.thru(interceptor); | ||
} | ||
module.exports = wrapperReverse; |
@@ -58,3 +58,3 @@ var arrayEvery = require('../internal/arrayEvery'), | ||
if (thisArg && isIterateeCall(collection, predicate, thisArg)) { | ||
predicate = null; | ||
predicate = undefined; | ||
} | ||
@@ -61,0 +61,0 @@ if (typeof predicate != 'function' || thisArg !== undefined) { |
@@ -13,5 +13,5 @@ var baseIndexOf = require('../internal/baseIndexOf'), | ||
/** | ||
* Checks if `value` is in `collection` using | ||
* [`SameValueZero`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) | ||
* for equality comparisons. If `fromIndex` is negative, it is used as the offset | ||
* Checks if `target` is in `collection` using | ||
* [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero) | ||
* for equality comparisons. If `fromIndex` is negative, it's used as the offset | ||
* from the end of `collection`. | ||
@@ -48,5 +48,2 @@ * | ||
} | ||
if (!length) { | ||
return false; | ||
} | ||
if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) { | ||
@@ -58,6 +55,6 @@ fromIndex = 0; | ||
return (typeof collection == 'string' || !isArray(collection) && isString(collection)) | ||
? (fromIndex < length && collection.indexOf(target, fromIndex) > -1) | ||
: (baseIndexOf(collection, target, fromIndex) > -1); | ||
? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1) | ||
: (!!length && baseIndexOf(collection, target, fromIndex) > -1); | ||
} | ||
module.exports = includes; |
@@ -10,3 +10,3 @@ var baseEach = require('../internal/baseEach'), | ||
* an array of the results of each invoked method. Any additional arguments | ||
* are provided to each invoked method. If `methodName` is a function it is | ||
* are provided to each invoked method. If `methodName` is a function it's | ||
* invoked for, and `this` bound to, each element in `collection`. | ||
@@ -37,3 +37,3 @@ * | ||
baseEach(collection, function(value) { | ||
var func = isFunc ? path : ((isProp && value != null) ? value[path] : null); | ||
var func = isFunc ? path : ((isProp && value != null) ? value[path] : undefined); | ||
result[++index] = func ? func.apply(value, args) : invokePath(value, path, args); | ||
@@ -40,0 +40,0 @@ }); |
@@ -17,3 +17,4 @@ var arrayReduce = require('../internal/arrayReduce'), | ||
* The guarded methods are: | ||
* `assign`, `defaults`, `includes`, `merge`, `sortByAll`, and `sortByOrder` | ||
* `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`, | ||
* and `sortByOrder` | ||
* | ||
@@ -20,0 +21,0 @@ * @static |
@@ -59,3 +59,3 @@ var arraySome = require('../internal/arraySome'), | ||
if (thisArg && isIterateeCall(collection, predicate, thisArg)) { | ||
predicate = null; | ||
predicate = undefined; | ||
} | ||
@@ -62,0 +62,0 @@ if (typeof predicate != 'function' || thisArg !== undefined) { |
@@ -60,3 +60,3 @@ var baseCallback = require('../internal/baseCallback'), | ||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { | ||
iteratee = null; | ||
iteratee = undefined; | ||
} | ||
@@ -63,0 +63,0 @@ var index = -1; |
@@ -7,5 +7,5 @@ var baseSortByOrder = require('../internal/baseSortByOrder'), | ||
* This method is like `_.sortByAll` except that it allows specifying the | ||
* sort orders of the iteratees to sort by. A truthy value in `orders` will | ||
* sort the corresponding property name in ascending order while a falsey | ||
* value will sort it in descending order. | ||
* sort orders of the iteratees to sort by. If `orders` is unspecified, all | ||
* values are sorted in ascending order. Otherwise, a value is sorted in | ||
* ascending order if its corresponding order is "asc", and descending if "desc". | ||
* | ||
@@ -24,3 +24,3 @@ * If a property name is provided for an iteratee the created `_.property` | ||
* @param {Function[]|Object[]|string[]} iteratees The iteratees to sort by. | ||
* @param {boolean[]} orders The sort orders of `iteratees`. | ||
* @param {boolean[]} [orders] The sort orders of `iteratees`. | ||
* @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`. | ||
@@ -38,3 +38,3 @@ * @returns {Array} Returns the new sorted array. | ||
* // sort by `user` in ascending order and by `age` in descending order | ||
* _.map(_.sortByOrder(users, ['user', 'age'], [true, false]), _.values); | ||
* _.map(_.sortByOrder(users, ['user', 'age'], ['asc', 'desc']), _.values); | ||
* // => [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 42]] | ||
@@ -47,3 +47,3 @@ */ | ||
if (guard && isIterateeCall(iteratees, orders, guard)) { | ||
orders = null; | ||
orders = undefined; | ||
} | ||
@@ -50,0 +50,0 @@ if (!isArray(iteratees)) { |
@@ -18,2 +18,3 @@ module.exports = { | ||
'memoize': require('./function/memoize'), | ||
'modArgs': require('./function/modArgs'), | ||
'negate': require('./function/negate'), | ||
@@ -20,0 +21,0 @@ 'once': require('./function/once'), |
@@ -9,3 +9,3 @@ /** Used as the `TypeError` message for "Functions" methods. */ | ||
* The opposite of `_.before`; this method creates a function that invokes | ||
* `func` once it is called `n` or more times. | ||
* `func` once it's called `n` or more times. | ||
* | ||
@@ -12,0 +12,0 @@ * @static |
@@ -28,8 +28,8 @@ var createWrapper = require('../internal/createWrapper'), | ||
if (guard && isIterateeCall(func, n, guard)) { | ||
n = null; | ||
n = undefined; | ||
} | ||
n = (func && n == null) ? func.length : nativeMax(+n || 0, 0); | ||
return createWrapper(func, ARY_FLAG, null, null, null, null, n); | ||
return createWrapper(func, ARY_FLAG, undefined, undefined, undefined, undefined, n); | ||
} | ||
module.exports = ary; |
@@ -6,3 +6,3 @@ /** Used as the `TypeError` message for "Functions" methods. */ | ||
* Creates a function that invokes `func`, with the `this` binding and arguments | ||
* of the created function, while it is called less than `n` times. Subsequent | ||
* of the created function, while it's called less than `n` times. Subsequent | ||
* calls to the created function return the result of the last `func` invocation. | ||
@@ -37,3 +37,3 @@ * | ||
if (n <= 1) { | ||
func = null; | ||
func = undefined; | ||
} | ||
@@ -40,0 +40,0 @@ return result; |
@@ -35,3 +35,3 @@ var isObject = require('../lang/isObject'), | ||
* @param {number} [options.maxWait] The maximum time `func` is allowed to be | ||
* delayed before it is invoked. | ||
* delayed before it's invoked. | ||
* @param {boolean} [options.trailing=true] Specify invoking on the trailing | ||
@@ -94,5 +94,5 @@ * edge of the timeout. | ||
} else if (isObject(options)) { | ||
leading = options.leading; | ||
leading = !!options.leading; | ||
maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait); | ||
trailing = 'trailing' in options ? options.trailing : trailing; | ||
trailing = 'trailing' in options ? !!options.trailing : trailing; | ||
} | ||
@@ -107,20 +107,24 @@ | ||
} | ||
lastCalled = 0; | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
} | ||
function complete(isCalled, id) { | ||
if (id) { | ||
clearTimeout(id); | ||
} | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
if (isCalled) { | ||
lastCalled = now(); | ||
result = func.apply(thisArg, args); | ||
if (!timeoutId && !maxTimeoutId) { | ||
args = thisArg = undefined; | ||
} | ||
} | ||
} | ||
function delayed() { | ||
var remaining = wait - (now() - stamp); | ||
if (remaining <= 0 || remaining > wait) { | ||
if (maxTimeoutId) { | ||
clearTimeout(maxTimeoutId); | ||
} | ||
var isCalled = trailingCall; | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
if (isCalled) { | ||
lastCalled = now(); | ||
result = func.apply(thisArg, args); | ||
if (!timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
} | ||
} | ||
complete(trailingCall, maxTimeoutId); | ||
} else { | ||
@@ -132,13 +136,3 @@ timeoutId = setTimeout(delayed, remaining); | ||
function maxDelayed() { | ||
if (timeoutId) { | ||
clearTimeout(timeoutId); | ||
} | ||
maxTimeoutId = timeoutId = trailingCall = undefined; | ||
if (trailing || (maxWait !== wait)) { | ||
lastCalled = now(); | ||
result = func.apply(thisArg, args); | ||
if (!timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
} | ||
} | ||
complete(trailing, timeoutId); | ||
} | ||
@@ -183,3 +177,3 @@ | ||
if (isCalled && !timeoutId && !maxTimeoutId) { | ||
args = thisArg = null; | ||
args = thisArg = undefined; | ||
} | ||
@@ -186,0 +180,0 @@ return result; |
@@ -6,3 +6,3 @@ var baseDelay = require('../internal/baseDelay'), | ||
* Defers invoking the `func` until the current call stack has cleared. Any | ||
* additional arguments are provided to `func` when it is invoked. | ||
* additional arguments are provided to `func` when it's invoked. | ||
* | ||
@@ -9,0 +9,0 @@ * @static |
@@ -6,3 +6,3 @@ var baseDelay = require('../internal/baseDelay'), | ||
* Invokes `func` after `wait` milliseconds. Any additional arguments are | ||
* provided to `func` when it is invoked. | ||
* provided to `func` when it's invoked. | ||
* | ||
@@ -9,0 +9,0 @@ * @static |
@@ -16,3 +16,3 @@ var MapCache = require('../internal/MapCache'); | ||
* function. Its creation may be customized by replacing the `_.memoize.Cache` | ||
* constructor with one whose instances implement the [`Map`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-properties-of-the-map-prototype-object) | ||
* constructor with one whose instances implement the [`Map`](http://ecma-international.org/ecma-262/6.0/#sec-properties-of-the-map-prototype-object) | ||
* method interface of `get`, `has`, and `set`. | ||
@@ -19,0 +19,0 @@ * |
@@ -37,5 +37,5 @@ var baseFlatten = require('../internal/baseFlatten'), | ||
var rearg = restParam(function(func, indexes) { | ||
return createWrapper(func, REARG_FLAG, null, null, null, baseFlatten(indexes)); | ||
return createWrapper(func, REARG_FLAG, undefined, undefined, undefined, baseFlatten(indexes)); | ||
}); | ||
module.exports = rearg; |
@@ -11,3 +11,3 @@ /** Used as the `TypeError` message for "Functions" methods. */ | ||
* | ||
* **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/rest_parameters). | ||
* **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters). | ||
* | ||
@@ -14,0 +14,0 @@ * @static |
@@ -8,3 +8,3 @@ /** Used as the `TypeError` message for "Functions" methods. */ | ||
* | ||
* **Note:** This method is based on the [spread operator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator). | ||
* **Note:** This method is based on the [spread operator](https://developer.mozilla.org/Web/JavaScript/Reference/Operators/Spread_operator). | ||
* | ||
@@ -11,0 +11,0 @@ * @static |
@@ -7,9 +7,2 @@ var debounce = require('./debounce'), | ||
/** Used as an internal `_.debounce` options object by `_.throttle`. */ | ||
var debounceOptions = { | ||
'leading': false, | ||
'maxWait': 0, | ||
'trailing': false | ||
}; | ||
/** | ||
@@ -67,8 +60,5 @@ * Creates a throttled function that only invokes `func` at most once per | ||
} | ||
debounceOptions.leading = leading; | ||
debounceOptions.maxWait = +wait; | ||
debounceOptions.trailing = trailing; | ||
return debounce(func, wait, debounceOptions); | ||
return debounce(func, wait, { 'leading': leading, 'maxWait': +wait, 'trailing': trailing }); | ||
} | ||
module.exports = throttle; |
@@ -30,5 +30,5 @@ var createWrapper = require('../internal/createWrapper'), | ||
wrapper = wrapper == null ? identity : wrapper; | ||
return createWrapper(wrapper, PARTIAL_FLAG, null, [value], []); | ||
return createWrapper(wrapper, PARTIAL_FLAG, undefined, [value], []); | ||
} | ||
module.exports = wrap; |
/** | ||
* A specialized version of `_.sum` for arrays without support for iteratees. | ||
* A specialized version of `_.sum` for arrays without support for callback | ||
* shorthands and `this` binding.. | ||
* | ||
* @private | ||
* @param {Array} array The array to iterate over. | ||
* @param {Function} iteratee The function invoked per iteration. | ||
* @returns {number} Returns the sum. | ||
*/ | ||
function arraySum(array) { | ||
function arraySum(array, iteratee) { | ||
var length = array.length, | ||
@@ -13,3 +15,3 @@ result = 0; | ||
while (length--) { | ||
result += +array[length] || 0; | ||
result += +iteratee(array[length]) || 0; | ||
} | ||
@@ -16,0 +18,0 @@ return result; |
@@ -56,3 +56,3 @@ var arrayCopy = require('./arrayCopy'), | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -108,3 +108,3 @@ */ | ||
} | ||
// Check for circular references and return corresponding clone. | ||
// Check for circular references and return its corresponding clone. | ||
stackA || (stackA = []); | ||
@@ -111,0 +111,0 @@ stackB || (stackB = []); |
@@ -17,3 +17,3 @@ var isObject = require('../lang/isObject'); | ||
var result = new object; | ||
object.prototype = null; | ||
object.prototype = undefined; | ||
} | ||
@@ -20,0 +20,0 @@ return result || {}; |
@@ -5,2 +5,5 @@ var baseIndexOf = require('./baseIndexOf'), | ||
/** Used as the size to enable large array optimizations. */ | ||
var LARGE_ARRAY_SIZE = 200; | ||
/** | ||
@@ -25,3 +28,3 @@ * The base implementation of `_.difference` which accepts a single array | ||
isCommon = true, | ||
cache = (isCommon && values.length >= 200) ? createCache(values) : null, | ||
cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null, | ||
valuesLength = values.length; | ||
@@ -28,0 +31,0 @@ |
@@ -1,2 +0,3 @@ | ||
var isArguments = require('../lang/isArguments'), | ||
var arrayPush = require('./arrayPush'), | ||
isArguments = require('../lang/isArguments'), | ||
isArray = require('../lang/isArray'), | ||
@@ -14,9 +15,10 @@ isArrayLike = require('./isArrayLike'), | ||
* @param {boolean} [isStrict] Restrict flattening to arrays-like objects. | ||
* @param {Array} [result=[]] The initial result value. | ||
* @returns {Array} Returns the new flattened array. | ||
*/ | ||
function baseFlatten(array, isDeep, isStrict) { | ||
function baseFlatten(array, isDeep, isStrict, result) { | ||
result || (result = []); | ||
var index = -1, | ||
length = array.length, | ||
resIndex = -1, | ||
result = []; | ||
length = array.length; | ||
@@ -29,12 +31,8 @@ while (++index < length) { | ||
// Recursively flatten arrays (susceptible to call stack limits). | ||
value = baseFlatten(value, isDeep, isStrict); | ||
baseFlatten(value, isDeep, isStrict, result); | ||
} else { | ||
arrayPush(result, value); | ||
} | ||
var valIndex = -1, | ||
valLength = value.length; | ||
while (++valIndex < valLength) { | ||
result[++resIndex] = value[valIndex]; | ||
} | ||
} else if (!isStrict) { | ||
result[++resIndex] = value; | ||
result[result.length] = value; | ||
} | ||
@@ -41,0 +39,0 @@ } |
@@ -19,3 +19,3 @@ var equalArrays = require('./equalArrays'), | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -22,0 +22,0 @@ */ |
@@ -17,3 +17,3 @@ var arrayEach = require('./arrayEach'), | ||
* @param {Object} source The source object. | ||
* @param {Function} [customizer] The function to customize merging properties. | ||
* @param {Function} [customizer] The function to customize merged values. | ||
* @param {Array} [stackA=[]] Tracks traversed source objects. | ||
@@ -28,3 +28,3 @@ * @param {Array} [stackB=[]] Associates values with source counterparts. | ||
var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)), | ||
props = isSrcArr ? null : keys(source); | ||
props = isSrcArr ? undefined : keys(source); | ||
@@ -31,0 +31,0 @@ arrayEach(props || source, function(srcValue, key) { |
@@ -19,3 +19,3 @@ var arrayCopy = require('./arrayCopy'), | ||
* @param {Function} mergeFunc The function to merge values. | ||
* @param {Function} [customizer] The function to customize merging properties. | ||
* @param {Function} [customizer] The function to customize merged values. | ||
* @param {Array} [stackA=[]] Tracks traversed source objects. | ||
@@ -22,0 +22,0 @@ * @param {Array} [stackB=[]] Associates values with source counterparts. |
@@ -1,6 +0,4 @@ | ||
/** Native method references. */ | ||
var floor = Math.floor; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeRandom = Math.random; | ||
var nativeFloor = Math.floor, | ||
nativeRandom = Math.random; | ||
@@ -17,5 +15,5 @@ /** | ||
function baseRandom(min, max) { | ||
return min + floor(nativeRandom() * (max - min + 1)); | ||
return min + nativeFloor(nativeRandom() * (max - min + 1)); | ||
} | ||
module.exports = baseRandom; |
@@ -10,5 +10,2 @@ /** | ||
function baseToString(value) { | ||
if (typeof value == 'string') { | ||
return value; | ||
} | ||
return value == null ? '' : (value + ''); | ||
@@ -15,0 +12,0 @@ } |
@@ -5,2 +5,5 @@ var baseIndexOf = require('./baseIndexOf'), | ||
/** Used as the size to enable large array optimizations. */ | ||
var LARGE_ARRAY_SIZE = 200; | ||
/** | ||
@@ -13,3 +16,3 @@ * The base implementation of `_.uniq` without support for callback shorthands | ||
* @param {Function} [iteratee] The function invoked per iteration. | ||
* @returns {Array} Returns the new duplicate-value-free array. | ||
* @returns {Array} Returns the new duplicate free array. | ||
*/ | ||
@@ -21,3 +24,3 @@ function baseUniq(array, iteratee) { | ||
isCommon = true, | ||
isLarge = isCommon && length >= 200, | ||
isLarge = isCommon && length >= LARGE_ARRAY_SIZE, | ||
seen = isLarge ? createCache() : null, | ||
@@ -24,0 +27,0 @@ result = []; |
@@ -1,9 +0,4 @@ | ||
var LazyWrapper = require('./LazyWrapper'); | ||
var LazyWrapper = require('./LazyWrapper'), | ||
arrayPush = require('./arrayPush'); | ||
/** Used for native method references. */ | ||
var arrayProto = Array.prototype; | ||
/** Native method references. */ | ||
var push = arrayProto.push; | ||
/** | ||
@@ -28,7 +23,4 @@ * The base implementation of `wrapperValue` which returns the result of | ||
while (++index < length) { | ||
var args = [result], | ||
action = actions[index]; | ||
push.apply(args, action.args); | ||
result = action.func.apply(action.thisArg, args); | ||
var action = actions[index]; | ||
result = action.func.apply(action.thisArg, arrayPush([result], action.args)); | ||
} | ||
@@ -35,0 +27,0 @@ return result; |
@@ -1,6 +0,4 @@ | ||
/** Native method references. */ | ||
var floor = Math.floor; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeMin = Math.min; | ||
var nativeFloor = Math.floor, | ||
nativeMin = Math.min; | ||
@@ -34,3 +32,3 @@ /** Used as references for the maximum length and index of an array. */ | ||
while (low < high) { | ||
var mid = floor((low + high) / 2), | ||
var mid = nativeFloor((low + high) / 2), | ||
computed = iteratee(array[mid]), | ||
@@ -37,0 +35,0 @@ isDef = computed !== undefined, |
@@ -1,25 +0,5 @@ | ||
var constant = require('../utility/constant'), | ||
getNative = require('./getNative'); | ||
/** Native method references. */ | ||
var ArrayBuffer = getNative(global, 'ArrayBuffer'), | ||
bufferSlice = getNative(ArrayBuffer && new ArrayBuffer(0), 'slice'), | ||
floor = Math.floor, | ||
Uint8Array = getNative(global, 'Uint8Array'); | ||
var ArrayBuffer = global.ArrayBuffer, | ||
Uint8Array = global.Uint8Array; | ||
/** Used to clone array buffers. */ | ||
var Float64Array = (function() { | ||
// Safari 5 errors when using an array buffer to initialize a typed array | ||
// where the array buffer's `byteLength` is not a multiple of the typed | ||
// array's `BYTES_PER_ELEMENT`. | ||
try { | ||
var func = getNative(global, 'Float64Array'), | ||
result = new func(new ArrayBuffer(10), 0, 1) && func; | ||
} catch(e) {} | ||
return result || null; | ||
}()); | ||
/** Used as the size, in bytes, of each `Float64Array` element. */ | ||
var FLOAT64_BYTES_PER_ELEMENT = Float64Array ? Float64Array.BYTES_PER_ELEMENT : 0; | ||
/** | ||
@@ -33,24 +13,9 @@ * Creates a clone of the given array buffer. | ||
function bufferClone(buffer) { | ||
return bufferSlice.call(buffer, 0); | ||
} | ||
if (!bufferSlice) { | ||
// PhantomJS has `ArrayBuffer` and `Uint8Array` but not `Float64Array`. | ||
bufferClone = !(ArrayBuffer && Uint8Array) ? constant(null) : function(buffer) { | ||
var byteLength = buffer.byteLength, | ||
floatLength = Float64Array ? floor(byteLength / FLOAT64_BYTES_PER_ELEMENT) : 0, | ||
offset = floatLength * FLOAT64_BYTES_PER_ELEMENT, | ||
result = new ArrayBuffer(byteLength); | ||
var result = new ArrayBuffer(buffer.byteLength), | ||
view = new Uint8Array(result); | ||
if (floatLength) { | ||
var view = new Float64Array(result, 0, floatLength); | ||
view.set(new Float64Array(buffer, 0, floatLength)); | ||
} | ||
if (byteLength != offset) { | ||
view = new Uint8Array(result, offset); | ||
view.set(new Uint8Array(buffer, offset)); | ||
} | ||
return result; | ||
}; | ||
view.set(new Uint8Array(buffer)); | ||
return result; | ||
} | ||
module.exports = bufferClone; |
@@ -8,4 +8,4 @@ var baseCompareAscending = require('./baseCompareAscending'); | ||
* @private | ||
* @param {Object} object The object to compare to `other`. | ||
* @param {Object} other The object to compare to `object`. | ||
* @param {Object} object The object to compare. | ||
* @param {Object} other The other object to compare. | ||
* @returns {number} Returns the sort order indicator for `object`. | ||
@@ -12,0 +12,0 @@ */ |
var baseCompareAscending = require('./baseCompareAscending'); | ||
/** | ||
* Used by `_.sortByOrder` to compare multiple properties of each element | ||
* in a collection and stable sort them in the following order: | ||
* Used by `_.sortByOrder` to compare multiple properties of a value to another | ||
* and stable sort them. | ||
* | ||
* If `orders` is unspecified, sort in ascending order for all properties. | ||
* Otherwise, for each property, sort in ascending order if its corresponding value in | ||
* orders is true, and descending order if false. | ||
* If `orders` is unspecified, all valuess are sorted in ascending order. Otherwise, | ||
* a value is sorted in ascending order if its corresponding order is "asc", and | ||
* descending if "desc". | ||
* | ||
* @private | ||
* @param {Object} object The object to compare to `other`. | ||
* @param {Object} other The object to compare to `object`. | ||
* @param {Object} object The object to compare. | ||
* @param {Object} other The other object to compare. | ||
* @param {boolean[]} orders The order to sort by for each property. | ||
@@ -30,3 +30,4 @@ * @returns {number} Returns the sort order indicator for `object`. | ||
} | ||
return result * (orders[index] ? 1 : -1); | ||
var order = orders[index]; | ||
return result * ((order === 'asc' || order === true) ? 1 : -1); | ||
} | ||
@@ -33,0 +34,0 @@ } |
@@ -20,3 +20,3 @@ /* Native method references for those with the same name as other `lodash` methods. */ | ||
leftLength = partials.length, | ||
result = Array(argsLength + leftLength); | ||
result = Array(leftLength + argsLength); | ||
@@ -23,0 +23,0 @@ while (++leftIndex < leftLength) { |
@@ -6,9 +6,4 @@ var baseCallback = require('./baseCallback'), | ||
/** | ||
* Creates a function that aggregates a collection, creating an accumulator | ||
* object composed from the results of running each element in the collection | ||
* through an iteratee. | ||
* Creates a `_.countBy`, `_.groupBy`, `_.indexBy`, or `_.partition` function. | ||
* | ||
* **Note:** This function is used to create `_.countBy`, `_.groupBy`, `_.indexBy`, | ||
* and `_.partition`. | ||
* | ||
* @private | ||
@@ -15,0 +10,0 @@ * @param {Function} setter The function to set keys and values of the accumulator object. |
@@ -6,7 +6,4 @@ var bindCallback = require('./bindCallback'), | ||
/** | ||
* Creates a function that assigns properties of source object(s) to a given | ||
* destination object. | ||
* Creates a `_.assign`, `_.defaults`, or `_.merge` function. | ||
* | ||
* **Note:** This function is used to create `_.assign`, `_.defaults`, and `_.merge`. | ||
* | ||
* @private | ||
@@ -13,0 +10,0 @@ * @param {Function} assigner The function to assign values. |
var SetCache = require('./SetCache'), | ||
constant = require('../utility/constant'), | ||
getNative = require('./getNative'); | ||
@@ -18,6 +17,6 @@ | ||
*/ | ||
var createCache = !(nativeCreate && Set) ? constant(null) : function(values) { | ||
return new SetCache(values); | ||
}; | ||
function createCache(values) { | ||
return (nativeCreate && Set) ? new SetCache(values) : null; | ||
} | ||
module.exports = createCache; |
@@ -15,3 +15,3 @@ var baseCreate = require('./baseCreate'), | ||
// Use a `switch` statement to work with class constructors. | ||
// See https://people.mozilla.org/~jorendorff/es6-draft.html#sec-ecmascript-function-objects-call-thisargument-argumentslist | ||
// See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist | ||
// for more details. | ||
@@ -26,2 +26,4 @@ var args = arguments; | ||
case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]); | ||
case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]); | ||
case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]); | ||
} | ||
@@ -28,0 +30,0 @@ var thisBinding = baseCreate(Ctor.prototype), |
@@ -14,5 +14,5 @@ var createWrapper = require('./createWrapper'), | ||
if (guard && isIterateeCall(func, arity, guard)) { | ||
arity = null; | ||
arity = undefined; | ||
} | ||
var result = createWrapper(func, flag, null, null, null, null, null, arity); | ||
var result = createWrapper(func, flag, undefined, undefined, undefined, undefined, undefined, arity); | ||
result.placeholder = curryFunc.placeholder; | ||
@@ -19,0 +19,0 @@ return result; |
var arrayExtremum = require('./arrayExtremum'), | ||
baseCallback = require('./baseCallback'), | ||
baseExtremum = require('./baseExtremum'), | ||
isArray = require('../lang/isArray'), | ||
isIterateeCall = require('./isIterateeCall'), | ||
@@ -18,7 +19,7 @@ toIterable = require('./toIterable'); | ||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { | ||
iteratee = null; | ||
iteratee = undefined; | ||
} | ||
iteratee = baseCallback(iteratee, thisArg, 3); | ||
if (iteratee.length == 1) { | ||
collection = toIterable(collection); | ||
collection = isArray(collection) ? collection : toIterable(collection); | ||
var result = arrayExtremum(collection, iteratee, comparator, exValue); | ||
@@ -25,0 +26,0 @@ if (!(collection.length && result === exValue)) { |
@@ -13,2 +13,5 @@ var LodashWrapper = require('./LodashWrapper'), | ||
/** Used as the size to enable large array optimizations. */ | ||
var LARGE_ARRAY_SIZE = 200; | ||
/** Used as the `TypeError` message for "Functions" methods. */ | ||
@@ -38,3 +41,3 @@ var FUNC_ERROR_TEXT = 'Expected a function'; | ||
if (!wrapper && LodashWrapper.prototype.thru && getFuncName(func) == 'wrapper') { | ||
wrapper = new LodashWrapper([]); | ||
wrapper = new LodashWrapper([], true); | ||
} | ||
@@ -47,3 +50,3 @@ } | ||
var funcName = getFuncName(func), | ||
data = funcName == 'wrapper' ? getData(func) : null; | ||
data = funcName == 'wrapper' ? getData(func) : undefined; | ||
@@ -57,8 +60,10 @@ if (data && isLaziable(data[0]) && data[1] == (ARY_FLAG | CURRY_FLAG | PARTIAL_FLAG | REARG_FLAG) && !data[4].length && data[9] == 1) { | ||
return function() { | ||
var args = arguments; | ||
if (wrapper && args.length == 1 && isArray(args[0])) { | ||
return wrapper.plant(args[0]).value(); | ||
var args = arguments, | ||
value = args[0]; | ||
if (wrapper && args.length == 1 && isArray(value) && value.length >= LARGE_ARRAY_SIZE) { | ||
return wrapper.plant(value).value(); | ||
} | ||
var index = 0, | ||
result = length ? funcs[index].apply(this, args) : args[0]; | ||
result = length ? funcs[index].apply(this, args) : value; | ||
@@ -65,0 +70,0 @@ while (++index < length) { |
@@ -47,3 +47,3 @@ var arrayCopy = require('./arrayCopy'), | ||
isCurryRight = bitmask & CURRY_RIGHT_FLAG, | ||
Ctor = isBindKey ? null : createCtorWrapper(func); | ||
Ctor = isBindKey ? undefined : createCtorWrapper(func); | ||
@@ -72,8 +72,8 @@ function wrapper() { | ||
if (length < arity) { | ||
var newArgPos = argPos ? arrayCopy(argPos) : null, | ||
var newArgPos = argPos ? arrayCopy(argPos) : undefined, | ||
newArity = nativeMax(arity - length, 0), | ||
newsHolders = isCurry ? argsHolders : null, | ||
newHoldersRight = isCurry ? null : argsHolders, | ||
newPartials = isCurry ? args : null, | ||
newPartialsRight = isCurry ? null : args; | ||
newsHolders = isCurry ? argsHolders : undefined, | ||
newHoldersRight = isCurry ? undefined : argsHolders, | ||
newPartials = isCurry ? args : undefined, | ||
newPartialsRight = isCurry ? undefined : args; | ||
@@ -80,0 +80,0 @@ bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG); |
var repeat = require('../string/repeat'); | ||
/** Native method references. */ | ||
var ceil = Math.ceil; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeIsFinite = global.isFinite; | ||
var nativeCeil = Math.ceil, | ||
nativeIsFinite = global.isFinite; | ||
@@ -28,5 +26,5 @@ /** | ||
chars = chars == null ? ' ' : (chars + ''); | ||
return repeat(chars, ceil(padLength / chars.length)).slice(0, padLength); | ||
return repeat(chars, nativeCeil(padLength / chars.length)).slice(0, padLength); | ||
} | ||
module.exports = createPadding; |
@@ -15,3 +15,3 @@ var createWrapper = require('./createWrapper'), | ||
var holders = replaceHolders(partials, partialFunc.placeholder); | ||
return createWrapper(func, flag, null, partials, holders); | ||
return createWrapper(func, flag, undefined, partials, holders); | ||
}); | ||
@@ -18,0 +18,0 @@ return partialFunc; |
@@ -29,3 +29,3 @@ var createCtorWrapper = require('./createCtorWrapper'); | ||
leftLength = partials.length, | ||
args = Array(argsLength + leftLength); | ||
args = Array(leftLength + argsLength); | ||
@@ -32,0 +32,0 @@ while (++leftIndex < leftLength) { |
@@ -54,3 +54,3 @@ var baseSetData = require('./baseSetData'), | ||
bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG); | ||
partials = holders = null; | ||
partials = holders = undefined; | ||
} | ||
@@ -62,5 +62,5 @@ length -= (holders ? holders.length : 0); | ||
partials = holders = null; | ||
partials = holders = undefined; | ||
} | ||
var data = isBindKey ? null : getData(func), | ||
var data = isBindKey ? undefined : getData(func), | ||
newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity]; | ||
@@ -67,0 +67,0 @@ |
@@ -17,3 +17,3 @@ /** `Object#toString` result references. */ | ||
* @private | ||
* @param {Object} value The object to compare. | ||
* @param {Object} object The object to compare. | ||
* @param {Object} other The other object to compare. | ||
@@ -20,0 +20,0 @@ * @param {string} tag The `toStringTag` of the objects to compare. |
@@ -12,4 +12,3 @@ /** Used to escape characters for inclusion in compiled string literals. */ | ||
/** | ||
* Used by `_.template` to escape characters for inclusion in compiled | ||
* string literals. | ||
* Used by `_.template` to escape characters for inclusion in compiled string literals. | ||
* | ||
@@ -16,0 +15,0 @@ * @private |
@@ -11,3 +11,3 @@ var realNames = require('./realNames'); | ||
function getFuncName(func) { | ||
var result = func.name, | ||
var result = (func.name + ''), | ||
array = realNames[result], | ||
@@ -14,0 +14,0 @@ length = array ? array.length : 0; |
@@ -11,3 +11,3 @@ /* Native method references for those with the same name as other `lodash` methods. */ | ||
* @param {number} end The end of the view. | ||
* @param {Array} [transforms] The transformations to apply to the view. | ||
* @param {Array} transforms The transformations to apply to the view. | ||
* @returns {Object} Returns an object containing the `start` and `end` | ||
@@ -18,3 +18,3 @@ * positions of the view. | ||
var index = -1, | ||
length = transforms ? transforms.length : 0; | ||
length = transforms.length; | ||
@@ -21,0 +21,0 @@ while (++index < length) { |
@@ -5,3 +5,3 @@ /** Used to detect unsigned integer values. */ | ||
/** | ||
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) | ||
* Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
@@ -8,0 +8,0 @@ */ |
@@ -14,7 +14,8 @@ var LazyWrapper = require('./LazyWrapper'), | ||
function isLaziable(func) { | ||
var funcName = getFuncName(func); | ||
if (!(funcName in LazyWrapper.prototype)) { | ||
var funcName = getFuncName(func), | ||
other = lodash[funcName]; | ||
if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) { | ||
return false; | ||
} | ||
var other = lodash[funcName]; | ||
if (func === other) { | ||
@@ -21,0 +22,0 @@ return true; |
/** | ||
* Used as the [maximum length](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.max_safe_integer) | ||
* Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer) | ||
* of an array-like value. | ||
@@ -10,3 +10,3 @@ */ | ||
* | ||
* **Note:** This function is based on [`ToLength`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-tolength). | ||
* **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength). | ||
* | ||
@@ -13,0 +13,0 @@ * @private |
@@ -13,13 +13,9 @@ var LazyWrapper = require('./LazyWrapper'), | ||
function lazyClone() { | ||
var actions = this.__actions__, | ||
iteratees = this.__iteratees__, | ||
views = this.__views__, | ||
result = new LazyWrapper(this.__wrapped__); | ||
result.__actions__ = actions ? arrayCopy(actions) : null; | ||
var result = new LazyWrapper(this.__wrapped__); | ||
result.__actions__ = arrayCopy(this.__actions__); | ||
result.__dir__ = this.__dir__; | ||
result.__filtered__ = this.__filtered__; | ||
result.__iteratees__ = iteratees ? arrayCopy(iteratees) : null; | ||
result.__iteratees__ = arrayCopy(this.__iteratees__); | ||
result.__takeCount__ = this.__takeCount__; | ||
result.__views__ = views ? arrayCopy(views) : null; | ||
result.__views__ = arrayCopy(this.__views__); | ||
return result; | ||
@@ -26,0 +22,0 @@ } |
@@ -5,5 +5,7 @@ var baseWrapperValue = require('./baseWrapperValue'), | ||
/** Used as the size to enable large array optimizations. */ | ||
var LARGE_ARRAY_SIZE = 200; | ||
/** Used to indicate the type of lazy iteratees. */ | ||
var LAZY_DROP_WHILE_FLAG = 0, | ||
LAZY_FILTER_FLAG = 1, | ||
var LAZY_FILTER_FLAG = 1, | ||
LAZY_MAP_FLAG = 2; | ||
@@ -23,9 +25,8 @@ | ||
function lazyValue() { | ||
var array = this.__wrapped__.value(); | ||
if (!isArray(array)) { | ||
return baseWrapperValue(array, this.__actions__); | ||
} | ||
var dir = this.__dir__, | ||
var array = this.__wrapped__.value(), | ||
dir = this.__dir__, | ||
isArr = isArray(array), | ||
isRight = dir < 0, | ||
view = getView(0, array.length, this.__views__), | ||
arrLength = isArr ? array.length : 0, | ||
view = getView(0, arrLength, this.__views__), | ||
start = view.start, | ||
@@ -35,8 +36,12 @@ end = view.end, | ||
index = isRight ? end : (start - 1), | ||
takeCount = nativeMin(length, this.__takeCount__), | ||
iteratees = this.__iteratees__, | ||
iterLength = iteratees ? iteratees.length : 0, | ||
iterLength = iteratees.length, | ||
resIndex = 0, | ||
result = []; | ||
takeCount = nativeMin(length, this.__takeCount__); | ||
if (!isArr || arrLength < LARGE_ARRAY_SIZE || (arrLength == length && takeCount == length)) { | ||
return baseWrapperValue(array, this.__actions__); | ||
} | ||
var result = []; | ||
outer: | ||
@@ -52,27 +57,13 @@ while (length-- && resIndex < takeCount) { | ||
iteratee = data.iteratee, | ||
type = data.type; | ||
type = data.type, | ||
computed = iteratee(value); | ||
if (type == LAZY_DROP_WHILE_FLAG) { | ||
if (data.done && (isRight ? (index > data.index) : (index < data.index))) { | ||
data.count = 0; | ||
data.done = false; | ||
if (type == LAZY_MAP_FLAG) { | ||
value = computed; | ||
} else if (!computed) { | ||
if (type == LAZY_FILTER_FLAG) { | ||
continue outer; | ||
} else { | ||
break outer; | ||
} | ||
data.index = index; | ||
if (!data.done) { | ||
var limit = data.limit; | ||
if (!(data.done = limit > -1 ? (data.count++ >= limit) : !iteratee(value))) { | ||
continue outer; | ||
} | ||
} | ||
} else { | ||
var computed = iteratee(value); | ||
if (type == LAZY_MAP_FLAG) { | ||
value = computed; | ||
} else if (!computed) { | ||
if (type == LAZY_FILTER_FLAG) { | ||
continue outer; | ||
} else { | ||
break outer; | ||
} | ||
} | ||
} | ||
@@ -79,0 +70,0 @@ } |
@@ -15,9 +15,8 @@ var baseCreate = require('./baseCreate'), | ||
this.__wrapped__ = value; | ||
this.__actions__ = null; | ||
this.__actions__ = []; | ||
this.__dir__ = 1; | ||
this.__dropCount__ = 0; | ||
this.__filtered__ = false; | ||
this.__iteratees__ = null; | ||
this.__iteratees__ = []; | ||
this.__takeCount__ = POSITIVE_INFINITY; | ||
this.__views__ = null; | ||
this.__views__ = []; | ||
} | ||
@@ -24,0 +23,0 @@ |
@@ -8,3 +8,3 @@ /** | ||
* @param {Function} [iteratee] The function invoked per iteration. | ||
* @returns {Array} Returns the new duplicate-value-free array. | ||
* @returns {Array} Returns the new duplicate free array. | ||
*/ | ||
@@ -11,0 +11,0 @@ function sortedUniq(array, iteratee) { |
@@ -7,6 +7,6 @@ var baseClone = require('../internal/baseClone'), | ||
* Creates a clone of `value`. If `isDeep` is `true` nested objects are cloned, | ||
* otherwise they are assigned by reference. If `customizer` is provided it is | ||
* otherwise they are assigned by reference. If `customizer` is provided it's | ||
* invoked to produce the cloned values. If `customizer` returns `undefined` | ||
* cloning is handled by the method instead. The `customizer` is bound to | ||
* `thisArg` and invoked with two argument; (value [, index|key, object]). | ||
* `thisArg` and invoked with up to three argument; (value [, index|key, object]). | ||
* | ||
@@ -67,3 +67,3 @@ * **Note:** This method is loosely based on the | ||
return typeof customizer == 'function' | ||
? baseClone(value, isDeep, bindCallback(customizer, thisArg, 1)) | ||
? baseClone(value, isDeep, bindCallback(customizer, thisArg, 3)) | ||
: baseClone(value, isDeep); | ||
@@ -70,0 +70,0 @@ } |
@@ -5,6 +5,6 @@ var baseClone = require('../internal/baseClone'), | ||
/** | ||
* Creates a deep clone of `value`. If `customizer` is provided it is invoked | ||
* Creates a deep clone of `value`. If `customizer` is provided it's invoked | ||
* to produce the cloned values. If `customizer` returns `undefined` cloning | ||
* is handled by the method instead. The `customizer` is bound to `thisArg` | ||
* and invoked with two argument; (value [, index|key, object]). | ||
* and invoked with up to three argument; (value [, index|key, object]). | ||
* | ||
@@ -52,3 +52,3 @@ * **Note:** This method is loosely based on the | ||
return typeof customizer == 'function' | ||
? baseClone(value, true, bindCallback(customizer, thisArg, 1)) | ||
? baseClone(value, true, bindCallback(customizer, thisArg, 3)) | ||
: baseClone(value, true); | ||
@@ -55,0 +55,0 @@ } |
var isArrayLike = require('../internal/isArrayLike'), | ||
isObjectLike = require('../internal/isObjectLike'); | ||
/** `Object#toString` result references. */ | ||
var argsTag = '[object Arguments]'; | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objToString = objectProto.toString; | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** Native method references. */ | ||
var propertyIsEnumerable = objectProto.propertyIsEnumerable; | ||
/** | ||
@@ -33,5 +30,6 @@ * Checks if `value` is classified as an `arguments` object. | ||
function isArguments(value) { | ||
return isObjectLike(value) && isArrayLike(value) && objToString.call(value) == argsTag; | ||
return isObjectLike(value) && isArrayLike(value) && | ||
hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee'); | ||
} | ||
module.exports = isArguments; |
@@ -12,3 +12,3 @@ var getNative = require('../internal/getNative'), | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -15,0 +15,0 @@ */ |
@@ -10,3 +10,3 @@ var isObjectLike = require('../internal/isObjectLike'); | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -13,0 +13,0 @@ */ |
@@ -10,3 +10,3 @@ var isObjectLike = require('../internal/isObjectLike'); | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -13,0 +13,0 @@ */ |
var isObjectLike = require('../internal/isObjectLike'), | ||
isPlainObject = require('./isPlainObject'), | ||
support = require('../support'); | ||
isPlainObject = require('./isPlainObject'); | ||
/** Used for native method references. */ | ||
var objectProto = Object.prototype; | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objToString = objectProto.toString; | ||
/** | ||
* Checks if `value` is a DOM element. | ||
@@ -31,12 +21,5 @@ * | ||
function isElement(value) { | ||
return !!value && value.nodeType === 1 && isObjectLike(value) && | ||
(objToString.call(value).indexOf('Element') > -1); | ||
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); | ||
} | ||
// Fallback for environments without DOM support. | ||
if (!support.dom) { | ||
isElement = function(value) { | ||
return !!value && value.nodeType === 1 && isObjectLike(value) && !isPlainObject(value); | ||
}; | ||
} | ||
module.exports = isElement; |
@@ -10,3 +10,3 @@ var isArguments = require('./isArguments'), | ||
/** | ||
* Checks if `value` is empty. A value is considered empty unless it is an | ||
* Checks if `value` is empty. A value is considered empty unless it's an | ||
* `arguments` object, array, string, or jQuery-like collection with a length | ||
@@ -13,0 +13,0 @@ * greater than `0` or an object with own enumerable properties. |
@@ -6,6 +6,6 @@ var baseIsEqual = require('../internal/baseIsEqual'), | ||
* Performs a deep comparison between two values to determine if they are | ||
* equivalent. If `customizer` is provided it is invoked to compare values. | ||
* equivalent. If `customizer` is provided it's invoked to compare values. | ||
* If `customizer` returns `undefined` comparisons are handled by the method | ||
* instead. The `customizer` is bound to `thisArg` and invoked with three | ||
* arguments: (value, other [, index|key]). | ||
* instead. The `customizer` is bound to `thisArg` and invoked with up to | ||
* three arguments: (value, other [, index|key]). | ||
* | ||
@@ -12,0 +12,0 @@ * **Note:** This method supports comparing arrays, booleans, `Date` objects, |
@@ -10,3 +10,3 @@ var isObjectLike = require('../internal/isObjectLike'); | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -13,0 +13,0 @@ */ |
@@ -1,6 +0,3 @@ | ||
var getNative = require('../internal/getNative'); | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeIsFinite = global.isFinite, | ||
nativeNumIsFinite = getNative(Number, 'isFinite'); | ||
var nativeIsFinite = global.isFinite; | ||
@@ -10,3 +7,3 @@ /** | ||
* | ||
* **Note:** This method is based on [`Number.isFinite`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite). | ||
* **Note:** This method is based on [`Number.isFinite`](http://ecma-international.org/ecma-262/6.0/#sec-number.isfinite). | ||
* | ||
@@ -35,6 +32,6 @@ * @static | ||
*/ | ||
var isFinite = nativeNumIsFinite || function(value) { | ||
function isFinite(value) { | ||
return typeof value == 'number' && nativeIsFinite(value); | ||
}; | ||
} | ||
module.exports = isFinite; |
@@ -1,3 +0,2 @@ | ||
var baseIsFunction = require('../internal/baseIsFunction'), | ||
getNative = require('../internal/getNative'); | ||
var isObject = require('./isObject'); | ||
@@ -11,3 +10,3 @@ /** `Object#toString` result references. */ | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -17,5 +16,2 @@ */ | ||
/** Native method references. */ | ||
var Uint8Array = getNative(global, 'Uint8Array'); | ||
/** | ||
@@ -37,9 +33,9 @@ * Checks if `value` is classified as a `Function` object. | ||
*/ | ||
var isFunction = !(baseIsFunction(/x/) || (Uint8Array && !baseIsFunction(Uint8Array))) ? baseIsFunction : function(value) { | ||
function isFunction(value) { | ||
// The use of `Object#toString` avoids issues with the `typeof` operator | ||
// in older versions of Chrome and Safari which return 'function' for regexes | ||
// and Safari 8 equivalents which return 'object' for typed array constructors. | ||
return objToString.call(value) == funcTag; | ||
}; | ||
// and Safari 8 which returns 'object' for typed array constructors. | ||
return isObject(value) && objToString.call(value) == funcTag; | ||
} | ||
module.exports = isFunction; |
@@ -8,3 +8,3 @@ var baseIsMatch = require('../internal/baseIsMatch'), | ||
* `object` contains equivalent property values. If `customizer` is provided | ||
* it is invoked to compare values. If `customizer` returns `undefined` | ||
* it's invoked to compare values. If `customizer` returns `undefined` | ||
* comparisons are handled by the method instead. The `customizer` is bound | ||
@@ -11,0 +11,0 @@ * to `thisArg` and invoked with three arguments: (value, other, index|key). |
@@ -1,7 +0,4 @@ | ||
var escapeRegExp = require('../string/escapeRegExp'), | ||
var isFunction = require('./isFunction'), | ||
isObjectLike = require('../internal/isObjectLike'); | ||
/** `Object#toString` result references. */ | ||
var funcTag = '[object Function]'; | ||
/** Used to detect host constructors (Safari > 5). */ | ||
@@ -19,11 +16,5 @@ var reIsHostCtor = /^\[object .+?Constructor\]$/; | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* of values. | ||
*/ | ||
var objToString = objectProto.toString; | ||
/** Used to detect if a method is native. */ | ||
var reIsNative = RegExp('^' + | ||
escapeRegExp(fnToString.call(hasOwnProperty)) | ||
fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&') | ||
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$' | ||
@@ -52,3 +43,3 @@ ); | ||
} | ||
if (objToString.call(value) == funcTag) { | ||
if (isFunction(value)) { | ||
return reIsNative.test(fnToString.call(value)); | ||
@@ -55,0 +46,0 @@ } |
@@ -10,3 +10,3 @@ var isObjectLike = require('../internal/isObjectLike'); | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -13,0 +13,0 @@ */ |
@@ -1,3 +0,4 @@ | ||
var getNative = require('../internal/getNative'), | ||
shimIsPlainObject = require('../internal/shimIsPlainObject'); | ||
var baseForIn = require('../internal/baseForIn'), | ||
isArguments = require('./isArguments'), | ||
isObjectLike = require('../internal/isObjectLike'); | ||
@@ -10,4 +11,7 @@ /** `Object#toString` result references. */ | ||
/** Used to check objects for own properties. */ | ||
var hasOwnProperty = objectProto.hasOwnProperty; | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -17,5 +21,2 @@ */ | ||
/** Native method references. */ | ||
var getPrototypeOf = getNative(Object, 'getPrototypeOf'); | ||
/** | ||
@@ -51,14 +52,23 @@ * Checks if `value` is a plain object, that is, an object created by the | ||
*/ | ||
var isPlainObject = !getPrototypeOf ? shimIsPlainObject : function(value) { | ||
if (!(value && objToString.call(value) == objectTag)) { | ||
function isPlainObject(value) { | ||
var Ctor; | ||
// Exit early for non `Object` objects. | ||
if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) || | ||
(!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) { | ||
return false; | ||
} | ||
var valueOf = getNative(value, 'valueOf'), | ||
objProto = valueOf && (objProto = getPrototypeOf(valueOf)) && getPrototypeOf(objProto); | ||
// IE < 9 iterates inherited properties before own properties. If the first | ||
// iterated property is an object's own property then there are no inherited | ||
// enumerable properties. | ||
var result; | ||
// In most environments an object's own properties are iterated before | ||
// its inherited properties. If the last iterated property is an object's | ||
// own property then there are no inherited enumerable properties. | ||
baseForIn(value, function(subValue, key) { | ||
result = key; | ||
}); | ||
return result === undefined || hasOwnProperty.call(value, result); | ||
} | ||
return objProto | ||
? (value == objProto || getPrototypeOf(value) == objProto) | ||
: shimIsPlainObject(value); | ||
}; | ||
module.exports = isPlainObject; |
@@ -1,2 +0,2 @@ | ||
var isObjectLike = require('../internal/isObjectLike'); | ||
var isObject = require('./isObject'); | ||
@@ -10,3 +10,3 @@ /** `Object#toString` result references. */ | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -33,5 +33,5 @@ */ | ||
function isRegExp(value) { | ||
return isObjectLike(value) && objToString.call(value) == regexpTag; | ||
return isObject(value) && objToString.call(value) == regexpTag; | ||
} | ||
module.exports = isRegExp; |
@@ -10,3 +10,3 @@ var isObjectLike = require('../internal/isObjectLike'); | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -13,0 +13,0 @@ */ |
@@ -49,3 +49,3 @@ var isLength = require('../internal/isLength'), | ||
/** | ||
* Used to resolve the [`toStringTag`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.prototype.tostring) | ||
* Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring) | ||
* of values. | ||
@@ -52,0 +52,0 @@ */ |
module.exports = { | ||
'add': require('./math/add'), | ||
'ceil': require('./math/ceil'), | ||
'floor': require('./math/floor'), | ||
'max': require('./math/max'), | ||
'min': require('./math/min'), | ||
'round': require('./math/round'), | ||
'sum': require('./math/sum') | ||
}; |
@@ -9,3 +9,3 @@ var createExtremum = require('../internal/createExtremum'), | ||
* Gets the maximum value of `collection`. If `collection` is empty or falsey | ||
* `-Infinity` is returned. If an iteratee function is provided it is invoked | ||
* `-Infinity` is returned. If an iteratee function is provided it's invoked | ||
* for each value in `collection` to generate the criterion by which the value | ||
@@ -12,0 +12,0 @@ * is ranked. The `iteratee` is bound to `thisArg` and invoked with three |
@@ -9,3 +9,3 @@ var createExtremum = require('../internal/createExtremum'), | ||
* Gets the minimum value of `collection`. If `collection` is empty or falsey | ||
* `Infinity` is returned. If an iteratee function is provided it is invoked | ||
* `Infinity` is returned. If an iteratee function is provided it's invoked | ||
* for each value in `collection` to generate the criterion by which the value | ||
@@ -12,0 +12,0 @@ * is ranked. The `iteratee` is bound to `thisArg` and invoked with three |
@@ -42,9 +42,7 @@ var arraySum = require('../internal/arraySum'), | ||
if (thisArg && isIterateeCall(collection, iteratee, thisArg)) { | ||
iteratee = null; | ||
iteratee = undefined; | ||
} | ||
var noIteratee = iteratee == null; | ||
iteratee = noIteratee ? iteratee : baseCallback(iteratee, thisArg, 3); | ||
return noIteratee | ||
? arraySum(isArray(collection) ? collection : toIterable(collection)) | ||
iteratee = baseCallback(iteratee, thisArg, 3); | ||
return iteratee.length == 1 | ||
? arraySum(isArray(collection) ? collection : toIterable(collection), iteratee) | ||
: baseSum(collection, iteratee); | ||
@@ -51,0 +49,0 @@ } |
@@ -7,3 +7,3 @@ /* Native method references for those with the same name as other `lodash` methods. */ | ||
* Checks if `n` is between `start` and up to but not including, `end`. If | ||
* `end` is not specified it is set to `start` with `start` then set to `0`. | ||
* `end` is not specified it's set to `start` with `start` then set to `0`. | ||
* | ||
@@ -39,3 +39,3 @@ * @static | ||
start = +start || 0; | ||
if (typeof end === 'undefined') { | ||
if (end === undefined) { | ||
end = start; | ||
@@ -42,0 +42,0 @@ start = 0; |
@@ -37,3 +37,3 @@ var baseRandom = require('../internal/baseRandom'), | ||
if (floating && isIterateeCall(min, max, floating)) { | ||
max = floating = null; | ||
max = floating = undefined; | ||
} | ||
@@ -40,0 +40,0 @@ var noMin = min == null, |
@@ -5,2 +5,3 @@ module.exports = { | ||
'defaults': require('./object/defaults'), | ||
'defaultsDeep': require('./object/defaultsDeep'), | ||
'extend': require('./object/extend'), | ||
@@ -7,0 +8,0 @@ 'findKey': require('./object/findKey'), |
@@ -8,3 +8,3 @@ var assignWith = require('../internal/assignWith'), | ||
* object. Subsequent sources overwrite property assignments of previous sources. | ||
* If `customizer` is provided it is invoked to produce the assigned values. | ||
* If `customizer` is provided it's invoked to produce the assigned values. | ||
* The `customizer` is bound to `thisArg` and invoked with five arguments: | ||
@@ -14,3 +14,3 @@ * (objectValue, sourceValue, key, object, source). | ||
* **Note:** This method mutates `object` and is based on | ||
* [`Object.assign`](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign). | ||
* [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign). | ||
* | ||
@@ -17,0 +17,0 @@ * @static |
@@ -42,3 +42,3 @@ var baseAssign = require('../internal/baseAssign'), | ||
if (guard && isIterateeCall(prototype, properties, guard)) { | ||
properties = null; | ||
properties = undefined; | ||
} | ||
@@ -45,0 +45,0 @@ return properties ? baseAssign(result, properties) : result; |
var assign = require('./assign'), | ||
assignDefaults = require('../internal/assignDefaults'), | ||
restParam = require('../function/restParam'); | ||
createDefaults = require('../internal/createDefaults'); | ||
@@ -23,11 +23,4 @@ /** | ||
*/ | ||
var defaults = restParam(function(args) { | ||
var object = args[0]; | ||
if (object == null) { | ||
return object; | ||
} | ||
args.push(assignDefaults); | ||
return assign.apply(undefined, args); | ||
}); | ||
var defaults = createDefaults(assign, assignDefaults); | ||
module.exports = defaults; |
@@ -29,3 +29,3 @@ var baseGet = require('../internal/baseGet'), | ||
function get(object, path, defaultValue) { | ||
var result = object == null ? undefined : baseGet(object, toPath(path), path + ''); | ||
var result = object == null ? undefined : baseGet(object, toPath(path), (path + '')); | ||
return result === undefined ? defaultValue : result; | ||
@@ -32,0 +32,0 @@ } |
@@ -35,3 +35,3 @@ var isIterateeCall = require('../internal/isIterateeCall'), | ||
if (guard && isIterateeCall(object, multiValue, guard)) { | ||
multiValue = null; | ||
multiValue = undefined; | ||
} | ||
@@ -38,0 +38,0 @@ var index = -1, |
@@ -13,3 +13,3 @@ var getNative = require('../internal/getNative'), | ||
* **Note:** Non-object values are coerced to objects. See the | ||
* [ES spec](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys) | ||
* [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys) | ||
* for more details. | ||
@@ -38,3 +38,3 @@ * | ||
var keys = !nativeKeys ? shimKeys : function(object) { | ||
var Ctor = object == null ? null : object.constructor; | ||
var Ctor = object == null ? undefined : object.constructor; | ||
if ((typeof Ctor == 'function' && Ctor.prototype === object) || | ||
@@ -41,0 +41,0 @@ (typeof object != 'function' && isArrayLike(object))) { |
@@ -8,3 +8,3 @@ var baseMerge = require('../internal/baseMerge'), | ||
* overwrite property assignments of previous sources. If `customizer` is | ||
* provided it is invoked to produce the merged values of the destination and | ||
* provided it's invoked to produce the merged values of the destination and | ||
* source properties. If `customizer` returns `undefined` merging is handled | ||
@@ -11,0 +11,0 @@ * by the method instead. The `customizer` is bound to `thisArg` and invoked |
@@ -10,3 +10,3 @@ var baseFlatten = require('../internal/baseFlatten'), | ||
* names may be specified as individual arguments or as arrays of property | ||
* names. If `predicate` is provided it is invoked for each property of `object` | ||
* names. If `predicate` is provided it's invoked for each property of `object` | ||
* picking the properties `predicate` returns truthy for. The predicate is | ||
@@ -13,0 +13,0 @@ * bound to `thisArg` and invoked with three arguments: (value, key, object). |
@@ -10,3 +10,3 @@ var baseGet = require('../internal/baseGet'), | ||
* This method is like `_.get` except that if the resolved value is a function | ||
* it is invoked with the `this` binding of its parent object and its result | ||
* it's invoked with the `this` binding of its parent object and its result | ||
* is returned. | ||
@@ -13,0 +13,0 @@ * |
@@ -8,3 +8,3 @@ var isIndex = require('../internal/isIndex'), | ||
* Sets the property value of `path` on `object`. If a portion of `path` | ||
* does not exist it is created. | ||
* does not exist it's created. | ||
* | ||
@@ -11,0 +11,0 @@ * @static |
@@ -49,3 +49,3 @@ var arrayEach = require('../internal/arrayEach'), | ||
} else { | ||
accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : null); | ||
accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined); | ||
} | ||
@@ -52,0 +52,0 @@ } else { |
{ | ||
"name": "lodash", | ||
"version": "3.9.3", | ||
"version": "3.10.1", | ||
"description": "The modern build of lodash modular utilities.", | ||
@@ -56,7 +56,7 @@ "homepage": "https://lodash.com/", | ||
}, | ||
"_id": "lodash@3.9.3", | ||
"_shasum": "0159e86832feffc6d61d852b12a953b99496bd32", | ||
"_from": "lodash@>=3.9.3 <3.10.0", | ||
"_npmVersion": "2.10.1", | ||
"_nodeVersion": "2.0.2", | ||
"_id": "lodash@3.10.1", | ||
"_shasum": "5bf45e8e49ba4189e17d482789dfd15bd140b7b6", | ||
"_from": "lodash@3.10.1", | ||
"_npmVersion": "2.13.1", | ||
"_nodeVersion": "0.12.5", | ||
"_npmUser": { | ||
@@ -89,8 +89,7 @@ "name": "jdalton", | ||
"dist": { | ||
"shasum": "0159e86832feffc6d61d852b12a953b99496bd32", | ||
"tarball": "http://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz" | ||
"shasum": "5bf45e8e49ba4189e17d482789dfd15bd140b7b6", | ||
"tarball": "http://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" | ||
}, | ||
"directories": {}, | ||
"_resolved": "https://registry.npmjs.org/lodash/-/lodash-3.9.3.tgz", | ||
"readme": "ERROR: No README data found!" | ||
"_resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz" | ||
} |
@@ -1,2 +0,2 @@ | ||
# lodash v3.9.3 | ||
# lodash v3.10.1 | ||
@@ -31,3 +31,3 @@ The [modern build](https://github.com/lodash/lodash/wiki/Build-Differences) of [lodash](https://lodash.com/) exported as [Node.js](http://nodejs.org/)/[io.js](https://iojs.org/) modules. | ||
See the [package source](https://github.com/lodash/lodash/tree/3.9.3-npm) for more details. | ||
See the [package source](https://github.com/lodash/lodash/tree/3.10.1-npm) for more details. | ||
@@ -43,4 +43,4 @@ **Note:**<br> | ||
* npm packages for [modern](https://www.npmjs.com/package/lodash), [compatibility](https://www.npmjs.com/package/lodash-compat), & [per method](https://www.npmjs.com/browse/keyword/lodash-modularized) builds | ||
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.9.3-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.9.3-amd) builds | ||
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.9.3-es) build | ||
* AMD modules for [modern](https://github.com/lodash/lodash/tree/3.10.1-amd) & [compatibility](https://github.com/lodash/lodash-compat/tree/3.10.1-amd) builds | ||
* ES modules for the [modern](https://github.com/lodash/lodash/tree/3.10.1-es) build | ||
@@ -52,3 +52,2 @@ ## Further Reading | ||
* [Changelog](https://github.com/lodash/lodash/wiki/Changelog) | ||
* [Release Notes](https://github.com/lodash/lodash/releases) | ||
* [Roadmap](https://github.com/lodash/lodash/wiki/Roadmap) | ||
@@ -62,4 +61,3 @@ * [More Resources](https://github.com/lodash/lodash/wiki/Resources) | ||
* [Lazily evaluated](http://filimanjaro.com/blog/2014/introducing-lazy-evaluation/) chaining | ||
* [_(…)](https://lodash.com/docs#_) supports intuitive chaining | ||
* [_.add](https://lodash.com/docs#add) for mathematical composition | ||
* [_(…)](https://lodash.com/docs#_) supports implicit chaining | ||
* [_.ary](https://lodash.com/docs#ary) & [_.rearg](https://lodash.com/docs#rearg) to change function argument limits & order | ||
@@ -75,2 +73,3 @@ * [_.at](https://lodash.com/docs#at) for cherry-picking collection values | ||
* [_.debounce](https://lodash.com/docs#debounce) & [_.throttle](https://lodash.com/docs#throttle) are cancelable & accept options for more control | ||
* [_.defaultsDeep](https://lodash.com/docs#defaultsDeep) for recursively assigning default properties | ||
* [_.fill](https://lodash.com/docs#fill) to fill arrays with values | ||
@@ -91,4 +90,5 @@ * [_.findKey](https://lodash.com/docs#findKey) for finding keys | ||
* [_.matchesProperty](https://lodash.com/docs#matchesProperty) to complement [_.matches](https://lodash.com/docs#matches) & [_.property](https://lodash.com/docs#property) | ||
* [_.merge](https://lodash.com/docs#merge) for a deep [_.extend](https://lodash.com/docs#extend) | ||
* [_.method](https://lodash.com/docs#method) & [_.methodOf](https://lodash.com/docs#methodOf) to create functions that invoke methods | ||
* [_.merge](https://lodash.com/docs#merge) for a deep [_.extend](https://lodash.com/docs#extend) | ||
* [_.modArgs](https://lodash.com/docs#modArgs) for more advanced functional composition | ||
* [_.parseInt](https://lodash.com/docs#parseInt) for consistent cross-environment behavior | ||
@@ -101,3 +101,2 @@ * [_.pull](https://lodash.com/docs#pull), [_.pullAt](https://lodash.com/docs#pullAt), & [_.remove](https://lodash.com/docs#remove) for mutating arrays | ||
* [_.sortByAll](https://lodash.com/docs#sortByAll) & [_.sortByOrder](https://lodash.com/docs#sortByOrder) for sorting by multiple properties & orders | ||
* [_.sum](https://lodash.com/docs#sum) to get the sum of values | ||
* [_.support](https://lodash.com/docs#support) for flagging environment features | ||
@@ -107,4 +106,6 @@ * [_.template](https://lodash.com/docs#template) supports [*“imports”*](https://lodash.com/docs#templateSettings-imports) options & [ES template delimiters](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components) | ||
* [_.unzipWith](https://lodash.com/docs#unzipWith) & [_.zipWith](https://lodash.com/docs#zipWith) to specify how grouped values should be combined | ||
* [_.valuesIn](https://lodash.com/docs#valuesIn) for getting values of all enumerable properties | ||
* [_.xor](https://lodash.com/docs#xor) to complement [_.difference](https://lodash.com/docs#difference), [_.intersection](https://lodash.com/docs#intersection), & [_.union](https://lodash.com/docs#union) | ||
* [_.valuesIn](https://lodash.com/docs#valuesIn) for getting values of all enumerable properties | ||
* [_.add](https://lodash.com/docs#add), [_.round](https://lodash.com/docs#round), [_.sum](https://lodash.com/docs#sum), & | ||
[more](https://lodash.com/docs "_.ceil & _.floor") math methods | ||
* [_.bind](https://lodash.com/docs#bind), [_.curry](https://lodash.com/docs#curry), [_.partial](https://lodash.com/docs#partial), & | ||
@@ -127,3 +128,3 @@ [more](https://lodash.com/docs "_.bindKey, _.curryRight, _.partialRight") support customizable argument placeholders | ||
Tested in Chrome 41-42, Firefox 37-38, IE 6-11, MS Edge, Opera 28-29, Safari 5-8, ChakraNode 0.12.2, io.js 2.1.0, Node.js 0.8.28, 0.10.38, & 0.12.4, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7.6 | ||
Tested in Chrome 43-44, Firefox 38-39, IE 6-11, MS Edge, Safari 5-8, ChakraNode 0.12.2, io.js 2.5.0, Node.js 0.8.28, 0.10.40, & 0.12.7, PhantomJS 1.9.8, RingoJS 0.11, & Rhino 1.7.6. | ||
Automated [browser](https://saucelabs.com/u/lodash) & [CI](https://travis-ci.org/lodash/lodash/) test runs are available. Special thanks to [Sauce Labs](https://saucelabs.com/) for providing automated browser testing. |
@@ -1,9 +0,9 @@ | ||
var baseToString = require('../internal/baseToString'); | ||
var baseToString = require('../internal/baseToString'), | ||
escapeRegExpChar = require('../internal/escapeRegExpChar'); | ||
/** | ||
* Used to match `RegExp` [special characters](http://www.regular-expressions.info/characters.html#special). | ||
* In addition to special characters the forward slash is escaped to allow for | ||
* easier `eval` use and `Function` compilation. | ||
* Used to match `RegExp` [syntax characters](http://ecma-international.org/ecma-262/6.0/#sec-patterns) | ||
* and those outlined by [`EscapeRegExpPattern`](http://ecma-international.org/ecma-262/6.0/#sec-escaperegexppattern). | ||
*/ | ||
var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, | ||
var reRegExpChars = /^[:!,]|[\\^$.*+?()[\]{}|\/]|(^[0-9a-fA-Fnrtuvx])|([\n\r\u2028\u2029])/g, | ||
reHasRegExpChars = RegExp(reRegExpChars.source); | ||
@@ -28,6 +28,6 @@ | ||
return (string && reHasRegExpChars.test(string)) | ||
? string.replace(reRegExpChars, '\\$&') | ||
: string; | ||
? string.replace(reRegExpChars, escapeRegExpChar) | ||
: (string || '(?:)'); | ||
} | ||
module.exports = escapeRegExp; |
var baseToString = require('../internal/baseToString'), | ||
createPadding = require('../internal/createPadding'); | ||
/** Native method references. */ | ||
var ceil = Math.ceil, | ||
floor = Math.floor; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeIsFinite = global.isFinite; | ||
var nativeCeil = Math.ceil, | ||
nativeFloor = Math.floor, | ||
nativeIsFinite = global.isFinite; | ||
@@ -42,4 +40,4 @@ /** | ||
var mid = (length - strLength) / 2, | ||
leftLength = floor(mid), | ||
rightLength = ceil(mid); | ||
leftLength = nativeFloor(mid), | ||
rightLength = nativeCeil(mid); | ||
@@ -46,0 +44,0 @@ chars = createPadding('', rightLength, chars); |
@@ -7,14 +7,2 @@ var isIterateeCall = require('../internal/isIterateeCall'), | ||
/** Used to detect and test for whitespace. */ | ||
var whitespace = ( | ||
// Basic whitespace characters. | ||
' \t\x0b\f\xa0\ufeff' + | ||
// Line terminators. | ||
'\n\r\u2028\u2029' + | ||
// Unicode category "Zs" space separators. | ||
'\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000' | ||
); | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
@@ -47,23 +35,14 @@ var nativeParseInt = global.parseInt; | ||
function parseInt(string, radix, guard) { | ||
if (guard && isIterateeCall(string, radix, guard)) { | ||
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt`. | ||
// Chrome fails to trim leading <BOM> whitespace characters. | ||
// See https://code.google.com/p/v8/issues/detail?id=3109 for more details. | ||
if (guard ? isIterateeCall(string, radix, guard) : radix == null) { | ||
radix = 0; | ||
} else if (radix) { | ||
radix = +radix; | ||
} | ||
return nativeParseInt(string, radix); | ||
string = trim(string); | ||
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); | ||
} | ||
// Fallback for environments with pre-ES5 implementations. | ||
if (nativeParseInt(whitespace + '08') != 8) { | ||
parseInt = function(string, radix, guard) { | ||
// Firefox < 21 and Opera < 15 follow ES3 for `parseInt`. | ||
// Chrome fails to trim leading <BOM> whitespace characters. | ||
// See https://code.google.com/p/v8/issues/detail?id=3109 for more details. | ||
if (guard ? isIterateeCall(string, radix, guard) : radix == null) { | ||
radix = 0; | ||
} else if (radix) { | ||
radix = +radix; | ||
} | ||
string = trim(string); | ||
return nativeParseInt(string, radix || (reHasHexPrefix.test(string) ? 16 : 10)); | ||
}; | ||
} | ||
module.exports = parseInt; |
var baseToString = require('../internal/baseToString'); | ||
/** Native method references. */ | ||
var floor = Math.floor; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeIsFinite = global.isFinite; | ||
var nativeFloor = Math.floor, | ||
nativeIsFinite = global.isFinite; | ||
@@ -42,3 +40,3 @@ /** | ||
} | ||
n = floor(n / 2); | ||
n = nativeFloor(n / 2); | ||
string += string; | ||
@@ -45,0 +43,0 @@ } while (n); |
@@ -19,3 +19,3 @@ var assignOwnDefaults = require('../internal/assignOwnDefaults'), | ||
/** Used to match [ES template delimiters](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-template-literal-lexical-components). */ | ||
/** Used to match [ES template delimiters](http://ecma-international.org/ecma-262/6.0/#sec-template-literal-lexical-components). */ | ||
var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g; | ||
@@ -131,3 +131,3 @@ | ||
if (otherOptions && isIterateeCall(string, options, otherOptions)) { | ||
options = otherOptions = null; | ||
options = otherOptions = undefined; | ||
} | ||
@@ -134,0 +134,0 @@ string = baseToString(string); |
@@ -55,3 +55,3 @@ var baseToString = require('../internal/baseToString'), | ||
if (guard && isIterateeCall(string, options, guard)) { | ||
options = null; | ||
options = undefined; | ||
} | ||
@@ -58,0 +58,0 @@ var length = DEFAULT_TRUNC_LENGTH, |
@@ -32,3 +32,3 @@ var baseToString = require('../internal/baseToString'), | ||
if (guard && isIterateeCall(string, pattern, guard)) { | ||
pattern = null; | ||
pattern = undefined; | ||
} | ||
@@ -35,0 +35,0 @@ string = baseToString(string); |
@@ -1,4 +0,1 @@ | ||
/** Used to detect DOM support. */ | ||
var document = (document = global.window) ? document.document : null; | ||
/** | ||
@@ -13,23 +10,2 @@ * An object environment feature flags. | ||
(function(x) { | ||
var Ctor = function() { this.x = x; }, | ||
object = { '0': x, 'length': x }, | ||
props = []; | ||
Ctor.prototype = { 'valueOf': x, 'y': x }; | ||
for (var key in new Ctor) { props.push(key); } | ||
/** | ||
* Detect if the DOM is supported. | ||
* | ||
* @memberOf _.support | ||
* @type boolean | ||
*/ | ||
try { | ||
support.dom = document.createDocumentFragment().nodeType === 11; | ||
} catch(e) { | ||
support.dom = false; | ||
} | ||
}(1, 0)); | ||
module.exports = support; |
@@ -6,3 +6,3 @@ var isError = require('../lang/isError'), | ||
* Attempts to invoke `func`, returning either the result or the caught error | ||
* object. Any additional arguments are provided to `func` when it is invoked. | ||
* object. Any additional arguments are provided to `func` when it's invoked. | ||
* | ||
@@ -9,0 +9,0 @@ * @static |
@@ -46,3 +46,3 @@ var baseCallback = require('../internal/baseCallback'), | ||
if (guard && isIterateeCall(func, thisArg, guard)) { | ||
thisArg = null; | ||
thisArg = undefined; | ||
} | ||
@@ -49,0 +49,0 @@ return isObjectLike(func) |
var arrayCopy = require('../internal/arrayCopy'), | ||
arrayPush = require('../internal/arrayPush'), | ||
baseFunctions = require('../internal/baseFunctions'), | ||
@@ -7,8 +8,2 @@ isFunction = require('../lang/isFunction'), | ||
/** Used for native method references. */ | ||
var arrayProto = Array.prototype; | ||
/** Native method references. */ | ||
var push = arrayProto.push; | ||
/** | ||
@@ -80,5 +75,3 @@ * Adds all own enumerable function properties of a source object to the | ||
} | ||
var args = [this.value()]; | ||
push.apply(args, arguments); | ||
return func.apply(object, args); | ||
return func.apply(object, arrayPush([this.value()], arguments)); | ||
}; | ||
@@ -85,0 +78,0 @@ }(func)); |
@@ -26,3 +26,3 @@ var baseGet = require('../internal/baseGet'), | ||
return function(path) { | ||
return baseGet(object, toPath(path), path + ''); | ||
return baseGet(object, toPath(path), (path + '')); | ||
}; | ||
@@ -29,0 +29,0 @@ } |
var isIterateeCall = require('../internal/isIterateeCall'); | ||
/** Native method references. */ | ||
var ceil = Math.ceil; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeMax = Math.max; | ||
var nativeCeil = Math.ceil, | ||
nativeMax = Math.max; | ||
/** | ||
* Creates an array of numbers (positive and/or negative) progressing from | ||
* `start` up to, but not including, `end`. If `end` is not specified it is | ||
* `start` up to, but not including, `end`. If `end` is not specified it's | ||
* set to `start` with `start` then set to `0`. If `end` is less than `start` | ||
@@ -44,3 +42,3 @@ * a zero-length range is created unless a negative `step` is specified. | ||
if (step && isIterateeCall(start, end, step)) { | ||
end = step = null; | ||
end = step = undefined; | ||
} | ||
@@ -59,3 +57,3 @@ start = +start || 0; | ||
var index = -1, | ||
length = nativeMax(ceil((end - start) / (step || 1)), 0), | ||
length = nativeMax(nativeCeil((end - start) / (step || 1)), 0), | ||
result = Array(length); | ||
@@ -62,0 +60,0 @@ |
var bindCallback = require('../internal/bindCallback'); | ||
/** Native method references. */ | ||
var floor = Math.floor; | ||
/* Native method references for those with the same name as other `lodash` methods. */ | ||
var nativeIsFinite = global.isFinite, | ||
var nativeFloor = Math.floor, | ||
nativeIsFinite = global.isFinite, | ||
nativeMin = Math.min; | ||
@@ -41,3 +39,3 @@ | ||
function times(n, iteratee, thisArg) { | ||
n = floor(n); | ||
n = nativeFloor(n); | ||
@@ -44,0 +42,0 @@ // Exit early to avoid a JSC JIT bug in Safari 8 |
{ | ||
"name": "validator", | ||
"description": "String validation and sanitization", | ||
"version": "3.41.2", | ||
"version": "4.4.0", | ||
"homepage": "http://github.com/chriso/validator.js", | ||
@@ -33,4 +33,3 @@ "keywords": [ | ||
"uglify-js": "latest", | ||
"coveralls": "latest", | ||
"contextify": "latest" | ||
"coveralls": "latest" | ||
}, | ||
@@ -45,8 +44,8 @@ "scripts": { | ||
"license": "MIT", | ||
"gitHead": "1e5acbcbcbb1a3ff187daeabe9c36890c9b8d97e", | ||
"_id": "validator@3.41.2", | ||
"_shasum": "2e4807a7353451b765f2316ea9bc3c4e177ac4db", | ||
"_from": "validator@>=3.41.2 <3.42.0", | ||
"_npmVersion": "2.12.1", | ||
"_nodeVersion": "0.12.6", | ||
"gitHead": "5c0603cab0005ee41235904c783f3ccb22e57fb0", | ||
"_id": "validator@4.4.0", | ||
"_shasum": "35e29555dd5f7826f970a4eaecff9e6df6df3da6", | ||
"_from": "validator@4.4.0", | ||
"_npmVersion": "3.3.12", | ||
"_nodeVersion": "5.1.1", | ||
"_npmUser": { | ||
@@ -57,4 +56,4 @@ "name": "cohara87", | ||
"dist": { | ||
"shasum": "2e4807a7353451b765f2316ea9bc3c4e177ac4db", | ||
"tarball": "http://registry.npmjs.org/validator/-/validator-3.41.2.tgz" | ||
"shasum": "35e29555dd5f7826f970a4eaecff9e6df6df3da6", | ||
"tarball": "http://registry.npmjs.org/validator/-/validator-4.4.0.tgz" | ||
}, | ||
@@ -68,3 +67,3 @@ "maintainers": [ | ||
"directories": {}, | ||
"_resolved": "https://registry.npmjs.org/validator/-/validator-3.41.2.tgz" | ||
"_resolved": "https://registry.npmjs.org/validator/-/validator-4.4.0.tgz" | ||
} |
@@ -49,4 +49,5 @@ # validator.js | ||
- **isDate(str)** - check if the string is a date. | ||
- **isDecimal(str)** - check if the string represents a decimal number, such as 0.1, .3, 1.1, 1.00003, 4.0, etc. | ||
- **isDivisibleBy(str, number)** - check if the string is a number that's divisible by another. | ||
- **isEmail(str [, options])** - check if the string is an email. `options` is an object which defaults to `{ allow_display_name: false, allow_utf8_local_part: true }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. | ||
- **isEmail(str [, options])** - check if the string is an email. `options` is an object which defaults to `{ allow_display_name: false, allow_utf8_local_part: true, require_tld: true }`. If `allow_display_name` is set to true, the validator will also match `Display Name <email-address>`. If `allow_utf8_local_part` is set to false, the validator will not allow any non-English UTF8 character in email address' local part. If `require_tld` is set to false, e-mail addresses without having TLD in their domain will also be matched. | ||
- **isFQDN(str [, options])** - check if the string is a fully qualified domain name (e.g. domain.com). `options` is an object which defaults to `{ require_tld: true, allow_underscores: false, allow_trailing_dot: false }`. | ||
@@ -61,2 +62,3 @@ - **isFloat(str [, options])** - check if the string is a float. `options` is an object which can contain the keys `min` and/or `max` to validate the float is within boundaries (e.g. `{ min: 7.22, max: 9.55 }`). | ||
- **isISIN(str)** - check if the string is an [ISIN][ISIN] (stock/security identifier). | ||
- **isISO8601(str)** - check if the string is a valid [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) date. | ||
- **isIn(str, values)** - check if the string is in a array of allowed values. | ||
@@ -67,3 +69,4 @@ - **isInt(str [, options])** - check if the string is an integer. `options` is an object which can contain the keys `min` and/or `max` to check the integer is within boundaries (e.g. `{ min: 10, max: 99 }`). | ||
- **isLowercase(str)** - check if the string is lowercase. | ||
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['zh-CN', 'en-ZA', 'en-AU', 'en-HK', 'pt-PT', 'fr-FR', 'el-GR', 'en-GB', 'en-US', 'en-ZM', 'ru-RU']`). | ||
- **isMACAddress(str)** - check if the string is a MAC address. | ||
- **isMobilePhone(str, locale)** - check if the string is a mobile phone number, (locale is one of `['zh-CN', 'zh-TW', 'en-ZA', 'en-AU', 'en-HK', 'pt-PT', 'fr-FR', 'el-GR', 'en-GB', 'en-US', 'en-ZM', 'ru-RU', 'nb-NO', 'nn-NO', 'vi-VN', 'en-NZ']`). | ||
- **isMongoId(str)** - check if the string is a valid hex-encoded representation of a [MongoDB ObjectId][mongoid]. | ||
@@ -74,6 +77,7 @@ - **isMultibyte(str)** - check if the string contains one or more multibyte chars. | ||
- **isSurrogatePair(str)** - check if the string contains any surrogate pairs chars. | ||
- **isURL(str [, options])** - check if the string is an URL. `options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false }`. | ||
- **isURL(str [, options])** - check if the string is an URL. `options` is an object which defaults to `{ protocols: ['http','https','ftp'], require_tld: true, require_protocol: false, require_valid_protocol: true, allow_underscores: false, host_whitelist: false, host_blacklist: false, allow_trailing_dot: false, allow_protocol_relative_urls: false }`. | ||
- **isUUID(str [, version])** - check if the string is a UUID (version 3, 4 or 5). | ||
- **isUppercase(str)** - check if the string is uppercase. | ||
- **isVariableWidth(str)** - check if the string contains a mixture of full and half-width chars. | ||
- **isWhitelisted(str, chars)** - checks characters if they appear in the whitelist. | ||
- **matches(str, pattern [, modifiers])** - check if string matches the pattern. Either `matches('foo', /foo/i)` or `matches('foo', 'foo', 'i')`. | ||
@@ -83,6 +87,6 @@ | ||
- **blacklist(input, chars)** - remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. blacklist(input, '\\[\\]'). | ||
- **blacklist(input, chars)** - remove characters that appear in the blacklist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `blacklist(input, '\\[\\]')`. | ||
- **escape(input)** - replace `<`, `>`, `&`, `'`, `"` and `/` with HTML entities. | ||
- **ltrim(input [, chars])** - trim characters from the left-side of the input. | ||
- **normalizeEmail(email [, options])** - canonicalize an email address. `options` is an object which defaults to `{ lowercase: true }`. With `lowercase` set to `true`, the local part of the email address is lowercased for all domains; the hostname is always lowercased and the local part of the email address is always lowercased for hosts that are known to be case-insensitive (currently only GMail). Normalization follows special rules for known providers: currently, GMail addresses have dots removed in the local part and are stripped of tags (e.g. `some.one+tag@gmail.com` becomes `someone@gmail.com`) and all `@googlemail.com` addresses are normalized to `@gmail.com`. | ||
- **normalizeEmail(email [, options])** - canonicalize an email address. `options` is an object which defaults to `{ lowercase: true, remove_dots: true, remove_extension: true }`. With `lowercase` set to `true`, the local part of the email address is lowercased for all domains; the hostname is always lowercased and the local part of the email address is always lowercased for hosts that are known to be case-insensitive (currently only GMail). Normalization follows special rules for known providers: currently, GMail addresses have dots removed in the local part and are stripped of extensions (e.g. `some.one+extension@gmail.com` becomes `someone@gmail.com`) and all `@googlemail.com` addresses are normalized to `@gmail.com`. | ||
- **rtrim(input [, chars])** - trim characters from the right-side of the input. | ||
@@ -96,3 +100,3 @@ - **stripLow(input [, keep_new_lines])** - remove characters with a numerical value < 32 and 127, mostly control characters. If `keep_new_lines` is `true`, newline characters are preserved (`\n` and `\r`, hex `0xA` and `0xD`). Unicode-safe in JavaScript. | ||
- **trim(input [, chars])** - trim characters (whitespace by default) from both sides of the input. | ||
- **whitelist(input, chars)** - remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. whitelist(input, '\\[\\]'). | ||
- **whitelist(input, chars)** - remove characters that do not appear in the whitelist. The characters are used in a RegExp and so you will need to escape some chars, e.g. `whitelist(input, '\\[\\]')`. | ||
@@ -135,2 +139,4 @@ ### XSS Sanitization | ||
Tests require node v4.0+. | ||
- `make test` - run the test suite. | ||
@@ -137,0 +143,0 @@ - `make test V=1` - run the test suite with added verbosity. |
@@ -201,3 +201,5 @@ var validator = require('../validator') | ||
, '+extension@gmail.com': false | ||
// some.name.midd..leNa...me...+extension@GoogleMail.com was removed from test cases because of a bug with validator.isEmail. See issue #258 | ||
, '...@gmail.com': false | ||
, '.+extension@googlemail.com': false | ||
, 'some.name.midd..leNa...me...+extension@GoogleMail.com': 'somenamemiddlename@gmail.com' | ||
} | ||
@@ -215,3 +217,3 @@ }); | ||
, 'blAH@x.com': 'blAH@x.com' | ||
// Domains that are known for being case-insensitive are always lowercased | ||
@@ -223,4 +225,18 @@ , 'SOME.name@GMAIL.com': 'somename@gmail.com' | ||
}); | ||
test({ | ||
sanitizer: 'normalizeEmail' | ||
, args: [{remove_dots: false}] | ||
, expect: { | ||
'SOME.name@GMAIL.com': 'some.name@gmail.com' | ||
} | ||
}); | ||
test({ | ||
sanitizer: 'normalizeEmail' | ||
, args: [{remove_extension: false}] | ||
, expect: { | ||
'foo+bar@gmail.com': 'foo+bar@gmail.com' | ||
} | ||
}); | ||
}); | ||
}); |
@@ -29,2 +29,4 @@ /*! | ||
define(definition); | ||
} else if (typeof define === 'function' && typeof define.petal === 'object') { | ||
define(name, [], definition); | ||
} else { | ||
@@ -37,9 +39,11 @@ this[name] = definition(); | ||
validator = { version: '3.41.2' }; | ||
validator = { version: '4.4.0' }; | ||
var emailUser = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e])|(\\[\x01-\x09\x0b\x0c\x0d-\x7f])))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))$/i; | ||
var emailUserPart = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i; | ||
var quotedEmailUser = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i; | ||
var emailUserUtf8 = /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))$/i; | ||
var emailUserUtf8Part = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i; | ||
var quotedEmailUserUtf8 = /^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i; | ||
var displayName = /^(?:[a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~\.]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(?:[a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~\.]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\s)*<(.+)>$/i; | ||
var displayName = /^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i; | ||
@@ -53,2 +57,4 @@ var creditCard = /^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/; | ||
var macAddress = /^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/; | ||
var ipv4Maybe = /^(\d+)\.(\d+)\.(\d+)\.(\d+)$/ | ||
@@ -70,2 +76,3 @@ , ipv6Block = /^[0-9A-F]{1,4}$/i; | ||
, hexadecimal = /^[0-9A-F]+$/i | ||
, decimal = /^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/ | ||
, hexcolor = /^#?([0-9A-F]{3}|[0-9A-F]{6})$/i; | ||
@@ -84,2 +91,3 @@ | ||
'zh-CN': /^(\+?0?86\-?)?1[345789]\d{9}$/, | ||
'zh-TW': /^(\+?886\-?|0)?9\d{8}$/, | ||
'en-ZA': /^(\+?27|0)\d{9}$/, | ||
@@ -94,5 +102,12 @@ 'en-AU': /^(\+?61|0)4\d{8}$/, | ||
'en-ZM': /^(\+26)?09[567]\d{7}$/, | ||
'ru-RU': /^(\+?7|8)?9\d{9}$/ | ||
'ru-RU': /^(\+?7|8)?9\d{9}$/, | ||
'nb-NO': /^(\+?47)?[49]\d{7}$/, | ||
'nn-NO': /^(\+?47)?[49]\d{7}$/, | ||
'vi-VN': /^(0|\+?84)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/, | ||
'en-NZ': /^(\+?64|0)2\d{7,9}$/ | ||
}; | ||
// from http://goo.gl/0ejHHW | ||
var iso8601 = /^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/; | ||
validator.extend = function (name, fn) { | ||
@@ -123,6 +138,4 @@ validator[name] = function () { | ||
input = ''; | ||
} else if (typeof input !== 'string') { | ||
input += ''; | ||
} | ||
return input; | ||
return '' + input; | ||
}; | ||
@@ -182,4 +195,2 @@ | ||
} | ||
} else if (/\s/.test(str)) { | ||
return false; | ||
} | ||
@@ -196,2 +207,7 @@ | ||
if (!validator.isByteLength(user, 0, 64) || | ||
!validator.isByteLength(domain, 0, 256)) { | ||
return false; | ||
} | ||
if (!validator.isFQDN(domain, {require_tld: options.require_tld})) { | ||
@@ -201,5 +217,20 @@ return false; | ||
return options.allow_utf8_local_part ? | ||
emailUserUtf8.test(user) : | ||
emailUser.test(user); | ||
if (user[0] === '"') { | ||
user = user.slice(1, user.length - 1); | ||
return options.allow_utf8_local_part ? | ||
quotedEmailUserUtf8.test(user) : | ||
quotedEmailUser.test(user); | ||
} | ||
var pattern = options.allow_utf8_local_part ? | ||
emailUserUtf8Part : emailUserPart; | ||
var user_parts = user.split('.'); | ||
for (var i = 0; i < user_parts.length; i++) { | ||
if (!pattern.test(user_parts[i])) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
@@ -211,2 +242,3 @@ | ||
, require_protocol: false | ||
, require_valid_protocol: true | ||
, allow_underscores: false | ||
@@ -230,3 +262,3 @@ , allow_trailing_dot: false | ||
protocol = split.shift(); | ||
if (options.protocols.indexOf(protocol) === -1) { | ||
if (options.require_valid_protocol && options.protocols.indexOf(protocol) === -1) { | ||
return false; | ||
@@ -280,2 +312,6 @@ } | ||
validator.isMACAddress = function (str) { | ||
return macAddress.test(str); | ||
}; | ||
validator.isIP = function (str, version) { | ||
@@ -375,2 +411,6 @@ version = validator.toString(version); | ||
} | ||
if (/[\uff01-\uff5e]/.test(part)) { | ||
// disallow full-width chars | ||
return false; | ||
} | ||
if (part[0] === '-' || part[part.length - 1] === '-' || | ||
@@ -400,2 +440,6 @@ part.indexOf('---') >= 0) { | ||
validator.isDecimal = function (str) { | ||
return str !== '' && decimal.test(str); | ||
}; | ||
validator.isHexadecimal = function (str) { | ||
@@ -424,3 +468,6 @@ return hexadecimal.test(str); | ||
options = options || {}; | ||
return str !== '' && float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max); | ||
if (str === '' || str === '.') { | ||
return false; | ||
} | ||
return float.test(str) && (!options.hasOwnProperty('min') || str >= options.min) && (!options.hasOwnProperty('max') || str <= options.max); | ||
}; | ||
@@ -443,3 +490,4 @@ | ||
validator.isByteLength = function (str, min, max) { | ||
return str.length >= min && (typeof max === 'undefined' || str.length <= max); | ||
var len = encodeURI(str).split(/%..|./).length - 1; | ||
return len >= min && (typeof max === 'undefined' || len <= max); | ||
}; | ||
@@ -452,4 +500,74 @@ | ||
function getTimezoneOffset(str) { | ||
var iso8601Parts = str.match(iso8601) | ||
, timezone, sign, hours, minutes; | ||
if (!iso8601Parts) { | ||
str = str.toLowerCase(); | ||
timezone = str.match(/(?:\s|gmt\s*)(-|\+)(\d{1,4})(\s|$)/); | ||
if (!timezone) { | ||
return str.indexOf('gmt') !== -1 ? 0 : null; | ||
} | ||
sign = timezone[1]; | ||
var offset = timezone[2]; | ||
if (offset.length === 3) { | ||
offset = '0' + offset; | ||
} | ||
if (offset.length <= 2) { | ||
hours = 0; | ||
minutes = parseInt(offset); | ||
} else { | ||
hours = parseInt(offset.slice(0, 2)); | ||
minutes = parseInt(offset.slice(2, 4)); | ||
} | ||
} else { | ||
timezone = iso8601Parts[21]; | ||
if (!timezone || timezone === 'z' || timezone === 'Z') { | ||
return 0; | ||
} | ||
sign = iso8601Parts[22]; | ||
if (timezone.indexOf(':') !== -1) { | ||
hours = parseInt(iso8601Parts[23]); | ||
minutes = parseInt(iso8601Parts[24]); | ||
} else { | ||
hours = 0; | ||
minutes = parseInt(iso8601Parts[23]); | ||
} | ||
} | ||
return (hours * 60 + minutes) * (sign === '-' ? 1 : -1); | ||
} | ||
validator.isDate = function (str) { | ||
return !isNaN(Date.parse(str)); | ||
var normalizedDate = new Date(Date.parse(str)); | ||
if (isNaN(normalizedDate)) { | ||
return false; | ||
} | ||
// normalizedDate is in the user's timezone. Apply the input | ||
// timezone offset to the date so that the year and day match | ||
// the input | ||
var timezoneOffset = getTimezoneOffset(str); | ||
if (timezoneOffset !== null) { | ||
var timezoneDifference = normalizedDate.getTimezoneOffset() - | ||
timezoneOffset; | ||
normalizedDate = new Date(normalizedDate.getTime() + | ||
60000 * timezoneDifference); | ||
} | ||
var day = String(normalizedDate.getDate()); | ||
var dayOrYear, dayOrYearMatches, year; | ||
//check for valid double digits that could be late days | ||
//check for all matches since a string like '12/23' is a valid date | ||
//ignore everything with nearby colons | ||
dayOrYearMatches = str.match(/(^|[^:\d])[23]\d([^:\d]|$)/g); | ||
if (!dayOrYearMatches) { | ||
return true; | ||
} | ||
dayOrYear = dayOrYearMatches.map(function(digitString) { | ||
return digitString.match(/\d+/g)[0]; | ||
}).join('/'); | ||
year = String(normalizedDate.getFullYear()).slice(-2); | ||
if (dayOrYear === day || dayOrYear === year) { | ||
return true; | ||
} else if ((dayOrYear === (day + '/' + year)) || (dayOrYear === (year + '/' + day))) { | ||
return true; | ||
} | ||
return false; | ||
}; | ||
@@ -466,3 +584,3 @@ | ||
, original = validator.toDate(str); | ||
return original && comparison && original < comparison; | ||
return !!(original && comparison && original < comparison); | ||
}; | ||
@@ -486,2 +604,12 @@ | ||
validator.isWhitelisted = function (str, chars) { | ||
for (var i = str.length - 1; i >= 0; i--) { | ||
if (chars.indexOf(str[i]) === -1) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
validator.isCreditCard = function (str) { | ||
@@ -607,7 +735,6 @@ var sanitized = str.replace(/[^0-9]+/g, ''); | ||
try { | ||
JSON.parse(str); | ||
} catch (e) { | ||
return false; | ||
} | ||
return true; | ||
var obj = JSON.parse(str); | ||
return !!obj && typeof obj === 'object'; | ||
} catch (e) {} | ||
return false; | ||
}; | ||
@@ -647,2 +774,6 @@ | ||
validator.isISO8601 = function (str) { | ||
return iso8601.test(str); | ||
}; | ||
validator.ltrim = function (str, chars) { | ||
@@ -687,3 +818,5 @@ var pattern = chars ? new RegExp('^[' + chars + ']+', 'g') : /^\s+/g; | ||
var default_normalize_email_options = { | ||
lowercase: true | ||
lowercase: true, | ||
remove_dots: true, | ||
remove_extension: true | ||
}; | ||
@@ -699,7 +832,12 @@ | ||
if (parts[1] === 'gmail.com' || parts[1] === 'googlemail.com') { | ||
parts[0] = parts[0].toLowerCase().replace(/\./g, ''); | ||
if (parts[0][0] === '+') { | ||
if (options.remove_extension) { | ||
parts[0] = parts[0].split('+')[0]; | ||
} | ||
if (options.remove_dots) { | ||
parts[0] = parts[0].replace(/\./g, ''); | ||
} | ||
if (!parts[0].length) { | ||
return false; | ||
} | ||
parts[0] = parts[0].split('+')[0]; | ||
parts[0] = parts[0].toLowerCase(); | ||
parts[1] = 'gmail.com'; | ||
@@ -706,0 +844,0 @@ } else if (options.lowercase) { |
@@ -23,2 +23,2 @@ /*! | ||
*/ | ||
!function(t,e){"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&"object"==typeof define.amd?define(e):this[t]=e()}("validator",function(t){"use strict";function e(t,e){t=t||{};for(var r in e)"undefined"==typeof t[r]&&(t[r]=e[r]);return t}function r(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),r="-?",n="[1-9]\\d*",i="[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*",o=["0",n,i],u="("+o.join("|")+")?",a="(\\"+t.decimal_separator+"\\d{2})?",s=u+a;return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?s+=r:t.negative_sign_before_digits&&(s=r+s)),t.allow_negative_sign_placeholder?s="( (?!\\-))?"+s:t.allow_space_after_symbol?s=" ?"+s:t.allow_space_after_digits&&(s+="( (?!$))?"),t.symbol_after_digits?s+=e:s=e+s,t.allow_negatives&&(t.parens_for_negatives?s="(\\("+s+"\\)|"+s+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(s=r+s)),new RegExp("^(?!-? )(?=.*\\d)"+s+"$")}t={version:"3.41.2"};var n=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e])|(\\[\x01-\x09\x0b\x0c\x0d-\x7f])))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))$/i,i=/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))$/i,o=/^(?:[a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~\.]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(?:[a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~\.]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\s)*<(.+)>$/i,u=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,a=/^[A-Z]{2}[0-9A-Z]{9}[0-9]$/,s=/^(?:[0-9]{9}X|[0-9]{10})$/,l=/^(?:[0-9]{13})$/,f=/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/,c=/^[0-9A-F]{1,4}$/i,F={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i},g=/^[A-Z]+$/i,p=/^[0-9A-Z]+$/i,x=/^[-+]?[0-9]+$/,d=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,_=/^(?:[-+]?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/,h=/^[0-9A-F]+$/i,A=/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,v=/^[\x00-\x7F]+$/,m=/[^\x00-\x7F]/,w=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,$=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,D=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,b=/^(?:[A-Z0-9+\/]{4})*(?:[A-Z0-9+\/]{2}==|[A-Z0-9+\/]{3}=|[A-Z0-9+\/]{4})$/i,y={"zh-CN":/^(\+?0?86\-?)?1[345789]\d{9}$/,"en-ZA":/^(\+?27|0)\d{9}$/,"en-AU":/^(\+?61|0)4\d{8}$/,"en-HK":/^(\+?852\-?)?[569]\d{3}\-?\d{4}$/,"fr-FR":/^(\+?33|0)[67]\d{8}$/,"pt-PT":/^(\+351)?9[1236]\d{7}$/,"el-GR":/^(\+30)?((2\d{9})|(69\d{8}))$/,"en-GB":/^(\+?44|0)7\d{9}$/,"en-US":/^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,"en-ZM":/^(\+26)?09[567]\d{7}$/,"ru-RU":/^(\+?7|8)?9\d{9}$/};t.extend=function(e,r){t[e]=function(){var e=Array.prototype.slice.call(arguments);return e[0]=t.toString(e[0]),r.apply(t,e)}},t.init=function(){for(var e in t)"function"==typeof t[e]&&"toString"!==e&&"toDate"!==e&&"extend"!==e&&"init"!==e&&t.extend(e,t[e])},t.toString=function(t){return"object"==typeof t&&null!==t&&t.toString?t=t.toString():null===t||"undefined"==typeof t||isNaN(t)&&!t.length?t="":"string"!=typeof t&&(t+=""),t},t.toDate=function(t){return"[object Date]"===Object.prototype.toString.call(t)?t:(t=Date.parse(t),isNaN(t)?null:new Date(t))},t.toFloat=function(t){return parseFloat(t)},t.toInt=function(t,e){return parseInt(t,e||10)},t.toBoolean=function(t,e){return e?"1"===t||"true"===t:"0"!==t&&"false"!==t&&""!==t},t.equals=function(e,r){return e===t.toString(r)},t.contains=function(e,r){return e.indexOf(t.toString(r))>=0},t.matches=function(t,e,r){return"[object RegExp]"!==Object.prototype.toString.call(e)&&(e=new RegExp(e,r)),e.test(t)};var E={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0};t.isEmail=function(r,u){if(u=e(u,E),u.allow_display_name){var a=r.match(o);a&&(r=a[1])}else if(/\s/.test(r))return!1;var s=r.split("@"),l=s.pop(),f=s.join("@"),c=l.toLowerCase();return("gmail.com"===c||"googlemail.com"===c)&&(f=f.replace(/\./g,"").toLowerCase()),t.isFQDN(l,{require_tld:u.require_tld})?u.allow_utf8_local_part?i.test(f):n.test(f):!1};var C={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1};t.isURL=function(r,n){if(!r||r.length>=2083||/\s/.test(r))return!1;if(0===r.indexOf("mailto:"))return!1;n=e(n,C);var i,o,u,a,s,l,f;if(f=r.split("://"),f.length>1){if(i=f.shift(),-1===n.protocols.indexOf(i))return!1}else{if(n.require_protocol)return!1;n.allow_protocol_relative_urls&&"//"===r.substr(0,2)&&(f[0]=r.substr(2))}return r=f.join("://"),f=r.split("#"),r=f.shift(),f=r.split("?"),r=f.shift(),f=r.split("/"),r=f.shift(),f=r.split("@"),f.length>1&&(o=f.shift(),o.indexOf(":")>=0&&o.split(":").length>2)?!1:(a=f.join("@"),f=a.split(":"),u=f.shift(),f.length&&(l=f.join(":"),s=parseInt(l,10),!/^[0-9]+$/.test(l)||0>=s||s>65535)?!1:t.isIP(u)||t.isFQDN(u,n)||"localhost"===u?n.host_whitelist&&-1===n.host_whitelist.indexOf(u)?!1:n.host_blacklist&&-1!==n.host_blacklist.indexOf(u)?!1:!0:!1)},t.isIP=function(e,r){if(r=t.toString(r),!r)return t.isIP(e,4)||t.isIP(e,6);if("4"===r){if(!f.test(e))return!1;var n=e.split(".").sort(function(t,e){return t-e});return n[3]<=255}if("6"===r){var i=e.split(":"),o=!1,u=t.isIP(i[i.length-1],4),a=u?7:8;if(i.length>a)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(i.shift(),i.shift(),o=!0):"::"===e.substr(e.length-2)&&(i.pop(),i.pop(),o=!0);for(var s=0;s<i.length;++s)if(""===i[s]&&s>0&&s<i.length-1){if(o)return!1;o=!0}else if(u&&s==i.length-1);else if(!c.test(i[s]))return!1;return o?i.length>=1:i.length===a}return!1};var I={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1};t.isFQDN=function(t,r){r=e(r,I),r.allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var n=t.split(".");if(r.require_tld){var i=n.pop();if(!n.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(i))return!1}for(var o,u=0;u<n.length;u++){if(o=n[u],r.allow_underscores){if(o.indexOf("__")>=0)return!1;o=o.replace(/_/g,"")}if(!/^[a-z\u00a1-\uffff0-9-]+$/i.test(o))return!1;if("-"===o[0]||"-"===o[o.length-1]||o.indexOf("---")>=0)return!1}return!0},t.isBoolean=function(t){return["true","false","1","0"].indexOf(t)>=0},t.isAlpha=function(t){return g.test(t)},t.isAlphanumeric=function(t){return p.test(t)},t.isNumeric=function(t){return x.test(t)},t.isHexadecimal=function(t){return h.test(t)},t.isHexColor=function(t){return A.test(t)},t.isLowercase=function(t){return t===t.toLowerCase()},t.isUppercase=function(t){return t===t.toUpperCase()},t.isInt=function(t,e){return e=e||{},d.test(t)&&(!e.hasOwnProperty("min")||t>=e.min)&&(!e.hasOwnProperty("max")||t<=e.max)},t.isFloat=function(t,e){return e=e||{},""!==t&&_.test(t)&&(!e.hasOwnProperty("min")||t>=e.min)&&(!e.hasOwnProperty("max")||t<=e.max)},t.isDivisibleBy=function(e,r){return t.toFloat(e)%t.toInt(r)===0},t.isNull=function(t){return 0===t.length},t.isLength=function(t,e,r){var n=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],i=t.length-n.length;return i>=e&&("undefined"==typeof r||r>=i)},t.isByteLength=function(t,e,r){return t.length>=e&&("undefined"==typeof r||t.length<=r)},t.isUUID=function(t,e){var r=F[e?e:"all"];return r&&r.test(t)},t.isDate=function(t){return!isNaN(Date.parse(t))},t.isAfter=function(e,r){var n=t.toDate(r||new Date),i=t.toDate(e);return!!(i&&n&&i>n)},t.isBefore=function(e,r){var n=t.toDate(r||new Date),i=t.toDate(e);return i&&n&&n>i},t.isIn=function(e,r){var n;if("[object Array]"===Object.prototype.toString.call(r)){var i=[];for(n in r)i[n]=t.toString(r[n]);return i.indexOf(e)>=0}return"object"==typeof r?r.hasOwnProperty(e):r&&"function"==typeof r.indexOf?r.indexOf(e)>=0:!1},t.isCreditCard=function(t){var e=t.replace(/[^0-9]+/g,"");if(!u.test(e))return!1;for(var r,n,i,o=0,a=e.length-1;a>=0;a--)r=e.substring(a,a+1),n=parseInt(r,10),i?(n*=2,o+=n>=10?n%10+1:n):o+=n,i=!i;return!!(o%10===0?e:!1)},t.isISIN=function(t){if(!a.test(t))return!1;for(var e,r,n=t.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),i=0,o=!0,u=n.length-2;u>=0;u--)e=n.substring(u,u+1),r=parseInt(e,10),o?(r*=2,i+=r>=10?r+1:r):i+=r,o=!o;return parseInt(t.substr(t.length-1),10)===(1e4-i)%10},t.isISBN=function(e,r){if(r=t.toString(r),!r)return t.isISBN(e,10)||t.isISBN(e,13);var n,i=e.replace(/[\s-]+/g,""),o=0;if("10"===r){if(!s.test(i))return!1;for(n=0;9>n;n++)o+=(n+1)*i.charAt(n);if(o+="X"===i.charAt(9)?100:10*i.charAt(9),o%11===0)return!!i}else if("13"===r){if(!l.test(i))return!1;var u=[1,3];for(n=0;12>n;n++)o+=u[n%2]*i.charAt(n);if(i.charAt(12)-(10-o%10)%10===0)return!!i}return!1},t.isMobilePhone=function(t,e){return e in y?y[e].test(t):!1};var O={symbol:"$",require_symbol:!1,allow_space_after_symbol:!1,symbol_after_digits:!1,allow_negatives:!0,parens_for_negatives:!1,negative_sign_before_digits:!1,negative_sign_after_digits:!1,allow_negative_sign_placeholder:!1,thousands_separator:",",decimal_separator:".",allow_space_after_digits:!1};t.isCurrency=function(t,n){return n=e(n,O),r(n).test(t)},t.isJSON=function(t){try{JSON.parse(t)}catch(e){return!1}return!0},t.isMultibyte=function(t){return m.test(t)},t.isAscii=function(t){return v.test(t)},t.isFullWidth=function(t){return w.test(t)},t.isHalfWidth=function(t){return $.test(t)},t.isVariableWidth=function(t){return w.test(t)&&$.test(t)},t.isSurrogatePair=function(t){return D.test(t)},t.isBase64=function(t){return b.test(t)},t.isMongoId=function(e){return t.isHexadecimal(e)&&24===e.length},t.ltrim=function(t,e){var r=e?new RegExp("^["+e+"]+","g"):/^\s+/g;return t.replace(r,"")},t.rtrim=function(t,e){var r=e?new RegExp("["+e+"]+$","g"):/\s+$/g;return t.replace(r,"")},t.trim=function(t,e){var r=e?new RegExp("^["+e+"]+|["+e+"]+$","g"):/^\s+|\s+$/g;return t.replace(r,"")},t.escape=function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/\//g,"/").replace(/\`/g,"`")},t.stripLow=function(e,r){var n=r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return t.blacklist(e,n)},t.whitelist=function(t,e){return t.replace(new RegExp("[^"+e+"]+","g"),"")},t.blacklist=function(t,e){return t.replace(new RegExp("["+e+"]+","g"),"")};var S={lowercase:!0};return t.normalizeEmail=function(r,n){if(n=e(n,S),!t.isEmail(r))return!1;var i=r.split("@",2);if(i[1]=i[1].toLowerCase(),"gmail.com"===i[1]||"googlemail.com"===i[1]){if(i[0]=i[0].toLowerCase().replace(/\./g,""),"+"===i[0][0])return!1;i[0]=i[0].split("+")[0],i[1]="gmail.com"}else n.lowercase&&(i[0]=i[0].toLowerCase());return i.join("@")},t.init(),t}); | ||
!function(t,e){"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&"object"==typeof define.amd?define(e):"function"==typeof define&&"object"==typeof define.petal?define(t,[],e):this[t]=e()}("validator",function(t){"use strict";function e(t){var e,r,n,i,o=t.match(N);if(o){if(e=o[21],!e||"z"===e||"Z"===e)return 0;r=o[22],-1!==e.indexOf(":")?(n=parseInt(o[23]),i=parseInt(o[24])):(n=0,i=parseInt(o[23]))}else{if(t=t.toLowerCase(),e=t.match(/(?:\s|gmt\s*)(-|\+)(\d{1,4})(\s|$)/),!e)return-1!==t.indexOf("gmt")?0:null;r=e[1];var u=e[2];3===u.length&&(u="0"+u),u.length<=2?(n=0,i=parseInt(u)):(n=parseInt(u.slice(0,2)),i=parseInt(u.slice(2,4)))}return(60*n+i)*("-"===r?1:-1)}function r(t,e){t=t||{};for(var r in e)"undefined"==typeof t[r]&&(t[r]=e[r]);return t}function n(t){var e="(\\"+t.symbol.replace(/\./g,"\\.")+")"+(t.require_symbol?"":"?"),r="-?",n="[1-9]\\d*",i="[1-9]\\d{0,2}(\\"+t.thousands_separator+"\\d{3})*",o=["0",n,i],u="("+o.join("|")+")?",a="(\\"+t.decimal_separator+"\\d{2})?",s=u+a;return t.allow_negatives&&!t.parens_for_negatives&&(t.negative_sign_after_digits?s+=r:t.negative_sign_before_digits&&(s=r+s)),t.allow_negative_sign_placeholder?s="( (?!\\-))?"+s:t.allow_space_after_symbol?s=" ?"+s:t.allow_space_after_digits&&(s+="( (?!$))?"),t.symbol_after_digits?s+=e:s=e+s,t.allow_negatives&&(t.parens_for_negatives?s="(\\("+s+"\\)|"+s+")":t.negative_sign_before_digits||t.negative_sign_after_digits||(s=r+s)),new RegExp("^(?!-? )(?=.*\\d)"+s+"$")}t={version:"4.4.0"};var i=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~]+$/i,o=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f]))*$/i,u=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+$/i,a=/^([\s\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|(\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*$/i,s=/^[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+[a-z\d!#\$%&'\*\+\-\/=\?\^_`{\|}~\.\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF\s]*<(.+)>$/i,l=/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11})$/,f=/^[A-Z]{2}[0-9A-Z]{9}[0-9]$/,c=/^(?:[0-9]{9}X|[0-9]{10})$/,d=/^(?:[0-9]{13})$/,g=/^([0-9a-fA-F][0-9a-fA-F]:){5}([0-9a-fA-F][0-9a-fA-F])$/,p=/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/,F=/^[0-9A-F]{1,4}$/i,_={3:/^[0-9A-F]{8}-[0-9A-F]{4}-3[0-9A-F]{3}-[0-9A-F]{4}-[0-9A-F]{12}$/i,4:/^[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,5:/^[0-9A-F]{8}-[0-9A-F]{4}-5[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$/i,all:/^[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}$/i},x=/^[A-Z]+$/i,h=/^[0-9A-Z]+$/i,v=/^[-+]?[0-9]+$/,m=/^(?:[-+]?(?:0|[1-9][0-9]*))$/,A=/^(?:[-+]?(?:[0-9]+))?(?:\.[0-9]*)?(?:[eE][\+\-]?(?:[0-9]+))?$/,$=/^[0-9A-F]+$/i,w=/^[-+]?([0-9]+|\.[0-9]+|[0-9]+\.[0-9]+)$/,D=/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i,b=/^[\x00-\x7F]+$/,y=/[^\x00-\x7F]/,I=/[^\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,O=/[\u0020-\u007E\uFF61-\uFF9F\uFFA0-\uFFDC\uFFE8-\uFFEE0-9a-zA-Z]/,E=/[\uD800-\uDBFF][\uDC00-\uDFFF]/,C=/^(?:[A-Z0-9+\/]{4})*(?:[A-Z0-9+\/]{2}==|[A-Z0-9+\/]{3}=|[A-Z0-9+\/]{4})$/i,S={"zh-CN":/^(\+?0?86\-?)?1[345789]\d{9}$/,"zh-TW":/^(\+?886\-?|0)?9\d{8}$/,"en-ZA":/^(\+?27|0)\d{9}$/,"en-AU":/^(\+?61|0)4\d{8}$/,"en-HK":/^(\+?852\-?)?[569]\d{3}\-?\d{4}$/,"fr-FR":/^(\+?33|0)[67]\d{8}$/,"pt-PT":/^(\+351)?9[1236]\d{7}$/,"el-GR":/^(\+30)?((2\d{9})|(69\d{8}))$/,"en-GB":/^(\+?44|0)7\d{9}$/,"en-US":/^(\+?1)?[2-9]\d{2}[2-9](?!11)\d{6}$/,"en-ZM":/^(\+26)?09[567]\d{7}$/,"ru-RU":/^(\+?7|8)?9\d{9}$/,"nb-NO":/^(\+?47)?[49]\d{7}$/,"nn-NO":/^(\+?47)?[49]\d{7}$/,"vi-VN":/^(0|\+?84)?((1(2([0-9])|6([2-9])|88|99))|(9((?!5)[0-9])))([0-9]{7})$/,"en-NZ":/^(\+?64|0)2\d{7,9}$/},N=/^([\+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24\:?00)([\.,]\d+(?!:))?)?(\17[0-5]\d([\.,]\d+)?)?([zZ]|([\+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;t.extend=function(e,r){t[e]=function(){var e=Array.prototype.slice.call(arguments);return e[0]=t.toString(e[0]),r.apply(t,e)}},t.init=function(){for(var e in t)"function"==typeof t[e]&&"toString"!==e&&"toDate"!==e&&"extend"!==e&&"init"!==e&&t.extend(e,t[e])},t.toString=function(t){return"object"==typeof t&&null!==t&&t.toString?t=t.toString():(null===t||"undefined"==typeof t||isNaN(t)&&!t.length)&&(t=""),""+t},t.toDate=function(t){return"[object Date]"===Object.prototype.toString.call(t)?t:(t=Date.parse(t),isNaN(t)?null:new Date(t))},t.toFloat=function(t){return parseFloat(t)},t.toInt=function(t,e){return parseInt(t,e||10)},t.toBoolean=function(t,e){return e?"1"===t||"true"===t:"0"!==t&&"false"!==t&&""!==t},t.equals=function(e,r){return e===t.toString(r)},t.contains=function(e,r){return e.indexOf(t.toString(r))>=0},t.matches=function(t,e,r){return"[object RegExp]"!==Object.prototype.toString.call(e)&&(e=new RegExp(e,r)),e.test(t)};var j={allow_display_name:!1,allow_utf8_local_part:!0,require_tld:!0};t.isEmail=function(e,n){if(n=r(n,j),n.allow_display_name){var l=e.match(s);l&&(e=l[1])}var f=e.split("@"),c=f.pop(),d=f.join("@"),g=c.toLowerCase();if(("gmail.com"===g||"googlemail.com"===g)&&(d=d.replace(/\./g,"").toLowerCase()),!t.isByteLength(d,0,64)||!t.isByteLength(c,0,256))return!1;if(!t.isFQDN(c,{require_tld:n.require_tld}))return!1;if('"'===d[0])return d=d.slice(1,d.length-1),n.allow_utf8_local_part?a.test(d):o.test(d);for(var p=n.allow_utf8_local_part?u:i,F=d.split("."),_=0;_<F.length;_++)if(!p.test(F[_]))return!1;return!0};var B={protocols:["http","https","ftp"],require_tld:!0,require_protocol:!1,require_valid_protocol:!0,allow_underscores:!1,allow_trailing_dot:!1,allow_protocol_relative_urls:!1};t.isURL=function(e,n){if(!e||e.length>=2083||/\s/.test(e))return!1;if(0===e.indexOf("mailto:"))return!1;n=r(n,B);var i,o,u,a,s,l,f;if(f=e.split("://"),f.length>1){if(i=f.shift(),n.require_valid_protocol&&-1===n.protocols.indexOf(i))return!1}else{if(n.require_protocol)return!1;n.allow_protocol_relative_urls&&"//"===e.substr(0,2)&&(f[0]=e.substr(2))}return e=f.join("://"),f=e.split("#"),e=f.shift(),f=e.split("?"),e=f.shift(),f=e.split("/"),e=f.shift(),f=e.split("@"),f.length>1&&(o=f.shift(),o.indexOf(":")>=0&&o.split(":").length>2)?!1:(a=f.join("@"),f=a.split(":"),u=f.shift(),f.length&&(l=f.join(":"),s=parseInt(l,10),!/^[0-9]+$/.test(l)||0>=s||s>65535)?!1:t.isIP(u)||t.isFQDN(u,n)||"localhost"===u?n.host_whitelist&&-1===n.host_whitelist.indexOf(u)?!1:n.host_blacklist&&-1!==n.host_blacklist.indexOf(u)?!1:!0:!1)},t.isMACAddress=function(t){return g.test(t)},t.isIP=function(e,r){if(r=t.toString(r),!r)return t.isIP(e,4)||t.isIP(e,6);if("4"===r){if(!p.test(e))return!1;var n=e.split(".").sort(function(t,e){return t-e});return n[3]<=255}if("6"===r){var i=e.split(":"),o=!1,u=t.isIP(i[i.length-1],4),a=u?7:8;if(i.length>a)return!1;if("::"===e)return!0;"::"===e.substr(0,2)?(i.shift(),i.shift(),o=!0):"::"===e.substr(e.length-2)&&(i.pop(),i.pop(),o=!0);for(var s=0;s<i.length;++s)if(""===i[s]&&s>0&&s<i.length-1){if(o)return!1;o=!0}else if(u&&s==i.length-1);else if(!F.test(i[s]))return!1;return o?i.length>=1:i.length===a}return!1};var Z={require_tld:!0,allow_underscores:!1,allow_trailing_dot:!1};t.isFQDN=function(t,e){e=r(e,Z),e.allow_trailing_dot&&"."===t[t.length-1]&&(t=t.substring(0,t.length-1));var n=t.split(".");if(e.require_tld){var i=n.pop();if(!n.length||!/^([a-z\u00a1-\uffff]{2,}|xn[a-z0-9-]{2,})$/i.test(i))return!1}for(var o,u=0;u<n.length;u++){if(o=n[u],e.allow_underscores){if(o.indexOf("__")>=0)return!1;o=o.replace(/_/g,"")}if(!/^[a-z\u00a1-\uffff0-9-]+$/i.test(o))return!1;if(/[\uff01-\uff5e]/.test(o))return!1;if("-"===o[0]||"-"===o[o.length-1]||o.indexOf("---")>=0)return!1}return!0},t.isBoolean=function(t){return["true","false","1","0"].indexOf(t)>=0},t.isAlpha=function(t){return x.test(t)},t.isAlphanumeric=function(t){return h.test(t)},t.isNumeric=function(t){return v.test(t)},t.isDecimal=function(t){return""!==t&&w.test(t)},t.isHexadecimal=function(t){return $.test(t)},t.isHexColor=function(t){return D.test(t)},t.isLowercase=function(t){return t===t.toLowerCase()},t.isUppercase=function(t){return t===t.toUpperCase()},t.isInt=function(t,e){return e=e||{},m.test(t)&&(!e.hasOwnProperty("min")||t>=e.min)&&(!e.hasOwnProperty("max")||t<=e.max)},t.isFloat=function(t,e){return e=e||{},""===t||"."===t?!1:A.test(t)&&(!e.hasOwnProperty("min")||t>=e.min)&&(!e.hasOwnProperty("max")||t<=e.max)},t.isDivisibleBy=function(e,r){return t.toFloat(e)%t.toInt(r)===0},t.isNull=function(t){return 0===t.length},t.isLength=function(t,e,r){var n=t.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]/g)||[],i=t.length-n.length;return i>=e&&("undefined"==typeof r||r>=i)},t.isByteLength=function(t,e,r){var n=encodeURI(t).split(/%..|./).length-1;return n>=e&&("undefined"==typeof r||r>=n)},t.isUUID=function(t,e){var r=_[e?e:"all"];return r&&r.test(t)},t.isDate=function(t){var r=new Date(Date.parse(t));if(isNaN(r))return!1;var n=e(t);if(null!==n){var i=r.getTimezoneOffset()-n;r=new Date(r.getTime()+6e4*i)}var o,u,a,s=String(r.getDate());return(u=t.match(/(^|[^:\d])[23]\d([^:\d]|$)/g))?(o=u.map(function(t){return t.match(/\d+/g)[0]}).join("/"),a=String(r.getFullYear()).slice(-2),o===s||o===a?!0:o===s+"/"+a||o===a+"/"+s?!0:!1):!0},t.isAfter=function(e,r){var n=t.toDate(r||new Date),i=t.toDate(e);return!!(i&&n&&i>n)},t.isBefore=function(e,r){var n=t.toDate(r||new Date),i=t.toDate(e);return!!(i&&n&&n>i)},t.isIn=function(e,r){var n;if("[object Array]"===Object.prototype.toString.call(r)){var i=[];for(n in r)i[n]=t.toString(r[n]);return i.indexOf(e)>=0}return"object"==typeof r?r.hasOwnProperty(e):r&&"function"==typeof r.indexOf?r.indexOf(e)>=0:!1},t.isWhitelisted=function(t,e){for(var r=t.length-1;r>=0;r--)if(-1===e.indexOf(t[r]))return!1;return!0},t.isCreditCard=function(t){var e=t.replace(/[^0-9]+/g,"");if(!l.test(e))return!1;for(var r,n,i,o=0,u=e.length-1;u>=0;u--)r=e.substring(u,u+1),n=parseInt(r,10),i?(n*=2,o+=n>=10?n%10+1:n):o+=n,i=!i;return!!(o%10===0?e:!1)},t.isISIN=function(t){if(!f.test(t))return!1;for(var e,r,n=t.replace(/[A-Z]/g,function(t){return parseInt(t,36)}),i=0,o=!0,u=n.length-2;u>=0;u--)e=n.substring(u,u+1),r=parseInt(e,10),o?(r*=2,i+=r>=10?r+1:r):i+=r,o=!o;return parseInt(t.substr(t.length-1),10)===(1e4-i)%10},t.isISBN=function(e,r){if(r=t.toString(r),!r)return t.isISBN(e,10)||t.isISBN(e,13);var n,i=e.replace(/[\s-]+/g,""),o=0;if("10"===r){if(!c.test(i))return!1;for(n=0;9>n;n++)o+=(n+1)*i.charAt(n);if(o+="X"===i.charAt(9)?100:10*i.charAt(9),o%11===0)return!!i}else if("13"===r){if(!d.test(i))return!1;var u=[1,3];for(n=0;12>n;n++)o+=u[n%2]*i.charAt(n);if(i.charAt(12)-(10-o%10)%10===0)return!!i}return!1},t.isMobilePhone=function(t,e){return e in S?S[e].test(t):!1};var z={symbol:"$",require_symbol:!1,allow_space_after_symbol:!1,symbol_after_digits:!1,allow_negatives:!0,parens_for_negatives:!1,negative_sign_before_digits:!1,negative_sign_after_digits:!1,allow_negative_sign_placeholder:!1,thousands_separator:",",decimal_separator:".",allow_space_after_digits:!1};t.isCurrency=function(t,e){return e=r(e,z),n(e).test(t)},t.isJSON=function(t){try{var e=JSON.parse(t);return!!e&&"object"==typeof e}catch(r){}return!1},t.isMultibyte=function(t){return y.test(t)},t.isAscii=function(t){return b.test(t)},t.isFullWidth=function(t){return I.test(t)},t.isHalfWidth=function(t){return O.test(t)},t.isVariableWidth=function(t){return I.test(t)&&O.test(t)},t.isSurrogatePair=function(t){return E.test(t)},t.isBase64=function(t){return C.test(t)},t.isMongoId=function(e){return t.isHexadecimal(e)&&24===e.length},t.isISO8601=function(t){return N.test(t)},t.ltrim=function(t,e){var r=e?new RegExp("^["+e+"]+","g"):/^\s+/g;return t.replace(r,"")},t.rtrim=function(t,e){var r=e?new RegExp("["+e+"]+$","g"):/\s+$/g;return t.replace(r,"")},t.trim=function(t,e){var r=e?new RegExp("^["+e+"]+|["+e+"]+$","g"):/^\s+|\s+$/g;return t.replace(r,"")},t.escape=function(t){return t.replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(/</g,"<").replace(/>/g,">").replace(/\//g,"/").replace(/\`/g,"`")},t.stripLow=function(e,r){var n=r?"\\x00-\\x09\\x0B\\x0C\\x0E-\\x1F\\x7F":"\\x00-\\x1F\\x7F";return t.blacklist(e,n)},t.whitelist=function(t,e){return t.replace(new RegExp("[^"+e+"]+","g"),"")},t.blacklist=function(t,e){return t.replace(new RegExp("["+e+"]+","g"),"")};var q={lowercase:!0,remove_dots:!0,remove_extension:!0};return t.normalizeEmail=function(e,n){if(n=r(n,q),!t.isEmail(e))return!1;var i=e.split("@",2);if(i[1]=i[1].toLowerCase(),"gmail.com"===i[1]||"googlemail.com"===i[1]){if(n.remove_extension&&(i[0]=i[0].split("+")[0]),n.remove_dots&&(i[0]=i[0].replace(/\./g,"")),!i[0].length)return!1;i[0]=i[0].toLowerCase(),i[1]="gmail.com"}else n.lowercase&&(i[0]=i[0].toLowerCase());return i.join("@")},t.init(),t}); |
{ | ||
"name": "anchor", | ||
"version": "0.10.5", | ||
"version": "0.11.0", | ||
"description": "Recursive validation library with support for objects and lists", | ||
@@ -28,3 +28,3 @@ "homepage": "http://sailsjs.org", | ||
"type": "git", | ||
"url": "git://github.com/balderdashy/anchor.git" | ||
"url": "git://github.com/sailsjs/anchor.git" | ||
}, | ||
@@ -35,5 +35,5 @@ "author": "Mike McNeil", | ||
"dependencies": { | ||
"geojsonhint": "^1.1.0", | ||
"lodash": "~3.9.3", | ||
"validator": "~3.41.2" | ||
"geojsonhint": "1.1.0", | ||
"lodash": "3.10.1", | ||
"validator": "4.4.0" | ||
}, | ||
@@ -47,4 +47,4 @@ "bundledDependencies": [ | ||
"async": "~0.2.10", | ||
"mocha": "1.9.x" | ||
"mocha": "2.3.4" | ||
} | ||
} |
anchor | ||
====== | ||
[![Build Status](https://travis-ci.org/balderdashy/anchor.svg?branch=master)](https://travis-ci.org/balderdashy/anchor) | ||
[![Build Status](https://travis-ci.org/sailsjs/anchor.svg?branch=master)](https://travis-ci.org/sailsjs/anchor) | ||
[![npm version](https://badge.fury.io/js/anchor.svg)](http://badge.fury.io/js/anchor) | ||
[![Dependency Status](https://david-dm.org/balderdashy/anchor.svg)](https://david-dm.org/balderdashy/anchor) | ||
@@ -18,3 +17,3 @@ Anchor is a javascript library that lets you define strict types. | ||
Adds support for strongly typed arguments, like http://lea.verou.me/2011/05/strongly-typed-javascript/, but goes a step further by adding support for array and object sub-validation. | ||
It's also the core validation library for the Sails ecosystem. | ||
It's also the core validation library for the Sails ecosystem. | ||
@@ -144,9 +143,9 @@ (Built on top of the great work with https://github.com/chriso/validator.js) | ||
homepage: 'url', | ||
// This requires any data | ||
someData: {}, | ||
// This will require a list of >=0 hex colors | ||
favoriteColors: ['htmlcolor'], | ||
// This will require a list of >=0 badge objects, as defined: | ||
@@ -196,3 +195,3 @@ badges: [{ | ||
But sometimes you want to support several different argument structures. | ||
But sometimes you want to support several different argument structures. | ||
And to do that, you have to, either explicitly or implicitly, name those arguments so your function can know which one was which, irrespective of how the arguments are specified. | ||
@@ -213,4 +212,4 @@ Here's how you specify multiple usages: | ||
}) | ||
// Here you can define your named arguments as temporal custom data types, | ||
// Here you can define your named arguments as temporal custom data types, | ||
// each with their OWN validation rules | ||
@@ -222,3 +221,3 @@ .args({ | ||
}) | ||
// To pass valiation, the user arguments must match at least one of the usages below | ||
@@ -228,3 +227,3 @@ // and each argument must pass its validation definition above | ||
['endpoint', 'id', 'done'], | ||
// Callback is optional | ||
@@ -276,3 +275,3 @@ ['endpoint', 'id'] | ||
.defaults({ | ||
}), | ||
@@ -308,12 +307,12 @@ .usage( | ||
}); | ||
// Do stuff here | ||
// This could be anything-- we chose to demonstrate a create method | ||
// This could be anything-- we chose to demonstrate a create method | ||
// in this case from our favorite ORM, Waterline (http://github.com/mikermcneil/waterline) | ||
async.auto([ | ||
// Create the user itself | ||
user: User.create(params).done, | ||
// Grant permission for the user to administer itself | ||
@@ -325,7 +324,7 @@ permission: Permission.create({ | ||
}).done | ||
], function (err, results) { | ||
// Just basic usage, but this prevents you from dealing with non-existent values and null pointers | ||
// both when providing a consistent API on the server-side | ||
// both when providing a consistent API on the server-side | ||
// AND when marshalling server-sent data on the client-side | ||
@@ -343,6 +342,6 @@ // i.e. this sucks: user.friends && user.friends.length && user.friends[0] && user.friends[0].id | ||
}); | ||
// Respond with JSON | ||
// Could just pass the user object, | ||
// but in this case we're demonstrating a custom mapping | ||
// Could just pass the user object, | ||
// but in this case we're demonstrating a custom mapping | ||
// (like you might use to implement a custom, predefined API) | ||
@@ -357,3 +356,3 @@ // You can safely know all the .'s you're using won't result in any errors, since you validated this above | ||
}); | ||
} | ||
@@ -375,4 +374,4 @@ ``` | ||
create: { | ||
// Marshal the request | ||
// Marshal the request | ||
request : { | ||
@@ -382,3 +381,3 @@ id : 'int', | ||
}, | ||
// Marshal the response to use the predetermined API | ||
@@ -391,3 +390,3 @@ response : { | ||
}, | ||
// Define an arbitrarily named attribute that will be used in response | ||
@@ -410,3 +409,3 @@ // and the function that will populate it | ||
adapter: 'mongo', | ||
attributes: { | ||
@@ -422,11 +421,11 @@ id: 'int', | ||
}, | ||
// Create a user, but also create the permission for it to manage itself | ||
create: function (values,cb) { | ||
async.auto({ | ||
// Create the user itself | ||
user: User.create(values).done, | ||
// Grant permission for the user to administer itself | ||
@@ -438,3 +437,3 @@ permission: Permission.create({ | ||
}).done | ||
], function (err, results) { | ||
@@ -472,4 +471,1 @@ cb(err, results.user); | ||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/18e6e2459aed1edbdee85d77d63b623b "githalytics.com")](http://githalytics.com/balderdashy/anchor) | ||
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3735181
868
55066
2
454
32
Updatedgeojsonhint@1.1.0
Updatedlodash@3.10.1
Updatedvalidator@4.4.0