@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 702 B
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import"../../../core/has.js";import t from"../../../core/PooledArray.js";class e{constructor(t,e){this._factoryCallback=t,this._lengthCallback=e,this._pool=new Map}acquire(t){if(!e.test.disabled){const e=this._pool.get(t);if(e&&0!==e.length)return e.pop()}try{return this._factoryCallback(t)}catch(s){throw s}}release(s){if(e.test.disabled)return;const o=this._lengthCallback(s);let l=this._pool.get(o);l||(l=new t({shrink:!0}),this._pool.set(o,l)),l.push(s)}clear(){this._pool.clear()}get test(){}static{this.test={disabled:!1}}}export{e as BufferPool};