text: export default class ObjectPool {
    // @todo Add initial size
    constructor(T, initialSize) {
      this.freeList = [];
      this.count = 0;
      this.T = T;
      this.isObjectPool = true;
  
      var extraArgs = null;
      if (arguments.length > 1) {
        extraArgs = Array.prototype.slice.call(arguments);
        extraArgs.shift();
      }
  
      this.createElement = extraArgs
        ? () => {
            return new T(...extraArgs);
          }
        : () => {
            return new T();
          };
  
      if (typeof initialSize !== "undefined") {
        this.expand(initialSize);
      }
    }
  
    acquire() {
      // Grow the list by 20%ish if we're out
      if (this.freeList.length <= 0) {
        this.expand(Math.round(this.count * 0.2) + 1);
      }
  
      var item = this.freeList.pop();
  
      return item;
    }
  
    release(item) {
      item.reset();
      this.freeList.push(item);
    }
  
    expand(count) {
      for (var n = 0; n < count; n++) {
        this.freeList.push(this.createElement());
      }
      this.count += count;
    }
  
    totalSize() {
      return this.count;
    }
  
    totalFree() {
      return this.freeList.length;
    }
  
    totalUsed() {
      return this.count - this.freeList.length;
    }
  }
  