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

Method wrap

src/Chain.js:459–470  ·  view source on GitHub ↗

* Wraps value inside a chain object if it is not already a chain. * @param {?number[]|string|Uint8Array|Chain} value * @param {string} [encoding='utf8'] Byte encoding * @return {Chain}

(value, encoding = 'utf8')

Source from the content-addressed store, hash-verified

457 * @return {Chain}
458 */
459 static wrap (value, encoding = 'utf8') {
460 if (value instanceof Chain) {
461 // nothing to do, value already is a chain object
462 return value
463 }
464 if (value === null || value.length === 0) {
465 // use empty chain constant when possible
466 return Chain.empty()
467 }
468 // create new chain object
469 return new Chain(value, encoding)
470 }
471
472 /**
473 * Joins all elements of an array (or an array-like object) into a chain.

Callers 15

testMethod · 0.80
toLowerCaseMethod · 0.80
toUpperCaseMethod · 0.80
splitMethod · 0.80
substrMethod · 0.80
truncateMethod · 0.80
extendMethod · 0.80
joinMethod · 0.80
setContentMethod · 0.80
translateMethod · 0.80
performTranslateMethod · 0.80
getVariantOptionsMethod · 0.80

Calls 1

emptyMethod · 0.80

Tested by 1

testMethod · 0.64