MCPcopy Create free account
hub / github.com/TruthHun/BookStack / fromCodePoint

Function fromCodePoint

static/word2md/mammoth.browser.js:27453–27489  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27451 var stringFromCharCode = String.fromCharCode
27452 var floor = Math.floor
27453 var fromCodePoint = function () {
27454 var MAX_SIZE = 0x4000
27455 var codeUnits = []
27456 var highSurrogate
27457 var lowSurrogate
27458 var index = -1
27459 var length = arguments.length
27460 if (!length) {
27461 return ''
27462 }
27463 var result = ''
27464 while (++index < length) {
27465 var codePoint = Number(arguments[index])
27466 if (
27467 !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
27468 codePoint < 0 || // not a valid Unicode code point
27469 codePoint > 0x10FFFF || // not a valid Unicode code point
27470 floor(codePoint) !== codePoint // not an integer
27471 ) {
27472 throw RangeError('Invalid code point: ' + codePoint)
27473 }
27474 if (codePoint <= 0xFFFF) { // BMP code point
27475 codeUnits.push(codePoint)
27476 } else { // Astral code point; split in surrogate halves
27477 // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
27478 codePoint -= 0x10000
27479 highSurrogate = (codePoint >> 10) + 0xD800
27480 lowSurrogate = (codePoint % 0x400) + 0xDC00
27481 codeUnits.push(highSurrogate, lowSurrogate)
27482 }
27483 if (index + 1 === length || codeUnits.length > MAX_SIZE) {
27484 result += stringFromCharCode.apply(null, codeUnits)
27485 codeUnits.length = 0
27486 }
27487 }
27488 return result
27489 }
27490 if (Object.defineProperty) {
27491 Object.defineProperty(String, 'fromCodePoint', {
27492 value: fromCodePoint,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected