summaryrefslogtreecommitdiff
path: root/node_modules/locutus/php/strings/str_repeat.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/locutus/php/strings/str_repeat.js')
-rw-r--r--node_modules/locutus/php/strings/str_repeat.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/node_modules/locutus/php/strings/str_repeat.js b/node_modules/locutus/php/strings/str_repeat.js
new file mode 100644
index 0000000..b8df8a7
--- /dev/null
+++ b/node_modules/locutus/php/strings/str_repeat.js
@@ -0,0 +1,26 @@
+'use strict';
+
+module.exports = function str_repeat(input, multiplier) {
+ // eslint-disable-line camelcase
+ // discuss at: http://locutus.io/php/str_repeat/
+ // original by: Kevin van Zonneveld (http://kvz.io)
+ // improved by: Jonas Raoni Soares Silva (http://www.jsfromhell.com)
+ // improved by: Ian Carter (http://euona.com/)
+ // example 1: str_repeat('-=', 10)
+ // returns 1: '-=-=-=-=-=-=-=-=-=-='
+
+ var y = '';
+ while (true) {
+ if (multiplier & 1) {
+ y += input;
+ }
+ multiplier >>= 1;
+ if (multiplier) {
+ input += input;
+ } else {
+ break;
+ }
+ }
+ return y;
+};
+//# sourceMappingURL=str_repeat.js.map \ No newline at end of file