/node_modules/bower/node_modules/inquirer/node_modules/lodash/build.js
JavaScript | 3099 lines | 2423 code | 163 blank | 513 comment | 178 complexity | 600c0be1c5d66ab3cb12d17b46f9a787 MD5 | raw file
Possible License(s): MIT, JSON, BSD-2-Clause, Unlicense, GPL-2.0, WTFPL, LGPL-3.0, Apache-2.0, 0BSD, BSD-3-Clause, CC-BY-SA-3.0
Large files files are truncated, but you can click here to view the full file
- #!/usr/bin/env node
- ;(function() {
- 'use strict';
- /** Load Node.js modules */
- var vm = require('vm');
- /** Load other modules */
- var _ = require('./lodash.js'),
- minify = require('./build/minify.js'),
- util = require('./build/util.js');
- /** Module shortcuts */
- var fs = util.fs,
- path = util.path;
- /** The current working directory */
- var cwd = process.cwd();
- /** Used for array method references */
- var arrayRef = [];
- /** Shortcut used to push arrays of values to an array */
- var push = arrayRef.push;
- /** Used to detect the Node.js executable in command-line arguments */
- var reNode = RegExp('(?:^|' + path.sepEscaped + ')node(?:\\.exe)?$');
- /** Shortcut used to convert array-like objects to arrays */
- var slice = arrayRef.slice;
- /** Shortcut to the `stdout` object */
- var stdout = process.stdout;
- /** Used to associate aliases with their real names */
- var aliasToRealMap = {
- 'all': 'every',
- 'any': 'some',
- 'collect': 'map',
- 'detect': 'find',
- 'drop': 'rest',
- 'each': 'forEach',
- 'extend': 'assign',
- 'foldl': 'reduce',
- 'foldr': 'reduceRight',
- 'head': 'first',
- 'include': 'contains',
- 'inject': 'reduce',
- 'methods': 'functions',
- 'object': 'zipObject',
- 'select': 'filter',
- 'tail': 'rest',
- 'take': 'first',
- 'unique': 'uniq'
- };
- /** Used to associate real names with their aliases */
- var realToAliasMap = {
- 'assign': ['extend'],
- 'contains': ['include'],
- 'every': ['all'],
- 'filter': ['select'],
- 'find': ['detect'],
- 'first': ['head', 'take'],
- 'forEach': ['each'],
- 'functions': ['methods'],
- 'map': ['collect'],
- 'reduce': ['foldl', 'inject'],
- 'reduceRight': ['foldr'],
- 'rest': ['drop', 'tail'],
- 'some': ['any'],
- 'uniq': ['unique'],
- 'zipObject': ['object']
- };
- /** Used to track function dependencies */
- var dependencyMap = {
- 'after': [],
- 'assign': ['isArray', 'keys'],
- 'at': ['isString'],
- 'bind': ['isFunction', 'isObject'],
- 'bindAll': ['bind', 'functions'],
- 'bindKey': ['isFunction', 'isObject'],
- 'clone': ['assign', 'forEach', 'forOwn', 'isArray', 'isObject'],
- 'cloneDeep': ['clone'],
- 'compact': [],
- 'compose': [],
- 'contains': ['indexOf', 'isString'],
- 'countBy': ['createCallback', 'forEach'],
- 'createCallback': ['identity', 'isEqual', 'keys'],
- 'debounce': [],
- 'defaults': ['isArray', 'keys'],
- 'defer': ['bind'],
- 'delay': [],
- 'difference': ['indexOf'],
- 'escape': [],
- 'every': ['createCallback', 'isArray'],
- 'filter': ['createCallback', 'isArray'],
- 'find': ['createCallback', 'forEach', 'isArray'],
- 'findIndex': ['createCallback'],
- 'findKey': ['createCallback'],
- 'first': [],
- 'flatten': ['createCallback', 'isArray'],
- 'forEach': ['createCallback', 'isArguments', 'isArray', 'isString', 'keys'],
- 'forIn': ['createCallback', 'isArguments'],
- 'forOwn': ['createCallback', 'isArguments', 'keys'],
- 'functions': ['forIn', 'isFunction'],
- 'groupBy': ['createCallback', 'forEach'],
- 'has': [],
- 'identity': [],
- 'indexOf': ['sortedIndex'],
- 'initial': [],
- 'intersection': ['indexOf'],
- 'invert': ['keys'],
- 'invoke': ['forEach'],
- 'isArguments': [],
- 'isArray': [],
- 'isBoolean': [],
- 'isDate': [],
- 'isElement': [],
- 'isEmpty': ['forOwn', 'isArguments', 'isFunction'],
- 'isEqual': ['forIn', 'isArguments', 'isFunction'],
- 'isFinite': [],
- 'isFunction': [],
- 'isNaN': ['isNumber'],
- 'isNull': [],
- 'isNumber': [],
- 'isObject': [],
- 'isPlainObject': ['forIn', 'isArguments', 'isFunction'],
- 'isRegExp': [],
- 'isString': [],
- 'isUndefined': [],
- 'keys': ['forOwn', 'isArguments', 'isObject'],
- 'last': [],
- 'lastIndexOf': [],
- 'map': ['createCallback', 'isArray'],
- 'max': ['createCallback', 'isArray', 'isString'],
- 'memoize': [],
- 'merge': ['forEach', 'forOwn', 'isArray', 'isObject', 'isPlainObject'],
- 'min': ['createCallback', 'isArray', 'isString'],
- 'mixin': ['forEach', 'functions'],
- 'noConflict': [],
- 'omit': ['forIn', 'indexOf'],
- 'once': [],
- 'pairs': ['keys'],
- 'parseInt': ['isString'],
- 'partial': ['isFunction', 'isObject'],
- 'partialRight': ['isFunction', 'isObject'],
- 'pick': ['forIn', 'isObject'],
- 'pluck': ['map'],
- 'random': [],
- 'range': [],
- 'reduce': ['createCallback', 'isArray'],
- 'reduceRight': ['createCallback', 'forEach', 'isString', 'keys'],
- 'reject': ['createCallback', 'filter'],
- 'rest': [],
- 'result': ['isFunction'],
- 'runInContext': ['defaults', 'pick'],
- 'shuffle': ['forEach'],
- 'size': ['keys'],
- 'some': ['createCallback', 'isArray'],
- 'sortBy': ['createCallback', 'forEach'],
- 'sortedIndex': ['createCallback', 'identity'],
- 'tap': ['value'],
- 'template': ['defaults', 'escape', 'keys', 'values'],
- 'throttle': [],
- 'times': ['createCallback'],
- 'toArray': ['isString', 'values'],
- 'unescape': [],
- 'union': ['isArray', 'uniq'],
- 'uniq': ['createCallback', 'indexOf'],
- 'uniqueId': [],
- 'unzip': ['max', 'pluck'],
- 'value': ['forOwn', 'isArray'],
- 'values': ['keys'],
- 'where': ['filter'],
- 'without': ['difference'],
- 'wrap': [],
- 'zip': ['max', 'pluck'],
- 'zipObject': [],
- // method used by the `backbone` and `underscore` builds
- 'chain': ['value'],
- 'findWhere': ['find']
- };
- /** Used to inline `iteratorTemplate` */
- var iteratorOptions = [
- 'args',
- 'arrays',
- 'bottom',
- 'firstArg',
- 'init',
- 'loop',
- 'shadowedProps',
- 'top',
- 'useHas',
- 'useKeys'
- ];
- /** List of all methods */
- var allMethods = _.without(_.keys(dependencyMap));
- /** List of Lo-Dash methods */
- var lodashMethods = _.without(allMethods, 'chain', 'findWhere');
- /** List of Backbone's Lo-Dash dependencies */
- var backboneDependencies = [
- 'bind',
- 'bindAll',
- 'chain',
- 'clone',
- 'contains',
- 'countBy',
- 'defaults',
- 'escape',
- 'every',
- 'extend',
- 'filter',
- 'find',
- 'first',
- 'forEach',
- 'groupBy',
- 'has',
- 'indexOf',
- 'initial',
- 'invert',
- 'invoke',
- 'isArray',
- 'isEmpty',
- 'isEqual',
- 'isFunction',
- 'isObject',
- 'isRegExp',
- 'isString',
- 'keys',
- 'last',
- 'lastIndexOf',
- 'map',
- 'max',
- 'min',
- 'mixin',
- 'omit',
- 'once',
- 'pairs',
- 'pick',
- 'reduce',
- 'reduceRight',
- 'reject',
- 'rest',
- 'result',
- 'shuffle',
- 'size',
- 'some',
- 'sortBy',
- 'sortedIndex',
- 'toArray',
- 'uniqueId',
- 'value',
- 'values',
- 'without'
- ];
- /** List of Lo-Dash only methods */
- var lodashOnlyMethods = [
- 'at',
- 'bindKey',
- 'cloneDeep',
- 'createCallback',
- 'findIndex',
- 'findKey',
- 'forIn',
- 'forOwn',
- 'isPlainObject',
- 'merge',
- 'parseInt',
- 'partialRight',
- 'runInContext',
- 'unzip'
- ];
- /** List of Underscore methods */
- var underscoreMethods = _.without.apply(_, [allMethods].concat(lodashOnlyMethods));
- /** List of ways to export the `lodash` function */
- var exportsAll = [
- 'amd',
- 'commonjs',
- 'global',
- 'node'
- ];
- /*--------------------------------------------------------------------------*/
- /**
- * Adds support for Underscore style chaining to the `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function addChainMethods(source) {
- // add `_.chain`
- source = source.replace(matchFunction(source, 'tap'), function(match) {
- var indent = getIndent(match);
- return match && (indent + [
- '',
- '/**',
- ' * Creates a `lodash` object that wraps the given `value`.',
- ' *',
- ' * @static',
- ' * @memberOf _',
- ' * @category Chaining',
- ' * @param {Mixed} value The value to wrap.',
- ' * @returns {Object} Returns the wrapper object.',
- ' * @example',
- ' *',
- ' * var stooges = [',
- " * { 'name': 'moe', 'age': 40 },",
- " * { 'name': 'larry', 'age': 50 },",
- " * { 'name': 'curly', 'age': 60 }",
- ' * ];',
- ' *',
- ' * var youngest = _.chain(stooges)',
- ' * .sortBy(function(stooge) { return stooge.age; })',
- " * .map(function(stooge) { return stooge.name + ' is ' + stooge.age; })",
- ' * .first();',
- " * // => 'moe is 40'",
- ' */',
- 'function chain(value) {',
- ' value = new lodashWrapper(value);',
- ' value.__chain__ = true;',
- ' return value;',
- '}',
- '',
- match
- ].join('\n' + indent));
- });
- // add `wrapperChain`
- source = source.replace(matchFunction(source, 'wrapperToString'), function(match) {
- var indent = getIndent(match);
- return match && (indent + [
- '',
- '/**',
- ' * Enables method chaining on the wrapper object.',
- ' *',
- ' * @name chain',
- ' * @memberOf _',
- ' * @category Chaining',
- ' * @returns {Mixed} Returns the wrapper object.',
- ' * @example',
- ' *',
- ' * var sum = _([1, 2, 3])',
- ' * .chain()',
- ' * .reduce(function(sum, num) { return sum + num; })',
- ' * .value()',
- ' * // => 6`',
- ' */',
- 'function wrapperChain() {',
- ' this.__chain__ = true;',
- ' return this;',
- '}',
- '',
- match
- ].join('\n' + indent));
- });
- // add `lodash.chain` assignment
- source = source.replace(getMethodAssignments(source), function(match) {
- return match.replace(/^(?: *\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/\n)?( *)lodash\.VERSION *=/m, '$1lodash.chain = chain;\n\n$&');
- });
- // add `lodash.prototype.chain` assignment
- source = source.replace(/^( *)lodash\.prototype\.value *=.+\n/m, '$1lodash.prototype.chain = wrapperChain;\n$&');
- // remove `lodash.prototype.toString` and `lodash.prototype.valueOf` assignments
- source = source.replace(/^ *lodash\.prototype\.(?:toString|valueOf) *=.+\n/gm, '');
- // remove `lodash.prototype` batch method assignments
- source = source.replace(/(?:\s*\/\/.*)*\n( *)forOwn\(lodash, *function\(func, *methodName\)[\s\S]+?\n\1}.+/g, '');
- // replace `_.mixin`
- source = replaceFunction(source, 'mixin', [
- 'function mixin(object) {',
- ' forEach(functions(object), function(methodName) {',
- ' var func = lodash[methodName] = object[methodName];',
- '',
- ' lodash.prototype[methodName] = function() {',
- ' var args = [this.__wrapped__];',
- ' push.apply(args, arguments);',
- '',
- ' var result = func.apply(lodash, args);',
- ' if (this.__chain__) {',
- ' result = new lodashWrapper(result);',
- ' result.__chain__ = true;',
- ' }',
- ' return result;',
- ' };',
- ' });',
- '}'
- ].join('\n'));
- // replace wrapper `Array` method assignments
- source = source.replace(/^(?:(?: *\/\/.*\n)*(?: *if *\(.+\n)?( *)(each|forEach)\(\['[\s\S]+?\n\1}\);(?:\n *})?\n+)+/m, function(match, indent, funcName) {
- return indent + [
- '// add `Array` mutator functions to the wrapper',
- funcName + "(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(methodName) {",
- ' var func = arrayRef[methodName];',
- ' lodash.prototype[methodName] = function() {',
- ' var value = this.__wrapped__;',
- ' func.apply(value, arguments);',
- '',
- ' // avoid array-like object bugs with `Array#shift` and `Array#splice`',
- ' // in Firefox < 10 and IE < 9',
- ' if (!support.spliceObjects && value.length === 0) {',
- ' delete value[0];',
- ' }',
- ' return this;',
- ' };',
- '});',
- '',
- '// add `Array` accessor functions to the wrapper',
- funcName + "(['concat', 'join', 'slice'], function(methodName) {",
- ' var func = arrayRef[methodName];',
- ' lodash.prototype[methodName] = function() {',
- ' var value = this.__wrapped__,',
- ' result = func.apply(value, arguments);',
- '',
- ' if (this.__chain__) {',
- ' result = new lodashWrapper(result);',
- ' result.__chain__ = true;',
- ' }',
- ' return result;',
- ' };',
- '});',
- ''
- ].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;
- }
- /**
- * Adds build `commands` to the copyright/license header of the `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @param {Array} [commands=[]] An array of commands.
- * @returns {String} Returns the modified source.
- */
- function addCommandsToHeader(source, commands) {
- return source.replace(/(\/\**\n)( \*)( *@license[\s*]+)( *Lo-Dash [\w.-]+)(.*)/, function() {
- // remove `node path/to/build.js` from `commands`
- if (reNode.test(commands[0])) {
- commands.splice(0, 2);
- }
- // add quotes to commands with spaces or equals signs
- commands = _.map(commands, function(command) {
- var separator = (command.match(/[= ]/) || [''])[0];
- if (separator) {
- var pair = command.split(separator);
- command = pair[0] + separator + '"' + pair[1] + '"';
- }
- // escape newlines, carriage returns, multi-line comment end tokens
- command = command
- .replace(/\n/g, '\\n')
- .replace(/\r/g, '\\r')
- .replace(/\*\//g, '*\\/');
- return command;
- });
- // add build commands to copyright/license header
- var parts = slice.call(arguments, 1);
- return (
- parts[0] +
- parts[1] +
- parts[2] + parts[3] + ' (Custom Build)' + parts[4] + '\n' +
- parts[1] + ' Build: `lodash ' + commands.join(' ') + '`'
- );
- });
- }
- /**
- * Compiles template files matched by the given file path `pattern` into a
- * single source, extending `_.templates` with precompiled templates named after
- * each template file's basename.
- *
- * @private
- * @param {String} [pattern='<cwd>/*.jst'] The file path pattern.
- * @param {Object} options The options object.
- * @returns {String} Returns the compiled source.
- */
- function buildTemplate(pattern, options) {
- pattern || (pattern = path.join(cwd, '*.jst'));
- var directory = path.dirname(pattern);
- var source = [
- ';(function(window) {',
- " var freeExports = typeof exports == 'object' && typeof require == 'function' && exports;",
- '',
- " var freeModule = typeof module == 'object' && module && module.exports == freeExports && module;",
- '',
- " var freeGlobal = typeof global == 'object' && global;",
- ' if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal) {',
- ' window = freeGlobal;',
- ' }',
- '',
- ' var templates = {},',
- ' _ = window._;',
- ''
- ];
- // convert to a regexp
- pattern = RegExp(
- path.basename(pattern)
- .replace(/[.+?^=!:${}()|[\]\/\\]/g, '\\$&')
- .replace(/\*/g, '.*?') + '$'
- );
- fs.readdirSync(directory).forEach(function(filename) {
- var filePath = path.join(directory, filename);
- if (pattern.test(filename)) {
- var text = fs.readFileSync(filePath, 'utf8'),
- precompiled = getFunctionSource(_.template(text, null, options)),
- prop = filename.replace(/\..*$/, '');
- source.push(" templates['" + prop.replace(/['\n\r\t]/g, '\\$&') + "'] = " + precompiled + ';', '');
- }
- });
- source.push(
- " if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {",
- " define(['" + options.moduleId + "'], function(lodash) {",
- ' _ = lodash;',
- ' lodash.templates = lodash.extend(lodash.templates || {}, templates);',
- ' });',
- " } else if (freeExports && !freeExports.nodeType) {",
- " _ = require('" + options.moduleId + "');",
- " if (freeModule) {",
- ' (freeModule.exports = templates).templates = templates;',
- ' } else {',
- ' freeExports.templates = templates;',
- ' }',
- ' } else if (_) {',
- ' _.templates = _.extend(_.templates || {}, templates);',
- ' }',
- '}(this));'
- );
- return source.join('\n');
- }
- /**
- * Capitalizes a given string.
- *
- * @private
- * @param {String} string The string to capitalize.
- * @returns {String} Returns the capitalized string.
- */
- function capitalize(string) {
- return string[0].toUpperCase() + string.toLowerCase().slice(1);
- }
- /**
- * Removes unnecessary comments, whitespace, and pseudo private properties.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function cleanupSource(source) {
- return source
- // remove pseudo private properties
- .replace(/(?:(?:\s*\/\/.*)*\s*lodash\._[^=]+=.+\n)+/g, '\n')
- // remove extraneous whitespace
- .replace(/^ *\n/gm, '\n')
- // remove lines with just whitespace and semicolons
- .replace(/^ *;\n/gm, '')
- // consolidate multiple newlines
- .replace(/\n{3,}/g, '\n\n')
- // consolidate consecutive horizontal rule comment separators
- .replace(/(?:\s*\/\*-+\*\/\s*){2,}/g, function(separators) {
- return separators.match(/^\s*/)[0] + separators.slice(separators.lastIndexOf('/*'));
- });
- }
- /**
- * Writes the help message to standard output.
- *
- * @private
- */
- function displayHelp() {
- console.log([
- '',
- ' Commands:',
- '',
- ' lodash backbone Build with only methods required by Backbone',
- ' lodash legacy Build tailored for older environments without ES5 support',
- ' lodash modern Build tailored for newer environments with ES5 support',
- ' lodash mobile Build without method compilation and most bug fixes for old browsers',
- ' lodash strict Build with `_.assign`, `_.bindAll`, & `_.defaults` in strict mode',
- ' lodash underscore Build tailored for projects already using Underscore',
- ' lodash include=... Comma separated method/category names to include in the build',
- ' lodash minus=... Comma separated method/category names to remove from those included in the build',
- ' lodash plus=... Comma separated method/category names to add to those included in the build',
- ' lodash category=... Comma separated categories of methods to include in the build (case-insensitive)',
- ' (i.e. “arrays”, “chaining”, “collections”, “functions”, “objects”, and “utilities”)',
- ' lodash exports=... Comma separated names of ways to export the `lodash` function',
- ' (i.e. “amd”, “commonjs”, “global”, “node”, and “none”)',
- ' lodash iife=... Code to replace the immediately-invoked function expression that wraps Lo-Dash',
- ' (e.g. `lodash iife="!function(window){%output%}(this)"`)',
- '',
- ' lodash template=... File path pattern used to match template files to precompile',
- ' (e.g. `lodash template=./*.jst`)',
- ' lodash settings=... Template settings used when precompiling templates',
- ' (e.g. `lodash settings="{interpolate:/{{([\\s\\S]+?)}}/g}"`)',
- ' lodash moduleId=... The AMD module ID of Lo-Dash, which defaults to “lodash”, used by precompiled templates',
- '',
- ' All arguments, except `legacy` with `mobile`, `modern`, or `underscore`, may be combined.',
- ' Unless specified by `-o` or `--output`, all files created are saved to the current working directory.',
- '',
- ' Options:',
- '',
- ' -c, --stdout Write output to standard output',
- ' -d, --debug Write only the non-minified development output',
- ' -h, --help Display help information',
- ' -m, --minify Write only the minified production output',
- ' -o, --output Write output to a given path/filename',
- ' -p, --source-map Generate a source map for the minified output, using an optional source map URL',
- ' -s, --silent Skip status updates normally logged to the console',
- ' -V, --version Output current version of Lo-Dash',
- ''
- ].join('\n'));
- }
- /**
- * Gets the aliases associated with a given function name.
- *
- * @private
- * @param {String} methodName The name of the method to get aliases for.
- * @returns {Array} Returns an array of aliases.
- */
- function getAliases(methodName) {
- return realToAliasMap[methodName] || [];
- }
- /**
- * Gets the category of the given method name.
- *
- * @private
- * @param {String} source The source to inspect.
- * @param {String} methodName The method name.
- * @returns {String} Returns the method name's category.
- */
- function getCategory(source, methodName) {
- var result = /@category +(\w+)/.exec(matchFunction(source, methodName));
- return result ? result[1] : '';
- }
- /**
- * Gets an array of category dependencies for a given category.
- *
- * @private
- * @param {String} source The source to inspect.
- * @param {String} category The category.
- * @returns {Array} Returns an array of cetegory dependants.
- */
- function getCategoryDependencies(source, category) {
- var methods = _.uniq(getMethodsByCategory(source, category).reduce(function(result, methodName) {
- push.apply(result, getDependencies(methodName));
- return result;
- }, []));
- var categories = _.uniq(methods.map(function(methodName) {
- return getCategory(source, methodName);
- }));
- return categories.filter(function(other) {
- return other != category;
- });
- }
- /**
- * Gets an array of depenants for a method by a given name.
- *
- * @private
- * @param {String} methodName The method name.
- * @returns {Array} Returns an array of method dependants.
- */
- function getDependants(methodName) {
- // iterate over the `dependencyMap`, adding the names of methods that
- // have `methodName` as a dependency
- return _.reduce(dependencyMap, function(result, dependencies, otherName) {
- if (_.contains(dependencies, methodName)) {
- result.push(otherName);
- }
- return result;
- }, []);
- }
- /**
- * Gets an array of dependencies for a given method name. If passed an array
- * of dependencies it will return an array containing the given dependencies
- * plus any additional detected sub-dependencies.
- *
- * @private
- * @param {Array|String} methodName A single method name or array of
- * dependencies to query.
- * @param- {Object} [stackA=[]] Internally used track queried methods.
- * @returns {Array} Returns an array of method dependencies.
- */
- function getDependencies(methodName, stack) {
- var dependencies = Array.isArray(methodName) ? methodName : dependencyMap[methodName];
- if (!dependencies) {
- return [];
- }
- stack || (stack = []);
- // recursively accumulate the dependencies of the `methodName` function, and
- // the dependencies of its dependencies, and so on
- return _.uniq(dependencies.reduce(function(result, otherName) {
- if (!_.contains(stack, otherName)) {
- stack.push(otherName);
- result.push.apply(result, getDependencies(otherName, stack).concat(otherName));
- }
- return result;
- }, []));
- }
- /**
- * Gets the formatted source of the given function.
- *
- * @private
- * @param {Function} func The function to process.
- * @param {String} indent The function indent.
- * @returns {String} Returns the formatted source.
- */
- function getFunctionSource(func, indent) {
- var source = func.source || (func + '');
- if (indent == null) {
- indent = ' ';
- }
- // format leading whitespace
- return source.replace(/\n(?:.*)/g, function(match, index) {
- match = match.slice(1);
- return (
- '\n' + indent +
- (match == '}' && !_.contains(source, '}', index + 2) ? '' : ' ')
- ) + match;
- });
- }
- /**
- * Gets the indent of the given function.
- *
- * @private
- * @param {Function} func The function to process.
- * @returns {String} Returns the indent.
- */
- function getIndent(func) {
- return /^ *(?=\S)/m.exec(func.source || func)[0];
- }
- /**
- * Gets the `_.isArguments` fallback from `source`.
- *
- * @private
- * @param {String} source The source to inspect.
- * @returns {String} Returns the `isArguments` fallback.
- */
- function getIsArgumentsFallback(source) {
- return (source.match(/(?:\s*\/\/.*)*\n( *)if *\((?:!support\.argsClass|!isArguments)[\s\S]+?};\n\1}/) || [''])[0];
- }
- /**
- * Gets the `_.isArray` fallback from `source`.
- *
- * @private
- * @param {String} source The source to inspect.
- * @returns {String} Returns the `isArray` fallback.
- */
- function getIsArrayFallback(source) {
- return matchFunction(source, 'isArray')
- .replace(/^[\s\S]+?=\s*nativeIsArray\b/, '')
- .replace(/[;\s]+$/, '');
- }
- /**
- * Gets the `_.isFunction` fallback from `source`.
- *
- * @private
- * @param {String} source The source to inspect.
- * @returns {String} Returns the `isFunction` fallback.
- */
- function getIsFunctionFallback(source) {
- return (source.match(/(?:\s*\/\/.*)*\n( *)if *\(isFunction\(\/x\/[\s\S]+?};\n\1}/) || [''])[0];
- }
- /**
- * Gets the `iteratorTemplate` from `source`.
- *
- * @private
- * @param {String} source The source to inspect.
- * @returns {String} Returns the `iteratorTemplate`.
- */
- function getIteratorTemplate(source) {
- return (source.match(/^( *)var iteratorTemplate *= *[\s\S]+?\n\1.+?;\n/m) || [''])[0];
- }
- /**
- * Gets the Lo-Dash method assignments snippet from `source`.
- *
- * @private
- * @param {String} source The source to inspect.
- * @returns {String} Returns the method assignments snippet.
- */
- function getMethodAssignments(source) {
- return (source.match(/\/\*-+\*\/\n(?:\s*\/\/.*)*\s*lodash\.\w+ *=[\s\S]+?lodash\.VERSION *=.+/) || [''])[0];
- }
- /**
- * Gets the names of methods in `source` belonging to the given `category`.
- *
- * @private
- * @param {String} source The source to inspect.
- * @param {String} category The category to filter by.
- * @returns {Array} Returns a new array of method names belonging to the given category.
- */
- function getMethodsByCategory(source, category) {
- return allMethods.filter(function(methodName) {
- return getCategory(source, methodName) == category;
- });
- }
- /**
- * Gets the real name, not alias, of a given method name.
- *
- * @private
- * @param {String} methodName The name of the method to resolve.
- * @returns {String} Returns the real method name.
- */
- function getRealName(methodName) {
- return aliasToRealMap[methodName] || methodName;
- }
- /**
- * Determines if all functions of the given names have been removed from `source`.
- *
- * @private
- * @param {String} source The source to inspect.
- * @param {String} [funcName1, funcName2, ...] The names of functions to check.
- * @returns {Boolean} Returns `true` if all functions have been removed, else `false`.
- */
- function isRemoved(source) {
- return slice.call(arguments, 1).every(function(funcName) {
- return !(
- matchFunction(source, funcName) ||
- RegExp('^ *lodash\\.prototype\\.' + funcName + ' *=.+', 'm').test(source)
- );
- });
- }
- /**
- * Searches `source` for a `funcName` function declaration, expression, or
- * assignment and returns the matched snippet.
- *
- * @private
- * @param {String} source The source to inspect.
- * @param {String} funcName The name of the function to match.
- * @returns {String} Returns the matched function snippet.
- */
- function matchFunction(source, funcName) {
- var result = source.match(RegExp(
- // match multi-line comment block
- '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/)?\\n' +
- // begin non-capturing group
- '( *)(?:' +
- // match a function declaration
- 'function ' + funcName + '\\b[\\s\\S]+?\\n\\1}|' +
- // match a variable declaration with function expression
- 'var ' + funcName + ' *=.*?function[\\s\\S]+?\\n\\1};' +
- // end non-capturing group
- ')\\n'
- ));
- // match variables that are explicitly defined as functions
- result || (result = source.match(RegExp(
- // match multi-line comment block
- '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/)?\\n' +
- // match simple variable declarations and those with `createIterator`
- ' *var ' + funcName + ' *=(?:.+?|.*?createIterator\\([\\s\\S]+?\\));\\n'
- )));
- return /@type +Function|function\s*\w*\(/.test(result) ? result[0] : '';
- }
- /**
- * Converts a comma separated options string into an array.
- *
- * @private
- * @param {String} value The option to convert.
- * @returns {Array} Returns the new converted array.
- */
- function optionToArray(value) {
- return _.compact(_.isArray(value)
- ? value
- : value.match(/\w+=(.*)$/)[1].split(/, */)
- );
- }
- /**
- * Converts a comma separated options string into an array containing
- * only real method names.
- *
- * @private
- * @param {String} source The source to inspect.
- * @param {String} value The option to convert.
- * @returns {Array} Returns the new converted array.
- */
- function optionToMethodsArray(source, value) {
- var methodNames = optionToArray(value);
- // convert aliases to real method names
- methodNames = methodNames.map(getRealName);
- // remove nonexistent and duplicate method names
- return _.uniq(_.intersection(allMethods, methodNames));
- }
- /**
- * Removes the all references to `varName` from `createIterator` in `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @param {String} identifier The name of the variable or property to remove.
- * @returns {String} Returns the modified source.
- */
- function removeFromCreateIterator(source, identifier) {
- var snippet = matchFunction(source, 'createIterator');
- if (!snippet) {
- return source;
- }
- // remove data object property assignment
- var modified = snippet
- .replace(RegExp("^(?: *\\/\\/.*\\n)* *'" + identifier + "':.+\\n+", 'm'), '')
- .replace(/,(?=\s*})/, '');
- source = source.replace(snippet, function() {
- return modified;
- });
- // clip at the `factory` assignment
- snippet = modified.match(/Function\([\s\S]+$/)[0];
- modified = snippet
- .replace(RegExp('\\b' + identifier + '\\b,? *', 'g'), '')
- .replace(/, *(?=',)/, '')
- .replace(/,(?=\s*\))/, '')
- source = source.replace(snippet, function() {
- return modified;
- });
- return source;
- }
- /**
- * Removes the `funcName` function declaration, expression, or assignment and
- * associated code from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @param {String} funcName The name of the function to remove.
- * @returns {String} Returns the modified source.
- */
- function removeFunction(source, funcName) {
- var snippet;
- // remove function
- if (funcName == 'runInContext') {
- source = removeRunInContext(source, funcName);
- } else if (funcName != 'each' && (snippet = matchFunction(source, funcName))) {
- source = source.replace(snippet, '');
- }
- // grab the method assignments snippet
- snippet = getMethodAssignments(source);
- // 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'), '');
- }, snippet);
- // replace with the modified snippet
- source = source.replace(snippet, function() {
- return modified;
- });
- return removeFromCreateIterator(source, funcName);
- }
- /**
- * Removes the `_.isArguments` fallback from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeIsArgumentsFallback(source) {
- return source.replace(getIsArgumentsFallback(source), '');
- }
- /**
- * Removes the `_.isArray` fallback from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeIsArrayFallback(source) {
- return source.replace(getIsArrayFallback(source), '');
- }
- /**
- * Removes the `_.isFunction` fallback from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeIsFunctionFallback(source) {
- return source.replace(getIsFunctionFallback(source), '');
- }
- /**
- * Removes the `Object.keys` object iteration optimization from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeKeysOptimization(source) {
- source = removeFromCreateIterator(source, 'useKeys');
- // remove optimized branch in `iteratorTemplate`
- source = source.replace(getIteratorTemplate(source), function(match) {
- return match.replace(/^(?: *\/\/.*\n)* *["']( *)<% *if *\(useHas *&& *useKeys[\s\S]+?["']\1<% *} *else *{ *%>.+\n([\s\S]+?) *["']\1<% *} *%>.+/m, "'\\n' +\n$2");
- });
- return source;
- }
- /**
- * Removes all `lodashWrapper` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeLodashWrapper(source) {
- source = removeFunction(source, 'lodashWrapper');
- // remove `lodashWrapper.prototype` assignment
- source = source.replace(/(?:\s*\/\/.*)*\n *lodashWrapper\.prototype *=.+/, '');
- // replace `new lodashWrapper` with `new lodash`
- source = source.replace(/\bnew lodashWrapper\b/g, 'new lodash');
- return source;
- }
- /**
- * Removes all `support.argsObject` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportArgsObject(source) {
- source = removeSupportProp(source, 'argsObject');
- // remove `argsAreObjects` from `_.isEqual`
- source = source.replace(matchFunction(source, 'isEqual'), function(match) {
- return match.replace(/!support.\argsObject[^:]+:\s*/g, '');
- });
- return source;
- }
- /**
- * Removes all `support.argsClass` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportArgsClass(source) {
- source = removeSupportProp(source, 'argsClass');
- // replace `support.argsClass` in the `_.isArguments` fallback
- source = source.replace(getIsArgumentsFallback(source), function(match) {
- return match.replace(/!support\.argsClass/g, '!isArguments(arguments)');
- });
- // remove `support.argsClass` from `_.isEmpty`
- source = source.replace(matchFunction(source, 'isEmpty'), function(match) {
- return match.replace(/\s*\(support\.argsClass\s*\?([^:]+):.+?\)\)/g, '$1');
- });
- // remove `support.argsClass` from `_.isPlainObject`
- _.each(['shimIsPlainObject', 'isPlainObject'], function(methodName) {
- source = source.replace(matchFunction(source, methodName), function(match) {
- return match.replace(/\s*\|\|\s*\(!support\.argsClass[\s\S]+?\)\)/, '');
- });
- });
- return source;
- }
- /**
- * Removes all `support.enumPrototypes` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportEnumPrototypes(source) {
- source = removeSupportProp(source, 'enumPrototypes');
- // remove `support.enumPrototypes` from `_.keys`
- source = source.replace(matchFunction(source, 'keys'), function(match) {
- return match
- .replace(/\(support\.enumPrototypes[^)]+\)(?:\s*\|\|\s*)?/, '')
- .replace(/\s*if *\(\s*\)[^}]+}/, '');
- });
- // remove `support.enumPrototypes` from `iteratorTemplate`
- source = source.replace(getIteratorTemplate(source), function(match) {
- return match
- .replace(/(?: *\/\/.*\n)* *["'] *(?:<% *)?if *\(support\.enumPrototypes *(?:&&|\))[\s\S]+?<% *} *(?:%>|["']).+/g, '')
- .replace(/support\.enumPrototypes\s*\|\|\s*/g, '');
- });
- return source;
- }
- /**
- * Removes all `support.nodeClass` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportNodeClass(source) {
- source = removeFunction(source, 'isNode');
- source = removeSupportProp(source, 'nodeClass');
- // remove `support.nodeClass` from `shimIsPlainObject`
- source = source.replace(matchFunction(source, 'shimIsPlainObject'), function(match) {
- return match.replace(/\(support\.nodeClass[\s\S]+?\)\)/, 'true');
- });
- // remove `support.nodeClass` from `_.clone`
- source = source.replace(matchFunction(source, 'clone'), function(match) {
- return match.replace(/\s*\|\|\s*\(!support\.nodeClass[\s\S]+?\)\)/, '');
- });
- // remove `support.nodeClass` from `_.isEqual`
- source = source.replace(matchFunction(source, 'isEqual'), function(match) {
- return match.replace(/\s*\|\|\s*\(!support\.nodeClass[\s\S]+?\)\)\)/, '');
- });
- return source;
- }
- /**
- * Removes all `support.nonEnumArgs` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportNonEnumArgs(source) {
- source = removeSupportProp(source, 'nonEnumArgs');
- // remove `support.nonEnumArgs` from `_.keys`
- source = source.replace(matchFunction(source, 'keys'), function(match) {
- return match
- .replace(/(?:\s*\|\|\s*)?\(support\.nonEnumArgs[^)]+\)\)/, '')
- .replace(/\s*if *\(\s*\)[^}]+}/, '');
- });
- // remove `nonEnumArgs` from `iteratorTemplate`
- source = source.replace(getIteratorTemplate(source), function(match) {
- return match
- .replace(/(?: *\/\/.*\n)*( *["'] *)<% *} *else *if *\(support\.nonEnumArgs[\s\S]+?(\1<% *} *%>.+)/, '$2')
- .replace(/\s*\|\|\s*support\.nonEnumArgs/, '');
- });
- return source;
- }
- /**
- * Removes all `support.nonEnumShadows` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportNonEnumShadows(source) {
- source = removeSupportProp(source, 'nonEnumShadows');
- source = removeVar(source, 'shadowedProps');
- source = removeFromCreateIterator(source, 'shadowedProps');
- // remove `support.nonEnumShadows` from `iteratorTemplate`
- source = source.replace(getIteratorTemplate(source), function(match) {
- return match.replace(/(?: *\/\/.*\n)* *["']( *)<% *if *\(support\.nonEnumShadows[\s\S]+?["']\1<% *} *%>.+/, '');
- });
- return source;
- }
- /**
- * Removes all `support.ownLast` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportOwnLast(source) {
- source = removeSupportProp(source, 'ownLast');
- // remove `support.ownLast` from `shimIsPlainObject`
- source = source.replace(matchFunction(source, 'shimIsPlainObject'), function(match) {
- return match.replace(/(?:\s*\/\/.*)*\n( *)if *\(support\.ownLast[\s\S]+?\n\1}/, '');
- });
- return source;
- }
- /**
- * Removes all `support.spliceObjects` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportSpliceObjects(source) {
- source = removeSupportProp(source, 'spliceObjects');
- // remove `support.spliceObjects` fix from the `Array` function mixins
- source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(!support\.spliceObjects[\s\S]+?(?:{\s*}|\n\1})/, '');
- return source;
- }
- /**
- * Removes all `support.unindexedChars` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSupportUnindexedChars(source) {
- source = removeSupportProp(source, 'unindexedChars');
- // remove `support.unindexedChars` from `_.at`
- source = source.replace(matchFunction(source, 'at'), function(match) {
- return match.replace(/^ *if *\(support\.unindexedChars[^}]+}\n+/m, '');
- });
- // remove `support.unindexedChars` from `_.reduceRight`
- source = source.replace(matchFunction(source, 'reduceRight'), function(match) {
- return match.replace(/}\s*else if *\(support\.unindexedChars[^}]+/, '');
- });
- // remove `support.unindexedChars` from `_.toArray`
- source = source.replace(matchFunction(source, 'toArray'), function(match) {
- return match.replace(/(return\b).+?support\.unindexedChars[^:]+:\s*/, '$1 ');
- });
- // remove `support.unindexedChars` from `iteratorTemplate`
- source = source.replace(getIteratorTemplate(source), function(match) {
- return match
- .replace(/'if *\(<%= *arrays *%>[^']*/, '$&\\n')
- .replace(/(?: *\/\/.*\n)* *["']( *)<% *if *\(support\.unindexedChars[\s\S]+?["']\1<% *} *%>.+/, '');
- });
- return source;
- }
- /**
- * Removes all `runInContext` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeRunInContext(source) {
- source = removeVar(source, 'contextProps');
- // remove function scaffolding, leaving most of its content
- source = source.replace(matchFunction(source, 'runInContext'), function(match) {
- return match
- .replace(/^[\s\S]+?function runInContext[\s\S]+?context *= *context.+| *return lodash[\s\S]+$/g, '')
- .replace(/^ {4}/gm, ' ');
- });
- // cleanup adjusted source
- source = source
- .replace(/\bcontext\b/g, 'window')
- .replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *var Array *=[\s\S]+?;\n/, '')
- .replace(/(return *|= *)_([;)])/g, '$1lodash$2')
- .replace(/^ *var _ *=.+\n+/m, '');
- return source;
- }
- /**
- * Removes all `setImmediate` references from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @returns {String} Returns the modified source.
- */
- function removeSetImmediate(source) {
- source = removeVar(source, 'setImmediate');
- // remove the `setImmediate` fork of `_.defer`.
- source = source.replace(/(?:\s*\/\/.*)*\n( *)if *\(isV8 *&& *freeModule[\s\S]+?\n\1}/, '');
- return source;
- }
- /**
- * Removes a given property from the `support` object in `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @param {String} varName The name of the `support` property to remove.
- * @returns {String} Returns the modified source.
- */
- function removeSupportProp(source, propName) {
- return source.replace(RegExp(
- // match multi-line comment block
- '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/)?\\n' +
- // match a `try` block
- '(?: *try\\b.+\\n)?' +
- // match the `support` property assignment
- ' *support\\.' + propName + ' *=.+\\n' +
- // match `catch` block
- '(?:( *).+?catch\\b[\\s\\S]+?\\n\\1}\\n)?'
- ), '');
- }
- /**
- * Removes a given variable from `source`.
- *
- * @private
- * @param {String} source The source to process.
- * @param {String} varName The name of the variable to remove.
- * @returns {String} Returns the modified source.
- */
- function removeVar(source, varName) {
- // simplify complex variable assignments
- if (/^(?:cloneableClasses|contextProps|ctorByClass|shadowedProps|whitespace)$/.test(varName)) {
- source = source.replace(RegExp('(var ' + varName + ' *=)[\\s\\S]+?;\\n\\n'), '$1=null;\n\n');
- }
- source = removeFunction(source, varName);
- source = source.replace(RegExp(
- // match multi-line comment block
- '(?:\\n +/\\*[^*]*\\*+(?:[^/][^*]*\\*+)*/)?\\n' +
- // match a variable declaration that's not part of a declaration list
- '( *)var ' + varName + ' *= *(?:.+?(?:;|&&\\n[^;]+;)|(?:\\w+\\(|{)[\\s\\S]+?\\n\\1.+?;)\\n|' +
- // match a variable in a declaration list
- '^ *' + varName + ' *=.+?,\\n',
- 'm'
- ), '');
- // remove a varaible at the start of a variable declaration list
- source = source.replace(RegExp('(var +)' + varName + ' *=.+?,\\s+'), '$1');
- // remove a variable at the end of a variable declaration list
- source = source.replace(RegExp(',\\s*' + varName + ' *=.+?;'), ';');
- return source;
- }
- /**
- * Replaces the `funcName` function body in `source` with `funcValue`.
- *
- * @private
- * @param {String} source The source to process.
- * @param {String} varName The name of the function to replace.
- * @returns {String} Returns the modified source.
- */
- function replaceFunction(source, funcName, funcValue) {
- var snippet = matchFunction(source, funcName);
- if (!snippet) {
- return source;
- }
- // clip snippet after the JSDoc comment block
- snippet = snippet.replace(/^\s*(?:\/\/.*|\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)\n/, '');
- source = source.replace(snippet, function() {
- return funcValue
- .replace(RegExp('^' + getIndent(funcValue), 'gm'), getIndent(snippet))
- .trimRight() + '\n';
- });
- return source;
- }
- /**
- * Replaces the `support` object `propName` property value in `source` with `propValue`.
- *
- * @private
- * @param {String} source The source to process.
- * @param {String} varName The name of the `support` property to replace.
- * @returns {String} Returns the modified source.
- */
- function replaceSupportProp(source, propName, propValue) {
- return source.replace(RegExp(
- // match a `try` block
- '(?: *try\\b.+\\n)?' +
- // match the `support` property assignment
- '( *support\\.' + propName + ' *=).+\\n' +
- // match `catch` block
- '(?:( *).+?catch\\b[\\s\\S]+?\\n\\2}\\n)?'
- ), function(match, left) {
- return left + ' ' + propValue + ';\n';
- });
- }
- /**
- * Replaces the `varName` variable declaration value in `source` with `varValue`.
- *
- * @private
- * @param {String} source The source to inspect.
- * @param {String} varName The name of the variable to replace.
- * @returns {String} Returns the modified source.
- */
- function replaceVar(source, varName, varValue) {
- // replace a variable that's not part of a declaration list
- var result = source.replace(RegExp(
- '(( *)var ' + varName + ' *=)' +
- '(?:.+?;|(?:Function\\(.+?|.*?[^,])\\n[\\s\\S]+?\\n\\2.+?;)\\n'
- ), function(match, left) {
- return left + ' ' + varValue + ';\n';
- });
- if (source == result) {
- // replace a varaible at the start or middle of a declaration list
- result = source.replace(RegExp('((?:var|\\n) +' + varName + ' *=).+?,'), function(match, left) {
- return left + ' ' + varValue + ',';
- });
- }
- if (source == result) {
- // replace a variable at the end of a variable declaration list
- result = source.replace(RegExp('(,\\s*' + varName + ' *=).+?;'), function(match, left) {
- return left + ' ' + varValue + ';';
- });
- }
- return result;
- }
- /**
- * Hard-codes the `strict` template option value for `iteratorTemplate`.
- *
- * @private
- * @param {String} source The source to process.
- * @param {Boolean} value The value to set.
- * @returns {String} Returns the modified source.
- */
- function setUseStrictOption(source, value) {
- // inject or remove the "use strict" directive
- source = source.replace(/^([\s\S]*?function[^{]+{)(?:\s*'use strict';)?/, '$1' + (value ? "\n 'use strict';" : ''));
- // replace `strict` branch in `iteratorTemplate` with hard-coded option
- source = source.replace(getIteratorTemplate(source), function(match) {
- return match.replace(/(template\()(?:\s*"'use strict.+)?/, '$1' + (value ? '\n "\'use strict\';\\n" +' : ''));
- });
- return source;
- }
- /*--------------------------------------------------------------------------*/
- /**
- * Creates a debug and/or minified build, executing the `callback` for each.
- * The `callback` is invoked with two arguments; (filePath, outputSource).
- *
- * Note: For a list of comm…
Large files files are truncated, but you can click here to view the full file