MCPcopy Index your code
hub / github.com/witheve/Eve / fromCodePoint

Function fromCodePoint

src/commonmark.js:1002–1038  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1000 var stringFromCharCode = String.fromCharCode;
1001 var floor = Math.floor;
1002 var fromCodePoint = function() {
1003 var MAX_SIZE = 0x4000;
1004 var codeUnits = [];
1005 var highSurrogate;
1006 var lowSurrogate;
1007 var index = -1;
1008 var length = arguments.length;
1009 if (!length) {
1010 return '';
1011 }
1012 var result = '';
1013 while (++index < length) {
1014 var codePoint = Number(arguments[index]);
1015 if (
1016 !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
1017 codePoint < 0 || // not a valid Unicode code point
1018 codePoint > 0x10FFFF || // not a valid Unicode code point
1019 floor(codePoint) !== codePoint // not an integer
1020 ) {
1021 return String.fromCharCode(0xFFFD);
1022 }
1023 if (codePoint <= 0xFFFF) { // BMP code point
1024 codeUnits.push(codePoint);
1025 } else { // Astral code point; split in surrogate halves
1026 // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
1027 codePoint -= 0x10000;
1028 highSurrogate = (codePoint >> 10) + 0xD800;
1029 lowSurrogate = (codePoint % 0x400) + 0xDC00;
1030 codeUnits.push(highSurrogate, lowSurrogate);
1031 }
1032 if (index + 1 === length || codeUnits.length > MAX_SIZE) {
1033 result += stringFromCharCode.apply(null, codeUnits);
1034 codeUnits.length = 0;
1035 }
1036 }
1037 return result;
1038 };
1039 module.exports = fromCodePoint;
1040}
1041

Callers 2

scanDelimsFunction · 0.85
parseInlineFunction · 0.85

Calls 1

applyMethod · 0.45

Tested by

no test coverage detected