Skip to content

Missing support for ES2015 Map and Set #79

@lmammino

Description

@lmammino

The code doesn't seem to work when the underlying object (or an object along the path) is of type Set or Map.

We could support both by following this approach:

  • with Set, convert it into an array and access it as it is an array (some logic and memory considerations need to be made here)
  • with Map, you can simply use the get and has fields to access the data.

Code to replicate the issue:

var objectPath = require("object-path");

var s = new Set(['a','b','c']);
console.log(objectPath.get(s, '0')); // undefined
console.log((Array.from(s))[0]); // 'a'

var m = new Map();
m.set('a','b');
console.log(objectPath.get(m, 'a')); // undefined
console.log(m.get('a')); // 'b'

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions