Janet 1.43.0-e4b5045 Documentation
(Other Versions: 1.42.0 1.41.2 1.41.1 1.40.1 1.40.0 1.39.1 1.38.0 1.37.1 1.36.0 1.35.0 1.34.0 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/format-at buffer/from-bytes buffer/new buffer/new-filled buffer/popn buffer/push buffer/push-at buffer/push-byte buffer/push-float32 buffer/push-float64 buffer/push-string buffer/push-uint16 buffer/push-uint32 buffer/push-uint64 buffer/push-word buffer/slice buffer/trim


buffer/bit cfunction source
(buffer/bit buf bit-index)

Gets the bit at `bit-index` in a buffer, `buf`. Returns true if the bit is set, false if not.
Community Examples

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

Clears the bit at `bit-index` in a buffer, `buf`. Returns `buf`.
Community Examples

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

Sets the bit at `bit-index` in a buffer, `buf`. Returns `buf`.
Community Examples

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

Toggles the bit at `bit-index` in a buffer, `buf`. Returns `buf`.
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 buf)

Sets the size of a buffer, `buf`, to 0 and empties it. `buf` retains its memory so it can be efficiently refilled. Returns `buf`.
Community Examples

buffer/fill cfunction source
(buffer/fill buf &opt byte)

Fill up a buffer, `buf`, with bytes, defaulting to 0s. Does not change `buf`'s length. Returns `buf`.
Community Examples

buffer/format cfunction source
(buffer/format buf fmt & args)

Formats `fmt`, similar to `sprintf()`, with `args` into a buffer `buf`. Returns buf.
Community Examples

buffer/format-at cfunction source
(buffer/format-at buf at fmt & args)

Formats `fmt`, similar to `sprintf()`, with `args` into a buffer `buf`, starting at index `at`. Returns buf.
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 n &opt byte)

Creates a new buffer of length `n` filled up with `byte`. By default, `byte` is 0. Returns the new buffer.
Community Examples

buffer/popn cfunction source
(buffer/popn buf n)

Removes the last `n` bytes from a buffer, `buf`. Returns `buf`.
Community Examples

buffer/push cfunction source
(buffer/push buf & xs)

Push both single bytes and bytes type values to a buffer, `buf`. Values in `xs` that are bytes are pushed to `buf` as bytes, while bytes type values have their individual bytes pushed. Thus, this function behaves like both `buffer/push-byte` and `buffer/push-string`. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/push-at cfunction source
(buffer/push-at buf index & xs)

Same as `buffer/push`, but copies the new data into `buf` at index `index`.
Community Examples

buffer/push-byte cfunction source
(buffer/push-byte buf & xs)

Append bytes to a buffer, `buf`. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/push-float32 cfunction source
(buffer/push-float32 buf order data)

Push the underlying bytes of a 32 bit float, `data`, onto the end of the buffer, `buf`. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/push-float64 cfunction source
(buffer/push-float64 buf order data)

Push the underlying bytes of a 64 bit float, `data`, onto the end of the buffer, `buf`. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/push-string cfunction source
(buffer/push-string buf & xs)

Push bytes type values onto the end of a buffer, `buf`. Each `xs` should be a bytes type. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/push-uint16 cfunction source
(buffer/push-uint16 buf order data)

Push a 16 bit unsigned integer, `data`, onto the end of a buffer, `buf`. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/push-uint32 cfunction source
(buffer/push-uint32 buf order data)

Push a 32 bit unsigned integer, `data` onto the end of a buffer, `buf`. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/push-uint64 cfunction source
(buffer/push-uint64 buf order data)

Push a 64 bit unsigned integer, `data`, onto the end of a buffer, `buf`. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/push-word cfunction source
(buffer/push-word buf & xs)

Append machine words to a buffer, `buf`. The 4 bytes of the integer are appended in two's complement, little endian order, unsigned for all x. Returns `buf`. Expands `buf` as needed. Throws an error if size limit is exceeded.
Community Examples

buffer/slice cfunction source
(buffer/slice bytes &opt start end)

Same as `string/slice`, but returns a buffer.
Community Examples

buffer/trim cfunction source
(buffer/trim buf)

Set the backing capacity of a buffer, `buf`, to its current length. Returns `buf`.
Community Examples