Skip to content

Commit

Permalink
chore: remove node buffers from runtime code
Browse files Browse the repository at this point in the history
Node `Buffers` are subclasses of `Uint8Array` and we don't use any
`Buffer`-specific functions, so do not demand `Buffer`s where
`Uint8Array`s will do.

`Buffer`s are still used in the tests because the `Buffer` requirement
needs pull out of (at least) the `cids` and `multihash` modules first.
  • Loading branch information
achingbrain committed Jul 24, 2020
1 parent b8b2ee3 commit 9243bc5
Show file tree
Hide file tree
Showing 15 changed files with 808 additions and 991 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"lerna": "3.20.2",
"lerna": "3.22.1",
"packages": [
"packages/*"
],
Expand Down
1,235 changes: 776 additions & 459 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"update-contributors": "aegir release --lint=false --test=false --bump=false --build=false --changelog=false --commit=false --tag=false --push=false --ghrelease=false --docs=false --publish=false"
},
"devDependencies": {
"lerna": "^3.20.2"
"lerna": "^3.22.1"
},
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/ipfs-unixfs-exporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const files = []

for await (const file of importer([{
path: '/foo/bar.txt',
content: Buffer.from(0, 1, 2, 3)
content: new Uint8Array([0, 1, 2, 3])
}], ipld)) {
files.push(file)
}
Expand All @@ -74,7 +74,7 @@ for await (const buf of entry.content({
bytes.push(buf)
}

const content = Buffer.concat(bytes)
const content = new Uint8Array(bytes)

console.info(content) // 0, 1, 2, 3
```
Expand Down Expand Up @@ -185,7 +185,7 @@ for await (const chunk of entry.content({
}

// `data` contains the first 5 bytes of the file
const data = Buffer.concat(bufs)
const data = new Uint8Array(bufs)
```
If `entry` is a directory or hamt shard, passing `offset` and/or `length` to `entry.content()` will limit the number of files returned from the directory.
Expand Down
Loading

0 comments on commit 9243bc5

Please sign in to comment.