Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
chain-able-deps / dist / cache / standardReleaser.js
Size: Mime:
"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