Skip to content

azu/localforage-typescript-example

Repository files navigation

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.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

About

localforge and kvs/env example on TypeScript

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published