Pack bit values into bytes.
Numeric.bit.pack(values, order, level)Groups bits into bytes using the requested order.
- Parameters:
values: Bit values to packorder: Byte order used for packinglevel: Optional axis along which to pack two-dimensional matrices
- Returns: Packed byte values
- NumPy: Equivalent to
np.packbits.
import Numeric from '@neabyte/numerix'
const bytes = Numeric.bit.pack([1, 0, 1, 0, 0, 0, 0, 1])
console.log(bytes)
// [161]import Numeric from '@neabyte/numerix'
const bytes = Numeric.bit.pack([1, 0, 1, 0, 0, 0, 0, 1], 'little')
console.log(bytes)
// [133]import Numeric from '@neabyte/numerix'
const bytes = Numeric.bit.pack([1, 0, 1])
console.log(bytes)
// [160]import Numeric from '@neabyte/numerix'
const bytes = Numeric.bit.pack([])
console.log(bytes)
// []