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

thirsty

v0.2.0

Published

Simple Object Pool for Javascript

Downloads

14

Readme

thirsty

thirsty is a simple Object Pool implementation for Javascript.

Object pools help you tame the garbage collector by making it easy to preallocate and reuse objects. This is especially useful on mobile platforms.

For a more comprehensive introduction to Object Pools, read Static Memory Javascript with Object Pools.

Install

NPM

To install thirsty into a Node.js project, input the following command in the root directory of your project.

npm install thirsty --save

Bower

To install thirsty into a client-side project using Bower, input the following command in the root directory of your project.

bower install thirsty --save

Use

makePool(obj, num)

Creates an Object Pool containing an array of num objects that are equivalent to obj

Example

This example creates a pool of 100 objects that look like {name: 'Mack', age: 52}.

const thirsty = require('thirsty');

const template = {name: 'Mack', age: 52};

const pool = thirsty.makePool(template, 100);

get(pool)

Returns the next available object in pool Throws exception if pool is full

const thirsty = require('thirsty');

const template = {name: 'Mack', age: 52};

const pool = thirsty.makePool(template, 100);

const obj = thirsty.get(pool); // Returns first object in pool

scrub(pool, obj)

Resets obj in pool and marks it as free Throws error if obj is not in pool

const thirsty = require('thirsty');

const template = {name: 'Mack', age: 52};

const pool = thirsty.makePool(obj, 2);

const obj = thirsty.get(pool);

obj.name = 'Philip';
obj.age  = 28;

thirsty.scrub(pool, obj)
// pool.array[0] is once again {name: 'Mack', age: 52}