Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

string.prototype.split

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string.prototype.split

An ES spec-compliant `String.prototype.split` shim/polyfill/replacement that works as far down as ES3

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

Keywords

FAQs

Package last updated on 20 Mar 2024

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc