# string-at

> A robust & optimized ES3-compatible polyfill for the `String.prototype.at` proposal for ECMAScript 6/7 - based on https://mths.be/at

Latest version **1.1.0** (published 2019-12-19) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install string-at
pnpm add string-at
yarn add string-at
bun add string-at
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-12-19 |
| First published | 2015-03-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 2 |
| Unpacked size | 27.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 8 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | String, string, unicode, ES6, ES7, ecmascript, polyfill, code point, at |

## Links

- npm: https://www.npmjs.com/package/string-at
- Repository: https://github.com/ljharb/string-at
- Homepage: https://github.com/ljharb/string-at#readme
- Issues: https://github.com/ljharb/string-at/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/string-at

## Dependencies (2)

- [es-abstract](https://npm.io/package/es-abstract.md) ^1.17.0-next.1
- [define-properties](https://npm.io/package/define-properties.md) ^1.1.3

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 1.1.0 (latest) — 2019-12-19
- 1.0.1 — 2015-05-23
- 1.0.0 — 2015-03-20

## README

# string-at <sup>[![Version Badge][2]][1]</sup>

[![Build Status][3]][4]
[![dependency status][5]][6]
[![dev dependency status][7]][8]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][11]][1]

[![browser support][9]][10]

A robust & optimized ES3-compatible polyfill for [the `String.prototype.at` proposal for ECMAScript 6/7](http://esdiscuss.org/topic/string-prototype-symbolat-improved-string-prototype-charat).

This code is almost entirely copied from @mathiasbynens's excellent polyfill at https://mths.be/at - I created this one so that it did not automatically modify `String.prototype`, and so that it would fit in more neatly with the `es7-shim`.

Use it as a standalone function, or call its `shim` method to install it as a polyfill.

## Example

```js
var at = require('string-at');
var assert = require('assert');

var surrogatePair = '\uD834\uDF06 abc'; // a surrogate pair
assert(surrogatePair.length === 6);
assert(at(surrogatePair, 0) === '\uD834\uDF06');
assert(at(surrogatePair, 1) === '\uDF06');

var i = 0;
var str = '';
while (str.length < surrogatePair.length) {
	str += at(surrogatePair, str.length);
	i += 1;
}
assert(str === surrogatePair);
assert(i === 4); // 4 code points
assert(str.length === 6); // 6 "characters"

at.shim();
assert(surrogatePair.at(0) === at(surrogatePair, 0));
```

## Tests
Simply clone the repo, `npm install`, and run `npm test`

[1]: https://npmjs.org/package/string-at
[2]: http://versionbadg.es/ljharb/string-at.svg
[3]: https://travis-ci.org/ljharb/string-at.svg
[4]: https://travis-ci.org/ljharb/string-at
[5]: https://david-dm.org/ljharb/string-at.svg
[6]: https://david-dm.org/ljharb/string-at
[7]: https://david-dm.org/ljharb/string-at/dev-status.svg
[8]: https://david-dm.org/ljharb/string-at#info=devDependencies
[9]: https://ci.testling.com/ljharb/string-at.png
[10]: https://ci.testling.com/ljharb/string-at
[11]: https://nodei.co/npm/string-at.png?downloads=true&stars=true
[license-image]: http://img.shields.io/npm/l/string-at.svg
[license-url]: LICENSE
[downloads-image]: http://img.shields.io/npm/dm/string-at.svg
[downloads-url]: http://npm-stat.com/charts.html?package=string-at

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