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
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.
Copy file name to clipboardExpand all lines: packages/ipfs-unixfs-exporter/README.md
+3-3
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ const files = []
50
50
51
51
forawait (constfileofimporter([{
52
52
path:'/foo/bar.txt',
53
-
content:Buffer.from(0, 1, 2, 3)
53
+
content:newUint8Array([0, 1, 2, 3])
54
54
}], ipld)) {
55
55
files.push(file)
56
56
}
@@ -74,7 +74,7 @@ for await (const buf of entry.content({
74
74
bytes.push(buf)
75
75
}
76
76
77
-
constcontent=Buffer.concat(bytes)
77
+
constcontent=newUint8Array(bytes)
78
78
79
79
console.info(content) // 0, 1, 2, 3
80
80
```
@@ -185,7 +185,7 @@ for await (const chunk of entry.content({
185
185
}
186
186
187
187
// `data` contains the first 5 bytes of the file
188
-
constdata=Buffer.concat(bufs)
188
+
constdata=newUint8Array(bufs)
189
189
```
190
190
191
191
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.
Copy file name to clipboardExpand all lines: packages/ipfs-unixfs/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -141,7 +141,7 @@ const data = new UnixFS([options])
141
141
-`metadata`
142
142
-`symlink`
143
143
-`hamt-sharded-directory`
144
-
- data (Buffer): The optional data field for this node
144
+
- data (Uint8Array): The optional data field for this node
145
145
- blockSizes (Array, default: `[]`): If this is a `file` node that is made up of multiple blocks, `blockSizes` is a list numbers that represent the size of the file chunks stored in each child node. It is used to calculate the total file size.
146
146
- mode (Number, default `0644` for files, `0755` for directories/hamt-sharded-directories) file mode
147
147
- mtime (`Date`, `{ secs, nsecs }`, `{ Seconds, FractionalNanoseconds }`, `[ secs, nsecs ]`): The modification time of this node
0 commit comments