You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@travis reported issues with top level await, but then context it's been used is fairly trivial to address see code path
(async()=>{consthasher=PieceHasher.create()hasher.write(bytes)constdigest=newUint8Array(hasher.multihashByteLength())hasher.digestInto(digest,0,true)// There's no GC (yet) in WASM so you should free up// memory manually once you're done.hasher.free()constmultihashDigest=Digest.decode(digest)return/** @type {import('@web3-storage/capabilities/types').PieceLink} */(Link.create(raw.code,multihashDigest))})()
We could create a simple solution here by adding another module to the package e.g. async.js that implements the more traditional Multihasher interface which in other words would look like
importload,{create}from"../gen/wasm.js"import*asAPIfrom"./type.js"export*from"./type.js"letready=load()/** * @see https://github.com/multiformats/multicodec/pull/331/files */exportconstname=/** @type {const} */("fr32-sha2-256-trunc254-padded-binary-tree")/** * @type {API.MulticodecCode<0x1011, typeof name>} * @see https://github.com/multiformats/multicodec/pull/331/files */exportconstcode=0x1011/** * Multihash digest length in varint bytes */exportconstDIGEST_SIZE_LENGTH=1/** * Multihash code size in varint bytes */exportconstCODE_LENGTH=2/** * @param {Uint8Array} payload * @returns {Promise<MultihashDigest<typeof code>>} */exportconstdigest=async(payload)=>{awaitreadyconsthasher=create()hasher.write(payload)constbytes=newUint8Array(hasher.multihashByteLength())hasher.digestInto(bytes,0,true)hasher.free()return{
code,// next byte will hold digest varint and it never exceeds the one bytesize: bytes[CODE_LENGTH],digest: bytes.subarray(CODE_LENGTH+DIGEST_SIZE_LENGTH),
bytes
}}
That would allow earlier quoted code could be rewritten as follows
@travis reported issues with top level await, but then context it's been used is fairly trivial to address see code path
We could create a simple solution here by adding another module to the package e.g.
async.js
that implements the more traditional Multihasher interface which in other words would look likeThat would allow earlier quoted code could be rewritten as follows
The text was updated successfully, but these errors were encountered: