Skip to content

Commit 9243bc5

Browse files
committed
chore: remove node buffers from runtime code
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.
1 parent b8b2ee3 commit 9243bc5

File tree

15 files changed

+808
-991
lines changed

15 files changed

+808
-991
lines changed

lerna.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"lerna": "3.20.2",
2+
"lerna": "3.22.1",
33
"packages": [
44
"packages/*"
55
],

package-lock.json

Lines changed: 776 additions & 459 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"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"
2020
},
2121
"devDependencies": {
22-
"lerna": "^3.20.2"
22+
"lerna": "^3.22.1"
2323
},
2424
"repository": {
2525
"type": "git",

packages/ipfs-unixfs-exporter/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const files = []
5050

5151
for await (const file of importer([{
5252
path: '/foo/bar.txt',
53-
content: Buffer.from(0, 1, 2, 3)
53+
content: new Uint8Array([0, 1, 2, 3])
5454
}], ipld)) {
5555
files.push(file)
5656
}
@@ -74,7 +74,7 @@ for await (const buf of entry.content({
7474
bytes.push(buf)
7575
}
7676

77-
const content = Buffer.concat(bytes)
77+
const content = new Uint8Array(bytes)
7878

7979
console.info(content) // 0, 1, 2, 3
8080
```
@@ -185,7 +185,7 @@ for await (const chunk of entry.content({
185185
}
186186

187187
// `data` contains the first 5 bytes of the file
188-
const data = Buffer.concat(bufs)
188+
const data = new Uint8Array(bufs)
189189
```
190190
191191
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.

0 commit comments

Comments
 (0)