UNPKG

fake-indexeddb

Version:

Fake IndexedDB: a pure JS in-memory implementation of the IndexedDB API

48 lines (45 loc) 1.16 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; class FakeDOMStringList { constructor(...values) { this._values = values; for (let i = 0; i < values.length; i++) { this[i] = values[i]; } } contains(value) { return this._values.includes(value); } item(i) { if (i < 0 || i >= this._values.length) { return null; } return this._values[i]; } get length() { return this._values.length; } [Symbol.iterator]() { return this._values[Symbol.iterator](); } // Handled by proxy // Used internally, should not be used by others. I could maybe get rid of these and replace rather than mutate, but too lazy to check the spec. _push(...values) { for (let i = 0; i < values.length; i++) { this[this._values.length + i] = values[i]; } this._values.push(...values); } _sort(...values) { this._values.sort(...values); for (let i = 0; i < this._values.length; i++) { this[i] = this._values[i]; } return this; } } var _default = exports.default = FakeDOMStringList; module.exports = exports.default;