0.2.0 • Published 2 years ago
json-to-typed v0.2.0
json-to-typed
Exposes the TypedJsonFile
class that allows you to read and write JSON files with type safety using the to-typed package.
async function run() {
const file = await new TypedJsonFile('./settings.json', Convert.to({
port: 3000,
host: 'localhost'
}));
const data = await file.read();
console.log(`Current address is http://${data.host}:${data.port}`);
await file.write({
port: data.port + 1,
host: data.host
});
}
It also includes a cli utility that generates a TypedJsonFile
class for for each JSON file in a directory.
npx json-to-typed gen ./settings.json ./src/settings.ts
Requires ES modules.
0.2.0
2 years ago
0.1.2
3 years ago
0.1.1
3 years ago
0.1.0
3 years ago
0.0.23
3 years ago
0.0.22
3 years ago
0.0.21
3 years ago
0.0.20
3 years ago
0.0.19
3 years ago
0.0.18
3 years ago
0.0.17
3 years ago
0.0.16
3 years ago
0.0.15
3 years ago
0.0.14
3 years ago
0.0.12
3 years ago
0.0.11
3 years ago
0.0.10
3 years ago
0.0.9
3 years ago
0.0.8
3 years ago