multiformats / multiformats/js-multiformats

block.bytes can be a nodejs Buffer

Open
#191 2 comments 0 reactions 1 assignee View on GitHub

@rvagg is already working on this.

Since Jul 26, 2022.

P2
Dominant language
TypeScript
Stars
268
Forks
57
PR merge metrics
No merged PRs in 30d

Description

Would like to know if this is the desired behavior:

Block = await import('multiformats/block')
codec = await import('@ipld/dag-cbor')
{ sha256: hasher } = await import('multiformats/hashes/sha2')

bytes = Buffer.from([ 100, 97, 115, 100, 102 ])
block = await Block.decode({ bytes, codec, hasher })

block.bytes instanceof Buffer // true

Noticed this while testing with the ipfs block api in node. Buffer extends Uint8Array which is great, but it seems to override some of the characteristics of Uint8Array.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.