# nbsp

> Replaces normal spaces with non-breaking ones

Latest version **1.0.2** (published 2018-07-23) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install nbsp
pnpm add nbsp
yarn add nbsp
bun add nbsp
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2018-07-23 |
| First published | 2018-06-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 140.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Adrian Klimek |
| Maintainers | adrianklimek |

## Links

- npm: https://www.npmjs.com/package/nbsp
- Repository: https://github.com/adrianklimek/nbsp
- Homepage: https://github.com/adrianklimek/nbsp#readme
- Issues: https://github.com/adrianklimek/nbsp/issues
- npm.io page: https://npm.io/package/nbsp

## Recent versions

- 1.0.2 (latest) — 2018-07-23
- 1.0.1 — 2018-06-11
- 1.0.0 — 2018-06-08

## README

# nbsp
Nbsp is a JavaScript module that replaces normal spaces with non-breaking ones.
The configuration allows to declare a list of words/characters which 
trailing space will be replaced with non-breaking one. It's also possible to 
replace spaces after strings that are within a chars length range.

## Installation

### Install with npm:
```
npm install nbsp
```

### Install with yarn:
```
yarn add nbsp
```

## Usage

### Basic usage
```
import nbsp from 'nbsp'

document.addEventListener('DOMContentLoaded', () => {
  const textElement = document.querySelector('p')
  nbsp(textElement)
})
```

### Parameters
| Name    | Description       | Type   | Default                  |
| ------- | ----------------- | ------ | ------------------------ |
| text | a source element or a plain text | HTMLelement, String | - |
| opts | - | Object | - |
| opts.words | replace a space after any of this words/characters | Array | [] |
| opts.min | replace a space after any string within the min-max range | Number | 0 |
| opts.max | replace a space after any string within the min-max range | Number | 0 |
| opts.removeWidows | replace a space before last word | Boolean | false |

```
import nbsp from 'nbsp'

document.addEventListener('DOMContentLoaded', () => {
  const textElement = document.querySelector('p')
  
  nbsp(textElement, {
    min: 1,
    max: 1,
    removeWidows: true
  })
})
```

If you don't want to modify element's node values you can pass element's 
content as the `text` argument.

```
import nbsp from 'nbsp'

document.addEventListener('DOMContentLoaded', () => {
  const textContent = document.querySelector('p').innerHTML
  
  const result = nbsp(textContent, {
    min: 1,
    max: 1,
    removeWidows: true
  })
})
```

## License
nbsp.js is licensed under [MIT license](https://opensource.org/licenses/MIT).

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