hughsk / flat

:steam_locomotive: Flatten/unflatten nested Javascript objects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Feature request: Flatten __proto__

Ghost---Shadow opened this issue · comments

const a = {
  __proto__: {
    fun: () => 'foo',
    __proto__: {
      fun: () => 'bar',
    },
  },
};

Should flatten to

const a = {
  '__proto__.fun': () => 'foo',
  '__proto__.__proto__.fun': () => 'bar',
};

We can have a flag like extraKeys: ['__proto__']

I don't see a good reason to implement this, these are reserved parts of an object and should not be considered serializable. For example JSON.stringify() also ignores these values.