: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
iteratee = cb(iteratee, context);
each(obj, function(v, index, list) {
computed = iteratee(v, index, list);
if (computed < lastComputed || (computed === Infinity && result === Infinity)) {
// Safely create a real, live array from anything iterable.
var reStrSymbol = /[^\ud800-\udfff]|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff]/g;
if (isArray(obj)) return slice.call(obj);
// Keep surrogate pair characters together.
return obj.match(reStrSymbol);
if (isArrayLike(obj)) return map(obj, identity);
// Sample **n** random values from a collection using the modern version of the
// [Fisher-Yates shuffle](https://en.wikipedia.org/wiki/Fisher–Yates_shuffle).
// If **n** is not specified, returns a single random element.
// The internal `guard` argument allows it to work with `_.map`.
function sample(obj, n, guard) {
if (n == null || guard) {
if (!isArrayLike(obj)) obj = values(obj);
return obj[random(obj.length - 1)];
var sample = toArray(obj);
var length = getLength(sample);
n = Math.max(Math.min(n, length), 0);
for (var index = 0; index < n; index++) {
var rand = random(index, last);
var temp = sample[index];
sample[index] = sample[rand];
return sample.slice(0, n);
return sample(obj, Infinity);
// Sort the object's values by a criterion produced by an iteratee.
function sortBy(obj, iteratee, context) {
iteratee = cb(iteratee, context);
return pluck(map(obj, function(value, key, list) {
criteria: iteratee(value, key, list)
}).sort(function(left, right) {
if (a > b || a === void 0) return 1;
if (a < b || b === void 0) return -1;
return left.index - right.index;
// An internal function used for aggregate "group by" operations.
function group(behavior, partition) {
return function(obj, iteratee, context) {
var result = partition ? [[], []] : {};
iteratee = cb(iteratee, context);
each(obj, function(value, index) {
var key = iteratee(value, index, obj);
behavior(result, value, key);
// Groups the object's values by a criterion. Pass either a string attribute
// to group by, or a function that returns the criterion.
var groupBy = group(function(result, value, key) {
if (has$1(result, key)) result[key].push(value); else result[key] = [value];
// Indexes the object's values by a criterion, similar to `_.groupBy`, but for
// when you know that your index values will be unique.
var indexBy = group(function(result, value, key) {
// Counts instances of an object that group by a certain criterion. Pass
// either a string attribute to count by, or a function that returns the
var countBy = group(function(result, value, key) {
if (has$1(result, key)) result[key]++; else result[key] = 1;
// Split a collection into two arrays: one whose elements all pass the given
// truth test, and one whose elements all do not pass the truth test.
var partition = group(function(result, value, pass) {
result[pass ? 0 : 1].push(value);
// Return the number of elements in a collection.
if (obj == null) return 0;
return isArrayLike(obj) ? obj.length : keys(obj).length;
// Internal `_.pick` helper function to determine whether `key` is an enumerable
// property name of `obj`.
function keyInObj(value, key, obj) {
// Return a copy of the object only containing the allowed properties.
var pick = restArguments(function(obj, keys) {
var result = {}, iteratee = keys[0];
if (obj == null) return result;
if (isFunction$1(iteratee)) {
if (keys.length > 1) iteratee = optimizeCb(iteratee, keys[1]);
keys = flatten$1(keys, false, false);
for (var i = 0, length = keys.length; i < length; i++) {
if (iteratee(value, key, obj)) result[key] = value;
// Return a copy of the object without the disallowed properties.
var omit = restArguments(function(obj, keys) {
var iteratee = keys[0], context;
if (isFunction$1(iteratee)) {
iteratee = negate(iteratee);
if (keys.length > 1) context = keys[1];
keys = map(flatten$1(keys, false, false), String);
iteratee = function(value, key) {
return !contains(keys, key);
return pick(obj, iteratee, context);
// Returns everything but the last entry of the array. Especially useful on
// the arguments object. Passing **n** will return all the values in
// the array, excluding the last N.
function initial(array, n, guard) {
return slice.call(array, 0, Math.max(0, array.length - (n == null || guard ? 1 : n)));
// Get the first element of an array. Passing **n** will return the first N
// values in the array. The **guard** check allows it to work with `_.map`.
function first(array, n, guard) {
if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
if (n == null || guard) return array[0];
return initial(array, array.length - n);
// Returns everything but the first entry of the `array`. Especially useful on
// the `arguments` object. Passing an **n** will return the rest N values in the
function rest(array, n, guard) {
return slice.call(array, n == null || guard ? 1 : n);
// Get the last element of an array. Passing **n** will return the last N
function last(array, n, guard) {
if (array == null || array.length < 1) return n == null || guard ? void 0 : [];
if (n == null || guard) return array[array.length - 1];
return rest(array, Math.max(0, array.length - n));
// Trim out all falsy values from an array.
function compact(array) {
return filter(array, Boolean);
// Flatten out an array, either recursively (by default), or up to `depth`.
// Passing `true` or `false` as `depth` means `1` or `Infinity`, respectively.
function flatten(array, depth) {
return flatten$1(array, depth, false);
// Take the difference between one array and a number of other arrays.
// Only the elements present in just the first array will remain.
var difference = restArguments(function(array, rest) {
rest = flatten$1(rest, true, true);
return filter(array, function(value){
return !contains(rest, value);
// Return a version of the array that does not contain the specified value(s).
var without = restArguments(function(array, otherArrays) {
return difference(array, otherArrays);
// Produce a duplicate-free version of the array. If the array has already
// been sorted, you have the option of using a faster algorithm.
// The faster algorithm will not work with an iteratee if the iteratee
// is not a one-to-one function, so providing an iteratee will disable
function uniq(array, isSorted, iteratee, context) {
if (!isBoolean(isSorted)) {
if (iteratee != null) iteratee = cb(iteratee, context);
for (var i = 0, length = getLength(array); i < length; i++) {
computed = iteratee ? iteratee(value, i, array) : value;
if (isSorted && !iteratee) {
if (!i || seen !== computed) result.push(value);
if (!contains(seen, computed)) {
} else if (!contains(result, value)) {
// Produce an array that contains the union: each distinct element from all of
var union = restArguments(function(arrays) {
return uniq(flatten$1(arrays, true, true));
// Produce an array that contains every item shared between all the
function intersection(array) {
var argsLength = arguments.length;
for (var i = 0, length = getLength(array); i < length; i++) {
if (contains(result, item)) continue;
for (j = 1; j < argsLength; j++) {
if (!contains(arguments[j], item)) break;
if (j === argsLength) result.push(item);
// Complement of zip. Unzip accepts an array of arrays and groups
// each array's elements on shared indices.
var length = (array && max(array, getLength).length) || 0;
var result = Array(length);
for (var index = 0; index < length; index++) {
result[index] = pluck(array, index);
// Zip together multiple lists into a single array -- elements that share
var zip = restArguments(unzip);
// Converts lists into objects. Pass either a single array of `[key, value]`
// pairs, or two parallel arrays of the same length -- one of keys, and one of
// the corresponding values. Passing by pairs is the reverse of `_.pairs`.
function object(list, values) {
for (var i = 0, length = getLength(list); i < length; i++) {
result[list[i]] = values[i];
result[list[i][0]] = list[i][1];
// Generate an integer Array containing an arithmetic progression. A port of
// the native Python `range()` function. See
// [the Python documentation](https://docs.python.org/library/functions.html#range).
function range(start, stop, step) {
step = stop < start ? -1 : 1;
var length = Math.max(Math.ceil((stop - start) / step), 0);
var range = Array(length);
for (var idx = 0; idx < length; idx++, start += step) {
// Chunk a single array into multiple arrays, each containing `count` or fewer
function chunk(array, count) {
if (count == null || count < 1) return [];
var i = 0, length = array.length;
result.push(slice.call(array, i, i += count));
// Helper function to continue chaining intermediate results.
function chainResult(instance, obj) {
return instance._chain ? _$1(obj).chain() : obj;
// Add your own custom functions to the Underscore object.
each(functions(obj), function(name) {
var func = _$1[name] = obj[name];
_$1.prototype[name] = function() {
var args = [this._wrapped];
push.apply(args, arguments);
return chainResult(this, func.apply(_$1, args));
// Add all mutator `Array` functions to the wrapper.
each(['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift'], function(name) {
var method = ArrayProto[name];
_$1.prototype[name] = function() {
method.apply(obj, arguments);
if ((name === 'shift' || name === 'splice') && obj.length === 0) {
return chainResult(this, obj);
// Add all accessor `Array` functions to the wrapper.
each(['concat', 'join', 'slice'], function(name) {
var method = ArrayProto[name];
_$1.prototype[name] = function() {
if (obj != null) obj = method.apply(obj, arguments);
return chainResult(this, obj);
restArguments: restArguments,
isUndefined: isUndefined,
isArrayBuffer: isArrayBuffer,
isDataView: isDataView$1,
isFunction: isFunction$1,
isArguments: isArguments$1,
isTypedArray: isTypedArray$1,
templateSettings: templateSettings,
findLastIndex: findLastIndex,
sortedIndex: sortedIndex,
lastIndexOf: lastIndexOf,
reduceRight: reduceRight,