<commit_before># es5-shim <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![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-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

`es5-shim.js` and `es5-shim.min.js` monkey-patch a JavaScript context to
contain all EcmaScript 5 methods that can be faithfully emulated with a
legacy JavaScript engine.
**Note:** As `es5-shim.js` is designed to patch the native Javascript
engine, it should be the library that is loaded first.

`es5-sham.js` and `es5-sham.min.js` monkey-patch other ES5 methods as
closely as possible.  For these methods, as closely as possible to ES5
is not very close.  Many of these shams are intended only to allow code
to be written to ES5 without causing run-time errors in older engines.
In many cases, this means that these shams cause many ES5 methods to
silently fail.  Decide carefully whether this is what you want.
**Note:** `es5-sham.js` requires `es5-shim.js` to be able to work properly.

## Tests

The tests are written with the Jasmine BDD test framework.
To run the tests, navigate to <root-folder>/tests/ , or,
simply `npm install` and `npm test`.

## Shims

### Complete tests ###

* Array.prototype.every ([standalone shim](https://www.npmjs.com/package/array.prototype.every))
* Array.prototype.filter ([standalone shim](https://www.npmjs.com/package/array.prototype.filter))
* Array.prototype.forEach ([standalone shim](https://www.npmjs.com/package/array.prototype.foreach))
* Array.prototype.indexOf ([standalone shim](https://www.npmjs.com/package/array.prototype.indexof))
* Array.prototype.lastIndexOf ([standalone shim](https://www.npmjs.com/package/array.prototype.lastindexof))
* Array.prototype.map ([standalone shim](https://www.npmjs.com/package/array.prototype.map))
* Array.prototype.slice
* Array.prototype.some ([standalone shim](https://www.npmjs.com/package/array.prototype.some))
* Array.prototype.sort
* Array.prototype.reduce ([standalone shim](https://www.npmjs.com/package/array.prototype.reduce))
* Array.prototype.reduceRight ([standalone shim](https://www.npmjs.com/package/array.prototype.reduceright))
* Array.prototype.push ([standalone shim](https://www.npmjs.com/package/array.prototype.push))
* Array.prototype.join
* Array.prototype.splice ([standalone shim](https://www.npmjs.com/package/array.prototype.splice))
* Array.isArray
* Date.now
* Date.prototype.toJSON
* Function.prototype.bind
    * :warning: Caveat: the bound function has a prototype property.
    * :warning: Caveat: bound functions do not try too hard to keep you
      from manipulating their ``arguments`` and ``caller`` properties.
    * :warning: Caveat: bound functions don't have checks in ``call`` and
      ``apply`` to avoid executing as a constructor.
* Number.prototype.toExponential ([standalone shim](https://www.npmjs.com/package/number.prototype.toexponential))
* Number.prototype.toFixed
* Number.prototype.toPrecision
* Object.keys ([standalone shim](https://www.npmjs.com/package/object-keys))
* String.prototype.split ([standalone shim](https://www.npmjs.com/package/string.prototype.split))
* String.prototype.trim ([standalone shim](https://www.npmjs.com/package/string.prototype.trim))
* String.prototype.lastIndexOf ([standalone shim](https://www.npmjs.com/package/string.prototype.lastindexof))
* String.prototype.replace
    * Firefox (through v29) natively handles capturing groups incorrectly.
* Date.parse (for ISO parsing)
* Date.prototype.toISOString
* parseInt ([standalone shim](https://www.npmjs.com/package/parseint))
* parseFloat
* Error.prototype.toString
* Error.prototype.name
* Error.prototype.message
* RegExp.prototype.toString

## Shams

* :warning: Object.create

    For the case of simply "begetting" an object that inherits
    prototypically from another, this should work fine across legacy
    engines.

    :warning: The second argument is passed to Object.defineProperties
    which will probably fail either silently or with extreme prejudice.

* :warning: Object.getPrototypeOf

    This will return "undefined" in some cases.  It uses `__proto__` if
    it's available.  Failing that, it uses constructor.prototype, which
    depends on the constructor property of the object's prototype having
    not been replaced.  If your object was created like this, it won't
    work:

        function Foo() {
        }
        Foo.prototype = {};
<commit_msg>[readme] add standalone shims<commit_after># es5-shim <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![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-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

`es5-shim.js` and `es5-shim.min.js` monkey-patch a JavaScript context to
contain all EcmaScript 5 methods that can be faithfully emulated with a
legacy JavaScript engine.
**Note:** As `es5-shim.js` is designed to patch the native Javascript
engine, it should be the library that is loaded first.

`es5-sham.js` and `es5-sham.min.js` monkey-patch other ES5 methods as
closely as possible.  For these methods, as closely as possible to ES5
is not very close.  Many of these shams are intended only to allow code
to be written to ES5 without causing run-time errors in older engines.
In many cases, this means that these shams cause many ES5 methods to
silently fail.  Decide carefully whether this is what you want.
**Note:** `es5-sham.js` requires `es5-shim.js` to be able to work properly.

## Tests

The tests are written with the Jasmine BDD test framework.
To run the tests, navigate to <root-folder>/tests/ , or,
simply `npm install` and `npm test`.

## Shims

### Complete tests ###

* Array.prototype.every ([standalone shim](https://www.npmjs.com/package/array.prototype.every))
* Array.prototype.filter ([standalone shim](https://www.npmjs.com/package/array.prototype.filter))
* Array.prototype.forEach ([standalone shim](https://www.npmjs.com/package/array.prototype.foreach))
* Array.prototype.indexOf ([standalone shim](https://www.npmjs.com/package/array.prototype.indexof))
* Array.prototype.lastIndexOf ([standalone shim](https://www.npmjs.com/package/array.prototype.lastindexof))
* Array.prototype.map ([standalone shim](https://www.npmjs.com/package/array.prototype.map))
* Array.prototype.slice
* Array.prototype.some ([standalone shim](https://www.npmjs.com/package/array.prototype.some))
* Array.prototype.sort
* Array.prototype.reduce ([standalone shim](https://www.npmjs.com/package/array.prototype.reduce))
* Array.prototype.reduceRight ([standalone shim](https://www.npmjs.com/package/array.prototype.reduceright))
* Array.prototype.push ([standalone shim](https://www.npmjs.com/package/array.prototype.push))
* Array.prototype.join
* Array.prototype.splice ([standalone shim](https://www.npmjs.com/package/array.prototype.splice))
* Array.isArray
* Date.now ([standalone shim](https://www.npmjs.com/package/date))
* Date.prototype.toJSON ([standalone shim](https://www.npmjs.com/package/date))
* Function.prototype.bind
    * :warning: Caveat: the bound function has a prototype property.
    * :warning: Caveat: bound functions do not try too hard to keep you
      from manipulating their ``arguments`` and ``caller`` properties.
    * :warning: Caveat: bound functions don't have checks in ``call`` and
      ``apply`` to avoid executing as a constructor.
* Number.prototype.toExponential ([standalone shim](https://www.npmjs.com/package/number.prototype.toexponential))
* Number.prototype.toFixed
* Number.prototype.toPrecision
* Object.keys ([standalone shim](https://www.npmjs.com/package/object-keys))
* String.prototype.split ([standalone shim](https://www.npmjs.com/package/string.prototype.split))
* String.prototype.trim ([standalone shim](https://www.npmjs.com/package/string.prototype.trim))
* String.prototype.lastIndexOf ([standalone shim](https://www.npmjs.com/package/string.prototype.lastindexof))
* String.prototype.replace
    * Firefox (through v29) natively handles capturing groups incorrectly.
* Date.parse (for ISO parsing) ([standalone shim](https://www.npmjs.com/package/date))
* Date.prototype.toISOString ([standalone shim](https://www.npmjs.com/package/date))
* parseInt ([standalone shim](https://www.npmjs.com/package/parseint))
* parseFloat
* Error.prototype.toString
* Error.prototype.name
* Error.prototype.message
* RegExp.prototype.toString

## Shams

* :warning: Object.create

    For the case of simply "begetting" an object that inherits
    prototypically from another, this should work fine across legacy
    engines.

    :warning: The second argument is passed to Object.defineProperties
    which will probably fail either silently or with extreme prejudice.

* :warning: Object.getPrototypeOf

    This will return "undefined" in some cases.  It uses `__proto__` if
    it's available.  Failing that, it uses constructor.prototype, which
    depends on the constructor property of the object's prototype having
    not been replaced.  If your object was created like this, it won't
    work:

        function Foo() {
        }
        Foo.prototype = {};

{'fraction_non_alphanumeric': 0.1334317032040472, 'fraction_numerical': 0.0031618887015177066, 'mean_word_length': 4.778928136419001, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 38, 'lorem ipsum': 0, 'www.': 38, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6355550', 'n_tokens_mistral': 2977, 'n_tokens_neox': 2794, 'n_words': 767}