# buddy-system

> Prevent single words from breaking to a new line.

Latest version **1.0.2** (published 2015-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install buddy-system
pnpm add buddy-system
yarn add buddy-system
bun add buddy-system
```

## 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.2 |
| Published | 2015-02-17 |
| First published | 2015-01-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Adam Kochanowicz |
| Maintainers | olsonpm |
| Keywords | buddy-system buddysystem buddy system concatenation orphan widow |

## Links

- npm: https://www.npmjs.com/package/buddy-system
- Repository: https://github.com/olsonpm/buddy-system
- Issues: https://github.com/olsonpm/buddy-system/issues
- npm.io page: https://npm.io/package/buddy-system

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2015-02-17
- 1.0.1 — 2015-01-26
- 1.0.0 — 2015-01-26

## README

# Buddy-System

#### Created by: [ajkochanowicz](https://github.com/ajkochanowicz)
#### [Demo](http://codepen.io/ajkochanowicz/pen/mKbtB)
#### [Demo (jQuery)](http://codepen.io/ajkochanowicz/pen/ezEmp)

Avoids single words breaking onto the last line of text.

# Install
```
npm install buddy-system
```

## Require in node (currently only supported as a jquery plugin)
```
var $ = require('jquery');
require('buddy-system')($); <----- Attaches itself to the jquery object
```

# Usage

## Without jQuery

Use dist/buddysystem.js and simply pass in an array of objects into ``buddySystem()``

    objs = document.getElementsByClassName('corrected')
    buddySystem(objs)
    
## With jQuery

Use dist/buddysystem.jquery.js after jQuery and $.buddySystem() on any element or elements.

    $('.corrected').buddySystem()
    
# How it works

Because you don't need yet another library in your app to do something so simple, this code snippet has been golfed to be as small as possible.

BuddySystem looks for the last space in a phrase like this one

    The rain in Spain falls mainly on the plains
    
And replaces it with ``&nbsp;``, causing the last two words to be parsed as one...holding hands together, the buddy system.

    The rain in Spain falls mainly on the&nbsp;plains
    
Of course, because ``&nbsp;`` is unicode markup for a non-breaking space, the text will appear as:

"The rain in Spain falls mainly on<br> 
the plains"

If the line breaks after the last "the".

# Want to contribute?
```
git clone https://github.com/olsonpm/buddy-system.git
cd buddy-system
npm install
make test
// dev your heart out
```

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