miktam / sizeof

Get size of a JavaScript object
MIT License
301 stars 45 forks source link

V2 - uses precise calculation for node.js, and separate implementation for the browser. #70

Closed miktam closed 1 year ago

miktam commented 1 year ago

V2 uses different implementations for Node.js and browsers.

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

Browser: Iterates through a tree recursively and, depending on the element type, calculates byte size.

codecov-commenter commented 1 year ago

Codecov Report

:exclamation: No coverage uploaded for pull request base (master@fad2ede). Click here to learn what that means. The diff coverage is n/a.

@@            Coverage Diff            @@
##             master      #70   +/-   ##
=========================================
  Coverage          ?   92.68%           
=========================================
  Files             ?        2           
  Lines             ?       41           
  Branches          ?        0           
=========================================
  Hits              ?       38           
  Misses            ?        3           
  Partials          ?        0           

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more