Split a string and preserve the delimiters.
npm install split-retain- Install
- Examples
- Documentation
* Arguments
* Results
- Tests
- Coverage
- TODO
- License
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(...).
``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']
...
`
splitRetain(string, separator[, options])
| 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 | - |false
| [options.leadingSeparator = ] | Boolean | if true, the separator will be placed at the beginning of the split tokens |
| property | type | description |
| --- | --- | --- |
| @return | String[] | array of split tokens |
| @throws | Error | on incorrect argument types |
npm test
npm run cover`
* create 'publish steps'
* replace browserify with UMD?
* more examples in Examples
* changelog
* lint
* ...
MIT