export class ScratchBuffers {
  constructor() {
    this._arrays = new Map();
  }

  getArray(key, length) {
    let arr = this._arrays.get(key);
    if (!arr || arr.length < length) {
      arr = new Array(length);
      this._arrays.set(key, arr);
    }
    if (arr.length !== length) {
      arr.length = length;
    }
    return arr;
  }
}
