项目原始demo,不改动
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
 
 

13 lines
373 B

  1. 'use strict';
  2. var toInteger = require('./_to-integer');
  3. var defined = require('./_defined');
  4. module.exports = function repeat(count) {
  5. var str = String(defined(this));
  6. var res = '';
  7. var n = toInteger(count);
  8. if (n < 0 || n == Infinity) throw RangeError("Count can't be negative");
  9. for (;n > 0; (n >>>= 1) && (str += str)) if (n & 1) res += str;
  10. return res;
  11. };