Repository URL to install this package:
|
Version:
6.0.4 ▾
|
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* @desc call destructor on a pooled instance, put it back in the pool
* @since 5.0.0
* @memberOf pooler
*
* @param instance call destructor
*
* @prop {Array} instancePool
* @prop {number} poolSize
* @prop {Function} destructor
*
* @example
*
* class Eh {}
* addPoolingTo(Eh)
* const eh = Eh.getPooled()
* eh.release()
*
*/
function standardReleaser(instance) {
var Klass = this;
if (process.env.NODE_ENV !== 'production') {
if (!(instance instanceof Klass)) {
throw new Error("Trying to release an instance\n into a pool of a different type.");
}
}
instance.destructor();
if (Klass.instancePool.length < Klass.poolSize) {
Klass.instancePool.push(instance);
}
}
exports.default = standardReleaser;
//# sourceMappingURL=standardReleaser.js.map