natergj / excel4node

Node module to allow for easy Excel file creation
MIT License
1.38k stars 215 forks source link

issue 269 fix. change Object lookup to Map #276

Closed natergj closed 5 years ago

natergj commented 5 years ago

complex strings (arrays) could not be used as keys for an object lookup. since Map keys can be any type, switch to using those for lookups.

fixes: https://github.com/natergj/excel4node/issues/269

xlazex commented 5 years ago

Using simple JSON.stringify causes that problem.

const s1 = JSON.stringify({ a: 1, b: 2, c: 3 }) 
const s2 = JSON.stringify({ c: 3, b: 2, a: 1 }) //the same as previous
console.log(s1 === s2) //false

because:

"{"a":1,"b":2,"c":3}" not equals "{"c":3,"b":2,"a":1}" (as strings)