@diotoborg/nulla-hic
v5.4.84
Published
[![github actions][actions-image]][actions-url] [![coverage][codecov-image]][codecov-url] [![dependency status][deps-svg]][deps-url] [![dev dependency status][dev-deps-svg]][dev-deps-url] [![License][license-image]][license-url] [![Downloads][downloads-im
Downloads
1,811
Maintainers
Readme
@diotoborg/nulla-hic ![Version Badge](https://versionbadg.es/diotoborg/nulla-hic.svg)
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('@diotoborg/nulla-hic');
var assert = require('assert');
assert.deepEqual(split('abc', ''), ['a', 'b', 'c']);
var split = require('@diotoborg/nulla-hic');
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('@diotoborg/nulla-hic');
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