smartenv/dist/smartenv.environment.js

36 lines
4.2 KiB
JavaScript
Raw Permalink Normal View History

2016-04-04 16:24:22 +00:00
"use strict";
2016-02-18 12:27:45 +00:00
var classes = require("./smartenv.classes");
var objectStorage = require("./smartenv.objectstorage");
2016-02-17 20:44:40 +00:00
var environment;
var envDetermined = false;
/**
* returns the environment
* @returns {Environment}
*/
2016-02-20 09:50:32 +00:00
exports.getEnv = function () {
2016-02-17 20:44:40 +00:00
if (!envDetermined) {
2016-02-20 09:11:25 +00:00
environment = new classes.Environment();
2016-02-17 20:44:40 +00:00
envDetermined = true; // ensure code above only runs once
}
;
return environment;
};
/**
* prints the environment to console
*/
2016-02-20 09:50:32 +00:00
exports.printEnv = function () {
2016-02-17 20:44:40 +00:00
if (this.getEnv().isNode) {
2016-02-23 14:03:14 +00:00
console.log("running on NODE");
2016-02-17 20:44:40 +00:00
var smartenvVersion = require("../package.json").version;
2016-02-23 14:03:14 +00:00
console.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
2016-02-17 20:44:40 +00:00
}
else {
2016-02-23 14:03:14 +00:00
console.log("running on BROWSER");
console.log("browser is " + this.getEnv().userAgent);
2016-02-17 20:44:40 +00:00
}
2016-02-23 14:03:14 +00:00
console.log("the smartenv registration store currently holds the following properties:");
2016-02-18 12:27:45 +00:00
console.log(Object.getOwnPropertyNames(objectStorage.obs.getAll()));
2016-02-17 20:44:40 +00:00
};
2016-04-04 16:24:22 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZW52LmVudmlyb25tZW50LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFLQSxJQUFPLE9BQU8sV0FBVyxvQkFBb0IsQ0FBQyxDQUFDO0FBQy9DLElBQU8sYUFBYSxXQUFXLDBCQUEwQixDQUFDLENBQUM7QUFHM0QsSUFBSSxXQUErQixDQUFDO0FBQ3BDLElBQUksYUFBYSxHQUFXLEt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