🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

string-split

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-split

A curried `String.prototype.split` with support for splitting by String, RegExp, or Function.

0.3.1
latest
Source
npm
Version published
Weekly downloads
55
-14.06%
Maintainers
1
Weekly downloads
 
Created
Source

string-split

A curried String.prototype.split with support for splitting by String, RegExp, or Function.

Build Status Code Climate js-standard-style

npm install string-split --save
npm stats

npm NPM downloads Dependency Status

Examples

require
var split = require('string-split');
full application
split(".", "example.com");
//=> ["example", "com"]
partial application
var undot = split('.')
undot('example.com');
//=> ["example", "com"]
iteratee
var transform = split("::");
var foodtypes = ["Entree::Seafood", "Entree::Chicken"];

foodtypes.map(transform);
//=> [ ["Entree", "Seafood"], ["Entree", "Chicken"] ]
predicate
function isNumber (chr, _) {
  return !!Number(chr)
}

split(isNumber, 'Hello1World2')
//=> ['Hello', 'World']
predicate using index
function odd (chr, idx) {
  return idx % 2 !== 0
}

split(odd, 'AaBbCcDd')
//=> ['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 current chr or idx.

  • chr: (String) current character.
  • idx: (Number) current character index.

License

GitHub license

Keywords

curried

FAQs

Package last updated on 16 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts