localforage-typescript-example
localForage and @kvs/env examples on TypeScript
localForage: generics key
import localforage from "localforage"
(async () => {
await localforage.setItem<string>('key', 'value')
const value = localforage.getItem<string>('key')
console.log(typeof value === "string"); // => true
})();
@kvs/env: use Schema type
import { kvsEnvStorage } from "@kvs/env"
(async () => {
type Schema = {
key: string
}
const storage = await kvsEnvStorage<Schema>({
name: "example",
version: 1
});
await storage.set("key", "value");
const value = storage.get("key");
console.log(typeof value === "string"); // => true
})();
Changelog
See Releases page.
Running tests
Install devDependencies and Run npm test
:
npm test
Contributing
Pull requests and stars are always welcome.
For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Author
License
MIT © azu