Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[FeatureRequest] More type out of box #182

Open
@loynoir

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /