Skip to content

v2.0.0 Different implementation for node.js and the browser

Compare
Choose a tag to compare
@miktam miktam released this 24 Jan 14:54
· 16 commits to master since this release
c8675b6

This version uses two different implementations for Node and browser.

Node.js: The function uses the Buffer.from(objectToString) method to convert the string representation of the object to a buffer, and then it uses the byteLength property to obtain the size of the buffer in bytes.

Browser implementation uses a combination of recursion and a stack to iterate through all of its properties, adding up the number of bytes for each data type it encounters.