slice โ
Returns a section of the hex or byte array given a start/end bytes offset.
Install โ
ts
import { slice } from 'viem'
Usage โ
ts
import { slice } from 'viem'
sliceHex('0x0123456789', 1, 4)
// 0x234567
slice(new Uint8Array([1, 122, 51, 123]), 1, 3)
// Uint8Array [122, 51]
Returns โ
Hex | ByteArray
The section of the sliced value.
Parameters โ
value โ
- Type:
Hex | ByteArray
The hex or byte array to slice.
ts
sliceHex(
'0x0123456789',
1,
4
)
start (optional) โ
- Type:
number
The start offset (in bytes).
ts
sliceHex(
'0x0123456789',
1
)
end (optional) โ
- Type:
number
The end offset (in bytes).
ts
sliceHex(
'0x0123456789',
1,
4
)