Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usemaps gives undefined instead #102

Open
SanderElias opened this issue Jan 12, 2019 · 0 comments
Open

usemaps gives undefined instead #102

SanderElias opened this issue Jan 12, 2019 · 0 comments

Comments

@SanderElias
Copy link

I'm looking into this for the base of my library. I have no control over what data I need to handle later on, other as the requirement "All js types should be supported"

import { encode, decode, createCodec } from 'msgpack-lite';
const options = { codec: createCodec({ usemap: true, preset: true }) };

const test = Array.from({ length: 10 }, (e, i) => ({
  name: i + ' sander',
  dob: new Date(1900, 4, 14),
  stuff: new Map<any, any>([
    [1, [2, 4, 5, 7, 2, 4]],
    ['blah', false],
    [{ a: 'b' }, { a: 'hi' }],
    [3, 4],
    ['somestring', 'anotherString']
  ]),
  tags: new Set(['a', 'b', 'dd'])
}));

const enc = encode(test, options);
const dec = decode(enc, options);

result:
image

I know set's are not supported out of the box, and will add my own extension for that, but this issue is blocking me now.
Is there a mistake in my code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant