# breakword

> Get index of character after which variable 'word' must be broken given variable 'length' (accounts for wide characters).

Latest version **1.0.6** (published 2023-05-30) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.6 |
| Published | 2023-05-30 |
| First published | 2017-05-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 14.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | tecfu |
| Maintainers | tecfu |
| Keywords | wordbreak, break-word, textwrap |

## Links

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

## Dependencies (1)

- [wcwidth](https://npm.io/package/wcwidth.md) ^1.0.1

## Recent versions

- 1.0.6 (latest) — 2023-05-30
- 1.0.5 — 2019-11-03
- 1.0.4 — 2019-11-03
- 1.0.3 — 2017-05-20
- 1.0.2 — 2017-05-14
- 1.0.1 — 2017-05-14
- 1.0.0 — 2017-05-14

## README

# breakword

Get index i.e. 0,1,2,... of the character where a word must be broken given it must
be wrapped within a certain length of spaces. 

Useful because javascript's String.length does not reflect the true width of emojis and wide characters.

## Installation

```
npm install breakword 
```

## Examples

1. To find the index of the character to break after if we want to limit our characters fit on a line 3 spaces wide.

```js
const Breakword = require ("breakword");
const word = "打破我的角色三";
const breakIndex = Breakword(word,3); 
console.log(breakIndex) //0
```
The result here - 0 - means all the characters before index 0 (in this case only the character 打) can fit in a line 3 spaces long.

## Test

```bash
npm test
```

- Save new test results to test/test.json

```bash
npm --save run test
```

- Display test outputs only

```bash
npm --display run test
```

## Build

```bash
npm run-script build
```

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