kvs

Lightweight key-value storage library for Browser, Node.js, and In-Memory.

MIT License

Downloads
101.4K
Stars
177
Committers
4

Bot releases are hidden (Show)

kvs - v2.2.0 Latest Release

Published by azu 9 months ago

What's Changed

Features

New Contributors

Full Changelog: https://github.com/azu/kvs/compare/v2.1.5...v2.2.0

kvs - v2.1.5

Published by azu about 1 year ago

What's Changed

Refactoring

reduce install size

Full Changelog: https://github.com/azu/kvs/compare/v2.1.4...v2.1.5

kvs - v2.1.4

Published by azu about 1 year ago

What's Changed

Documentation

Refactoring

Testing

New Contributors

Full Changelog: https://github.com/azu/kvs/compare/v2.1.3...v2.1.4

kvs - v2.1.3

Published by azu about 2 years ago

2.1.3 (2022-09-25)

Bug Fixes

kvs - v2.1.2

Published by azu about 2 years ago

2.1.2 (2022-08-21)

Bug Fixes

  • kvs/env: module entry point to browser (b8529ad)
kvs - v2.1.1

Published by azu over 2 years ago

kvs - v2.1.0

Published by azu over 2 years ago

2.1.0 (2022-03-02)

Bug Fixes

  • indexeddb: remove "debug" option (#25) (606b9a2)

Performance Improvements

It aim to reduce file size.

Path Size
packages/env/module/browser.js 1.06 KB (-22.84% 🔽)
packages/indexeddb/module/index.js 1.05 KB (-22.06% 🔽)
packages/localstorage/module/index.js 853 B (-27.04% 🔽)

This library require AsyncIterator support from the beginning.
It means that it require ES2018+ support.

kvs - v2.0.0

Published by azu over 2 years ago

2.0.0 (2022-02-19)

Bug Fixes

BREAKING CHANGES

  • storage: storage package sperate storags by name option

Previously, @kvs/storage does not separate key per storage.
This issue cause iteration error like #20

However, It need to change saving storage's key for fixing the issue.
We need to bump it as major update.

Affected Packages

  • @kvs/env in Node.js
    • 📝 Browser is not affected because it uses IndexedDB
  • @kvs/storage
  • @kvs/localstorage
  • @kvs/memorystorage
  • @kvs/node-localstorage
  • @kvs/storage-sync

Previous: storage save value with key

key: value

This PR: storage save value with ${name}.__.${key}.

${name}.__.${key}: value

It means that kvs package can not load value which is saved by previous version.

Migration

You need to write manuall migration code using upgrade.

If you have used @kvs/localstorage, you can write following.
Unfortunately, this migration should use raw localStorage API because @kvs/localstorage can not access the key which is created in kvs 1.x.

import { kvsLocalStorage } from "@kvs/localstorage";
type StorageSchema = {
    a1: string;
    b2: number;
    c3: boolean;
};
const databaseName = "kvs-database";
const storage = kvsStorageSync<StorageSchema>({
    name: databaseName,
    version: 2, // If previous `version` is 1, you need to update the version to 2
    storage: localStorage,
    upgrade({ oldVersion }: { kvs: KVSSync<StorageSchema>; oldVersion: number; newVersion: number }): any {
        if (oldVersion < 2) {
            // manually migration to new key format
            ["a1", "b2", "c3"].forEach((key) => {
                // CAUTION: use raw localStorage for migration
                const item = localStorage.getItem(key);
                if (item) {
                    localStorage.setItem(`${databaseName}.__.${key}`, item);
                }
            });
        }
    }
});
KVS raw localStorage
@kvs/localstorage localStorage API
@kvs/memorystorage NONE
@kvs/node-localstorage node-localstorage package
@kvs/env in Node.js node-localstorage package
kvs -

Published by azu over 3 years ago

for TypeScript User

1.2.0 require TS 4.1+ because it use Key Remapping in Mapped Types.

Features

  • support index signature in SchemaTypes
(async () => {
    type Scheme = {
        [index:string]: string;
    };
    const storage = await kvsEnvStorage<Scheme>({
        name: "test-data",
        version: 1,
    });
    const value = await storage.set("key", "value");
})();
kvs - v1.1.0

Published by azu almost 4 years ago

1.1.0 (2020-10-29)

Features

kvs - 1.0.0

Published by azu about 4 years ago

First Stable Version.

kvs - v0.3.1

Published by azu about 4 years ago

0.3.1 (2020-08-22)

Note: Version bump only for package kvs

kvs - v0.3.0

Published by azu about 4 years ago

0.3.0 (2020-08-22)

Features

  • storage-sync: add storage-sync package (#11) (5748776)
kvs - v0.2.1

Published by azu about 4 years ago

0.2.1 (2020-08-22)

Note: Version bump only for package kvs

kvs - Schema

Published by azu about 4 years ago

Introduce Schema #2

kvs - v0.1.0

Published by azu about 4 years ago

0.1.0 (2020-08-08)

Bug Fixes

Features

  • @kvs/localstorage: add localstorage implementation (54fc38b)
  • @kvs/memorystorage: add in memory implementation (553247b)
  • @kvs/node-localstorage: add node implementation (5160012)
  • @lvs/env: add universal env (36eef88)
  • add close() to interface (a269d1d)
  • add debug options (75a083e)
  • kvs/indexeddb: add [Symbol.asyncIterator] (68392d4)
  • kvs/indexeddb: add dropInstance (0a38a0c)
  • kvs/indexeddb: implement basic usage (cc14444)