aboutsummaryrefslogtreecommitdiff
path: root/js/lib/from-code-point.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib/from-code-point.js')
-rw-r--r--js/lib/from-code-point.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/js/lib/from-code-point.js b/js/lib/from-code-point.js
new file mode 100644
index 0000000..94eca65
--- /dev/null
+++ b/js/lib/from-code-point.js
@@ -0,0 +1,49 @@
+// derived from https://github.com/mathiasbynens/String.fromCodePoint
+/*! http://mths.be/fromcodepoint v0.2.1 by @mathias */
+if (String.fromCodePoint) {
+
+ module.exports = String.fromCodePoint;
+
+} else {
+
+ var stringFromCharCode = String.fromCharCode;
+ var floor = Math.floor;
+ var fromCodePoint = function(_) {
+ var MAX_SIZE = 0x4000;
+ var codeUnits = [];
+ var highSurrogate;
+ var lowSurrogate;
+ var index = -1;
+ var length = arguments.length;
+ if (!length) {
+ return '';
+ }
+ var result = '';
+ while (++index < length) {
+ var codePoint = Number(arguments[index]);
+ if (
+ !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
+ codePoint < 0 || // not a valid Unicode code point
+ codePoint > 0x10FFFF || // not a valid Unicode code point
+ floor(codePoint) != codePoint // not an integer
+ ) {
+ return String.fromCharCode(0xFFFD);
+ }
+ if (codePoint <= 0xFFFF) { // BMP code point
+ codeUnits.push(codePoint);
+ } else { // Astral code point; split in surrogate halves
+ // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
+ codePoint -= 0x10000;
+ highSurrogate = (codePoint >> 10) + 0xD800;
+ lowSurrogate = (codePoint % 0x400) + 0xDC00;
+ codeUnits.push(highSurrogate, lowSurrogate);
+ }
+ if (index + 1 == length || codeUnits.length > MAX_SIZE) {
+ result += stringFromCharCode.apply(null, codeUnits);
+ codeUnits.length = 0;
+ }
+ }
+ return result;
+ };
+ module.exports = fromCodePoint;
+}
cal.com/unread0
-rw-r--r--tags/de/00/201212090046.08906.tiposchi@tiscali.it/debian0
-rw-r--r--tags/de/00/20150109110003.91DFC300038@coreander.jones.dk/sys0
-rw-r--r--tags/de/00/20150109110003.91DFC300038@coreander.jones.dk/unread0
-rw-r--r--tags/de/00/20150513185316.10515.65525.reportbug@chemistry.wooz.org/debian0
-rw-r--r--tags/de/00/20150513185316.10515.65525.reportbug@chemistry.wooz.org/unread0
-rw-r--r--tags/de/00/20181129080001.5D6FD1CCD84@lxp5.free-owl.de/sys0
-rw-r--r--tags/de/00/20181129080001.5D6FD1CCD84@lxp5.free-owl.de/unread0
-rw-r--r--tags/de/00/268359106.144443.1670368762383@mailbox-store-cf76b6dcc-ztw2l/signed0
-rw-r--r--tags/de/00/268359106.144443.1670368762383@mailbox-store-cf76b6dcc-ztw2l/unread0
-rw-r--r--tags/de/00/46F8353F.7040200@frankengul.org/debian0
-rw-r--r--tags/de/00/46F8353F.7040200@frankengul.org/unread0
-rw-r--r--tags/de/00/54ED09EE.1020906@vr-web.de/attachment0
-rw-r--r--tags/de/00/54ED09EE.1020906@vr-web.de/debian0
-rw-r--r--tags/de/00/54ED09EE.1020906@vr-web.de/unread0
-rw-r--r--tags/de/00/8e4cf434-2f1d-59b2-fb4d-1ae04de66df4@debian.org/debian0
-rw-r--r--tags/de/00/8e4cf434-2f1d-59b2-fb4d-1ae04de66df4@debian.org/signed0
-rw-r--r--tags/de/00/DDDDFFED-E1C0-44FB-94AF-3113F954A707@gmx.de/debian0
-rw-r--r--tags/de/00/DDDDFFED-E1C0-44FB-94AF-3113F954A707@gmx.de/inbox0
-rw-r--r--tags/de/00/DDDDFFED-E1C0-44FB-94AF-3113F954A707@gmx.de/old0
32 files changed, 0 insertions, 0 deletions