Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-sizeof

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-sizeof

Sizeof of a JavaScript object in Bytes

  • 2.6.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
221K
decreased by-13.33%
Maintainers
1
Weekly downloads
 
Created

What is object-sizeof?

The object-sizeof npm package is used to calculate the approximate memory usage of JavaScript objects. It helps developers understand the memory footprint of their data structures, which can be crucial for optimizing performance and managing resources effectively.

What are object-sizeof's main functionalities?

Calculate size of a simple object

This feature allows you to calculate the memory size of a simple JavaScript object. The code sample demonstrates how to use the `sizeof` function to get the size of an object with basic key-value pairs.

const sizeof = require('object-sizeof');
const obj = { a: 1, b: 2, c: 3 };
console.log(sizeof(obj)); // Outputs the size of the object in bytes

Calculate size of a nested object

This feature allows you to calculate the memory size of a nested JavaScript object. The code sample shows how to use the `sizeof` function to get the size of an object with nested structures.

const sizeof = require('object-sizeof');
const nestedObj = { a: 1, b: { c: 2, d: { e: 3 } } };
console.log(sizeof(nestedObj)); // Outputs the size of the nested object in bytes

Calculate size of an array

This feature allows you to calculate the memory size of a JavaScript array. The code sample demonstrates how to use the `sizeof` function to get the size of an array.

const sizeof = require('object-sizeof');
const arr = [1, 2, 3, 4, 5];
console.log(sizeof(arr)); // Outputs the size of the array in bytes

Calculate size of a complex object

This feature allows you to calculate the memory size of a complex JavaScript object that includes various data types. The code sample shows how to use the `sizeof` function to get the size of an object with mixed data types.

const sizeof = require('object-sizeof');
const complexObj = { a: 1, b: [1, 2, 3], c: { d: 'string', e: true } };
console.log(sizeof(complexObj)); // Outputs the size of the complex object in bytes

Other packages similar to object-sizeof

Keywords

FAQs

Package last updated on 12 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc