davidmarkclements / fast-redact

very fast object redaction
MIT License
284 stars 30 forks source link

Not redacting objects that have a toJSON function #64

Open random42 opened 11 months ago

random42 commented 11 months ago

When objects have a toJSON function redacting is not working:

const fastRedact = require('fast-redact');

const data = {
  a: 'asd',
  toJSON: () => ({
    a: 'well',
  }),
};

const s = fastRedact({
  paths: ['a'],
});

console.log(s(data));

Prints:

{"a":"well"}