Socket
Socket
Sign inDemoInstall

string-repeat

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc