mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 20:07:49 +00:00
Add comments to _.escape and _.repeat. [ci skip]
This commit is contained in:
@@ -7792,6 +7792,7 @@
|
|||||||
* // => 'fred, barney, & pebbles'
|
* // => 'fred, barney, & pebbles'
|
||||||
*/
|
*/
|
||||||
function escape(string) {
|
function escape(string) {
|
||||||
|
// reset `lastIndex` because in IE < 9 `String#replace` does not
|
||||||
string = string == null ? '' : String(string);
|
string = string == null ? '' : String(string);
|
||||||
return (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string))
|
return (reUnescapedHtml.lastIndex = 0, reUnescapedHtml.test(string))
|
||||||
? string.replace(reUnescapedHtml, escapeHtmlChar)
|
? string.replace(reUnescapedHtml, escapeHtmlChar)
|
||||||
@@ -7967,6 +7968,9 @@
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
string = String(string);
|
string = String(string);
|
||||||
|
|
||||||
|
// leverage the exponentiation by squaring algorithm for a faster repeat
|
||||||
|
// http://en.wikipedia.org/wiki/Exponentiation_by_squaring
|
||||||
do {
|
do {
|
||||||
if (n % 2) {
|
if (n % 2) {
|
||||||
result += string;
|
result += string;
|
||||||
|
|||||||
Reference in New Issue
Block a user