clean up and fix some errors
This commit is contained in:
parent
582afc0361
commit
491f22ffca
77
index.js
77
index.js
@ -24,25 +24,48 @@ var Environment = (function () {
|
||||
*/
|
||||
var SmartenvEnvironment;
|
||||
(function (SmartenvEnvironment) {
|
||||
function init() {
|
||||
var environment;
|
||||
(function () {
|
||||
var localRunTimeEnv = "undefined";
|
||||
var localUserAgent = "undefined";
|
||||
if (typeof window !== 'undefined') {
|
||||
localRunTimeEnv = 'browser';
|
||||
localUserAgent = navigator.userAgent;
|
||||
}
|
||||
else if (typeof process !== 'undefined') {
|
||||
localRunTimeEnv = 'node';
|
||||
}
|
||||
environment = new Environment(localRunTimeEnv, localUserAgent);
|
||||
})();
|
||||
return function () {
|
||||
return environment;
|
||||
};
|
||||
}
|
||||
SmartenvEnvironment.init = init;
|
||||
var environment;
|
||||
var envDetermined = false;
|
||||
/**
|
||||
* returns the environment
|
||||
* @returns {Environment}
|
||||
*/
|
||||
var getEnv = function () {
|
||||
if (!envDetermined) {
|
||||
(function () {
|
||||
var localRunTimeEnv = "undefined";
|
||||
var localUserAgent = "undefined";
|
||||
if (typeof window !== 'undefined') {
|
||||
localRunTimeEnv = 'browser';
|
||||
localUserAgent = navigator.userAgent;
|
||||
}
|
||||
else if (typeof process !== 'undefined') {
|
||||
localRunTimeEnv = 'node';
|
||||
}
|
||||
environment = new Environment(localRunTimeEnv, localUserAgent);
|
||||
})();
|
||||
}
|
||||
;
|
||||
return environment;
|
||||
};
|
||||
/**
|
||||
* prints the environment to console
|
||||
*/
|
||||
var printEnv = function () {
|
||||
if (this.getEnv().isNode) {
|
||||
var smartenvVersion = require("./package.json").version;
|
||||
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.log("browser is " + this.getEnv().userAgent);
|
||||
}
|
||||
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
||||
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete()));
|
||||
};
|
||||
SmartenvEnvironment.init = function (objectArg) {
|
||||
objectArg.getEnv = getEnv;
|
||||
objectArg.printEnv = printEnv;
|
||||
};
|
||||
})(SmartenvEnvironment || (SmartenvEnvironment = {}));
|
||||
/// <reference path="index.ts" />
|
||||
var SmartenvObjectStorage;
|
||||
@ -81,20 +104,6 @@ var plugins = {
|
||||
_: require("lodash")
|
||||
};
|
||||
var smartenv = {}; //create smartenv object
|
||||
smartenv.getEnv = SmartenvEnvironment.init();
|
||||
SmartenvEnvironment.init(smartenv);
|
||||
smartenv.obs = SmartenvObjectStorage.init();
|
||||
/* ----------------------------------------- *
|
||||
* ----- print info ------------------------ *
|
||||
* ----------------------------------------- */
|
||||
smartenv.printEnv = function () {
|
||||
if (smartenv.getEnv().isNode) {
|
||||
var smartenvVersion = require("./package.json").version;
|
||||
plugins.beautylog.log("node version is " + smartenv.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.log("browser is " + smartenv.getEnv().userAgent);
|
||||
}
|
||||
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
||||
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete).sort());
|
||||
};
|
||||
module.exports = smartenv;
|
||||
|
16
ts/index.js
16
ts/index.js
@ -7,21 +7,7 @@ var plugins = {
|
||||
_: require("lodash")
|
||||
};
|
||||
var smartenv = {}; //create smartenv object
|
||||
smartenv.getEnv = SmartenvEnvironment.init();
|
||||
SmartenvEnvironment.init(smartenv);
|
||||
smartenv.obs = SmartenvObjectStorage.init();
|
||||
/* ----------------------------------------- *
|
||||
* ----- print info ------------------------ *
|
||||
* ----------------------------------------- */
|
||||
smartenv.printEnv = function () {
|
||||
if (smartenv.getEnv().isNode) {
|
||||
var smartenvVersion = require("./package.json").version;
|
||||
plugins.beautylog.log("node version is " + smartenv.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
||||
}
|
||||
else {
|
||||
plugins.beautylog.log("browser is " + smartenv.getEnv().userAgent);
|
||||
}
|
||||
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
||||
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete).sort());
|
||||
};
|
||||
module.exports = smartenv;
|
||||
//# sourceMappingURL=index.js.map
|
@ -1 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,4CAA4C;AAC5C,gDAAgD;AAChD,kDAAkD;AAClD,IAAI,OAAO,GAAG;IACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;CACvB,CAAA;AACD,IAAI,QAAQ,GAAO,EAAE,CAAC,CAAC,wBAAwB;AAE/C,QAAQ,CAAC,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE,CAAC;AAC7C,QAAQ,CAAC,GAAG,GAAG,qBAAqB,CAAC,IAAI,EAAE,CAAC;AAG5C;;+CAE+C;AAC/C,QAAQ,CAAC,QAAQ,GAAG;IAChB,EAAE,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAC3B,IAAI,eAAe,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAO,CAAC;QACxD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,kBAAkB,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,WAAW,GAAG,2BAA2B,GAAG,eAAe,CAAC,CAAC;IAC9H,CAAC;IAAC,IAAI,CAAC,CAAC;QACJ,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,aAAa,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,2EAA2E,CAAC,CAAC;IACnG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;AAC7E,CAAC,CAAC;AAIF,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"}
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,4CAA4C;AAC5C,gDAAgD;AAChD,kDAAkD;AAClD,IAAI,OAAO,GAAG;IACV,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC;IACrC,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC;CACvB,CAAA;AACD,IAAI,QAAQ,GAAO,EAAE,CAAC,CAAC,wBAAwB;AAE/C,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;AACnC,QAAQ,CAAC,GAAG,GAAG,qBAAqB,CAAC,IAAI,EAAE,CAAC;AAI5C,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"}
|
17
ts/index.ts
17
ts/index.ts
@ -8,24 +8,9 @@ var plugins = {
|
||||
}
|
||||
var smartenv:any = {}; //create smartenv object
|
||||
|
||||
smartenv.getEnv = SmartenvEnvironment.init();
|
||||
SmartenvEnvironment.init(smartenv);
|
||||
smartenv.obs = SmartenvObjectStorage.init();
|
||||
|
||||
|
||||
/* ----------------------------------------- *
|
||||
* ----- print info ------------------------ *
|
||||
* ----------------------------------------- */
|
||||
smartenv.printEnv = function() {
|
||||
if (smartenv.getEnv().isNode) {
|
||||
var smartenvVersion = require("./package.json").version;
|
||||
plugins.beautylog.log("node version is " + smartenv.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
||||
} else {
|
||||
plugins.beautylog.log("browser is " + smartenv.getEnv().userAgent)
|
||||
}
|
||||
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
||||
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete).sort());
|
||||
};
|
||||
|
||||
|
||||
|
||||
module.exports = smartenv;
|
||||
|
@ -3,23 +3,47 @@
|
||||
* Deals with the environment the current JS script is running in.
|
||||
*/
|
||||
module SmartenvEnvironment {
|
||||
export function init(){
|
||||
var environment:Environment;
|
||||
(function() {
|
||||
var localRunTimeEnv = "undefined";
|
||||
var localUserAgent = "undefined";
|
||||
if (typeof window !== 'undefined') {
|
||||
localRunTimeEnv = 'browser';
|
||||
localUserAgent = navigator.userAgent;
|
||||
} else if (typeof process !== 'undefined') {
|
||||
localRunTimeEnv = 'node';
|
||||
}
|
||||
environment = new Environment(localRunTimeEnv,localUserAgent);
|
||||
})();
|
||||
|
||||
var environment:Environment;
|
||||
var envDetermined:boolean = false;
|
||||
|
||||
return function() {
|
||||
return environment;
|
||||
/**
|
||||
* returns the environment
|
||||
* @returns {Environment}
|
||||
*/
|
||||
var getEnv = function(){
|
||||
if (!envDetermined) {
|
||||
(function() {
|
||||
var localRunTimeEnv = "undefined";
|
||||
var localUserAgent = "undefined";
|
||||
if (typeof window !== 'undefined') {
|
||||
localRunTimeEnv = 'browser';
|
||||
localUserAgent = navigator.userAgent;
|
||||
} else if (typeof process !== 'undefined') {
|
||||
localRunTimeEnv = 'node';
|
||||
}
|
||||
environment = new Environment(localRunTimeEnv,localUserAgent);
|
||||
})();
|
||||
};
|
||||
return environment;
|
||||
};
|
||||
|
||||
/**
|
||||
* prints the environment to console
|
||||
*/
|
||||
var printEnv = function() {
|
||||
if (this.getEnv().isNode) {
|
||||
var smartenvVersion = require("./package.json").version;
|
||||
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
||||
} else {
|
||||
plugins.beautylog.log("browser is " + this.getEnv().userAgent)
|
||||
}
|
||||
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
||||
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete()));
|
||||
}
|
||||
|
||||
export var init = function(objectArg) {
|
||||
objectArg.getEnv = getEnv;
|
||||
objectArg.printEnv = printEnv;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user