- 
                Notifications
    
You must be signed in to change notification settings  - Fork 171
 
Open
Description
Background
Migrate from msgpack-lite, which has support for many types out of box.
And I had a look at types at @msgpack/msgpack/dist/encode.d.ts,
seems everything is also OK out-of-box.
export declare function encode<ContextType = undefined>(
  // seems everything is OK out-of-box
  value: unknown, 
  options?: EncodeOptions<SplitUndefined<ContextType>>
): Uint8Array;Reproduce
var msgpack=require('@msgpack/msgpack')
var nop=x=>msgpack.decode(msgpack.encode(x))Actual
> nop({x:Buffer.from('x'), y:new ArrayBuffer(0), z:new Error('msg')})
{ x: Uint8Array(1) [ 120 ], y: {}, z: {} }Expected
> msgpack = require('msgpack-lite')
> nop({x:Buffer.from('x'), y:new ArrayBuffer(0), z:new Error('msg')})
{
  x: <Buffer 78>,
  y: ArrayBuffer { [Uint8Contents]: <>, byteLength: 0 },
  z: Error: msg
}Suggestion
export declare function encode<ContextType = undefined>(
  value: unknown, 
  options?: EncodeOptions<SplitUndefined<ContextType>>
): Uint8Array;
export declare function encodeOutOfBox<ContextType = undefined>(
  // any types are tested, `decode(encode(value))` should be same out of box
  value: TESTED_TYPES, 
  options?: EncodeOptions<SplitUndefined<ContextType>>
): Uint8Array;connor4312, kefniark and loynoir
Metadata
Metadata
Assignees
Labels
No labels