@cfstcyr/ts-saved-config
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

ts-saved-config

Save config to a file or in the browser local storage. This package uses configstore for its file storage and store2 for its browser local storage.

Usage

import { Configuration, num, str } from '@cfstcyr/ts-saved-config';

const myConfig = Configuration('file', 'my-config', {
    apiKey: str({
        required: true,
    }),
    user: json<User>({}),
    count: num({
        default: 10,
    }),
});

myConfig.getApiKey(); // Returns string or throws an error if not set
myConfig.get('user'); // Returns User or undefined if not set
myConfig.get('count'); // Returns number or 10 if not set

Readme

Keywords

none

Package Sidebar

Install

npm i @cfstcyr/ts-saved-config

Weekly Downloads

1

Version

1.0.1

License

ISC

Unpacked Size

69.7 kB

Total Files

65

Last publish

Collaborators

  • cfstcyr