clean-split
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Clean Split Travis CI Build Status

Cleanly split a string by retaining the delimiter.

NPM Badge

Install

npm install clean-split

Usage

const cleanSplit = require("clean-split");

cleanSplit("a-b-c", "-");
//=> ["a", "-", "b", "-", "c"]

cleanSplit("a-b-c", "-", { anchor: "before" });
//=> ["a-", "b-", "c"]

cleanSplit("a-b-c", "-", { anchor: "after" });
//=> ["a", "-b", "-c"]

API

cleanSplit(string, delimiter, options?)

string

Type: string

The string to split.

delimiter

Type: string or regexp

The delimiter to split the string by.

options

Type: object

anchor

Type: string (none, before, after, left or right)
Default: none

Anchor the delimiter to different sides of the split.

Package Sidebar

Install

npm i clean-split

Weekly Downloads

27

Version

1.1.0

License

MIT

Unpacked Size

4.91 kB

Total Files

6

Last publish

Collaborators

  • richienb