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

Method performView

src/Viewer/Bytes.js:70–95  ·  view source on GitHub ↗

* Performs view of given content. * @protected * @param {string} content * @return {void|Promise} Resolves when completed.

(content)

Source from the content-addressed store, hash-verified

68 * @return {void|Promise} Resolves when completed.
69 */
70 async performView (content) {
71 const bytes = content.getBytes()
72 const format = this.getSettingValue('format')
73
74 // Encode bytes to string
75 let string, charBits
76 switch (format) {
77 case 'hexadecimal':
78 string = ByteEncoder.hexStringFromBytes(bytes)
79 charBits = 4
80 break
81 case 'binary':
82 string = ByteEncoder.binaryStringFromBytes(bytes)
83 charBits = 1
84 }
85
86 // Group result
87 const groupBits = this.getSettingValue('groupBits')
88 if (groupBits !== null) {
89 const groupChars = groupBits / charBits
90 string = StringUtil.chunk(string, groupChars).join(' ')
91 }
92
93 // Show it
94 this.getView().setText(string)
95 }
96
97 /**
98 * Triggered when the text has been changed inside the view.

Callers

nothing calls this directly

Calls 8

getBytesMethod · 0.80
getSettingValueMethod · 0.80
hexStringFromBytesMethod · 0.80
binaryStringFromBytesMethod · 0.80
joinMethod · 0.80
setTextMethod · 0.80
getViewMethod · 0.80
chunkMethod · 0.45

Tested by

no test coverage detected