js-sizeof

0.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i js-sizeof

Weekly Downloads

258

Version

0.0.1

License

none

Last publish

Collaborators

  • andyburke