# string.prototype.endswith

> A robust & optimized `String.prototype.endsWith` polyfill, based on the ECMAScript 6 specification.

Latest version **1.0.2** (published 2024-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install string.prototype.endswith
pnpm add string.prototype.endswith
yarn add string.prototype.endswith
bun add string.prototype.endswith
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2024-03-18 |
| First published | 2013-12-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >= 0.4 |
| Dependencies | 4 |
| Unpacked size | 30.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 36 |
| Author | Mathias Bynens |
| Maintainers | mathias, google-wombot |
| Keywords | string, endswith, es6, ecmascript, polyfill |

## Links

- npm: https://www.npmjs.com/package/string.prototype.endswith
- Repository: https://github.com/mathiasbynens/String.prototype.endsWith
- Homepage: https://mths.be/endswith
- Issues: https://github.com/mathiasbynens/String.prototype.endsWith/issues
- npm.io page: https://npm.io/package/string.prototype.endswith

## Dependencies (4)

- [call-bind](https://npm.io/package/call-bind.md) ^1.0.7
- [es-abstract](https://npm.io/package/es-abstract.md) ^1.23.2
- [es-object-atoms](https://npm.io/package/es-object-atoms.md) ^1.0.0
- [define-properties](https://npm.io/package/define-properties.md) ^1.2.1

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2024-03-18
- 1.0.1 — 2023-09-12
- 1.0.0 — 2020-05-21
- 0.2.0 — 2014-04-10
- 0.1.0 — 2013-12-23

## README

# string.prototype.endswith <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![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:

* <https://github.com/paulmillr/es6-shim/blob/d8c4ec246a15e7df55da60b7f9b745af84ca9021/es6-shim.js#L175-L184> 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)
* <https://github.com/google/traceur-compiler/blob/315bdad05d41de46d25337422d66686d63100d7a/src/runtime/polyfills/String.js#L39-L66> 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
<script src="https://bundle.run/string.prototype.endswith"></script>
```

> **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

---
_Source: https://npm.io/package/string.prototype.endswith · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
