# condense-newlines

> Replace extraneous newlines with a single newline, or pass a specified number of newlines to use.

Latest version **0.2.1** (published 2016-04-23) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2016-04-23 |
| First published | 2014-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert, doowb |
| Keywords | docs, documentation, generate, generator, markdown, templates, verb |

## Links

- npm: https://www.npmjs.com/package/condense-newlines
- Repository: https://github.com/jonschlinkert/condense-newlines
- Issues: https://github.com/jonschlinkert/condense-newlines/issues
- npm.io page: https://npm.io/package/condense-newlines

## Dependencies (3)

- [kind-of](https://npm.io/package/kind-of.md) ^3.0.2
- [is-whitespace](https://npm.io/package/is-whitespace.md) ^0.3.0
- [extend-shallow](https://npm.io/package/extend-shallow.md) ^2.0.1

## Alternatives

- [@cantoo/pdf-lib](https://npm.io/package/@cantoo/pdf-lib.md) — 297.9K weekly downloads
- [datatables.net-buttons](https://npm.io/package/datatables.net-buttons.md) — 200.1K weekly downloads
- [@ckeditor/ckeditor5-export-pdf](https://npm.io/package/@ckeditor/ckeditor5-export-pdf.md) — 167.0K weekly downloads
- [scanbot-web-sdk](https://npm.io/package/scanbot-web-sdk.md) — 15.0K weekly downloads
- [@syncfusion/ej2-angular-pdfviewer](https://npm.io/package/@syncfusion/ej2-angular-pdfviewer.md) — 8.8K weekly downloads

## Recent versions

- 0.2.1 (latest) — 2016-04-23
- 0.2.0 — 2016-03-08
- 0.1.0 — 2014-07-12

## README

# condense-newlines [![NPM version](https://img.shields.io/npm/v/condense-newlines.svg?style=flat)](https://www.npmjs.com/package/condense-newlines) [![NPM downloads](https://img.shields.io/npm/dm/condense-newlines.svg?style=flat)](https://npmjs.org/package/condense-newlines) [![Build Status](https://img.shields.io/travis/jonschlinkert/condense-newlines.svg?style=flat)](https://travis-ci.org/jonschlinkert/condense-newlines)

Replace extraneous newlines with a single newline, or pass a specified number of newlines to use.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ npm install condense-newlines --save
```

## Usage

```js
var condense = require('condense-newlines');
console.log(condense('\n\na\n\n\nb\nc\r\n\r\nd\n\n\n'));
//=> '\na\nb\nc\nd\n';
```

## Options

### options.sep

Specify the separator to use

```js
console.log(condense('\n\na\n\n\nb\nc\r\n\r\nd\n\n\n', {sep: '\n\n'}));
//=> '\n\na\n\nb\n\nc\n\nd\n\n';
```

### options.min

The minimum number of consecutive newlines to condense.

**Default**

: `2`

```js
console.log(condense('\n\na\n\n\nb\nc\r\n\r\nd\n\n\n', {min: 2}));
//=> '\n\na\n\nb\n\nc\n\nd\n\n';
```

### options.keepWhitespace

Don't treat whitespace-only lines as newlines.

```js
console.log(condense('\n\na\n\n      \nb\nc\r\n\r\nd\n\n\n', {
  keepWhitespace: true, sep: '\n\n'
}));

//=> '\n\na\n\n      \nb\n\nc\n\nd\n\n';
```

## Related projects

You might also be interested in these projects:

* [arr-union](https://www.npmjs.com/package/arr-union): Combines a list of arrays, returning a single array with unique values, using strict equality… [more](https://www.npmjs.com/package/arr-union) | [homepage](https://github.com/jonschlinkert/arr-union)
* [array-unique](https://www.npmjs.com/package/array-unique): Return an array free of duplicate values. Fastest ES5 implementation. | [homepage](https://github.com/jonschlinkert/array-unique)
* [arrayify-compact](https://www.npmjs.com/package/arrayify-compact): Casts the given value to a flatten array, and removes falsey items (similar to lodash… [more](https://www.npmjs.com/package/arrayify-compact) | [homepage](https://github.com/jonschlinkert/arrayify-compact)

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/condense-newlines/issues/new).

## Building docs

Generate readme and API documentation with [verb](https://github.com/verbose/verb):

```sh
$ npm install verb && npm run docs
```

Or, if [verb](https://github.com/verbose/verb) is installed globally:

```sh
$ verb
```

## Running tests

Install dev dependencies:

```sh
$ npm install -d && npm test
```

## Author

**Jon Schlinkert**

* [github/jonschlinkert](https://github.com/jonschlinkert)
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT license](https://github.com/jonschlinkert/condense-newlines/blob/master/LICENSE).

***

_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 23, 2016._

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