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

Method performDecode

src/Encoder/CharacterBlock.js:101–118  ·  view source on GitHub ↗

* Performs decode on given content. * @protected * @param {Chain} content * @return {number[]|string|Uint8Array|Chain|Promise} Decoded content

(content)

Source from the content-addressed store, hash-verified

99 * @return {number[]|string|Uint8Array|Chain|Promise} Decoded content
100 */
101 performDecode (content) {
102 switch (this._mode) {
103 case CharacterToBlockMode: {
104 return content.split(this.getSeparator())
105 .map((block, index, blocks) =>
106 this.performBlockDecodeToChar(block, index, blocks, content))
107 .filter(codePoint => codePoint !== null)
108 }
109 case BlockToCharacterMode: {
110 const blocks = content.getCodePoints()
111 .map((codePoint, index) =>
112 this.performCharDecodeToBlock(codePoint, index, content))
113 .filter(block => block !== null)
114 .map(Chain.wrap)
115 return Chain.join(blocks, this.getSeparator())
116 }
117 }
118 }
119
120 /**
121 * Encodes given character to a block.

Callers

nothing calls this directly

Calls 6

getSeparatorMethod · 0.95
splitMethod · 0.80
getCodePointsMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected