mariocasciaro / object-path

A tiny JavaScript utility to access deep properties using a path (for Node and the Browser)
MIT License
1.06k stars 84 forks source link

Missing support for ES2015 Map and Set #79

Open lmammino opened 7 years ago

lmammino commented 7 years ago

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:

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'