Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mathiasbynens/String.prototype.endsWith
A robust & optimized ES3-compatible polyfill for the `String.prototype.endsWith` method in ECMAScript 6.
https://github.com/mathiasbynens/String.prototype.endsWith
Last synced: 3 months ago
JSON representation
A robust & optimized ES3-compatible polyfill for the `String.prototype.endsWith` method in ECMAScript 6.
- Host: GitHub
- URL: https://github.com/mathiasbynens/String.prototype.endsWith
- Owner: mathiasbynens
- License: mit
- Created: 2013-12-10T15:21:23.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2024-03-20T17:17:33.000Z (8 months ago)
- Last Synced: 2024-07-06T02:19:01.113Z (4 months ago)
- Language: JavaScript
- Homepage: https://mths.be/endswith
- Size: 47.9 KB
- Stars: 35
- Watchers: 7
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE-MIT.txt
Awesome Lists containing this project
- es6-tools - `String.prototype.endsWith`
README
# string.prototype.endswith [![Version Badge][npm-version-svg]][package-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]
An ESnext spec-compliant `String.prototype.endsWith` shim/polyfill/replacement that works as far down as ES3.
This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](https://tc39.es/ecma262/#sec-string.prototype.endswith).
Because `String.prototype.endsWith` depends on a receiver (the `this` value), the main export takes the string to operate on as the first argument.
Other polyfills for `String.prototype.endsWith` are available:
* by [Paul Miller](http://paulmillr.com/) (~~fails some tests: [1](https://github.com/paulmillr/es6-shim/issues/168), [2](https://github.com/paulmillr/es6-shim/issues/175)~~ passes all tests)
* by Google (~~[fails a lot of tests](https://github.com/google/traceur-compiler/pull/555)~~ now uses this polyfill and passes all tests)## Installation
Via [npm](http://npmjs.org/):
```bash
npm install string.prototype.endswith
```Then, in [Node.js](http://nodejs.org/):
```js
var endsWith = require('string.prototype.endswith');
``````html
```
> **NOTE**: It's recommended that you install this module using a package manager
> such as `npm`, because loading multiple polyfills from a CDN (such as `bundle.run`)
> will lead to duplicated code.## Notes
Polyfills + test suites for [`String.prototype.startsWith`](https://mths.be/startswith) and [`String.prototype.contains`](https://mths.be/contains) are available, too.
## Author
| [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") |
|---|
| [Mathias Bynens](https://mathiasbynens.be/) |## License
This polyfill is available under the [MIT](https://mths.be/mit) license.
## Tests
Simply clone the repo, `npm install`, and run `npm test`[package-url]: https://npmjs.org/package/string.prototype.endswith
[npm-version-svg]: https://versionbadg.es/es-shims/String.prototype.endsWith.svg
[deps-svg]: https://david-dm.org/es-shims/String.prototype.endsWith.svg
[deps-url]: https://david-dm.org/es-shims/String.prototype.endsWith
[dev-deps-svg]: https://david-dm.org/es-shims/String.prototype.endsWith/dev-status.svg
[dev-deps-url]: https://david-dm.org/es-shims/String.prototype.endsWith#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/string.prototype.endswith.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/string.prototype.endswith.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/string.prototype.endswith.svg
[downloads-url]: https://npm-stat.com/charts.html?package=string.prototype.endswith