pax_global_header00006660000000000000000000000064134605235010014511gustar00rootroot0000000000000052 comment=3c13601b64ced8957f15b6a4c288afcc97a2f402 redent-3.0.0/000077500000000000000000000000001346052350100127725ustar00rootroot00000000000000redent-3.0.0/.editorconfig000066400000000000000000000002571346052350100154530ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 redent-3.0.0/.gitattributes000066400000000000000000000000231346052350100156600ustar00rootroot00000000000000* text=auto eol=lf redent-3.0.0/.gitignore000066400000000000000000000000271346052350100147610ustar00rootroot00000000000000node_modules yarn.lock redent-3.0.0/.npmrc000066400000000000000000000000231346052350100141050ustar00rootroot00000000000000package-lock=false redent-3.0.0/.travis.yml000066400000000000000000000000651346052350100151040ustar00rootroot00000000000000language: node_js node_js: - '12' - '10' - '8' redent-3.0.0/index.d.ts000066400000000000000000000012041346052350100146700ustar00rootroot00000000000000import {Options as IndentStringOptions} from 'indent-string'; declare namespace redent { type Options = IndentStringOptions; } /** [Strip redundant indentation](https://github.com/sindresorhus/strip-indent) and [indent the string](https://github.com/sindresorhus/indent-string). @param string - The string to normalize indentation. @param count - How many times you want `options.indent` repeated. Default: `0`. @example ``` import redent = require('redent'); redent('\n foo\n bar\n', 1); //=> '\n foo\n bar\n' ``` */ declare function redent( string: string, count?: number, options?: redent.Options ): string; export = redent; redent-3.0.0/index.js000066400000000000000000000003171346052350100144400ustar00rootroot00000000000000'use strict'; const stripIndent = require('strip-indent'); const indentString = require('indent-string'); module.exports = (string, count = 0, options) => indentString(stripIndent(string), count, options); redent-3.0.0/index.test-d.ts000066400000000000000000000005371346052350100156550ustar00rootroot00000000000000import {expectType} from 'tsd'; import redent = require('.'); const options: redent.Options = {}; expectType(redent('\n foo\n bar\n')); expectType(redent('\n foo\n bar\n', 1)); expectType(redent('\n foo\n bar\n', 1, {indent: ' '})); expectType(redent('\n foo\n bar\n', 1, {includeEmptyLines: true})); redent-3.0.0/license000066400000000000000000000021251346052350100143370ustar00rootroot00000000000000MIT License Copyright (c) Sindre Sorhus (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. redent-3.0.0/package.json000066400000000000000000000013221346052350100152560ustar00rootroot00000000000000{ "name": "redent", "version": "3.0.0", "description": "Strip redundant indentation and indent the string", "license": "MIT", "repository": "sindresorhus/redent", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=8" }, "scripts": { "test": "xo && ava && tsd" }, "files": [ "index.js", "index.d.ts" ], "keywords": [ "string", "strip", "trim", "indent", "indentation", "add", "reindent", "normalize", "remove", "whitespace", "space" ], "dependencies": { "indent-string": "^4.0.0", "strip-indent": "^3.0.0" }, "devDependencies": { "ava": "^1.4.1", "tsd": "^0.7.2", "xo": "^0.24.0" } } redent-3.0.0/readme.md000066400000000000000000000016251346052350100145550ustar00rootroot00000000000000# redent [![Build Status](https://travis-ci.org/sindresorhus/redent.svg?branch=master)](https://travis-ci.org/sindresorhus/redent) > [Strip redundant indentation](https://github.com/sindresorhus/strip-indent) and [indent the string](https://github.com/sindresorhus/indent-string) ## Install ``` $ npm install redent ``` ## Usage ```js const redent = require('redent'); redent('\n foo\n bar\n', 1); //=> '\n foo\n bar\n' ``` ## API ### redent(string, [count], [options]) #### string Type: `string` The string to normalize indentation. #### count Type: `number`
Default: `0` How many times you want `options.indent` repeated. #### options Type: `object` ##### indent Type: `string`
Default: `' '` The string to use for the indent. ##### includeEmptyLines Type: `boolean`
Default: `false` Also indent empty lines. ## License MIT © [Sindre Sorhus](https://sindresorhus.com) redent-3.0.0/test.js000066400000000000000000000005061346052350100143100ustar00rootroot00000000000000import test from 'ava'; import redent from '.'; test('main', t => { t.is(redent('\n foo\n bar\n', 1), '\n foo\n bar\n'); t.is(redent('\n foo\n bar\n', 5, {indent: '-'}), '\n-----foo\n----- bar\n'); t.is(redent('\n foo\n bar\n', 5, {indent: '-', includeEmptyLines: true}), '-----\n-----foo\n----- bar\n-----'); });