Files
n8n-openai-adapter/lib/binary.ex
T
2012-03-30 14:51:40 +02:00

28 lines
701 B
Elixir

defmodule Binary do
@doc """
Access the binary via a predicate.
If an integer, it does a byte lookup with the index
starting with one. Negative indexes performs a reverse
lookup, for example, -1 can be used to retrieve the
last byte in the binary. Returns nil if an out of bounds
access occurs.
If a regular expression, it returns a binary with the
matched contents.
This implements the same API as the `Access` protocol.
Notice currently Elixir does not provide functions for
accessing utf-8 code points.
## Examples
binary = "abc"
Binary.access binary, -1 #=> 99
"""
def access(binary, access) do
Access.BitString.access(binary, access)
end
end