Skip to content

Instantly share code, notes, and snippets.

@mcavaliere
Created September 28, 2018 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcavaliere/e417c982fd1cd55c2e8307b5fe6a68d5 to your computer and use it in GitHub Desktop.
Save mcavaliere/e417c982fd1cd55c2e8307b5fe6a68d5 to your computer and use it in GitHub Desktop.
// 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