Janet 1.27.0-01aab66 Documentation
(Other Versions: 1.26.0 1.25.1 1.24.0 1.23.0 1.22.0 1.21.0 1.20.0 1.19.0 1.18.1 1.17.1 1.16.1 1.15.0 1.13.1 1.12.2 1.11.1 1.10.1 1.9.1 1.8.1 1.7.0 1.6.0 1.5.1 1.5.0 1.4.0 1.3.1 )

Buffer Module

Index

buffer/bit buffer/bit-clear buffer/bit-set buffer/bit-toggle buffer/blit buffer/clear buffer/fill buffer/format buffer/new buffer/new-filled buffer/popn buffer/push buffer/push-at buffer/push-byte buffer/push-string buffer/push-word buffer/slice buffer/trim

cfunction (buffer/bit buffer index)
Gets the bit at the given bit-index. Returns true if the bit is set, false if not.
Community Examples / source
cfunction (buffer/bit-clear buffer index)
Clears the bit at the given bit-index. Returns the buffer.
Community Examples / source
cfunction (buffer/bit-set buffer index)
Sets the bit at the given bit-index. Returns the buffer.
Community Examples / source
cfunction (buffer/bit-toggle buffer index)
Toggles the bit at the given bit index in buffer. Returns the buffer.
Community Examples / source
cfunction (buffer/blit dest src &opt dest-start src-start src-end)
Insert the contents of `src` into `dest`. Can optionally take indices that indicate which part of `src` to copy into which part of `dest`. Indices can be negative in order to index from the end of `src` or `dest`. Returns `dest`.
Community Examples / source
cfunction (buffer/clear buffer)
Sets the size of a buffer to 0 and empties it. The buffer retains its memory so it can be efficiently refilled. Returns the modified buffer.
Community Examples / source
cfunction (buffer/fill buffer &opt byte)
Fill up a buffer with bytes, defaulting to 0s. Does not change the buffer's length. Returns the modified buffer.
Community Examples / source
cfunction (buffer/format buffer format & args)
Snprintf like functionality for printing values into a buffer. Returns the modified buffer.
Community Examples / source
cfunction (buffer/new capacity)
Creates a new, empty buffer with enough backing memory for `capacity` bytes. Returns a new buffer of length 0.
Community Examples / source
cfunction (buffer/new-filled count &opt byte)
Creates a new buffer of length `count` filled with `byte`. By default, `byte` is 0. Returns the new buffer.
Community Examples / source
cfunction (buffer/popn buffer n)
Removes the last `n` bytes from the buffer. Returns the modified buffer.
Community Examples / source
cfunction (buffer/push buffer & xs)
Push both individual bytes and byte sequences to a buffer. For each x in xs, push the byte if x is an integer, otherwise push the bytesequence to the buffer. Thus, this function behaves like both `buffer/push-string` and `buffer/push-byte`. Returns the modified buffer. Will throw an error if the buffer overflows.
Community Examples / source
cfunction (buffer/push-at buffer index & xs)
Same as buffer/push, but inserts new data at index `index`.
Community Examples / source
cfunction (buffer/push-byte buffer & xs)
Append bytes to a buffer. Will expand the buffer as necessary. Returns the modified buffer. Will throw an error if the buffer overflows.
Community Examples / source
cfunction (buffer/push-string buffer & xs)
Push byte sequences onto the end of a buffer. Will accept any of strings, keywords, symbols, and buffers. Returns the modified buffer. Will throw an error if the buffer overflows.
Community Examples / source
cfunction (buffer/push-word buffer & xs)
Append machine words to a buffer. The 4 bytes of the integer are appended in twos complement, little endian order, unsigned for all x. Returns the modified buffer. Will throw an error if the buffer overflows.
Community Examples / source
cfunction (buffer/slice bytes &opt start end)
Takes a slice of a byte sequence from `start` to `end`. The range is half open, [start, end). Indexes can also be negative, indicating indexing from the end of the end of the array. By default, `start` is 0 and `end` is the length of the buffer. Returns a new buffer.
Community Examples / source
cfunction (buffer/trim buffer)
Set the backing capacity of the buffer to the current length of the buffer. Returns the modified buffer.
Community Examples / source