Compare commits

..

2 Commits

Author SHA1 Message Date
Derrick Hammer 17a434f400
*Update dist 2022-12-21 15:16:14 -05:00
Derrick Hammer 6e0608c9a9
*Add savePath utility method 2022-12-21 15:15:55 -05:00
3 changed files with 9 additions and 1 deletions

1
dist/index.d.ts vendored
View File

@ -17,6 +17,7 @@ export default class Config {
openDir(dir: string): void; openDir(dir: string): void;
open(file: string): void; open(file: string): void;
save(file: string, data: object): void; save(file: string, data: object): void;
savePath(file: string, path: string): void;
set(key: string, value: any): void; set(key: string, value: any): void;
has(key: string): any; has(key: string): any;
private normalize; private normalize;

3
dist/index.js vendored
View File

@ -89,6 +89,9 @@ class Config {
fs_1.default.writeFileSync(fullPath, JSON.stringify(data)); fs_1.default.writeFileSync(fullPath, JSON.stringify(data));
this.open(fullPath); this.open(fullPath);
} }
savePath(file, path) {
this.save(file, this.get(path));
}
set(key, value) { set(key, value) {
(0, bsert_1.default)(typeof key === "string", "Key must be a string."); (0, bsert_1.default)(typeof key === "string", "Key must be a string.");
if (value == null) { if (value == null) {

View File

@ -94,7 +94,7 @@ export default class Config {
} }
} }
public save(file: string, data: object) { public save(file: string, data: object): void {
assert(typeof data === "object"); assert(typeof data === "object");
assert(!Array.isArray(data)); assert(!Array.isArray(data));
@ -109,6 +109,10 @@ export default class Config {
this.open(fullPath); this.open(fullPath);
} }
public savePath(file: string, path: string): void {
this.save(file, this.get(path));
}
public set(key: string, value: any) { public set(key: string, value: any) {
assert(typeof key === "string", "Key must be a string."); assert(typeof key === "string", "Key must be a string.");