smartenv/dist/smartenv.environment.js
2016-02-23 15:03:14 +01:00

35 lines
4.2 KiB
JavaScript

var classes = require("./smartenv.classes");
var objectStorage = require("./smartenv.objectstorage");
var environment;
var envDetermined = false;
/**
* returns the environment
* @returns {Environment}
*/
exports.getEnv = function () {
if (!envDetermined) {
environment = new classes.Environment();
envDetermined = true; // ensure code above only runs once
}
;
return environment;
};
/**
* prints the environment to console
*/
exports.printEnv = function () {
if (this.getEnv().isNode) {
console.log("running on NODE");
var smartenvVersion = require("../package.json").version;
console.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
}
else {
console.log("running on BROWSER");
console.log("browser is " + this.getEnv().userAgent);
}
console.log("the smartenv registration store currently holds the following properties:");
console.log(Object.getOwnPropertyNames(objectStorage.obs.getAll()));
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZW52LmVudmlyb25tZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUtBLElBQU8sT0FBTyxXQUFXLG9CQUFvQixDQUFDLENBQUM7QUFDL0MsSUFBTyxhQUFhLFdBQVcsMEJBQTBCLENBQUMsQ0FBQztBQUczRCxJQUFJLFdBQStCLENBQUM7QUFDcEMsSUFBSSxhQUFhLEdBQVcsS0FBSyxDQUFDO0FBRWxDOzs7R0FHRztBQUNRLGNBQU0sR0FBRztJQUNoQixFQUFFLENBQUMsQ0FBQyxDQUFDLGFBQWEsQ0FBQyxDQUFDLENBQUM7UUFDakIsV0FBVyxHQUFHLElBQUksT0FBTyxDQUFDLFdBQVcsRUFBRSxDQUFDO1FBQ3hDLGFBQWEsR0FBRyxJQUFJLENBQUMsQ0FBQyxtQ0FBbUM7SUFDN0QsQ0FBQztJQUFBLENBQUM7SUFDRixNQUFNLENBQUMsV0FBVyxDQUFDO0FBQ3ZCLENBQUMsQ0FBQztBQUVGOztHQUVHO0FBQ1MsZ0JBQVEsR0FBRztJQUNuQixFQUF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