Skip to content

Bytes.slice

Returns a section of a Bytes.Bytes value given a start/end bytes offset.

Imports

Named
import { Bytes } from 'ox'

Examples

import { Bytes } from 'ox'
 
Bytes.slice(
  Bytes.from([1, 2, 3, 4, 5, 6, 7, 8, 9]),
  1,
  4,
)
Uint8Array([2, 3, 4])

Definition

function slice(
  value: Bytes,
  start?: number | undefined,
  end?: number | undefined,
  options?: slice.Options,
): Bytes

Source: src/core/Bytes.ts

Parameters

value

  • Type: Bytes

The Bytes.Bytes value.

start

  • Type: number | undefined
  • Optional

Start offset.

end

  • Type: number | undefined
  • Optional

End offset.

options

  • Type: slice.Options
  • Optional

Slice options.

options.strict

  • Type: boolean
  • Optional

Asserts that the sliced value is the same size as the given start/end offsets.

Return Type

Sliced Bytes.Bytes value.

Bytes