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

Method preview

test/Helper/ChainUtil.js:39–51  ·  view source on GitHub ↗

* Creates string preview of given Chain object. * @param {Chain} content * @return {string}

(content)

Source from the content-addressed store, hash-verified

37 * @return {string}
38 */
39 static preview (content) {
40 if (!content.needsTextEncoding()) {
41 // truncate text to preview length
42 return content.truncate(previewLength)
43 }
44
45 // create hex byte preview
46 const previewBytes = content.getBytes().slice(0, previewLength / 2)
47 const preview = ByteEncoder.hexStringFromBytes(previewBytes)
48 return content.getBytes().length > previewLength / 2
49 ? preview + '…'
50 : preview
51 }
52}

Callers 1

testMethod · 0.80

Calls 4

needsTextEncodingMethod · 0.80
truncateMethod · 0.80
getBytesMethod · 0.80
hexStringFromBytesMethod · 0.80

Tested by 1

testMethod · 0.64