AK-21/Graphite-Industrial-Intelligence
0
1# trim-lines2 3[![Build][build-badge]][build]4[![Coverage][coverage-badge]][coverage]5[![Downloads][downloads-badge]][downloads]6[![Size][size-badge]][size]7 8Remove spaces and tabs around line breaks.9 10## Contents11 12* [What is this?](#what-is-this)13* [When should I use this?](#when-should-i-use-this)14* [Install](#install)15* [Use](#use)16* [API](#api)17 * [`trimLines(value)`](#trimlinesvalue)18* [Types](#types)19* [Compatibility](#compatibility)20* [Contribute](#contribute)21* [License](#license)22 23## What is this?24 25This package is a tiny utility that removes spaces and tabs around line endings,26keeping the line endings, and not removing whitespace at the start or end of the27string.28It might look trivial, but it’s actually pretty complex to get performant.29 30## When should I use this?31 32When you need to trim markdown-like whitespace around line endings and don’t33want to run into performance problems.34 35## Install36 37This package is [ESM only][esm].38In Node.js (version 14.14+, 16.0+, or 18.0+), install with [npm][]:39 40```sh41npm install trim-lines42```43 44In Deno with [`esm.sh`][esmsh]:45 46```js47import trimLines from 'https://esm.sh/trim-lines@3'48```49 50In browsers with [`esm.sh`][esmsh]:51 52```html53<script type="module">54 import trimLines from 'https://esm.sh/trim-lines@3?bundle'55</script>56```57 58## Use59 60```js61import {trimLines} from 'trim-lines'62 63console.log(trimLines(' foo\t\n\n bar \n\tbaz ')) // => ' foo\n\nbar\nbaz '64```65 66## API67 68This package exports the identifier `trimLines`.69There is no default export.70 71### `trimLines(value)`72 73Remove spaces and tabs around line breaks in `value` (`string`).74 75## Types76 77This package is fully typed with [TypeScript][].78It exports no additional types.79 80## Compatibility81 82This package is at least compatible with all maintained versions of Node.js.83As of now, that is Node.js 14.14+, 16.0+, and 18.0+.84It also works in Deno and modern browsers.85 86## Contribute87 88Yes please!89See [How to Contribute to Open Source][contribute].90 91## License92 93[MIT][license] © [Titus Wormer][author]94 95<!-- Definitions -->96 97[build-badge]: https://github.com/wooorm/trim-lines/workflows/main/badge.svg98 99[build]: https://github.com/wooorm/trim-lines/actions100 101[coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/trim-lines.svg102 103[coverage]: https://codecov.io/github/wooorm/trim-lines104 105[downloads-badge]: https://img.shields.io/npm/dm/trim-lines.svg106 107[downloads]: https://www.npmjs.com/package/trim-lines108 109[size-badge]: https://img.shields.io/bundlephobia/minzip/trim-lines.svg110 111[size]: https://bundlephobia.com/result?p=trim-lines112 113[npm]: https://docs.npmjs.com/cli/install114 115[license]: license116 117[author]: https://wooorm.com118 119[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c120 121[esmsh]: https://esm.sh122 123[typescript]: https://www.typescriptlang.org124 125[contribute]: https://opensource.guide/how-to-contribute/126 