Initial commit
[yaffs-website] / node_modules / repeating / index.js
1 'use strict';
2 var isFinite = require('is-finite');
3
4 module.exports = function (str, n) {
5         if (typeof str !== 'string') {
6                 throw new TypeError('Expected `input` to be a string');
7         }
8
9         if (n < 0 || !isFinite(n)) {
10                 throw new TypeError('Expected `count` to be a positive finite number');
11         }
12
13         var ret = '';
14
15         do {
16                 if (n & 1) {
17                         ret += str;
18                 }
19
20                 str += str;
21         } while ((n >>= 1));
22
23         return ret;
24 };