Buffer polyfill is considerably slower than the one built in node.
When I try to get the size of the following object { a: 1, b: 2, c: 3, d: { a: 1, b: 2, c: 3, d: { a: 1, b: 2, c: 3, d: { a: 1, b: 2, c: 3 } } } } one million times (1_000_000) in node 20 it takes 1817ms with the polyfill and 1197ms without.
I'm proposing to import the polyfill only when running in browser to speed up the calculation in node environment.
Buffer polyfill is considerably slower than the one built in node. When I try to get the size of the following object
{ a: 1, b: 2, c: 3, d: { a: 1, b: 2, c: 3, d: { a: 1, b: 2, c: 3, d: { a: 1, b: 2, c: 3 } } } }
one million times (1_000_000) in node 20 it takes1817ms
with the polyfill and1197ms
without.I'm proposing to import the polyfill only when running in browser to speed up the calculation in node environment.