Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Final config.js
export default class {
init() {
this.config = // ... load the object ...
// For posterity, but we don't need to return it at the moment.
return this.config;
},
settingExists( key ) {
let found = Object.keys( this.config ).indexOf( key )
return found;
}
static printFormatInstructions() {
console.log('Your config file must be in json format, and contain the following keys: foo, bar, baz.');
}
}
// Final usage
import Config from 'config.js';
Config.init();
// Later
if ( ! Config.settingExists( 'foo' ) ) {
Config.printFormatInstructions();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment