Closed gajus closed 5 years ago
Currently, Buffer becomes a stringified expression, e.g.
import createClone from 'rfdc';
const clone = createClone();
const requestDefinition = {
foo: Buffer.from('bar')
};
console.log('IN', requestDefinition);
console.log('OUT', clone(requestDefinition));
IN { foo: <Buffer 62 61 72> }
OUT { foo: { '0': 98, '1': 97, '2': 114 } }
Equally, would be nice to have functionality equivalent to https://www.npmjs.com/package/map-obj that would allow to customise cloning behaviour per key/value.
This module is specialist on cloning "simple" objects very fast. The more types get supported, the more special cases have to be supported which slows down the average case. I don't think it's a good idea to go into that direction. Similar with the map-obj
module: keeping such functionality in a specialised module seems best to me.
yes I agree with @BridgeAR - having said that if were able to create a PR with buffer support that includes benchmarks showing zero overhead I'd be happy to accept. closing for now
Is there a reason for not supporting Buffer cloning?