string.prototype.split
An ES spec-compliant `String.prototype.split` shim/polyfill/replacement that works as far down as ES3
Last updated 3 years ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install string.prototype.split 
SYNC missed versions from official npm registry.

string.prototype.split Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

An ES spec-compliant String.prototype.split shim/polyfill/replacement that works as far down as ES3. There's a number of bugs in various browser versions that this package addresses.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the spec.

Because String.prototype.split depends on a receiver (the “this” value), the main export takes the string to operate on as the first argument.

Example

var split = require('string.prototype.split');
var assert = require('assert');

assert.deepEqual(split('abc', ''), ['a', 'b', 'c']);
var split = require('string.prototype.split');
var assert = require('assert');
/* when String#split is not present */
delete String.prototype.split;
var shimmedSplit = split.shim();

assert.equal(shimmedSplit, String.prototype.split);
assert.deepEqual(shimmedSplit('abc', ''), ['a', 'b', 'c']);
var split = require('string.prototype.split');
var assert = require('assert');
/* when String#split is present */
var shimmedSplit = split.shim();

assert.equal(shimmedSplit, String.prototype.split);
assert.deepEqual(shimmedSplit('abc', ''), ['a', 'b', 'c']);

Tests

Simply clone the repo, npm install, and run npm test

Current Tags

  • 1.0.9                                ...           latest (3 years ago)

9 Versions

  • 1.0.9                                ...           3 years ago
  • 1.0.8                                ...           3 years ago
  • 1.0.7                                ...           4 years ago
  • 1.0.6                                ...           5 years ago
  • 1.0.5                                ...           5 years ago
  • 1.0.4                                ...           6 years ago
  • 1.0.3                                ...           6 years ago
  • 1.0.2                                ...           6 years ago
  • 1.0.1                                ...           6 years ago
Maintainers (1)
Downloads
Total 45
Today 0
This Week 0
This Month 45
Last Day 0
Last Week 9
Last Month 0
Dependencies (7)
Dev Dependencies (12)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE