A small, dependency-free library to calculate the rough size of a javascript object in memory.
  • JavaScript 100%
Find a file
2015-02-25 04:33:24 -08:00
tests Initial commit. 2015-02-25 04:33:24 -08:00
.gitignore Initial commit. 2015-02-25 04:33:24 -08:00
.jsbeautifyrc Initial commit. 2015-02-25 04:33:24 -08:00
.jshintrc Initial commit. 2015-02-25 04:33:24 -08:00
.travis.yml Initial commit. 2015-02-25 04:33:24 -08:00
index.js Initial commit. 2015-02-25 04:33:24 -08:00
package.json Initial commit. 2015-02-25 04:33:24 -08:00
README.md Initial commit. 2015-02-25 04:33:24 -08:00

js-sizeof

NPM version Build Status Coverage Status

A small (<50 loc), dependency-free library to calculate the rough size of a javascript object in memory.

Installation

npm install js-sizeof

Usage

    var sizeof = require( 'js-sizeof' );

    var obj = {
        floop: 0,
        gloop: 'gloop!',
        ploop: [ 1, 2, 3 ]
    };
    
    var foo = {
        bar: {
            fiz: 1,
            baz: 'hi!',
            buz: [ 1, 2, 3 ]
        },
        bloop: obj,
        otherBloop: obj, // shouldn't end up counted twice
    };
    
    console.log( sizeof( foo ) );

CHANGELOG

0.0.1

  • Initial revision
    • I wanted a really small, dependency free library to get the size of objects
    • Other options either had crazy dependencies or were more than just sizeof