Skip to content

Commit

Permalink
update buffer conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Dec 2, 2024
1 parent 990b3e5 commit 16c1b48
Showing 1 changed file with 0 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,6 @@ const buffer: Buffer = Buffer.from([1, 2, 3, 4]);
const uint8Array: Uint8Array = buffer; // No conversion needed
```

If you need a copy of the data (to avoid shared memory):

```ts
const uint8ArrayCopy: Uint8Array = new Uint8Array(buffer);
```

### Conversion from Uint8Array to Buffer

You can create a `Buffer` from a `Uint8Array` using `Buffer.from`:
Expand All @@ -232,7 +226,6 @@ const uint8Array: Uint8Array = new Uint8Array([1, 2, 3, 4]);
const buffer: Buffer = Buffer.from(uint8Array.buffer);
```


</details>

#### Before
Expand Down

0 comments on commit 16c1b48

Please sign in to comment.