Janet 1.32.1-cc5beda Documentation
(Other Versions:
1.31.0
1.29.1
1.28.0
1.27.0
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/from-bytes 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
buffer/bit cfunction source
(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 source
(buffer/bit-clear buffer index) Clears the bit at the given bit-index. Returns the buffer.Community Examples
buffer/bit-set cfunction source
(buffer/bit-set buffer index) Sets the bit at the given bit-index. Returns the buffer.Community Examples
buffer/bit-toggle cfunction source
(buffer/bit-toggle buffer index) Toggles the bit at the given bit index in buffer. Returns the buffer.Community Examples
buffer/blit cfunction source
(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
buffer/clear cfunction source
(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 source
(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 source
(buffer/format buffer format & args) Snprintf like functionality for printing values into a buffer. Returns the modified buffer.Community Examples
buffer/from-bytes cfunction source
(buffer/from-bytes & byte-vals) Creates a buffer from integer parameters with byte values. All integers will be coerced to the range of 1 byte 0-255.Community Examples
buffer/new cfunction source
(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 source
(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 source
(buffer/popn buffer n) Removes the last `n` bytes from the buffer. Returns the modified buffer.Community Examples
buffer/push cfunction source
(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
buffer/push-at cfunction source
(buffer/push-at buffer index & xs) Same as buffer/push, but copies the new data into the buffer at index `index`.Community Examples
buffer/push-byte cfunction source
(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
buffer/push-string cfunction source
(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
buffer/push-word cfunction source
(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
buffer/slice cfunction source
(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 source
(buffer/trim buffer) Set the backing capacity of the buffer to the current length of the buffer. Returns the modified buffer.Community Examples