A robust & optimized ES3-compatible polyfill for the
String.prototype.at proposal for ECMAScript 6/7.
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
Use it as a standalone function, or call its
shim method to install it as a polyfill.
var at = ;var assert = ;var surrogatePair = '\uD834\uDF06 abc'; // a surrogate pair;;;var i = 0;var str = '';while strlength < surrogatePairlengthstr += ;i += 1;;; // 4 code points; // 6 "characters"at;;
Simply clone the repo,
npm install, and run