GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - AXT-Studio/OriginStorage: Typed LocalStorage-like wrapper for IndexedDB (by AyaExpTech)

BranchesTags
Open more actions menu

Latest commit

 

History

5 Commits
5 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.vscode
.vscode
 
 
src
src
 
 
tests
tests
 
 
.editorconfig
.editorconfig
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
jsr.json
jsr.json
 
 
mod.ts
mod.ts
 
 
package.json
package.json
 
 

Repository files navigation

AyaExpTech OriginStorage

Typed LocalStorage-like wrapper for IndexedDB (by AyaExpTech)

IndexedDBのObjectStoreをLocalStorageのように扱うための、薄いラッパーライブラリです。

License

copyright (c) 2026- Ayasaka-Koto(AyaExpTech).
Released under the MIT License.

Installation

このライブラリはJSRパッケージとして公開されています。

  • Web (esm.sh CDN)
    import { OriginStorage } from "https://esm.sh/jsr/@ayaexptech/originstorage";
  • npm
    npx jsr add @ayaexptech/originstorage
    import { OriginStorage } from "@ayaexptech/originstorage";
  • pnpm
    pnpm add jsr:@ayaexptech/originstorage
    import { OriginStorage } from "@ayaexptech/originstorage";
  • Deno (Add Package)
    deno add jsr:@ayaexptech/originstorage
    import { OriginStorage } from "@ayaexptech/originstorage";
  • Deno (Adhoc Import)
    import { OriginStorage } from "jsr:@ayaexptech/originstorage";
  • Bun
    bunx jsr add @ayaexptech/originstorage
    import { OriginStorage } from "@ayaexptech/originstorage";

Usage

基本的にはWeb Storage API(sessionStorageやlocalStorage)と同じように使えます。
ただし、IndexedDBを扱う都合上、各メソッドはPromiseを返します。適宜awaitなどを使用してください。

import { OriginStorage } from "@ayaexptech/originstorage";

const exampleOriginStorage = new OriginStorage("example");
await exampleOriginStorage.setItem("hoge", "fuga");
await exampleOriginStorage.getItem("hoge"); // => "fuga"
await exampleOriginStorage.removeItem("hoge");
await exampleOriginStorage.clear();
await exampleOriginStorage.getSize(); // => 0 (lengthやsizeではないので注意)
  • keyはstringである必要があります。
  • valueは構造化複製可能であればなんでもよいです。

new OriginStorage()は型引数として保存するKey-Valueペアの型をもらうことができます。

type StorageSchema = {
    count: number;
    kind: 1 | 2;
};
const storage = new OriginStorage<StorageSchema>("with_schema");
await storage.getItem("invalid");
//                    ^^^^^^^^^ ... Error
await storage.setItem("kind", 99);
//                            ^^ ... Error
await storage.getItem("count") // @type {number | undefined} (undefinedの可能性がある点に注意!)

また、has()やentries()など、ECMAScript Mapに似たメソッドもいくつか用意されています。

引数やメソッドなどの詳細はJSRのドキュメントページ及びJSDocコメントを参照してください。

Contributing

  • バグ報告: GitHub Issues
  • Pull Request: Issueを立てたうえで、メンテナーの指示を待ってください。メンテナーの指示のないPRは却下されます。

Developing

  • Format: pnpm run fmt (pnpm run fmt:check)
  • Lint: pnpm run lint:fix (pnpm run lint)
  • Test: pnpm run test
    • Check slow-types: pnpm run test:jsr

About

Typed LocalStorage-like wrapper for IndexedDB (by AyaExpTech)

jsr.io/@ayaexptech/originstorage

Topics

typescripttypescript-libraryweb-library

Resources

Readme
MIT license
Activity
Custom properties

Stars

0 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Sponsor this project

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.