# split-retain

> Split a string and preserve the delimiters.

Latest version **1.0.1** (published 2016-08-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install split-retain
pnpm add split-retain
yarn add split-retain
bun add split-retain
```

## 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.1 |
| Published | 2016-08-30 |
| First published | 2016-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Gergely Hornich |
| Maintainers | ghornich |
| Keywords | string, split, explode, separator, delimiter, keep, retain, preserve, leading, trailing |

## Links

- npm: https://www.npmjs.com/package/split-retain
- Repository: https://github.com/ghornich/split-retain
- Homepage: https://github.com/ghornich/split-retain#readme
- Issues: https://github.com/ghornich/split-retain/issues
- npm.io page: https://npm.io/package/split-retain

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-08-30
- 1.0.0 — 2016-08-30

## README

# split-retain
Split a string and preserve the delimiters.

<!-- toc -->

- [Install](#install)
- [Examples](#examples)
- [Documentation](#documentation)
  * [Arguments](#arguments)
  * [Results](#results)
- [Tests](#tests)
- [Coverage](#coverage)
- [TODO](#todo)
- [License](#license)

<!-- tocstop -->

## Install

**Node.js**  
`npm install split-retain --save`

`var splitRetain = require('split-retain');`

**Browser**  
Include the full or minified version on your webpage from `browser/`, then use `splitRetain(...)`.

`<script src="path/to/split-retain.min.js">`

## Examples

```js
splitRetain('home/jack/images/photo12.jpeg', '/')
// ['home/', 'jack/', 'images/', 'photo12.jpeg']

splitRetain('home/jack/images/photo12.jpeg', '/', { leadingSeparator: true })
// ['home', '/jack', '/images', '/photo12.jpeg']

...
```

## Documentation

`splitRetain(string, separator[, options])`

### Arguments

| argument | type | desription |
| --- | --- | --- |
| string | String | string to split |
| separator | String<br>———<br>RegExp | single character<br>———<br>must have grouping parentheses and global flag, e.g. `/(\d+)/g` |
| [options = `{}`] | Object | - |
| [options.leadingSeparator = `false`] | Boolean | if `true`, the separator will be placed at the beginning of the split tokens |

### Results

| property | type | description |
| --- | --- | --- |
| @return | String[] | array of split tokens |
| @throws | Error | on incorrect argument types |

## Tests

`npm test`

## Coverage

`npm run cover`

## TODO

* create 'publish steps'
* replace browserify with UMD?
* more examples in Examples
* changelog
* lint
* ...

## License

MIT

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