modern-idb
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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()

/modern-idb/

    Package Sidebar

    Install

    npm i modern-idb

    Weekly Downloads

    4

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    28.4 kB

    Total Files

    7

    Last publish

    Collaborators

    • lvivski