diff --git a/README.md b/README.md new file mode 100644 index 0000000..b7f9e69 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# configurationLoader + +configurationLoader.js loads configurations from a json file and then merges them with existing confiugrations using a flag (overwriteInlineConfigs) to decide which parameters should be overwritten. By default this flag is false, that is inline configurations take precedence over those set in json file. The loader returns a promise object which once resolved will give access to configuration object. This object has also getter and setter methods which should be used to get and set configuration parameters. + +**Usage** +```javascript +configurationLoader({ + json: 'url.to.configuration.json', + data: inline.configuration, + overwriteInlineConfigs: [optional boolean parameter] +}).then(function(data) { + window.myProject.configuration = data; + // It's now safe to run scripts depending on configuration parameters +}); + +var test = myProject.configuration.get('nameOfProperty'); +``` diff --git a/configuration.js b/configuration.old.js similarity index 100% rename from configuration.js rename to configuration.old.js diff --git a/configurationLoader.js b/configurationLoader.js index ece1332..0be15b5 100644 --- a/configurationLoader.js +++ b/configurationLoader.js @@ -1,23 +1,8 @@ -/* - -DEV NOTES: - -configurationLoader loads configurations from a json file and then merges them with existing confiugrations using a flag (overwriteInlineConfigs) to decide which parameters should be overwritten. By default this flag is false, that is inline configurations take precedence over those set in json file. The loader returns a promise object which once resolved will give access to configuration object. This object has also getter and setter methods which should be used to get and set configuration parameters. - -Usage example: - -configurationLoader({ - json: 'url.to.configuration.json', - data: inline.configuration, - overwriteInlineConfigs: [boolean] -}).then(function(data) { - window.myProject.configuration = data; - //it's now safe to run scripts that depend on configuration parameters -}); - -var test = myProject.configuration.get('nameOfProperty'); - -*/ +/** + * VI configurationLoader v1.0.0 + * For documentation see: + * https://github.com/frontend-framework/configuration + */ configurationLoader = function(options) { 'use strict'; diff --git a/package.json b/package.json new file mode 100644 index 0000000..41261f7 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "configurationLoader", + "version": "1.0.0", + "description": "configurationLoader.js loads configurations from a json file and then merges them with existing confiugrations", + "main": "configurationLoader.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/frontend-framework/configuration.git" + }, + "keywords": [], + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/frontend-framework/configuration/issues" + }, + "homepage": "https://github.com/frontend-framework/configuration#readme" +}