MCPcopy Create free account
hub / github.com/cryptii/cryptii / bytesFromCodePoints

Method bytesFromCodePoints

src/TextEncoder.js:131–139  ·  view source on GitHub ↗

* 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')

Source from the content-addressed store, hash-verified

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.

Callers 3

TextEncoder.jsFile · 0.80
getCharBytesAtMethod · 0.80
getBytesMethod · 0.80

Calls 1

Tested by

no test coverage detected