mirror of
https://github.com/mtan93/homebridge.git
synced 2026-03-24 05:04:15 +00:00
Remove non-standard "type annotations"
Since we're not actually using Flow.
This commit is contained in:
@@ -2,18 +2,18 @@ import fs from 'fs';
|
||||
|
||||
export class Config {
|
||||
|
||||
constructor(path:string, data:object = {}) {
|
||||
constructor(path, data = {}) {
|
||||
this.path = path;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
get(key:string) {
|
||||
get(key) {
|
||||
this.validateKey(key);
|
||||
let [providerName, keyName] = key.split(".");
|
||||
return this.data[providerName] && this.data[providerName][keyName];
|
||||
}
|
||||
|
||||
set(key:string, value:object) {
|
||||
set(key, value) {
|
||||
this.validateKey(key);
|
||||
let [providerName, keyName] = key.split(".");
|
||||
this.data[providerName] = this.data[providerName] || {};
|
||||
@@ -21,12 +21,12 @@ export class Config {
|
||||
this.save();
|
||||
}
|
||||
|
||||
validateKey(key:string) {
|
||||
validateKey(key) {
|
||||
if (key.split(".").length != 2)
|
||||
throw new Error(`The config key '${key}' is invalid. Configuration keys must be in the form [my-provider].[myKey]`);
|
||||
}
|
||||
|
||||
static load(configPath: string): Config {
|
||||
static load(configPath) {
|
||||
// load up the previous config if found
|
||||
if (fs.existsSync(configPath))
|
||||
return new Config(configPath, JSON.parse(fs.readFileSync(configPath)));
|
||||
|
||||
Reference in New Issue
Block a user