repeat-string
Advanced tools
Comparing version
20
index.js
/*! | ||
* repeat-string <https://github.com/jonschlinkert/repeat-string> | ||
* | ||
* Copyright (c) 2014 Jon Schlinkert, contributors. | ||
* Copyright (c) 2014-2015 Jon Schlinkert, contributors. | ||
* Licensed under the MIT License | ||
@@ -10,3 +10,3 @@ */ | ||
module.exports = function repeat(str, count) { | ||
module.exports = function repeat(str, num) { | ||
if (typeof str !== 'string') { | ||
@@ -16,15 +16,13 @@ throw new TypeError('repeat-string expects a string.'); | ||
if (count < 1) { | ||
return ''; | ||
} | ||
var res = ''; | ||
var result = ''; | ||
while (count > 0) { | ||
if (count & 1) { | ||
result += str; | ||
while (num) { | ||
if (num & 1) { | ||
res += str; | ||
} | ||
count >>= 1; | ||
num >>= 1; | ||
str += str; | ||
} | ||
return result; | ||
return res; | ||
}; |
{ | ||
"name": "repeat-string", | ||
"description": "Repeat the given string, n times.", | ||
"version": "0.2.2", | ||
"description": "Fastest implementation for repeating a string.", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/jonschlinkert/repeat-string", | ||
@@ -17,8 +17,6 @@ "author": { | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "https://github.com/jonschlinkert/repeat-string/blob/master/LICENSE-MIT" | ||
} | ||
], | ||
"license": { | ||
"type": "MIT", | ||
"url": "https://github.com/jonschlinkert/repeat-string/blob/master/LICENSE-MIT" | ||
}, | ||
"main": "index.js", | ||
@@ -32,13 +30,26 @@ "engines": { | ||
"devDependencies": { | ||
"chai": "~1.9.1", | ||
"should": "^4.0.4", | ||
"verb": "^0.2.15" | ||
"should": "^4.0.4" | ||
}, | ||
"keywords": [ | ||
"fill", | ||
"javascript", | ||
"js", | ||
"left", | ||
"left-pad", | ||
"multiple", | ||
"node.js", | ||
"pad", | ||
"padding", | ||
"repeat", | ||
"repeating", | ||
"right", | ||
"right-pad", | ||
"str", | ||
"string", | ||
"times" | ||
"text", | ||
"times", | ||
"util", | ||
"utility", | ||
"utils" | ||
] | ||
} |
# repeat-string [](http://badge.fury.io/js/repeat-string) | ||
> Repeat the given string, n times. | ||
> Fastest implementation for repeating a string. | ||
## Install | ||
#### Install with [npm](npmjs.org) | ||
## Install with [npm](npmjs.org) | ||
@@ -11,3 +10,3 @@ ```bash | ||
``` | ||
#### Install with [bower](https://github.com/bower/bower) | ||
### Install with [bower](https://github.com/bower/bower) | ||
@@ -33,2 +32,3 @@ ```bash | ||
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
### Other javascript/node.js utils | ||
@@ -63,3 +63,3 @@ | ||
## License | ||
Copyright (c) 2014 Jon Schlinkert, contributors. | ||
Copyright (c) 2014 Jon Schlinkert | ||
Released under the MIT license | ||
@@ -69,2 +69,2 @@ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 01, 2014._ | ||
_This file was generated by [verb](https://github.com/assemble/verb) on December 06, 2014. To update, run `npm i -g verb && verb`._ |
/*! | ||
* repeat-string <https://github.com/jonschlinkert/repeat-string> | ||
* | ||
* Copyright (c) 2014 Jon Schlinkert, contributors. | ||
* Copyright (c) 2014 Jon Schlinkert | ||
* Licensed under the MIT License | ||
@@ -10,3 +10,2 @@ */ | ||
var assert = require('assert'); | ||
var should = require('should'); | ||
@@ -13,0 +12,0 @@ var repeat = require('./'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
-66.67%0
-100%9159
-0.15%60
-6.25%