Merge master, small refactor

This commit is contained in:
Tom Moor
2018-07-15 07:58:58 -07:00
179 changed files with 2521 additions and 1121 deletions

24
app/utils/emoji.js Normal file
View File

@@ -0,0 +1,24 @@
// @flow
export function toCodePoint(unicodeSurrogates, sep) {
var r = [],
c = 0,
p = 0,
i = 0;
while (i < unicodeSurrogates.length) {
c = unicodeSurrogates.charCodeAt(i++);
if (p) {
r.push((0x10000 + ((p - 0xd800) << 10) + (c - 0xdc00)).toString(16));
p = 0;
} else if (0xd800 <= c && c <= 0xdbff) {
p = c;
} else {
r.push(c.toString(16));
}
}
return r.join(sep || '-');
}
export function emojiToUrl(string: text) {
return `https://twemoji.maxcdn.com/2/72x72/${toCodePoint(string)}.png`;
}