JanetDocsPlaygroundI'm feeling luckyGitHub sign in


    src/core/buffer.c on line 333, column 1

    (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.

1 exampleSign in to add an example
Example usage

janet:1:> (def buf @"ABCDE")
janet:2:> (buffer/slice 0)
error: bad slot #0, expected string|symbol|keyword|buffer, got 0
  in buffer/slice
  in _thunk [repl] (tailcall) on line 2, column 1
janet:3:> (buffer/slice buf 0)
janet:4:> (buffer/slice buf 0 1)
janet:5:> (buffer/slice buf 0 -1)
janet:6:> (buffer/slice buf 1 3)