aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es5-ext/string/#/repeat
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
committerFlorian Dold <florian.dold@gmail.com>2017-12-10 21:51:33 +0100
commit0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch)
treef9864d4a4148621378958794cbbfdc2393733283 /node_modules/es5-ext/string/#/repeat
parent6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff)
upgrade dependencies
Diffstat (limited to 'node_modules/es5-ext/string/#/repeat')
-rw-r--r--node_modules/es5-ext/string/#/repeat/shim.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/node_modules/es5-ext/string/#/repeat/shim.js b/node_modules/es5-ext/string/#/repeat/shim.js
index 7b8d8fbed..ac259a83b 100644
--- a/node_modules/es5-ext/string/#/repeat/shim.js
+++ b/node_modules/es5-ext/string/#/repeat/shim.js
@@ -1,6 +1,6 @@
-/* eslint no-bitwise: "off" */
-
-// Thanks: http://www.2ality.com/2014/01/efficient-string-repeat.html
+// Thanks
+// @rauchma http://www.2ality.com/2014/01/efficient-string-repeat.html
+// @mathiasbynens https://github.com/mathiasbynens/String.prototype.repeat/blob/4a4b567def/repeat.js
"use strict";
@@ -12,11 +12,13 @@ module.exports = function (count) {
count = toInteger(count);
if (count < 0) throw new RangeError("Count must be >= 0");
if (!isFinite(count)) throw new RangeError("Count must be < ∞");
- if (!count) return "";
- if (count === 1) return str;
result = "";
- if (count & 1) result += str;
- while ((count >>>= 1)) str += str;
- return result + str;
+ while (count) {
+ if (count % 2) result += str;
+ if (count > 1) str += str;
+ // eslint-disable-next-line no-bitwise
+ count >>= 1;
+ }
+ return result;
};