diff options
author | Michael Perrotte <mike@npmjs.com> | 2020-01-31 23:59:21 +0300 |
---|---|---|
committer | isaacs <i@izs.me> | 2020-05-08 04:11:51 +0300 |
commit | 56e1f868e8634a4bf0f7a7186a68a6f3de9cfb2a (patch) | |
tree | f05cdcb56d66480641b6c8f8bb823bc10c6842df /node_modules/indent-string | |
parent | 8f6b6204f9cdbfc8e2a27a1c3b3f1591ac7e0d60 (diff) |
npm-pick-manifest@6.0.0
Diffstat (limited to 'node_modules/indent-string')
-rw-r--r-- | node_modules/indent-string/index.d.ts | 42 | ||||
-rw-r--r-- | node_modules/indent-string/index.js | 35 | ||||
-rw-r--r-- | node_modules/indent-string/license | 9 | ||||
-rw-r--r-- | node_modules/indent-string/package.json | 69 | ||||
-rw-r--r-- | node_modules/indent-string/readme.md | 70 |
5 files changed, 225 insertions, 0 deletions
diff --git a/node_modules/indent-string/index.d.ts b/node_modules/indent-string/index.d.ts new file mode 100644 index 000000000..118523115 --- /dev/null +++ b/node_modules/indent-string/index.d.ts @@ -0,0 +1,42 @@ +declare namespace indentString { + interface Options { + /** + The string to use for the indent. + + @default ' ' + */ + readonly indent?: string; + + /** + Also indent empty lines. + + @default false + */ + readonly includeEmptyLines?: boolean; + } +} + +/** +Indent each line in a string. + +@param string - The string to indent. +@param count - How many times you want `options.indent` repeated. Default: `1`. + +@example +``` +import indentString = require('indent-string'); + +indentString('Unicorns\nRainbows', 4); +//=> ' Unicorns\n Rainbows' + +indentString('Unicorns\nRainbows', 4, {indent: '♥'}); +//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows' +``` +*/ +declare function indentString( + string: string, + count?: number, + options?: indentString.Options +): string; + +export = indentString; diff --git a/node_modules/indent-string/index.js b/node_modules/indent-string/index.js new file mode 100644 index 000000000..e1ab804f2 --- /dev/null +++ b/node_modules/indent-string/index.js @@ -0,0 +1,35 @@ +'use strict'; + +module.exports = (string, count = 1, options) => { + options = { + indent: ' ', + includeEmptyLines: false, + ...options + }; + + if (typeof string !== 'string') { + throw new TypeError( + `Expected \`input\` to be a \`string\`, got \`${typeof string}\`` + ); + } + + if (typeof count !== 'number') { + throw new TypeError( + `Expected \`count\` to be a \`number\`, got \`${typeof count}\`` + ); + } + + if (typeof options.indent !== 'string') { + throw new TypeError( + `Expected \`options.indent\` to be a \`string\`, got \`${typeof options.indent}\`` + ); + } + + if (count === 0) { + return string; + } + + const regex = options.includeEmptyLines ? /^/gm : /^(?!\s*$)/gm; + + return string.replace(regex, options.indent.repeat(count)); +}; diff --git a/node_modules/indent-string/license b/node_modules/indent-string/license new file mode 100644 index 000000000..e7af2f771 --- /dev/null +++ b/node_modules/indent-string/license @@ -0,0 +1,9 @@ +MIT License + +Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/indent-string/package.json b/node_modules/indent-string/package.json new file mode 100644 index 000000000..c681a4ac1 --- /dev/null +++ b/node_modules/indent-string/package.json @@ -0,0 +1,69 @@ +{ + "_from": "indent-string@^4.0.0", + "_id": "indent-string@4.0.0", + "_inBundle": false, + "_integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "_location": "/indent-string", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "indent-string@^4.0.0", + "name": "indent-string", + "escapedName": "indent-string", + "rawSpec": "^4.0.0", + "saveSpec": null, + "fetchSpec": "^4.0.0" + }, + "_requiredBy": [ + "/aggregate-error" + ], + "_resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "_shasum": "624f8f4497d619b2d9768531d58f4122854d7251", + "_spec": "indent-string@^4.0.0", + "_where": "/Users/mperrotte/npminc/cli/node_modules/aggregate-error", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/indent-string/issues" + }, + "bundleDependencies": false, + "deprecated": false, + "description": "Indent each line in a string", + "devDependencies": { + "ava": "^1.4.1", + "tsd": "^0.7.2", + "xo": "^0.24.0" + }, + "engines": { + "node": ">=8" + }, + "files": [ + "index.js", + "index.d.ts" + ], + "homepage": "https://github.com/sindresorhus/indent-string#readme", + "keywords": [ + "indent", + "string", + "pad", + "align", + "line", + "text", + "each", + "every" + ], + "license": "MIT", + "name": "indent-string", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/indent-string.git" + }, + "scripts": { + "test": "xo && ava && tsd" + }, + "version": "4.0.0" +} diff --git a/node_modules/indent-string/readme.md b/node_modules/indent-string/readme.md new file mode 100644 index 000000000..49967de07 --- /dev/null +++ b/node_modules/indent-string/readme.md @@ -0,0 +1,70 @@ +# indent-string [![Build Status](https://travis-ci.org/sindresorhus/indent-string.svg?branch=master)](https://travis-ci.org/sindresorhus/indent-string) + +> Indent each line in a string + + +## Install + +``` +$ npm install indent-string +``` + + +## Usage + +```js +const indentString = require('indent-string'); + +indentString('Unicorns\nRainbows', 4); +//=> ' Unicorns\n Rainbows' + +indentString('Unicorns\nRainbows', 4, {indent: '♥'}); +//=> '♥♥♥♥Unicorns\n♥♥♥♥Rainbows' +``` + + +## API + +### indentString(string, [count], [options]) + +#### string + +Type: `string` + +The string to indent. + +#### count + +Type: `number`<br> +Default: `1` + +How many times you want `options.indent` repeated. + +#### options + +Type: `object` + +##### indent + +Type: `string`<br> +Default: `' '` + +The string to use for the indent. + +##### includeEmptyLines + +Type: `boolean`<br> +Default: `false` + +Also indent empty lines. + + +## Related + +- [indent-string-cli](https://github.com/sindresorhus/indent-string-cli) - CLI for this module +- [strip-indent](https://github.com/sindresorhus/strip-indent) - Strip leading whitespace from every line in a string + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) |