GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [FeatureRequest] More type out of box · Issue #182 · msgpack/msgpack-javascript

[FeatureRequest] More type out of box #182

New issue
Copy link
New issue
Copy link
Open
Open
[FeatureRequest] More type out of box#182
Copy link

Description

@loynoir
loynoir
opened on Jun 16, 2021
Issue body actions

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;
Reacted by Connor Peet, Kevin Destrem and loynoir

Activity

  1. loynoir
    changed the title [-][FeatureRequest] better type guard[/-] [+][FeatureRequest] More type out of box[/+] on Aug 1, 2021
  2. loynoir commented on Aug 1, 2021

    @loynoir
    loynoir
    on Aug 1, 2021
    Author
    More actions

    Hi, @gfx

    Are there any plans to support more types out of box in the future?
    Are there any plans to transplant 24 types supported by msgpack-lite, which haven't updated since 2016?

    https://github.com/kawanet/msgpack-lite/blob/master/lib/ext-packer.js

    https://github.com/kawanet/msgpack-lite/blob/master/lib/ext-unpacker.js

  3. kefniark commented on Oct 16, 2021

    @kefniark
    kefniark
    on Oct 16, 2021
    More actions

    Same there, been migrating a project from msgpack-lite, and the lack of TypedArray was really annoying to deal with.
    Took me some time to figure why it mostly worked but only some fields were ExtData.
    So I end up writing my own codec extension and finally it works (my data is backward compatible with the one previously generated with msgpack-lite).

    But the process was really annoying and time consuming, for basic JS types like Uint8Array and Int32Array.

    So 👍 to get more types, even if its only as an optional typedarray extension code.

  4. makiuchi-d
    added a commit that references this issue on Feb 17, 2023

    一部TypedArrayがサポートされてないため、dashboardでのmsgpack通信を無効化 (#25)

    302e17f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.