pax_global_header00006660000000000000000000000064134555065320014522gustar00rootroot0000000000000052 comment=b537c94fd8376e4205146fbbef0bc08a477c5eab strip-indent-3.0.0/000077500000000000000000000000001345550653200141425ustar00rootroot00000000000000strip-indent-3.0.0/.editorconfig000066400000000000000000000002571345550653200166230ustar00rootroot00000000000000root = 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 strip-indent-3.0.0/.gitattributes000066400000000000000000000000231345550653200170300ustar00rootroot00000000000000* text=auto eol=lf strip-indent-3.0.0/.gitignore000066400000000000000000000000271345550653200161310ustar00rootroot00000000000000node_modules yarn.lock strip-indent-3.0.0/.npmrc000066400000000000000000000000231345550653200152550ustar00rootroot00000000000000package-lock=false strip-indent-3.0.0/.travis.yml000066400000000000000000000000541345550653200162520ustar00rootroot00000000000000language: node_js node_js: - '10' - '8' strip-indent-3.0.0/index.d.ts000066400000000000000000000006321345550653200160440ustar00rootroot00000000000000/** Strip leading whitespace from each line in a string. The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove. @example ``` import stripIndent = require('strip-indent'); const string = '\tunicorn\n\t\tcake'; // unicorn // cake stripIndent(string); //unicorn // cake ``` */ declare function stripIndent(string: string): string; export = stripIndent; strip-indent-3.0.0/index.js000066400000000000000000000004011345550653200156020ustar00rootroot00000000000000'use strict'; const minIndent = require('min-indent'); module.exports = string => { const indent = minIndent(string); if (indent === 0) { return string; } const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm'); return string.replace(regex, ''); }; strip-indent-3.0.0/index.test-d.ts000066400000000000000000000001741345550653200170220ustar00rootroot00000000000000import {expectType} from 'tsd'; import stripIndent = require('.'); expectType(stripIndent('\tunicorn\n\t\tcake')); strip-indent-3.0.0/license000066400000000000000000000021251345550653200155070ustar00rootroot00000000000000MIT 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. strip-indent-3.0.0/package.json000066400000000000000000000012651345550653200164340ustar00rootroot00000000000000{ "name": "strip-indent", "version": "3.0.0", "description": "Strip leading whitespace from each line in a string", "license": "MIT", "repository": "sindresorhus/strip-indent", "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": [ "strip", "indent", "indentation", "normalize", "remove", "delete", "whitespace", "space", "tab", "string" ], "dependencies": { "min-indent": "^1.0.0" }, "devDependencies": { "ava": "^1.4.1", "tsd": "^0.7.2", "xo": "^0.24.0" } } strip-indent-3.0.0/readme.md000066400000000000000000000015131345550653200157210ustar00rootroot00000000000000# strip-indent [![Build Status](https://travis-ci.org/sindresorhus/strip-indent.svg?branch=master)](https://travis-ci.org/sindresorhus/strip-indent) > Strip leading whitespace from each line in a string The line with the least number of leading whitespace, ignoring empty lines, determines the number to remove. Useful for removing redundant indentation. ## Install ``` $ npm install strip-indent ``` ## Usage ```js const stripIndent = require('strip-indent'); const string = '\tunicorn\n\t\tcake'; /* unicorn cake */ stripIndent(string); /* unicorn cake */ ``` ## Related - [strip-indent-cli](https://github.com/sindresorhus/strip-indent-cli) - CLI for this module - [indent-string](https://github.com/sindresorhus/indent-string) - Indent each line in a string ## License MIT © [Sindre Sorhus](https://sindresorhus.com) strip-indent-3.0.0/test.js000066400000000000000000000010241345550653200154540ustar00rootroot00000000000000import test from 'ava'; import stripIndent from '.'; test('main', t => { t.is(stripIndent('\nunicorn\n'), '\nunicorn\n'); t.is(stripIndent('\n unicorn\n'), '\nunicorn\n'); t.is(stripIndent('\t\t\n\t\t\n\t\t\t\n\n\n\n\t\t\t\t

Hello world!

\n\t\t\t\n\t\t'), '\n\n\t\n\n\n\n\t\t

Hello world!

\n\t\n'); t.is(stripIndent('\n\t\n\t\tunicorn\n\n\n\n\t\t\tunicorn'), '\n\t\nunicorn\n\n\n\n\tunicorn', 'ignore whitespace only lines'); });