(mapper: (utf16Unit: number) => string)
| 41 | |
| 42 | // FIXME: This is a copy of code in src/Data/String/Util.js |
| 43 | export 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 | |
| 76 | function isHighSurrogate(cc: number): boolean { |
| 77 | return cc >= 0xd800 && cc <= 0xdbff; |
no test coverage detected
searching dependent graphs…