NodeJS handles raw binary data with the classes Buffer
and Blob
, while Raku does so with the roles Buf
and Blob
, which are mutable and immutable buffers respectively. In Raku, a Buf
composes a Blob
so all Blob
methods are available to Buf
objects.
The following table summarizes the similarities and differences between buffer constructs in NodeJS and Raku:
NodeJS | Raku | |
---|---|---|
Buffer /Buf |
Fixed-length sequence of bytes (No methods such as push , pop , etc.) |
Sequence of bytes that can grow or shrink dynamically. You can use methods such as push , pop , etc. |
Iterable using the for..of syntax |
It cannot be iterated over using a looping construct. Use the method list to get hold of an iterator. |