string-split
A curried
String.prototype.split
with support for splitting by String, RegExp, or Function.
npm install string-split --save
npm stats
Examples
require
var split = ;
full application
;//=> ["example", "com"]
partial application
var undot = ;//=> ["example", "com"]
iteratee
var transform = ;var foodtypes = "Entree::Seafood" "Entree::Chicken"; foodtypes;//=> [ ["Entree", "Seafood"], ["Entree", "Chicken"] ]
predicate
{ return !!Numberchr} //=> ['Hello', 'World']
predicate using index
{ return idx % 2 !== 0} //=> ['A', 'B', 'C', 'D']
Features
- Supports splitting by String, RegExp, or Function.
- Curried.
API
split(splitBy, string)
arguments
splitBy: (String|RegExp|Function)
String, RegExp, or Function to split by.string: (String)
String to split.
returns
(Array)
List of split string parts.
splitBy function signature
Return
true
to split by currentchr
oridx
.
chr: (String)
current character.idx: (Number)
current character index.