1.1.1 • Published 10 months ago

using-pool v1.1.1

Weekly downloads
-
License
GNU GPLv3
Repository
github
Last release
10 months ago

using-pool

An object pool library using modern Typescript for auto-recycling.

It takes advatage of the using keyword to recycle the object as soon as it leaves the scope.

Example:

import { Pool } from 'using-pool'

const userPool = new Pool(() => ({/** an object factory */}))

function doSomething() {
    using user = userPool.get()

    // do some work with the object
    // (...)

} // as soon as it leaves the scope, `user` is recycled (comes back to the pool to be reused)

Installation

npm install using-pool

or

yarn add using-pool

pre requisites

  • node version: 14 or later
  • typescript version: 5.2.0-beta or later

You will also need to set your compilation target to "es2022" or below, and configure your lib setting to either include "esnext" or "esnext.disposable".

// tsconfig.json
{
    "compilerOptions": {
        "target": "es2022",
        "lib": ["es2022", "esnext.disposable", "dom"]
        // (...)
    }
}
1.1.1

10 months ago

1.1.0

10 months ago

1.0.0

10 months ago

0.0.1

10 months ago