• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/* eslint-disable @typescript-eslint/no-namespace */
2import { Builder } from './flexbuffers/builder.js'
3import { toReference } from './flexbuffers/reference.js'
4export { toReference } from './flexbuffers/reference.js'
5
6export function builder(): Builder {
7    return new Builder();
8}
9
10export function toObject(buffer: ArrayBuffer): unknown {
11    return toReference(buffer).toObject();
12}
13
14export function encode(object: unknown, size = 2048, deduplicateStrings = true, deduplicateKeys = true, deduplicateKeyVectors = true): Uint8Array {
15    const builder = new Builder(size > 0 ? size : 2048, deduplicateStrings, deduplicateKeys, deduplicateKeyVectors);
16    builder.add(object);
17    return builder.finish();
18}
19