* Encodes Unicode code points to bytes using given encoding. * @param {number[]} codePoints * @param {String} [encoding='utf8'] * @throws {Error} Throws an error if given encoding is not supported. * @return {Uint8Array} Uint8Array of bytes
(codePoints, encoding = 'utf8')
| 129 | * @return {Uint8Array} Uint8Array of bytes |
| 130 | */ |
| 131 | static bytesFromCodePoints (codePoints, encoding = 'utf8') { |
| 132 | switch (encoding) { |
| 133 | case 'utf8': |
| 134 | return TextEncoder._encodeCodePointsToUTF8Bytes(codePoints) |
| 135 | default: |
| 136 | throw new Error( |
| 137 | `Encoding to '${encoding}' is currently not supported.`) |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Decodes Unicode code points from bytes using given encoding. |
no test coverage detected