Skip to content

Adding support for Maps #23

Description

@luzlab

I'd like to add support for Map objects. I have some working code, but it's not clear where I should add code for new types. I also saw an issue on the meteor repo for this, and would like to submit a PR here so I can EJSON Maps in plain Node apps as well.

Any thoughts on how to add additional types?

import { Meteor } from 'meteor/meteor';
import { EJSON } from 'meteor/ejson';

Map.prototype.toJSONValue = function () {
  return JSON.stringify([...this]);
};

Map.prototype.typeName = function () {
  return 'Map';
};

EJSON.addType('Map', (jsonStr) => {
  return new Map(JSON.parse(jsonStr));
});

Activity

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