summaryrefslogtreecommitdiff
path: root/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js')
-rw-r--r--tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js b/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js
new file mode 100644
index 0000000000..0a3928b2c0
--- /dev/null
+++ b/tools/eslint/node_modules/escope/node_modules/es6-map/node_modules/es5-ext/string/#/repeat/shim.js
@@ -0,0 +1,22 @@
+// Thanks: http://www.2ality.com/2014/01/efficient-string-repeat.html
+
+'use strict';
+
+var value = require('../../../object/valid-value')
+ , toInteger = require('../../../number/to-integer');
+
+module.exports = function (count) {
+ var str = String(value(this)), result;
+ count = toInteger(count);
+ if (count < 0) throw new RangeError("Count must be >= 0");
+ if (!isFinite(count)) throw new RangeError("Count must be < ∞");
+ result = '';
+ if (!count) return result;
+ while (true) {
+ if (count & 1) result += str;
+ count >>>= 1;
+ if (count <= 0) break;
+ str += str;
+ }
+ return result;
+};