JSPM

split-retain

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4084
  • Score
    100M100P100Q126189F
  • License MIT

Split a string and preserve the delimiters.

Package Exports

  • split-retain

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (split-retain) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

split-retain

Split a string and preserve the delimiters.

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

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
———
RegExp
single character
———
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