Janet 1.12.2-b91fe8b Documentation
(Other Versions: 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-byte buffer/push-string buffer/push-word buffer/slice buffer/trim


buffer/bit 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

buffer/bit-clear cfunction
(buffer/bit-clear buffer index)

Clears the bit at the given bit-index. Returns the buffer.
Community Examples

buffer/bit-set cfunction
(buffer/bit-set buffer index)

Sets the bit at the given bit-index. Returns the buffer.
Community Examples

buffer/bit-toggle cfunction
(buffer/bit-toggle buffer index)

Toggles the bit at the given bit index in buffer. Returns the buffer.
Community Examples

buffer/blit 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 to index from the end of src or dest. Returns dest.
Community Examples

buffer/clear 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

buffer/fill 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

buffer/format cfunction
(buffer/format buffer format & args)

Snprintf like functionality for printing values into a buffer. Returns the modified buffer.
Community Examples

buffer/new 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

buffer/new-filled 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

buffer/popn cfunction
(buffer/popn buffer n)

Removes the last n bytes from the buffer. Returns the modified buffer.
Community Examples

buffer/push-byte cfunction
(buffer/push-byte buffer x)

Append a byte to a buffer. Will expand the buffer as necessary. Returns the modified buffer. Will throw an error if the buffer overflows.
Community Examples

buffer/push-string cfunction
(buffer/push-string buffer str)

Push a string onto the end of a buffer. Non string values will be converted to strings before being pushed. Returns the modified buffer. Will throw an error if the buffer overflows.
Community Examples

buffer/push-word cfunction
(buffer/push-word buffer x)

Append a machine word to a buffer. The 4 bytes of the integer are appended in twos complement, little endian order, unsigned. Returns the modified buffer. Will throw an error if the buffer overflows.
Community Examples

buffer/slice 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

buffer/trim cfunction
(buffer/trim buffer)

Set the backing capacity of the buffer to the current length of the buffer. Returns the modified buffer.
Community Examples