Skip to content

Commit

Permalink
Use proper script way to clone Emoji files from www
Browse files Browse the repository at this point in the history
Differential Revision: D5615872

fbshipit-source-id: 7f2c19f1a65f42b78136be7e6a608d0415c1a49f
  • Loading branch information
nmn authored and facebook-github-bot committed Aug 21, 2017
1 parent c3b47e5 commit 5cdf5f3
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Libraries/polyfills/String.prototype.es6.js
Expand Up @@ -92,3 +92,39 @@ if (!String.prototype.includes) {
}
};
}

if (!String.prototype.codePointAt) {
String.prototype.codePointAt = function(position) {
if (this == null) {
throw TypeError();
}
var string = String(this);
var size = string.length;
// `ToInteger`
var index = position ? Number(position) : 0;
if (Number.isNaN(index)) {
index = 0;
}
// Account for out-of-bounds indices:
if (index < 0 || index >= size) {
return undefined;
}
// Get the first code unit
var first = string.charCodeAt(index);
var second;
if (
// check if it’s the start of a surrogate pair
first >= 0xd800 &&
first <= 0xdbff && // high surrogate
size > index + 1 // there is a next code unit
) {
second = string.charCodeAt(index + 1);
if (second >= 0xdc00 && second <= 0xdfff) {
// low surrogate
// http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
return (first - 0xd800) * 0x400 + second - 0xdc00 + 0x10000;
}
}
return first;
};
}

0 comments on commit 5cdf5f3

Please sign in to comment.