Registry / database / yapool

yapool

JSON →
library1.0.0jsnpmunverified

yapool is a minimalist JavaScript object pooling library, currently at version 1.0.0. It provides a basic linked-list implementation for managing reusable objects, focusing on extreme simplicity over feature richness. Unlike more comprehensive alternatives, yapool offers a 'dead-simple' API for adding and removing objects. Its primary differentiator is its minimal footprint and straightforward approach, making it suitable for scenarios where `n` (the number of objects in the pool) is small. Developers should be aware that operations like `remove` have `O(n)` complexity, which limits its applicability for very large lists. Given its simplicity and the project's age (last published in 2014), its release cadence is very stable or infrequent, suggesting a maintenance-only status rather than active feature development.

npm install yapool
INSTALL
IMPORT
SIG · YAPOOL
Y
yapool
databasejavascriptv1.0.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Pool
const Pool = require('yapool')
yapool is a CommonJS module and exports the Pool constructor as its default.
Pool
import Pool from 'yapool'
import { Pool } from 'yapool'
When importing a CommonJS module in an ES Module context, the `module.exports` is typically treated as the default import. Named imports (`{ Pool }`) will likely fail for this package unless transpiled.

Demonstrates initializing a new Pool, adding and removing objects, and checking the pool's length.

const Pool = require('yapool'); const myObjectPool = new Pool(); // Add objects to the pool const obj1 = { id: 1, value: 'alpha' }; const obj2 = { id: 2, value: 'beta' }; myObjectPool.add(obj1); myObjectPool.add(obj2); console.log(`Pool length after adding: ${myObjectPool.length}`); // Expected: 2 // Remove an object from the pool myObjectPool.remove(obj1); console.log(`Pool length after removing obj1: ${myObjectPool.length}`); // Expected: 1 // Attempt to remove an object not in the pool (it will be a no-op) const obj3 = { id: 3, value: 'gamma' }; myObjectPool.remove(obj3); console.log(`Pool length after attempting to remove obj3: ${myObjectPool.length}`); // Expected: 1 // The remaining object in the pool is obj2 // (Note: yapool does not provide a way to 'get' an object, only add/remove)
Debug
Known issues
gotchaThe `remove` operation, and potentially `add` if it checks for existence, has `O(n)` time complexity. This makes `yapool` unsuitable for applications requiring high performance with very large object pools, as iterating through the linked list to find an object can become slow.
fix
For large pools or performance-critical applications, consider object pool implementations backed by hash maps or other data structures that offer `O(1)` or `O(log n)` average-case performance for lookups and deletions.
affects: >=1.0.0
gotchayapool is a bare-bones implementation lacking common features found in more robust object pooling libraries. It does not provide mechanisms for creating new objects when the pool is empty (factory functions), limiting the pool to pre-existing objects. It also lacks features like maximum pool size, object lifecycle callbacks (e.g., `onReturn`, `onBorrow`), or health checks. This requires manual management of object creation and disposal.
fix
Evaluate if yapool's minimal API meets your needs. For more advanced pooling scenarios, look for libraries that offer factory functions, max limits, and lifecycle hooks.
affects: >=1.0.0
gotchaAs a CommonJS-first package published in 2014, `yapool` may not fully support or be optimized for modern ES Module (ESM) environments and bundlers. While `import Pool from 'yapool'` typically works, named imports might fail, and bundlers might not be able to perform effective tree-shaking, potentially leading to larger bundle sizes if only parts of the module were theoretically used (though `yapool` is small).
fix
Use `import Pool from 'yapool'` when consuming in an ESM project. Be aware that older CommonJS modules might affect modern build optimizations. If strict ESM compatibility or advanced bundling is critical, consider a natively ESM object pool.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: Pool is not a constructor
Attempting to use `new Pool()` after importing incorrectly from a CommonJS module in an ES Module context, or attempting to use a named import that doesn't exist.
fix
Ensure you are using the correct import syntax for a CommonJS default export in ESM: `import Pool from 'yapool';`. If in CommonJS, use `const Pool = require('yapool');`.
Error: Cannot find module 'yapool'
The `yapool` package has not been installed, or the import/require path is incorrect.
fix
Install the package using npm: `npm install yapool`. Verify the package name in your `package.json` and in your `import` or `require` statement.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
24
Amazon
1
Resources
yapool — npm install yapool · libregistry