MCPcopy Create free account
hub / github.com/glideapps/quicktype / utf16ConcatMap

Function utf16ConcatMap

src/Strings.ts:43–74  ·  view source on GitHub ↗
(mapper: (utf16Unit: number) => string)

Source from the content-addressed store, hash-verified

41
42// FIXME: This is a copy of code in src/Data/String/Util.js
43export function utf16ConcatMap(mapper: (utf16Unit: number) => string): (s: string) => string {
44 const { charStringMap, charNoEscapeMap } = computeAsciiMap(mapper);
45
46 return function stringConcatMap_inner(s: string): string {
47 let cs: string[] | null = null;
48 let start = 0;
49 let i = 0;
50 while (i < s.length) {
51 const cc = s.charCodeAt(i);
52 if (!charNoEscapeMap[cc]) {
53 if (cs === null) cs = [];
54 cs.push(s.substring(start, i));
55
56 const str = charStringMap[cc];
57 if (str === undefined) {
58 cs.push(mapper(s.charCodeAt(i)));
59 } else {
60 cs.push(str);
61 }
62
63 start = i + 1;
64 }
65 i++;
66 }
67
68 if (cs === null) return s;
69
70 cs.push(s.substring(start, i));
71
72 return cs.join("");
73 };
74}
75
76function isHighSurrogate(cc: number): boolean {
77 return cc >= 0xd800 && cc <= 0xdbff;

Callers 3

Java.tsFile · 0.90
utf16LegalizeCharactersFunction · 0.85
Strings.tsFile · 0.85

Calls 2

computeAsciiMapFunction · 0.85
mapperFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…