# selective-whitespace

> Condense all string whitespace + options to preserve specific whitespace characters.

Latest version **1.0.4** (published 2016-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install selective-whitespace
pnpm add selective-whitespace
yarn add selective-whitespace
bun add selective-whitespace
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2016-05-03 |
| First published | 2015-12-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Michael Wuergler |
| Maintainers | radiovisual |
| Keywords | trim, strip, condense, whitespace, characters, all, options, preserve, keep, tabs, newlines, newline, return, character, selective, choose, tab, \n, \r, \s |

## Links

- npm: https://www.npmjs.com/package/selective-whitespace
- Repository: https://github.com/radiovisual/selective-whitespace
- Homepage: https://github.com/radiovisual/selective-whitespace#readme
- Issues: https://github.com/radiovisual/selective-whitespace/issues
- npm.io page: https://npm.io/package/selective-whitespace

## Dependencies (1)

- [tokenize-whitespace](https://npm.io/package/tokenize-whitespace.md) 0.0.1

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.4 (latest) — 2016-05-03
- 1.0.3 — 2016-03-04
- 1.0.2 — 2016-02-01
- 1.0.1 — 2016-01-28
- 1.0.0 — 2015-12-17
- 0.0.1 — 2015-12-06

## README

# selective-whitespace [![Build Status](https://travis-ci.org/radiovisual/selective-whitespace.svg)](https://travis-ci.org/radiovisual/selective-whitespace)

> Condense all whitespace in a string, with options to preserve specific whitespace characters.

## Install

```
$ npm install --save selective-whitespace
```


## Usage

```js
var selectiveWhitespace = require('selective-whitespace');

// Condense all whitespace (including \t\n\r)
selectiveWhitespace('  FOO      BAR    BAZ ');
//=> 'FOO BAR BAZ'

// Condense all whitespace (keep newlines)
selectiveWhitespace('FOO\n   BAR\n   BAZ\n ', {keep: '\n'});
//=> 'FOO\n BAR\n BAZ\n'

// Condense all whitespace (keep tabs)
selectiveWhitespace('\tFOO     \tBAR      \tBAZ', {keep: '\t'});
//=> '\tFOO \tBAR \tBAZ'

// Condense all whitespace (keep tabs and newlines)
selectiveWhitespace('\n\tFOO     \n\tBAR      \n\tBAZ', {keep: '\t,\n'});
//=> '\n\tFOO \n\tBAR \n\tBAZ'

// Strip all whitespace characters
selectiveWhitespace('\t\nFOO     \t\nBAR      \t\nBAZ', {stripAll:true});
//=> 'FOOBARBAZ'
```


## API

### selectiveWhitespace(str, [options]);

#### str

*Required*    
Type: `string`    

The string you want to condense.

#### options
 
Type: `object`  

Set or override the default options.
  
##### keep
 
Type: `string`  
options: `\n\t\r`  

Comma or pipe-delimited list of values to preserve. You can preserve newlines `\n`, tabs `\t` or return characters `\r`. 

##### stripAll 

Type: `Boolean`  
Default: `false`  
  
`stripAll` mode will remove **all** whitespace characters from the string.



## License

MIT © [Michael Wuergler](http://numetriclabs.com)

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