Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

msgpack lite

import msgpack from 'msgpack-lite'
import jsonpack from 'jsonpack'

export class Msgpack {
  static pack(data: Record<string, any> | Record<string, any>[]): Buffer {
    const pack: string = jsonpack.pack(data)
    return msgpack.encode(pack)
  }

  static unpack(data: Buffer | Uint8Array | number[]): any {
    const decode: string = msgpack.decode(data)
    return jsonpack.unpack(decode)
  }
}
 
PREVIOUS NEXT
Tagged: #msgpack #lite
ADD COMMENT
Topic
Name
5+3 =