Releases: azu/kvs
v2.2.0
What's Changed
Features
- feat: add node localstorage quota option by @toniopelo in #47
New Contributors
- @toniopelo made their first contribution in #47
Full Changelog: v2.1.5...v2.2.0
v2.1.5
v2.1.4
v2.1.3
v2.1.2
v2.1.1
Republish for v2.1.0
v2.1.0
2.1.0 (2022-03-02)
Bug Fixes
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.
v2.0.0
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 |
v1.2.0
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");
})();