mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 17:37:50 +00:00
Avoid circular dependencies.
Former-commit-id: a45dd055f44f72797cb62ba040ecc2d45cc24634
This commit is contained in:
102
dist/lodash.compat.js
vendored
102
dist/lodash.compat.js
vendored
@@ -326,6 +326,7 @@
|
||||
'firstArg': '',
|
||||
'index': 0,
|
||||
'init': '',
|
||||
'keys': null,
|
||||
'leading': false,
|
||||
'loop': '',
|
||||
'maxWait': 0,
|
||||
@@ -340,7 +341,6 @@
|
||||
'true': false,
|
||||
'undefined': false,
|
||||
'useHas': false,
|
||||
'useKeys': false,
|
||||
'value': null
|
||||
};
|
||||
}
|
||||
@@ -860,7 +860,7 @@
|
||||
|
||||
var conditions = []; if (support.enumPrototypes) { conditions.push('!(skipProto && index == "prototype")'); } if (support.enumErrorProps) { conditions.push('!(skipErrorProps && (index == "message" || index == "name"))'); }
|
||||
|
||||
if (obj.useHas && obj.useKeys) {
|
||||
if (obj.useHas && obj.keys) {
|
||||
__p += '\n var ownIndex = -1,\n ownProps = objectTypes[typeof iterable] && keys(iterable),\n length = ownProps ? ownProps.length : 0;\n\n while (++ownIndex < length) {\n index = ownProps[ownIndex];\n';
|
||||
if (conditions.length) {
|
||||
__p += ' if (' +
|
||||
@@ -916,34 +916,6 @@
|
||||
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, 3)",
|
||||
'array': "typeof length == 'number'",
|
||||
'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,
|
||||
'array': false
|
||||
};
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@@ -1375,7 +1347,7 @@
|
||||
// use `Function#bind` if it exists and is fast
|
||||
// (in V8 `Function#bind` is slower except when partially applied)
|
||||
if (!isPartial && !isAlt && !partialRightArgs.length && (support.fastBind || (nativeBind && partialArgs.length))) {
|
||||
args = [func, thisArg];
|
||||
var args = [func, thisArg];
|
||||
push.apply(args, partialArgs);
|
||||
var bound = nativeBind.call.apply(nativeBind, args);
|
||||
}
|
||||
@@ -1419,7 +1391,7 @@
|
||||
* @param {Object} [options1, options2, ...] The compile options object(s).
|
||||
* array - 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.
|
||||
* keys - A reference to `_.keys` for use in 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.
|
||||
@@ -1436,7 +1408,6 @@
|
||||
data.array = data.bottom = data.loop = data.top = '';
|
||||
data.init = 'iterable';
|
||||
data.useHas = true;
|
||||
data.useKeys = true;
|
||||
|
||||
// merge options into a template data object
|
||||
for (var object, index = 0; object = arguments[index]; index++) {
|
||||
@@ -1460,7 +1431,7 @@
|
||||
// return the compiled function
|
||||
return factory(
|
||||
errorClass, errorProto, hasOwnProperty, indicatorObject, isArguments,
|
||||
isArray, isString, data.useKeys && keys, lodash, objectProto, objectTypes, nonEnumProps,
|
||||
isArray, isString, data.keys, lodash, objectProto, objectTypes, nonEnumProps,
|
||||
stringClass, stringProto, toString
|
||||
);
|
||||
}
|
||||
@@ -1639,8 +1610,7 @@
|
||||
'args': 'object',
|
||||
'init': '[]',
|
||||
'top': 'if (!(objectTypes[typeof object])) return result',
|
||||
'loop': 'result.push(index)',
|
||||
'useKeys': false
|
||||
'loop': 'result.push(index)'
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -1667,21 +1637,35 @@
|
||||
return nativeKeys(object);
|
||||
};
|
||||
|
||||
/**
|
||||
* A function compiled to iterate `arguments` objects, arrays, objects, and
|
||||
* strings consistenly across environments, executing the `callback` for each
|
||||
* element in the `collection`. The `callback` is bound to `thisArg` and invoked
|
||||
* with three arguments; (value, index|key, collection). Callbacks may exit
|
||||
* iteration early by explicitly returning `false`.
|
||||
*
|
||||
* @private
|
||||
* @type Function
|
||||
* @param {Array|Object|String} collection The collection to iterate over.
|
||||
* @param {Function} [callback=identity] The function called per iteration.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array|Object|String} Returns `collection`.
|
||||
*/
|
||||
var baseEach = createIterator(eachIteratorOptions);
|
||||
/** 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, 3)",
|
||||
'array': "typeof length == 'number'",
|
||||
'keys': keys,
|
||||
'loop': 'if (callback(iterable[index], index, collection) === false) return result'
|
||||
};
|
||||
|
||||
/** 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]) {',
|
||||
'keys': keys,
|
||||
'loop': "if (typeof result[index] == 'undefined') result[index] = iterable[index]",
|
||||
'bottom': ' }\n}'
|
||||
};
|
||||
|
||||
/** Reusable iterator options for `forIn` and `forOwn` */
|
||||
var forOwnIteratorOptions = {
|
||||
'top': 'if (!objectTypes[typeof iterable]) return result;\n' + eachIteratorOptions.top,
|
||||
'array': false
|
||||
};
|
||||
|
||||
/**
|
||||
* Used to convert characters to HTML entities:
|
||||
@@ -1706,6 +1690,22 @@
|
||||
var reEscapedHtml = RegExp('(' + keys(htmlUnescapes).join('|') + ')', 'g'),
|
||||
reUnescapedHtml = RegExp('[' + keys(htmlEscapes).join('') + ']', 'g');
|
||||
|
||||
/**
|
||||
* A function compiled to iterate `arguments` objects, arrays, objects, and
|
||||
* strings consistenly across environments, executing the `callback` for each
|
||||
* element in the `collection`. The `callback` is bound to `thisArg` and invoked
|
||||
* with three arguments; (value, index|key, collection). Callbacks may exit
|
||||
* iteration early by explicitly returning `false`.
|
||||
*
|
||||
* @private
|
||||
* @type Function
|
||||
* @param {Array|Object|String} collection The collection to iterate over.
|
||||
* @param {Function} [callback=identity] The function called per iteration.
|
||||
* @param {Mixed} [thisArg] The `this` binding of `callback`.
|
||||
* @returns {Array|Object|String} Returns `collection`.
|
||||
*/
|
||||
var baseEach = createIterator(eachIteratorOptions);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user