class FakeStorage {
  #data = {};

  get length() {
    return Object.keys(this.#data).length;
  }

  key(n) {
    return Object.keys(this.#data)[Number.parseInt(n, 10)] ?? null;
  }

  getItem(key) {
    const _data = this.#data;
    const _key = `${key}`;
    return _data.hasOwnProperty(_key) ? _data[_key] : null;
  }

  setItem(key, value) {
    this.#data[`${key}`] = `${value}`;
  }

  removeItem(key, value) {
    const _data = this.#data;
    const _key = `${key}`;
    if (_data.hasOwnProperty(_key)) {
      delete _data[_key];
    }
  }

  clear(key, value) {
    this.#data = {};
  }
}

export default FakeStorage;

class FakeStorage {
  #data = new Map();

  get length() {
    return this.#data.size;
  }

  key(n) {
    n = Number.parseInt(n, 10);
    const iterator = this.#data.keys();
    let i = 0;
    let result = iterator.next();
    while (!result.done) {
      if (i === n) {
        return result.value;
      }
      i += 1;
      result = iterator.next();
    }
    return null;
  }

  getItem(key) {
    return this.#data.get(`${key}`) ?? null;
  }

  setItem(key, value) {
    this.#data.set(`${key}`, `${value}`);
  }

  removeItem(key) {
    this.#data.delete(`${key}`);
  }

  clear() {
    this.#data.clear();
  }
}

export default FakeStorage;

Refactor internals to store date in a Map instead of Object
Refactor internals to store date in a Map instead of Object