string-repeat
Advanced tools
Comparing version 1.0.3 to 1.1.0
32
index.js
@@ -1,14 +0,24 @@ | ||
module.exports = function(input, times) { | ||
var inputType = typeof input; | ||
var nativeRepeat = String.prototype.repeat; | ||
if(inputType !== 'string') throw new TypeError('Expected a string, saw ' + inputType); | ||
if(times < 0) throw new TypeError('Expected a positive integer'); | ||
module.exports = (function() { | ||
if (typeof nativeRepeat === 'function') { | ||
return function(input, times) { | ||
return input.repeat(times); | ||
}; | ||
} else { | ||
return function(input, times) { | ||
var inputType = typeof input; | ||
var ret = ''; | ||
if(input.length === 1) return input; | ||
if(input.length === 2) return input + input; | ||
for(var i = 0; i < times; i++) { | ||
ret += input; | ||
if(inputType !== 'string') throw new TypeError('Expected a string, saw ' + inputType); | ||
if(times < 0) throw new TypeError('Expected a positive integer'); | ||
var ret = ''; | ||
if(times === 1) return input; | ||
if(times === 2) return input + input; | ||
for(var i = 0; i < times; i++) { | ||
ret += input; | ||
} | ||
return ret; | ||
}; | ||
} | ||
return ret; | ||
}; | ||
})(); |
{ | ||
"name": "string-repeat", | ||
"version": "1.0.3", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/SassyCrafter/string-repeat" | ||
}, | ||
"version": "1.1.0", | ||
"description": "Repeat a string", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"test": "tape test.js" | ||
}, | ||
@@ -21,3 +17,6 @@ "keywords": [ | ||
"author": "Maximilian Lloyd <me@maxlloyd.no>", | ||
"license": "MIT" | ||
"license": "MIT", | ||
"devDependencies": { | ||
"tape": "~4.0.1" | ||
} | ||
} |
@@ -0,4 +1,6 @@ | ||
[Imgur](http://i.imgur.com/eml1orV.png?1) | ||
## Install | ||
``` | ||
$ npm install --save string-repeat | ||
$ npm install --save repeat | ||
``` | ||
@@ -30,3 +32,8 @@ | ||
## Patch notes: 1.1.0 | ||
Bug fixes and other improvements have been made, a logo has also been added | ||
## License | ||
MIT ©[Maximilian Lloyd](http://www.maxlloyd.no) |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
1715
21
1
39
1
1