# trim-newlines

> Trim newlines from the start and/or end of a string

Latest version **5.0.0** (published 2023-03-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install trim-newlines
pnpm add trim-newlines
yarn add trim-newlines
bun add trim-newlines
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2023-03-20 |
| First published | 2015-09-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=14.16 |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | trim, newline, newlines, linebreak, lf, crlf, left, right, start, end, string, remove, delete, strip |

## Links

- npm: https://www.npmjs.com/package/trim-newlines
- Repository: https://github.com/sindresorhus/trim-newlines
- Homepage: https://github.com/sindresorhus/trim-newlines#readme
- Issues: https://github.com/sindresorhus/trim-newlines/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/trim-newlines

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2023-03-20
- 3.0.1 (3-0-1) — 2021-05-28
- 4.1.1 — 2023-03-20
- 4.1.0 — 2023-03-20
- 4.0.2 — 2021-06-10
- 4.0.1 — 2021-05-28
- 4.0.0 — 2021-04-21
- 3.0.0 — 2019-04-29
- 2.0.0 — 2017-04-22
- 1.0.0 — 2015-09-29

## README

# trim-newlines

> Trim [newlines](https://en.wikipedia.org/wiki/Newline) from the start and/or end of a string

Looking to trim all whitespace, not just newlines? Use `String#trim()`, `String#trimStart()`, or `String#trimEnd()`.

## Install

```sh
npm install trim-newlines
```

## Usage

```js
import {trimNewlines, trimNewlinesStart, trimNewlinesEnd} from 'trim-newlines';

trimNewlines('\n🦄\n🦄\r\n');
//=> '🦄\n🦄'

trimNewlinesStart('\n🦄\r\n');
//=> '🦄\r\n'

trimNewlinesEnd('\n🦄\r\n');
//=> '\n🦄'
```

## API

### trimNewlines(string)

Trim from the start and end of a string.

### trimNewlinesStart(string)

Trim from the start of a string.

### trimNewlinesEnd(string)

Trim from the end of a string.

---
_Source: https://npm.io/package/trim-newlines · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
