New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

easy-object-pool

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easy-object-pool

an easy way to use object pool

  • 1.0.12
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-55.56%
Maintainers
1
Weekly downloads
 
Created
Source

Easy Object Pool

an easy way to use object pool

Install

yarn add easy-object-pool
or
npm i easy-object-pool -S

Usage

import {useObjectPool} from 'easy-object-pool'

class Cat {
}

const [getACat, recycleCat] = useObjectPool<Cat>(() => new Cat())

//create a Cat instance
const cat = getACat()

//recycle a Cat instance
recycleCat(cat)

Api

useObjectPool

function useObjectPool<T>(factoryMethod: (...params: any[]) => T, options?: {
	initializationMethod?: (instance: T, ...params: any[]) => void;
	disposeMethod?: (instance: T, ...params: any[]) => void;
	preInstantiationQuantity?: number;
	limit?: number;
}): [(...params: any[]) => T, (instance: T | T[]) => void, () => void]
Options interface
fieldtyperequireddefaultdescription
factoryMethodsee Declarefactory method to instantiate a instance
initializationMethodsee Declareinitialize a instance when get a instance
disposeMethodsee Declarecall if clean instances
preInstantiationQuantitynumber0instantiate some instances at ahead
limitnumber0set a limit quantity of pool
Returns

[getAInstance, recycleInstance, clear]

fieldtypedescription
getAInstancesee Declareget a instance
recycleInstancesee Declarerecycle a instance or instances
clearsee Declareclean all instances

clearAll

function clearAll()

Keywords

FAQs

Package last updated on 23 Nov 2021

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