npm.io
1.0.3 • Published 4 years ago

rough-object-size

Licence
Apache-2.0
Version
1.0.3
Deps
0
Size
16 kB
Vulns
0
Weekly
0
Stars
1

return max object size

Usage

use OBJECT_SIZE_MAX_LOOPS to change the default 1000 iteration loop


  const { roughObjectSize } = require('rough-object-size');


  const circular = {
      ok: 1,
    };
    const object = {
      circular,
      val: 1,
    };

    circular.object = circular;

    roughObjectSize(object) === 16


  const object = {
    bool: true,
    alon: 1,
    shimon: 'shimon',
    arr: [1],
    another: {
      wow: [1, 2, 3],
    },
  };

  roughObjectSize(object) ===(4 + 8 + 6 * 2 + 8 + 3 * 8);

Keywords