mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Use references to String#replace and String#split.
This commit is contained in:
11
lodash.js
11
lodash.js
@@ -1381,7 +1381,8 @@
|
|||||||
|
|
||||||
/** Used for built-in method references. */
|
/** Used for built-in method references. */
|
||||||
var arrayProto = context.Array.prototype,
|
var arrayProto = context.Array.prototype,
|
||||||
objectProto = context.Object.prototype;
|
objectProto = context.Object.prototype,
|
||||||
|
stringProto = context.String.prototype;
|
||||||
|
|
||||||
/** Used to resolve the decompiled source of functions. */
|
/** Used to resolve the decompiled source of functions. */
|
||||||
var funcToString = context.Function.prototype.toString;
|
var funcToString = context.Function.prototype.toString;
|
||||||
@@ -1436,7 +1437,9 @@
|
|||||||
nativeMin = Math.min,
|
nativeMin = Math.min,
|
||||||
nativeParseInt = context.parseInt,
|
nativeParseInt = context.parseInt,
|
||||||
nativeRandom = Math.random,
|
nativeRandom = Math.random,
|
||||||
nativeReverse = arrayProto.reverse;
|
nativeReplace = stringProto.replace,
|
||||||
|
nativeReverse = arrayProto.reverse,
|
||||||
|
nativeSplit = stringProto.split;
|
||||||
|
|
||||||
/* Built-in method references that are verified to be native. */
|
/* Built-in method references that are verified to be native. */
|
||||||
var DataView = getNative(context, 'DataView'),
|
var DataView = getNative(context, 'DataView'),
|
||||||
@@ -13513,7 +13516,7 @@
|
|||||||
var args = arguments,
|
var args = arguments,
|
||||||
string = toString(args[0]);
|
string = toString(args[0]);
|
||||||
|
|
||||||
return args.length < 3 ? string : string.replace(args[1], args[2]);
|
return args.length < 3 ? string : nativeReplace.call(string, args[1], args[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -13578,7 +13581,7 @@
|
|||||||
return castSlice(stringToArray(string), 0, limit);
|
return castSlice(stringToArray(string), 0, limit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return string.split(separator, limit);
|
return nativeSplit.call(string, separator, limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user