New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

pools

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pools

Object Pools: garbage-free object recycling.

latest
npmnpm
Version
1.0.1
Version published
Weekly downloads
1
-75%
Maintainers
1
Weekly downloads
 
Created
Source

Object pools can help prevent pauses due to garbage collection.

Most useful in real-time applications (e.g, games) where objects are created and discarded at a high rate.

Usage

As a stand-alone pool:

{ObjectPool} = require 'pools'
pool = new ObjectPool(MyClass)
x = pool.alloc(...) # use the same arguments as in 'new MyClass(...)'
pool.free(x) # the corpse of x will be re-animated by alloc()

As a class decorator (my preferred method):

{Pooled} = require 'pools'
Pooled class MyClass
    constructor: (junk) ->
x = MyClass.alloc(...)
x.free()

If a class has a destructor method, it is called from inside free().

{Pooled} = require 'pools'
Pooled class Test
    constructor: -> @status = 'inuse'
    destructor:  -> @status = 'free'

Or, a more realistic use of a destructor would be to call free() on any children that need it.

FAQs

Package last updated on 05 Oct 2015

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