https://github.com/jokingchicken/chickenconfig
handle json config in Deno
https://github.com/jokingchicken/chickenconfig
config deno
Last synced: 4 months ago
JSON representation
handle json config in Deno
- Host: GitHub
- URL: https://github.com/jokingchicken/chickenconfig
- Owner: JokingChicken
- Created: 2022-03-07T15:24:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-05-20T14:22:35.000Z (about 4 years ago)
- Last Synced: 2025-10-22T23:37:37.596Z (8 months ago)
- Topics: config, deno
- Language: TypeScript
- Homepage:
- Size: 32.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ChickenConfig
this deno library will help you handle a json file for config purposes.
makes use of a default object, to make type-completion and type-checking possible
---
## Where to get:
get it from deno: [https://deno.land/x/chickenconfig/mod.ts](https://deno.land/x/chickenconfig/mod.ts)
download via import:
```ts
import Config from "https://deno.land/x/chickenconfig/mod.ts";
```
---
## Usage:
```ts
import Config from "https://deno.land/x/chickenconfig/mod.ts";
// checks for file, creates if does not exist
const config = Config.load(
{
filename: "config.json",
searchDir: "./examples/"
},
{
"yourDefaultValue": true
}
);
// this reads the file; yourDefaultValue will be true, except when changed in file
// if 'yourDefaultValue' is not the same type as default, it will be overwritten with the default
var configObject = config.read();
configObject.yourDefaultValue = false;
// writes the file; yourDefaultValue will be false
// even if there is a different value in the file, it will only overwrite the default values
config.write();
```
more examples [here](./examples/example.ts)
---