Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

indent-string

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

indent-string - npm Package Compare versions

Comparing version 2.1.0 to 3.0.0

21

index.js
'use strict';
var repeating = require('repeating');
const repeating = require('repeating');
module.exports = function (str, indent, count) {
if (typeof str !== 'string' || typeof indent !== 'string') {
throw new TypeError('`string` and `indent` should be strings');
module.exports = (str, count, indent) => {
indent = indent === undefined ? ' ' : indent;
count = count === undefined ? 1 : count;
if (typeof str !== 'string') {
throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof str}\``);
}
if (count != null && typeof count !== 'number') {
throw new TypeError('`count` should be a number');
if (typeof count !== 'number') {
throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof count}\``);
}
if (typeof indent !== 'string') {
throw new TypeError(`Expected \`indent\` to be a \`string\`, got \`${typeof indent}\``);
}
if (count === 0) {

@@ -17,5 +24,5 @@ return str;

indent = count > 1 ? repeating(indent, count) : indent;
indent = count > 1 ? repeating(count, indent) : indent;
return str.replace(/^(?!\s*$)/mg, indent);
};
{
"name": "indent-string",
"version": "2.1.0",
"version": "3.0.0",
"description": "Indent each line in a string",

@@ -13,6 +13,6 @@ "license": "MIT",

"engines": {
"node": ">=0.10.0"
"node": ">=4"
},
"scripts": {
"test": "mocha"
"test": "xo && ava"
},

@@ -32,7 +32,11 @@ "files": [

"dependencies": {
"repeating": "^2.0.0"
"repeating": "^3.0.0"
},
"devDependencies": {
"mocha": "*"
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
}

@@ -16,7 +16,11 @@ # indent-string [![Build Status](https://travis-ci.org/sindresorhus/indent-string.svg?branch=master)](https://travis-ci.org/sindresorhus/indent-string)

```js
var indentString = require('indent-string');
const indentString = require('indent-string');
indentString('Unicorns\nRainbows', '♥', 4);
//=> ♥♥♥♥Unicorns
//=> ♥♥♥♥Rainbows
indentString('Unicorns\nRainbows', 4);
//=> ' Unicorns'
//=> ' Rainbows'
indentString('Unicorns\nRainbows', 4, '♥');
//=> '♥♥♥♥Unicorns'
//=> '♥♥♥♥Rainbows'
```

@@ -27,21 +31,13 @@

### indentString(string, indent, count)
### indentString(input, [count], [indent])
#### string
#### input
**Required**
Type: `string`
The string you want to indent.
String you want to indent.
#### indent
**Required**
Type: `string`
The string to use for the indent.
#### count
Type: `number`
Type: `number`<br>
Default: `1`

@@ -51,3 +47,10 @@

#### indent
Type: `string`<br>
Default: `' '`
String to use for the indent.
## Related

@@ -61,2 +64,2 @@

MIT © [Sindre Sorhus](http://sindresorhus.com)
MIT © [Sindre Sorhus](https://sindresorhus.com)
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc