0.0.1 • Published 5 months ago

@dada78641/dadautil v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

TypeScript MIT license npm version

@dada78641/DadaUtil

Basic configuration and cache utility for CLI tool development.

This package offers a straightforward API for managing configuration files at ~/.config/APPNAME/config.json and cache databases at ~/.cache/APPNAME/db.sqlite3. It simplifies persistent data storage and retrieval.

Ideal for simple CLI tools that require basic persistent state, without the overhead of a complex database.

Usage

import {DadaUtil} from './src/index.ts'

type UtilConfig = {
  hello: string;
  world: number;
}

const util = new DadaUtil<UtilConfig>('dadautiltest');
await util.init(); // opens the db and ensures the directories exist

const hello = util.getConfig('hello'); // string | null
const world = util.getConfig('world'); // number | null
console.log([hello, world]); // [null, null] unless your config.json file has them set
util.set('someCacheKey', {hello: 'world'});
const value = util.get<{hello: string}>('someCacheKey');
console.log(value); // {hello: 'world'}

License

MIT licensed.

0.0.1

5 months ago