Janet 1.1.0-dev Documentation
buffer/bit buffer/bit-clear buffer/bit-set buffer/bit-toggle buffer/blit buffer/clear buffer/format buffer/new buffer/new-filled buffer/popn buffer/push-byte buffer/push-string buffer/push-word buffer/slice
(buffer/bit buffer index) Gets the bit at the given bit-index. Returns true if the bit is set, false if not.
(buffer/bit-clear buffer index) Clears the bit at the given bit-index. Returns the buffer.
(buffer/bit-set buffer index) Sets the bit at the given bit-index. Returns the buffer.
(buffer/bit-toggle buffer index) Toggles the bit at the given bit index in buffer. Returns the buffer.
(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.
(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.
(buffer/format buffer format & args) Snprintf like functionality for printing values into a buffer. Returns the modified buffer.
(buffer/new capacity) Creates a new, empty buffer with enough memory for capacity bytes. Returns a new buffer.
(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.
(buffer/popn buffer n) Removes the last n bytes from the buffer. Returns the modified buffer.
(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.
(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.
(buffer/push-word buffer x) Append a machine word to a buffer. The 4 bytes of the integer are appended in twos complement, big endian order, unsigned. Returns the modified buffer. Will throw an error if the buffer overflows.
(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.