From 540851ab6acd7c9b562537b41cf3ffb29d5b2e74 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 13 Apr 2013 11:12:01 -0700 Subject: [PATCH] Reorganize build.js modifications and remove compilation from the `lodash modern build`. Former-commit-id: af5d0500be9e11d108bf941604ce2316cbd8c4b5 --- build.js | 397 ++++++++++++++++++++++----------------------- dist/lodash.js | 260 ++++++++++++----------------- dist/lodash.min.js | 75 ++++----- 3 files changed, 330 insertions(+), 402 deletions(-) diff --git a/build.js b/build.js index 04de9aa3c..e7ba3455c 100755 --- a/build.js +++ b/build.js @@ -380,18 +380,6 @@ // remove `lodash.prototype` batch method assignments source = source.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, ''); - // move `mixin(lodash)` to after the method assignments - source = source.replace(/(?:\s*\/\/.*)*\n( *)mixin\(lodash\).+/, ''); - source = source.replace(getMethodAssignments(source), function(match) { - var indent = /^ *(?=lodash\.)/m.exec(match)[0]; - return match + [ - '', - '', - '// add functions to `lodash.prototype`', - 'mixin(lodash);' - ].join('\n' + indent); - }); - // replace `_.mixin` source = replaceFunction(source, 'mixin', [ 'function mixin(object) {', @@ -449,6 +437,18 @@ ].join('\n' + indent); }); + // move `mixin(lodash)` to after the method assignments + source = source.replace(/(?:\s*\/\/.*)*\n( *)mixin\(lodash\).+/, ''); + source = source.replace(getMethodAssignments(source), function(match) { + var indent = /^ *(?=lodash\.)/m.exec(match)[0]; + return match + [ + '', + '', + '// add functions to `lodash.prototype`', + 'mixin(lodash);' + ].join('\n' + indent); + }); + return source; } @@ -986,9 +986,12 @@ // grab the method assignments snippet snippet = getMethodAssignments(source); - // remove method assignment from `lodash.prototype` + // remove method assignment from `lodash.prototype` source = source.replace(RegExp('^ *lodash\\.prototype\\.' + funcName + ' *=.+\\n', 'm'), ''); + // remove pseudo private methods + source = source.replace(RegExp('^(?: *//.*\\s*)* *lodash\\._' + funcName + ' *=.+\\n', 'm'), ''); + // remove assignment and aliases var modified = getAliases(funcName).concat(funcName).reduce(function(result, otherName) { return result.replace(RegExp('^(?: *//.*\\s*)* *lodash\\.' + otherName + ' *=.+\\n', 'm'), ''); @@ -1831,21 +1834,68 @@ source = setUseStrictOption(source, isStrict); if (isLegacy) { + source = removeKeysOptimization(source); + source = removeSetImmediate(source); + source = removeSupportProp(source, 'fastBind'); + source = replaceSupportProp(source, 'argsClass', 'false'); + _.each(['getPrototypeOf', 'nativeBind', 'nativeIsArray', 'nativeKeys'], function(varName) { source = replaceVar(source, varName, 'false'); }); - _.each(['argsClass', 'fastBind'], function(propName) { - source = replaceSupportProp(source, propName, 'false'); + _.each(['isIeOpera', 'isV8', 'nativeBind', 'nativeIsArray', 'nativeKeys', 'reNative'], function(varName) { + source = removeVar(source, varName); }); - source = removeKeysOptimization(source); + // remove native `Function#bind` branch in `_.bind` + source = source.replace(matchFunction(source, 'bind'), function(match) { + return match.replace(/(?:\s*\/\/.*)*\s*return support\.fastBind[^:]+:\s*/, 'return '); + }); + + // remove native `Array.isArray` branch in `_.isArray` + source = source.replace(matchFunction(source, 'isArray'), function(match) { + return match.replace(/nativeIsArray\s*\|\|\s*/, ''); + }); + + // replace `_.keys` with `shimKeys` + source = source.replace( + matchFunction(source, 'keys').replace(/[\s\S]+?var keys *= */, ''), + matchFunction(source, 'shimKeys').replace(/[\s\S]+?var shimKeys *= */, '') + ); + + source = removeFunction(source, 'shimKeys'); + + // replace `_.isArguments` with fallback + source = source.replace(matchFunction(source, 'isArguments').replace(/[\s\S]+?function isArguments/, ''), function() { + var fallback = getIsArgumentsFallback(source), + body = fallback.match(/isArguments *= *function([\s\S]+? *});/)[1], + indent = getIndent(fallback); + + return body.replace(RegExp('^' + indent, 'gm'), indent.slice(0, -2)) + '\n'; + }); + + source = removeIsArgumentsFallback(source); + } + if (isModern) { + source = removeSupportArgsObject(source); + source = removeSupportSpliceObjects(source); + source = removeIsArgumentsFallback(source); + + // remove `_.isPlainObject` fallback + source = source.replace(matchFunction(source, 'isPlainObject'), function(match) { + return match.replace(/!getPrototypeOf[^:]+:\s*/, ''); + }); + + if (!isMobile) { + source = removeIsFunctionFallback(source); + } } if (isMobile || isUnderscore) { source = removeKeysOptimization(source); source = removeSetImmediate(source); } if (isModern || isUnderscore) { + source = removeSupportArgsClass(source); source = removeSupportNonEnumShadows(source); source = removeSupportEnumPrototypes(source); source = removeSupportOwnLast(source); @@ -1941,16 +1991,6 @@ }); } } - if (isModern) { - // remove `_.isPlainObject` fallback - source = source.replace(matchFunction(source, 'isPlainObject'), function(match) { - return match.replace(/!getPrototypeOf[^:]+:\s*/, ''); - }); - - if (!isMobile) { - source = removeIsFunctionFallback(source); - } - } if (isUnderscore) { // replace `_.assign` source = replaceFunction(source, 'assign', [ @@ -2383,12 +2423,19 @@ '}' ].join('\n')); + // unexpose `lodash.support` + source = source.replace(/lodash\.support *= */, ''); + // remove `_.templateSettings.imports assignment source = source.replace(/,[^']*'imports':[^}]+}/, ''); // remove large array optimizations source = removeFunction(source, 'cachedContains'); + // replace `slice` with `nativeSlice.call` + source = removeFunction(source, 'slice'); + source = source.replace(/([^.])\bslice\(/g, '$1nativeSlice.call('); + // remove `_.isEqual` use from `createCallback` source = source.replace(matchFunction(source, 'createCallback'), function(match) { return match.replace(/\bisEqual\(([^,]+), *([^,]+)[^)]+\)/, '$1 === $2'); @@ -2401,19 +2448,36 @@ }); }); - // replace `slice` with `nativeSlice.call` - source = removeFunction(source, 'slice'); - source = source.replace(/([^.])\bslice\(/g, '$1nativeSlice.call('); + // modify `_.every`, `_.find`, `_.isEqual`, and `_.some` to use the private `indicatorObject` + _.each(['every', 'isEqual'], function(methodName) { + source = source.replace(matchFunction(source, methodName), function(match) { + return match.replace(/\(result *= *(.+?)\);/g, '!(result = $1) && indicatorObject;'); + }); + }); + + source = source.replace(matchFunction(source, 'find'), function(match) { + return match.replace(/return false/, 'return indicatorObject'); + }); + + source = source.replace(matchFunction(source, 'some'), function(match) { + return match.replace(/!\(result *= *(.+?)\);/, '(result = $1) && indicatorObject;'); + }); - // replace `lodash.createCallback` references with `createCallback` - if (!useLodashMethod('createCallback')) { - source = source.replace(/\blodash\.(createCallback\()\b/g, '$1'); - } // remove unneeded variables if (!useLodashMethod('clone') && !useLodashMethod('cloneDeep')) { source = removeVar(source, 'cloneableClasses'); source = removeVar(source, 'ctorByClass'); } + // remove chainability from `each` and `_.forEach` + if (!useLodashMethod('forEach')) { + _.each(['each', 'forEach'], function(methodName) { + source = source.replace(matchFunction(source, methodName), function(match) { + return match + .replace(/\n *return .+?([};\s]+)$/, '$1') + .replace(/\b(return) +result\b/, '$1') + }); + }); + } // remove unused features from `createBound` if (_.every(['bindKey', 'partial', 'partialRight'], function(methodName) { return !_.contains(buildMethods, methodName); @@ -2516,12 +2580,6 @@ } }); - // remove `isArguments` fallback before `isArguments` is transformed by - // other parts of the build process - if (isRemoved(source, 'isArguments')) { - source = removeIsArgumentsFallback(source); - } - // remove `iteratorTemplate` dependency checks from `_.template` source = source.replace(matchFunction(source, 'template'), function(match) { return match @@ -2531,58 +2589,7 @@ /*----------------------------------------------------------------------*/ - if (isLegacy) { - source = removeSetImmediate(source); - source = removeSupportProp(source, 'fastBind'); - - _.each(['isIeOpera', 'isV8', 'nativeBind', 'nativeIsArray', 'nativeKeys', 'reNative'], function(varName) { - source = removeVar(source, varName); - }); - - // remove native `Function#bind` branch in `_.bind` - source = source.replace(matchFunction(source, 'bind'), function(match) { - return match.replace(/(?:\s*\/\/.*)*\s*return support\.fastBind[^:]+:\s*/, 'return '); - }); - - // remove native `Array.isArray` branch in `_.isArray` - source = source.replace(matchFunction(source, 'isArray'), function(match) { - return match.replace(/nativeIsArray\s*\|\|\s*/, ''); - }); - - // replace `_.keys` with `shimKeys` - if (!isRemoved(source, 'keys')) { - source = source.replace( - matchFunction(source, 'keys').replace(/[\s\S]+?var keys *= */, ''), - matchFunction(source, 'shimKeys').replace(/[\s\S]+?var shimKeys *= */, '') - ); - - source = removeFunction(source, 'shimKeys'); - } - // replace `_.isArguments` with fallback - if (!isRemoved(source, 'isArguments')) { - source = source.replace(matchFunction(source, 'isArguments').replace(/[\s\S]+?function isArguments/, ''), function() { - var fallback = getIsArgumentsFallback(source), - body = fallback.match(/isArguments *= *function([\s\S]+? *});/)[1], - indent = getIndent(fallback); - - return body.replace(RegExp('^' + indent, 'gm'), indent.slice(0, -2)) + '\n'; - }); - - source = removeIsArgumentsFallback(source); - } - } - if (isModern) { - source = removeSupportArgsObject(source); - source = removeSupportSpliceObjects(source); - source = removeIsArgumentsFallback(source); - } if (isModern || isUnderscore) { - source = removeSupportArgsClass(source); - source = removeSupportNodeClass(source); - } - if (isMobile || isUnderscore) { - source = removeVar(source, 'iteratorTemplate'); - // inline all functions defined with `createIterator` _.functions(lodash).forEach(function(methodName) { // strip leading underscores to match pseudo private functions @@ -2595,86 +2602,62 @@ }); } }); - } - if (isUnderscore) { - // remove `_.assign`, `_.forIn`, `_.forOwn`, `_.isPlainObject`, and `_.zipObject` assignments - (function() { - var snippet = getMethodAssignments(source), - modified = snippet; - if (!useLodashMethod('assign')) { - modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.assign *=.+\n/m, ''); - } + if (isUnderscore) { + // unexpose "exit early" feature of `each`, `_.forEach`, `_.forIn`, and `_.forOwn` + _.each(['each', 'forEach', 'forIn', 'forOwn'], function(methodName) { + if (methodName == 'each' || !useLodashMethod(methodName)) { + source = source.replace(matchFunction(source, methodName), function(match) { + return match.replace(/=== *false\)/g, '=== indicatorObject)'); + }); + } + }); + + // remove `thisArg` from unexposed `forIn` and `forOwn` + _.each(['forIn', 'forOwn'], function(methodName) { + if (!useLodashMethod(methodName)) { + source = source.replace(matchFunction(source, methodName), function(match) { + return match + .replace(/(callback), *thisArg/g, '$1') + .replace(/^ *callback *=.+\n/m, ''); + }); + } + }); + + // replace `lodash.createCallback` references with `createCallback` if (!useLodashMethod('createCallback')) { - modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.createCallback *=.+\n/m, ''); + source = source.replace(/\blodash\.(createCallback\()\b/g, '$1'); } - if (!useLodashMethod('forIn')) { - modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.forIn *=.+\n/m, ''); - } - if (!useLodashMethod('forOwn')) { - modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.forOwn *=.+\n/m, ''); - } - if (!useLodashMethod('isPlainObject')) { - modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.isPlainObject *=.+\n/m, ''); - } - if (!useLodashMethod('zipObject')) { - modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.zipObject *=.+\n/m, ''); - } - source = source.replace(snippet, function() { - return modified; - }); - }()); + // remove `_.assign`, `_.forIn`, `_.forOwn`, `_.isPlainObject`, and `_.zipObject` assignments + (function() { + var snippet = getMethodAssignments(source), + modified = snippet; - // unexpose `lodash.support` - source = source.replace(/lodash\.support *= */, ''); - - // remove `thisArg` from unexposed `forIn` and `forOwn` - _.each(['forIn', 'forOwn'], function(methodName) { - if (!useLodashMethod(methodName)) { - source = source.replace(matchFunction(source, methodName), function(match) { - return match - .replace(/(callback), *thisArg/g, '$1') - .replace(/^ *callback *=.+\n/m, ''); + if (!useLodashMethod('assign')) { + modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.assign *=.+\n/m, ''); + } + if (!useLodashMethod('createCallback')) { + modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.createCallback *=.+\n/m, ''); + } + if (!useLodashMethod('forIn')) { + modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.forIn *=.+\n/m, ''); + } + if (!useLodashMethod('forOwn')) { + modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.forOwn *=.+\n/m, ''); + } + if (!useLodashMethod('isPlainObject')) { + modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.isPlainObject *=.+\n/m, ''); + } + if (!useLodashMethod('zipObject')) { + modified = modified.replace(/^(?: *\/\/.*\s*)* *lodash\.zipObject *=.+\n/m, ''); + } + source = source.replace(snippet, function() { + return modified; }); - } - }); - - // remove chainability from `each` and `_.forEach` - if (!useLodashMethod('forEach')) { - _.each(['each', 'forEach'], function(methodName) { - source = source.replace(matchFunction(source, methodName), function(match) { - return match - .replace(/\n *return .+?([};\s]+)$/, '$1') - .replace(/\b(return) +result\b/, '$1') - }); - }); + }()); } - - // unexpose "exit early" feature of `each`, `_.forEach`, `_.forIn`, and `_.forOwn` - _.each(['each', 'forEach', 'forIn', 'forOwn'], function(methodName) { - if (methodName == 'each' || !useLodashMethod(methodName)) { - source = source.replace(matchFunction(source, methodName), function(match) { - return match.replace(/=== *false\)/g, '=== indicatorObject)'); - }); - } - }); - - // modify `_.every`, `_.find`, `_.isEqual`, and `_.some` to use the private `indicatorObject` - _.each(['every', 'isEqual'], function(methodName) { - source = source.replace(matchFunction(source, methodName), function(match) { - return match.replace(/\(result *= *(.+?)\);/g, '!(result = $1) && indicatorObject;'); - }); - }); - - source = source.replace(matchFunction(source, 'find'), function(match) { - return match.replace(/return false/, 'return indicatorObject'); - }); - - source = source.replace(matchFunction(source, 'some'), function(match) { - return match.replace(/!\(result *= *(.+?)\);/, '(result = $1) && indicatorObject;'); - }); } - if (!(isMobile || isUnderscore)) { + else { source = removeFromCreateIterator(source, 'support'); // inline `iteratorTemplate` template @@ -2756,17 +2739,52 @@ /*------------------------------------------------------------------------*/ + // modify/remove references to removed methods/variables if (!isTemplate) { - // modify/remove references to removed methods/variables + if (isRemoved(source, 'clone')) { + source = removeVar(source, 'cloneableClasses'); + source = removeVar(source, 'ctorByClass'); + } + if (isRemoved(source, 'clone', 'isEqual', 'isPlainObject')) { + source = removeSupportNodeClass(source); + } + if (isRemoved(source, 'createIterator', 'bind', 'keys')) { + source = removeSupportProp(source, 'fastBind'); + source = removeVar(source, 'isV8'); + source = removeVar(source, 'nativeBind'); + } + if (isRemoved(source, 'createIterator', 'keys')) { + source = removeVar(source, 'nativeKeys'); + source = removeKeysOptimization(source); + source = removeSupportNonEnumArgs(source); + } + if (isRemoved(source, 'defer')) { + source = removeSetImmediate(source); + } if (isRemoved(source, 'invert')) { source = replaceVar(source, 'htmlUnescapes', "{'&':'&','<':'<','>':'>','"':'\"',''':\"'\"}"); } if (isRemoved(source, 'isArguments')) { + source = removeIsArgumentsFallback(source); source = replaceSupportProp(source, 'argsClass', 'true'); } + if (isRemoved(source, 'isArguments', 'isEmpty')) { + source = removeSupportArgsClass(source); + } + if (isRemoved(source, 'isArray')) { + source = removeVar(source, 'nativeIsArray'); + } if (isRemoved(source, 'isFunction')) { source = removeIsFunctionFallback(source); } + if (isRemoved(source, 'isPlainObject')) { + source = removeFunction(source, 'shimIsPlainObject'); + source = removeVar(source, 'getPrototypeOf'); + source = removeSupportOwnLast(source); + } + if (isRemoved(source, 'keys')) { + source = removeFunction(source, 'shimKeys'); + } if (isRemoved(source, 'mixin')) { // inline `_.mixin` call to ensure proper chaining behavior source = source.replace(/^( *)mixin\(lodash\).+/m, function(match, indent) { @@ -2788,6 +2806,14 @@ ].join('\n' + indent); }); } + if (isRemoved(source, 'parseInt')) { + source = removeVar(source, 'nativeParseInt'); + source = removeVar(source, 'reLeadingZeros'); + } + if (isRemoved(source, 'template')) { + // remove `templateSettings` assignment + source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *lodash\.templateSettings[\s\S]+?};\n/, ''); + } if (isRemoved(source, 'value')) { source = removeFunction(source, 'wrapperToString'); source = removeFunction(source, 'wrapperValueOf'); @@ -2816,39 +2842,6 @@ .replace(/(?:\s*\/\/.*)*\n( *)(?:each|forEach)\(\['[\s\S]+?\n\1}.+/g, '') .replace(/(?:\s*\/\/.*)*\n *lodash\.prototype.+/g, ''); } - // remove functions, variables, and snippets that the minifier may miss - if (isRemoved(source, 'clone')) { - source = removeVar(source, 'cloneableClasses'); - source = removeVar(source, 'ctorByClass'); - } - if (isRemoved(source, 'defer')) { - source = removeSetImmediate(source); - } - if (isRemoved(source, 'isArray')) { - source = removeVar(source, 'nativeIsArray'); - } - if (isRemoved(source, 'isPlainObject')) { - source = removeFunction(source, 'shimIsPlainObject'); - source = removeVar(source, 'getPrototypeOf'); - source = removeSupportOwnLast(source); - } - if (isRemoved(source, 'keys')) { - source = removeFunction(source, 'shimKeys'); - } - if (isRemoved(source, 'parseInt')) { - source = removeVar(source, 'nativeParseInt'); - source = removeVar(source, 'reLeadingZeros'); - } - if (isRemoved(source, 'template')) { - // remove `templateSettings` assignment - source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *lodash\.templateSettings[\s\S]+?};\n/, ''); - } - if (isRemoved(source, 'isArguments', 'isEmpty')) { - source = removeSupportArgsClass(source); - } - if (isRemoved(source, 'clone', 'isEqual', 'isPlainObject')) { - source = removeSupportNodeClass(source); - } if (!/\beach\(/.test(source)) { source = source.replace(matchFunction(source, 'each'), ''); } @@ -2862,16 +2855,6 @@ source = removeSupportNonEnumShadows(source); source = removeSupportEnumPrototypes(source); } - if (isRemoved(source, 'createIterator', 'bind', 'keys')) { - source = removeSupportProp(source, 'fastBind'); - source = removeVar(source, 'isV8'); - source = removeVar(source, 'nativeBind'); - } - if (isRemoved(source, 'createIterator', 'keys')) { - source = removeVar(source, 'nativeKeys'); - source = removeKeysOptimization(source); - source = removeSupportNonEnumArgs(source); - } if (!/support\.(?:enumPrototypes|nonEnumShadows|ownLast)\b/.test(source)) { // remove code used to resolve unneeded `support` properties source = source.replace(/^ *\(function[\s\S]+?\n(( *)var ctor *= *function[\s\S]+?(?:\n *for.+)+\n)([\s\S]+?)}\(1\)\);\n/m, function(match, setup, indent, body) { diff --git a/dist/lodash.js b/dist/lodash.js index 4cb22491c..eb8e8a60b 100644 --- a/dist/lodash.js +++ b/dist/lodash.js @@ -349,92 +349,6 @@ /*--------------------------------------------------------------------------*/ - /** - * The template used to create iterator functions. - * - * @private - * @param {Object} data The data object used to populate the text. - * @returns {String} Returns the interpolated text. - */ - var iteratorTemplate = function(obj) { - - var __p = 'var index, iterable = ' + - (obj.firstArg) + - ', result = ' + - (obj.init) + - ';\nif (!iterable) return result;\n' + - (obj.top) + - ';\n'; - if (obj.arrays) { - __p += 'var length = iterable.length; index = -1;\nif (' + - (obj.arrays) + - ') {\n while (++index < length) {\n ' + - (obj.loop) + - '\n }\n}\nelse { '; - } - - if (obj.useHas && obj.useKeys) { - __p += '\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] ? keys(iterable) : [],\n length = ownProps.length;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n ' + - (obj.loop) + - '\n } '; - } else { - __p += '\n for (index in iterable) {'; - if (obj.useHas) { - __p += '\n if ('; - if (obj.useHas) { - __p += 'hasOwnProperty.call(iterable, index)'; - } - __p += ') { '; - } - __p += - (obj.loop) + - '; '; - if (obj.useHas) { - __p += '\n }'; - } - __p += '\n } '; - } - - if (obj.arrays) { - __p += '\n}'; - } - __p += - (obj.bottom) + - ';\nreturn result'; - - return __p - }; - - /** Reusable iterator options for `assign` and `defaults` */ - var defaultsIteratorOptions = { - 'args': 'object, source, guard', - 'top': - 'var args = arguments,\n' + - ' argsIndex = 0,\n' + - " argsLength = typeof guard == 'number' ? 2 : args.length;\n" + - 'while (++argsIndex < argsLength) {\n' + - ' iterable = args[argsIndex];\n' + - ' if (iterable && objectTypes[typeof iterable]) {', - 'loop': "if (typeof result[index] == 'undefined') result[index] = iterable[index]", - 'bottom': ' }\n}' - }; - - /** Reusable iterator options shared by `each`, `forIn`, and `forOwn` */ - var eachIteratorOptions = { - 'args': 'collection, callback, thisArg', - 'top': "callback = callback && typeof thisArg == 'undefined' ? callback : lodash.createCallback(callback, thisArg)", - 'arrays': false, - 'loop': 'if (callback(iterable[index], index, collection) === false) return result' - }; - - /** Reusable iterator options for `forIn` and `forOwn` */ - var forOwnIteratorOptions = { - 'top': 'if (!objectTypes[typeof iterable]) return result;\n' + eachIteratorOptions.top, - 'arrays': false - }; - - /*--------------------------------------------------------------------------*/ - /** * Creates a function optimized to search large arrays for a given `value`, * starting at `fromIndex`, using strict equality for comparisons, i.e. `===`. @@ -567,54 +481,6 @@ return bound; } - /** - * Creates compiled iteration functions. - * - * @private - * @param {Object} [options1, options2, ...] The compile options object(s). - * arrays - A string of code to determine if the iterable is an array or array-like. - * useHas - A boolean to specify using `hasOwnProperty` checks in the object loop. - * useKeys - A boolean to specify using `_.keys` for own property iteration. - * args - A string of comma separated arguments the iteration function will accept. - * top - A string of code to execute before the iteration branches. - * loop - A string of code to execute in the object loop. - * bottom - A string of code to execute after the iteration branches. - * @returns {Function} Returns the compiled function. - */ - function createIterator() { - var data = { - // iterator options - 'arrays': 'isArray(iterable)', - 'bottom': '', - 'init': 'iterable', - 'loop': '', - 'top': '', - 'useHas': true, - 'useKeys': !!keys - }; - - // merge options into a template data object - for (var object, index = 0; object = arguments[index]; index++) { - for (var key in object) { - data[key] = object[key]; - } - } - var args = data.args; - data.firstArg = /^[^,]+/.exec(args)[0]; - - // create the function factory - var factory = Function( - 'hasOwnProperty, isArguments, isArray, isString, keys, ' + - 'lodash, objectTypes', - 'return function(' + args + ') {\n' + iteratorTemplate(data) + '\n}' - ); - // return the compiled function - return factory( - hasOwnProperty, isArguments, isArray, isString, keys, - lodash, objectTypes - ); - } - /** * Used by `template` to escape characters for inclusion in compiled * string literals. @@ -783,13 +649,18 @@ * @param {Object} object The object to inspect. * @returns {Array} Returns a new array of property names. */ - var shimKeys = createIterator({ - 'args': 'object', - 'init': '[]', - 'top': 'if (!(objectTypes[typeof object])) return result', - 'loop': 'result.push(index)', - 'arrays': false - }); + var shimKeys = function (object) { + var index, iterable = object, result = []; + if (!iterable) return result; + if (!(objectTypes[typeof object])) return result; + + for (index in iterable) { + if (hasOwnProperty.call(iterable, index)) { + result.push(index); + } + } + return result + }; /** * Creates an array composed of the own enumerable property names of `object`. @@ -862,18 +733,40 @@ * defaults(food, { 'name': 'banana', 'type': 'fruit' }); * // => { 'name': 'apple', 'type': 'fruit' } */ - var assign = createIterator(defaultsIteratorOptions, { - 'top': - defaultsIteratorOptions.top.replace(';', - ';\n' + - "if (argsLength > 3 && typeof args[argsLength - 2] == 'function') {\n" + - ' var callback = lodash.createCallback(args[--argsLength - 1], args[argsLength--], 2);\n' + - "} else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') {\n" + - ' callback = args[--argsLength];\n' + - '}' - ), - 'loop': 'result[index] = callback ? callback(result[index], iterable[index]) : iterable[index]' - }); + var assign = function (object, source, guard) { + var index, iterable = object, result = iterable; + if (!iterable) return result; + var args = arguments, + argsIndex = 0, + argsLength = typeof guard == 'number' ? 2 : args.length; + if (argsLength > 3 && typeof args[argsLength - 2] == 'function') { + var callback = lodash.createCallback(args[--argsLength - 1], args[argsLength--], 2); + } else if (argsLength > 2 && typeof args[argsLength - 1] == 'function') { + callback = args[--argsLength]; + } + while (++argsIndex < argsLength) { + iterable = args[argsIndex]; + if (iterable && objectTypes[typeof iterable]) {; + var length = iterable.length; index = -1; + if (isArray(iterable)) { + while (++index < length) { + result[index] = callback ? callback(result[index], iterable[index]) : iterable[index] + } + } + else { + var ownIndex = -1, + ownProps = objectTypes[typeof iterable] ? keys(iterable) : [], + length = ownProps.length; + + while (++ownIndex < length) { + index = ownProps[ownIndex]; + result[index] = callback ? callback(result[index], iterable[index]) : iterable[index] + } + } + } + }; + return result + }; /** * Creates a clone of `value`. If `deep` is `true`, nested objects will also @@ -1066,7 +959,35 @@ * _.defaults(food, { 'name': 'banana', 'type': 'fruit' }); * // => { 'name': 'apple', 'type': 'fruit' } */ - var defaults = createIterator(defaultsIteratorOptions); + var defaults = function (object, source, guard) { + var index, iterable = object, result = iterable; + if (!iterable) return result; + var args = arguments, + argsIndex = 0, + argsLength = typeof guard == 'number' ? 2 : args.length; + while (++argsIndex < argsLength) { + iterable = args[argsIndex]; + if (iterable && objectTypes[typeof iterable]) {; + var length = iterable.length; index = -1; + if (isArray(iterable)) { + while (++index < length) { + if (typeof result[index] == 'undefined') result[index] = iterable[index] + } + } + else { + var ownIndex = -1, + ownProps = objectTypes[typeof iterable] ? keys(iterable) : [], + length = ownProps.length; + + while (++ownIndex < length) { + index = ownProps[ownIndex]; + if (typeof result[index] == 'undefined') result[index] = iterable[index] + } + } + } + }; + return result + }; /** * This method is similar to `_.find`, except that it returns the key of the @@ -1129,9 +1050,17 @@ * }); * // => alerts 'name' and 'bark' (order is not guaranteed) */ - var forIn = createIterator(eachIteratorOptions, forOwnIteratorOptions, { - 'useHas': false - }); + var forIn = function (collection, callback, thisArg) { + var index, iterable = collection, result = iterable; + if (!iterable) return result; + if (!objectTypes[typeof iterable]) return result; + callback = callback && typeof thisArg == 'undefined' ? callback : lodash.createCallback(callback, thisArg); + + for (index in iterable) { + if (callback(iterable[index], index, collection) === false) return result; + } + return result + }; /** * Iterates over an object's own enumerable properties, executing the `callback` @@ -1154,7 +1083,22 @@ * }); * // => alerts '0', '1', and 'length' (order is not guaranteed) */ - var forOwn = createIterator(eachIteratorOptions, forOwnIteratorOptions); + var forOwn = function (collection, callback, thisArg) { + var index, iterable = collection, result = iterable; + if (!iterable) return result; + if (!objectTypes[typeof iterable]) return result; + callback = callback && typeof thisArg == 'undefined' ? callback : lodash.createCallback(callback, thisArg); + + var ownIndex = -1, + ownProps = objectTypes[typeof iterable] ? keys(iterable) : [], + length = ownProps.length; + + while (++ownIndex < length) { + index = ownProps[ownIndex]; + if (callback(iterable[index], index, collection) === false) return result + } + return result + }; /** * Creates a sorted array of all enumerable properties, own and inherited, diff --git a/dist/lodash.min.js b/dist/lodash.min.js index b18ea58de..8a1387e81 100644 --- a/dist/lodash.min.js +++ b/dist/lodash.min.js @@ -4,40 +4,41 @@ * Build: `lodash modern -o ./dist/lodash.js` * Underscore.js 1.4.4 underscorejs.org/LICENSE */ -;(function(n){function t(r){function a(n){return n&&typeof n=="object"&&!ge(n)&&Ht.call(n,"__wrapped__")?n:new K(n)}function B(n){var t=n.length,e=t>=c;if(e)for(var r={},u=-1;++ut||typeof n=="undefined")return 1;if(ne?0:e);++re?ee(0,u+e):e)||0,typeof u=="number"?a=-1<(nt(n)?n.indexOf(t,e):mt(n,t,e)):we(n,function(n){return++ru&&(u=o)}}else t=!t&&nt(n)?F:a.createCallback(t,e),ot(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function lt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Nt(r);++earguments.length;t=a.createCallback(t,r,4);var i=-1,o=n.length;if(typeof o=="number")for(u&&(e=n[++i]);++iarguments.length;if(typeof u!="number")var o=ye(n),u=o.length;return t=a.createCallback(t,r,4),ot(n,function(r,a,f){a=o?o[--u]:--u,e=i?(i=!1,n[a]):t(e,n[a],a,f)}),e}function vt(n,t,e){var r;t=a.createCallback(t,e),e=-1;var u=n?n.length:0; -if(typeof u=="number")for(;++ee?ee(0,u+e):e||0)-1;else if(e)return r=dt(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])=c;if(p)var s={};for(null!=e&&(l=[],e=a.createCallback(e,r));++umt(l,v))&&((e||p)&&l.push(v),o.push(r))}return o}function kt(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:y,variable:"",imports:{_:a}};var pe={a:"q,w,g",h:"var a=arguments,b=0,c=typeof g=='number'?2:a.length;while(++b":">",'"':""","'":"'"},be=Q(me),de=D(pe,{h:pe.h.replace(";",";if(c>3&&typeof a[c-2]=='function'){var d=p.createCallback(a[--c-1],a[c--],2);}else if(c>2&&typeof a[c-1]=='function'){d=a[--c];}"),f:"u[i]=d?d(u[i],m[i]):m[i]"}),_e=D(pe),ke=D(se,ve,{i:!1}),we=D(se,ve),je=function(n){if(!n||Wt.call(n)!=N)return!1; -var t=n.valueOf,e=typeof t=="function"&&(e=Gt(t))&&Gt(e);return e?n==e||Gt(n)==e:U(n)};fe&&u&&typeof Lt=="function"&&(jt=wt(Lt,r));var Ce=8==ue("08")?ue:function(n,t){return ue(nt(n)?n.replace(m,""):n,t||0)};return a.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},a.assign=de,a.at=function(n){for(var t=-1,e=Ut.apply(Tt,ie.call(arguments,1)),r=e.length,u=Nt(r);++t=c,o=[],l=o;n:for(;++umt(l,p)){i&&l.push(p);for(var v=e;--v;)if(!(r[v]||(r[v]=B(t[v])))(p))continue n;o.push(p)}}return o},a.invert=Q,a.invoke=function(n,t){var e=ie.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,i=Nt(typeof a=="number"?a:0); -return ot(n,function(n){i[++r]=(u?t:n[t]).apply(n,e)}),i},a.keys=ye,a.map=ft,a.max=ct,a.memoize=function(n,t){var e={};return function(){var r=f+(t?t.apply(this,arguments):arguments[0]);return Ht.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},a.merge=tt,a.min=function(n,t,e){var r=1/0,u=r;if(!t&&ge(n)){e=-1;for(var i=n.length;++emt(i,e))&&(u[e]=n)}),u},a.once=function(n){var t,e;return function(){return t?e:(t=!0,e=n.apply(this,arguments),n=null,e)}},a.pairs=function(n){for(var t=-1,e=ye(n),r=e.length,u=Nt(r);++te?ee(0,r+e):re(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},a.mixin=xt,a.noConflict=function(){return r._=zt,this -},a.parseInt=Ce,a.random=function(n,t){return null==n&&null==t&&(t=1),n=+n||0,null==t&&(t=n,n=0),n+Vt(ae()*((+t||0)-n+1))},a.reduce=pt,a.reduceRight=st,a.result=function(n,t){var r=n?n[t]:e;return X(r)?n[t]():r},a.runInContext=t,a.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:ye(n).length},a.some=vt,a.sortedIndex=dt,a.template=function(n,t,r){var u=a.templateSettings;n||(n=""),r=_e({},r,u);var i,o=_e({},r.imports,u.imports),u=ye(o),o=et(o),f=0,c=r.interpolate||b,v="__p+='",c=Bt((r.escape||b).source+"|"+c.source+"|"+(c===y?g:b).source+"|"+(r.evaluate||b).source+"|$","g"); -n.replace(c,function(t,e,r,u,a,o){return r||(r=u),v+=n.slice(f,o).replace(_,z),e&&(v+="'+__e("+e+")+'"),a&&(i=!0,v+="';"+a+";__p+='"),r&&(v+="'+((__t=("+r+"))==null?'':__t)+'"),f=o+t.length,t}),v+="';\n",c=r=r.variable,c||(r="obj",v="with("+r+"){"+v+"}"),v=(i?v.replace(l,""):v).replace(p,"$1").replace(s,"$1;"),v="function("+r+"){"+(c?"":r+"||("+r+"={});")+"var __t,__p='',__e=_.escape"+(i?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+v+"return __p}";try{var h=St(u,"return "+v).apply(e,o) -}catch(m){throw m.source=v,m}return t?h(t):(h.source=v,h)},a.unescape=function(n){return null==n?"":Ft(n).replace(v,G)},a.uniqueId=function(n){var t=++i;return Ft(null==n?"":n)+t},a.all=ut,a.any=vt,a.detect=it,a.foldl=pt,a.foldr=st,a.include=rt,a.inject=pt,we(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(){var t=[this.__wrapped__];return Jt.apply(t,arguments),n.apply(a,t)})}),a.first=ht,a.last=function(n,t,e){if(n){var r=0,u=n.length;if(typeof t!="number"&&null!=t){var i=u;for(t=a.createCallback(t,e);i--&&t(n[i],i,n);)r++ -}else if(r=t,null==r||e)return n[u-1];return V(n,ee(0,u-r))}},a.take=ht,a.head=ht,we(a,function(n,t){a.prototype[t]||(a.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e);return null==t||e&&typeof t!="function"?r:new K(r)})}),a.VERSION="1.1.1",a.prototype.toString=function(){return Ft(this.__wrapped__)},a.prototype.value=Ot,a.prototype.valueOf=Ot,ot(["join","pop","shift"],function(n){var t=Tt[n];a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),ot(["push","reverse","sort","unshift"],function(n){var t=Tt[n]; -a.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),ot(["concat","slice","splice"],function(n){var t=Tt[n];a.prototype[n]=function(){return new K(t.apply(this.__wrapped__,arguments))}}),a}var e,r=typeof exports=="object"&&exports,u=typeof module=="object"&&module&&module.exports==r&&module,a=typeof global=="object"&&global;(a.global===a||a.window===a)&&(n=a);var i=0,o={},f=+new Date+"",c=200,l=/\b__p\+='';/g,p=/\b(__p\+=)''\+/g,s=/(__e\(.*?\)|\b__t\))\+'';/g,v=/&(?:amp|lt|gt|quot|#39);/g,g=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,h=/\w*$/,y=/<%=([\s\S]+?)%>/g,m=/^0+(?=.$)/,b=/($^)/,d=/[&<>"']/g,_=/['\n\r\t\u2028\u2029\\]/g,k="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),w="[object Arguments]",j="[object Array]",C="[object Boolean]",x="[object Date]",O="[object Number]",N="[object Object]",E="[object RegExp]",I="[object String]",S={"[object Function]":!1}; -S[w]=S[j]=S[C]=S[x]=S[O]=S[N]=S[E]=S[I]=!0;var A={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1},$={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},q=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=q,define(function(){return q})):r&&!r.nodeType?u?(u.exports=q)._=q:r._=q:n._=q})(this); \ No newline at end of file +;(function(n){function t(o){function f(n){if(!n||re.call(n)!=S)return a;var t=n.valueOf,e=typeof t=="function"&&(e=Yt(t))&&Yt(e);return e?n==e||Yt(n)==e:X(n)}function q(n,t,e){if(!n||!F[typeof n])return n;t=t&&typeof e=="undefined"?t:M.createCallback(t,e);for(var r=-1,u=F[typeof n]?me(n):[],o=u.length;++r=s;if(e)for(var r={},u=-1;++ut||typeof n=="undefined")return 1;if(ne?0:e);++re?ce(0,u+e):e)||0,typeof u=="number"?o=-1<(it(n)?n.indexOf(t,e):jt(n,t,e)):q(n,function(n){return++ru&&(u=o)}}else t=!t&&it(n)?V:M.createCallback(t,e),gt(n,function(n,e,a){e=t(n,e,a),e>r&&(r=e,u=n)});return u}function mt(n,t){var e=-1,r=n?n.length:0;if(typeof r=="number")for(var u=Ft(r);++earguments.length;t=M.createCallback(t,r,4);var o=-1,i=n.length;if(typeof i=="number")for(u&&(e=n[++o]);++oarguments.length;if(typeof u!="number")var i=me(n),u=i.length;return t=M.createCallback(t,r,4),gt(n,function(r,f,c){f=i?i[--u]:--u,e=o?(o=a,n[f]):t(e,n[f],f,c)}),e}function _t(n,t,e){var r;t=M.createCallback(t,e),e=-1;var u=n?n.length:0; +if(typeof u=="number")for(;++ee?ce(0,u+e):e||0)-1;else if(e)return r=Ot(n,t),n[r]===t?r:-1;for(;++r>>1,e(n[r])=s;if(l)var v={};for(e!=u&&(c=[],e=M.createCallback(e,r));++ojt(c,g))&&((e||l)&&c.push(g),f.push(r))}return f}function Et(n,t){for(var e=-1,r=n?n.length:0,u={};++e/g,evaluate:/<%([\s\S]+?)%>/g,interpolate:d,variable:"",imports:{_:M}},Q.prototype=M.prototype;var he=ae||function(n){return n instanceof Ft||re.call(n)==O},me=fe?function(n){return at(n)?fe(n):[]}:K,be={"&":"&","<":"<",">":">",'"':""","'":"'"},de=et(be);return Dt&&i&&typeof te=="function"&&(St=It(te,o)),Rt=8==pe("08")?pe:function(n,t){return pe(it(n)?n.replace(_,""):n,t||0) +},M.after=function(n,t){return 1>n?t():function(){return 1>--n?t.apply(this,arguments):void 0}},M.assign=P,M.at=function(n){for(var t=-1,e=Wt.apply(Vt,ve.call(arguments,1)),r=e.length,u=Ft(r);++t=s,i=[],f=i; +n:for(;++ujt(f,c)){o&&f.push(c);for(var v=e;--v;)if(!(r[v]||(r[v]=U(t[v])))(c))continue n;i.push(c)}}return i},M.invert=et,M.invoke=function(n,t){var e=ve.call(arguments,2),r=-1,u=typeof t=="function",a=n?n.length:0,o=Ft(typeof a=="number"?a:0);return gt(n,function(n){o[++r]=(u?t:n[t]).apply(n,e)}),o},M.keys=me,M.map=yt,M.max=ht,M.memoize=function(n,t){var e={};return function(){var r=p+(t?t.apply(this,arguments):arguments[0]); +return Zt.call(e,r)?e[r]:e[r]=n.apply(this,arguments)}},M.merge=ft,M.min=function(n,t,e){var r=1/0,u=r;if(!t&&he(n)){e=-1;for(var a=n.length;++ejt(a,e))&&(u[e]=n)}),u},M.once=function(n){var t,e;return function(){return t?e:(t=r,e=n.apply(this,arguments),n=u,e) +}},M.pairs=function(n){for(var t=-1,e=me(n),r=e.length,u=Ft(r);++te?ce(0,r+e):le(e,r-1))+1);r--;)if(n[r]===t)return r;return-1},M.mixin=$t,M.noConflict=function(){return o._=Ht,this},M.parseInt=Rt,M.random=function(n,t){return n==u&&t==u&&(t=1),n=+n||0,t==u&&(t=n,n=0),n+Xt(se()*((+t||0)-n+1)) +},M.reduce=bt,M.reduceRight=dt,M.result=function(n,t){var r=n?n[t]:e;return ut(r)?n[t]():r},M.runInContext=t,M.size=function(n){var t=n?n.length:0;return typeof t=="number"?t:me(n).length},M.some=_t,M.sortedIndex=Ot,M.template=function(n,t,u){var a=M.templateSettings;n||(n=""),u=z({},u,a);var o,i=z({},u.imports,a.imports),a=me(i),i=ct(i),f=0,c=u.interpolate||k,l="__p+='",c=Kt((u.escape||k).source+"|"+c.source+"|"+(c===d?m:k).source+"|"+(u.evaluate||k).source+"|$","g");n.replace(c,function(t,e,u,a,i,c){return u||(u=a),l+=n.slice(f,c).replace(C,J),e&&(l+="'+__e("+e+")+'"),i&&(o=r,l+="';"+i+";__p+='"),u&&(l+="'+((__t=("+u+"))==null?'':__t)+'"),f=c+t.length,t +}),l+="';\n",c=u=u.variable,c||(u="obj",l="with("+u+"){"+l+"}"),l=(o?l.replace(v,""):l).replace(g,"$1").replace(y,"$1;"),l="function("+u+"){"+(c?"":u+"||("+u+"={});")+"var __t,__p='',__e=_.escape"+(o?",__j=Array.prototype.join;function print(){__p+=__j.call(arguments,'')}":";")+l+"return __p}";try{var p=qt(a,"return "+l).apply(e,i)}catch(s){throw s.source=l,s}return t?p(t):(p.source=l,p)},M.unescape=function(n){return n==u?"":Mt(n).replace(h,Z)},M.uniqueId=function(n){var t=++c;return Mt(n==u?"":n)+t +},M.all=pt,M.any=_t,M.detect=vt,M.foldl=bt,M.foldr=dt,M.include=lt,M.inject=bt,q(M,function(n,t){M.prototype[t]||(M.prototype[t]=function(){var t=[this.__wrapped__];return ne.apply(t,arguments),n.apply(M,t)})}),M.first=wt,M.last=function(n,t,e){if(n){var r=0,a=n.length;if(typeof t!="number"&&t!=u){var o=a;for(t=M.createCallback(t,e);o--&&t(n[o],o,n);)r++}else if(r=t,r==u||e)return n[a-1];return Y(n,ce(0,a-r))}},M.take=wt,M.head=wt,q(M,function(n,t){M.prototype[t]||(M.prototype[t]=function(t,e){var r=n(this.__wrapped__,t,e); +return t==u||e&&typeof t!="function"?r:new Q(r)})}),M.VERSION="1.1.1",M.prototype.toString=function(){return Mt(this.__wrapped__)},M.prototype.value=Bt,M.prototype.valueOf=Bt,gt(["join","pop","shift"],function(n){var t=Vt[n];M.prototype[n]=function(){return t.apply(this.__wrapped__,arguments)}}),gt(["push","reverse","sort","unshift"],function(n){var t=Vt[n];M.prototype[n]=function(){return t.apply(this.__wrapped__,arguments),this}}),gt(["concat","slice","splice"],function(n){var t=Vt[n];M.prototype[n]=function(){return new Q(t.apply(this.__wrapped__,arguments)) +}}),M}var e,r=!0,u=null,a=!1,o=typeof exports=="object"&&exports,i=typeof module=="object"&&module&&module.exports==o&&module,f=typeof global=="object"&&global;(f.global===f||f.window===f)&&(n=f);var c=0,l={},p=+new Date+"",s=200,v=/\b__p\+='';/g,g=/\b(__p\+=)''\+/g,y=/(__e\(.*?\)|\b__t\))\+'';/g,h=/&(?:amp|lt|gt|quot|#39);/g,m=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,b=/\w*$/,d=/<%=([\s\S]+?)%>/g,_=/^0+(?=.$)/,k=/($^)/,w=/[&<>"']/g,C=/['\n\r\t\u2028\u2029\\]/g,j="Array Boolean Date Function Math Number Object RegExp String _ attachEvent clearTimeout isFinite isNaN parseInt setImmediate setTimeout".split(" "),x="[object Arguments]",O="[object Array]",N="[object Boolean]",E="[object Date]",I="[object Number]",S="[object Object]",A="[object RegExp]",$="[object String]",B={"[object Function]":a}; +B[x]=B[O]=B[N]=B[E]=B[I]=B[S]=B[A]=B[$]=r;var F={"boolean":a,"function":r,object:r,number:a,string:a,undefined:a},R={"\\":"\\","'":"'","\n":"n","\r":"r"," ":"t","\u2028":"u2028","\u2029":"u2029"},T=t();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(n._=T,define(function(){return T})):o&&!o.nodeType?i?(i.exports=T)._=T:o._=T:n._=T})(this); \ No newline at end of file