1.0.0 • Published 1 year ago

modern-idb v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Modern-IDB

Modern IndexedDB wrapper with Promises, AsyncIterables and strict typing.

Motivation

IndexedDB API was available in browsers 3 years before Promises. Current event-based API is verbose and not as convenient to use in modern codebases as async/await.

Changes

  1. IDBRequest<T> is converted to Promise<T> (except for IDBRequest<IDBCursor | IDBCursorWithValue>)
  2. IDBTransaction<T> is extended with a promise: Promise<T> property to allow simpler async/await code.
  3. .openCursor() and .openKeyCursor() return an AsyncIterable<Cursor | CursorWithValue>
  4. openDatabase() has a generic to specify DB schema.
  5. Automatic versioning and DB migrations with migrations argument of openDatabase()