UNPKG

@cloudpss/ubjson

Version:

Opinionated UBJSON encoder/decoder for CloudPSS.

22 lines (12 loc) 659 B
# @cloudpss/ubjson Opinionated UBJSON encoder/decoder for CloudPSS. Inspired by https://bitbucket.org/shelacek/ubjson, optimized for huge objects. ## API ### encode(value: unknown): Uint8Array Encode JS value to UBJSON binary data. `Uint8Array`, `Int8Array`, `Int16Array`, `Int32Array`, `Float32Array`, `Float64Array` are recognized and encoded as optimized object format. Other type of typed arrays are not supported. ### decode(value: Uint8Array): unknown Decode UBJSON binary data to JS value. Numeric array of optimized object format will be decoded into corresponding typed arrays. Int64 (`L`) and high-precision number (`H`) are not supported.