npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

insize

v1.1.10

Published

A small library to get the memory size of a JavaScript object

Downloads

246

Readme

Insize

Welcome to Insize! 🎉

insize is a library designed to estimate the memory space occupied by runtime variables. It's like having a tape measure for your code!

Tests Coverage Downloads License NPM Version

Why Insize?

Ever wondered how much memory your variables are hogging? Insize helps you:

  • Estimate memory usage of variables.
  • Optimize your code by identifying memory-heavy variables.
  • Debug memory leaks by keeping an eye on variable sizes.
  • Test and profile your applications more effectively.

Installation

You can install Insize via npm:

npm install insize

Usage

Here's a quick example to get you started:

const insize = require('insize');

let myVariable = { name: "John", age: 30 };
console.log(`Memory size: ${insize(myVariable)} bytes`);

Insize exports data in different bytes' multiples. The default value is b, measuring in bytes.

insize(myVariable, 'kb'); // 204
insize(myVariable, 'Mb'); // 0.204
insize(myVariable, 'Gb'); // 0.000204

This library can be easily imported and used in typescript too.

import insize from insize;

let myVariable = { name: "John", age: 30 };
console.log(`Memory size: ${insize(myVariable)} bytes`);

Features

  • Easy to use: Simple API to get memory sizes.
  • Lightweight: Minimal overhead to your application.
  • Versatile: Works with various data types.

Use Cases

If you are wondering when and where it could be useful, these are real cases we used Insize for.

  • Testing: Ensure your tests don't consume excessive memory.
  • Optimization: Identify and optimize memory-heavy variables.
  • Debugging: Track down memory leaks by monitoring variable sizes.
  • Profiling: Profile your application's memory usage in different scenarios.

Testing

To run tests, you can use the following command:

npm test

Make sure you have all the necessary dependencies installed by running:

npm install

Test cases are generated using Insightest and exploit Jest. You can find the test files in the tests directory. To add new tests, create a new file with the .test.js extension in the tests directory.

Contributing

We welcome contributions! Feel free to open issues or submit pull requests.

Please, follow the Code of Conduct attached.

License

This project is licensed under the MIT License.


Happy measuring! 📏