UNPKG

@smikhalevski/object-pool

Version:
1 lines 512 B
"use strict";Object.defineProperty(exports,"t",{value:!0});var ObjectPool=function(){function t(t,i){this.i=[],this.h=0,this.o=t,this.u=i}return t.prototype.take=function(){var t=this.i,i=this.h;i===t.length&&this.allocate(t.length||5);var s=t[i];return t[this.h++]=null,s},t.prototype.release=function(t){var i=this.i,s=this.u;s&&s(t),i[0===this.h?i.length:--this.h]=t},t.prototype.allocate=function(t){for(var i=this.i,s=this.o,h=i.length,n=i.length+=t,o=h;o<n;o++)i[o]=s()},t}();exports.ObjectPool=ObjectPool;