///
/**
* bjd: a Binary JData (BJData) encoder and decoder for browsers and Node.js
* (https://neurojson.org/bjdata, https://github.com/NeuroJSON/js-bjdata)
*
* import * as bjd from 'bjd'; // or const bjd = require('bjd'), or the bjdata global
* const bytes = bjd.dumpb({a: [1, 2, 3], b: new Float32Array([1.5, 2.5])});
* const value = bjd.loadb(bytes);
*
* Copyright (c) 2019-2026 Qianqian Fang . Apache License 2.0.
*/
import { Decoder, DecodeOptions, loadb, loadbAll, decodeAt, nest } from './decoder';
import { Encoder, EncodeOptions, dumpb } from './encoder';
import { HighPrec, Extension, BJDataError } from './types';
export { Decoder, DecodeOptions, loadb, loadbAll, decodeAt, nest, Encoder, EncodeOptions, dumpb, HighPrec, Extension, BJDataError };
export const version = '1.0.0';
/** The BJData bytes of a value (the name of bjd 0.x; the same as dumpb). */
export function encode(value: any, opts: EncodeOptions = {}): Uint8Array {
return dumpb(value, opts);
}
/** [value, offset after it] of the value at an offset (as bjd 0.x returned; loadb returns the
* value alone). */
export function decode(input: any, offset: number | DecodeOptions = 0, opts: DecodeOptions = {}): [any, number] {
if (typeof offset === 'object') {
return decodeAt(input, 0, offset);
}
return decodeAt(input, offset, opts);
}
/** (bjd 0.x) */
export const decode_offset = decode;
const bjd = { version, dumpb, loadb, loadbAll, decodeAt, encode, decode, decode_offset, nest, Encoder, Decoder, HighPrec, Extension, BJDataError };
export default bjd;