From f5e48e4fd3b2ab208e8ab9c20f77bb5e5c8fbd0f Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Mon, 30 Nov 2015 15:04:04 +0100 Subject: [PATCH] now using classes, remove global funcionality to prevent bad habits --- index.js | 68 ++++++++++++++++++++++++++++++++++++----------- test.js | 9 +++---- ts/classes.js | 21 +++++++++++++++ ts/classes.js.map | 1 + ts/classes.ts | 21 +++++++++++++++ ts/index.js | 48 ++++++++++++++++++++++----------- ts/index.js.map | 2 +- ts/index.ts | 54 +++++++++++++++++++++++-------------- ts/test.js | 9 +++---- ts/test.js.map | 2 +- ts/test.ts | 9 +++---- 11 files changed, 175 insertions(+), 69 deletions(-) create mode 100644 ts/classes.js create mode 100644 ts/classes.js.map create mode 100644 ts/classes.ts diff --git a/index.js b/index.js index 7ad4484..801d432 100644 --- a/index.js +++ b/index.js @@ -1,20 +1,60 @@ +/// +var Environment = (function () { + function Environment(runtimeEnvArg, userAgentArg) { + if (userAgentArg === void 0) { userAgentArg = "undefined"; } + this.runtimeEnv = runtimeEnvArg; + this.userAgent = userAgentArg; + if (runtimeEnvArg == "node") { + this.isBrowser = false; + this.isNode = true; + this.nodeVersion = process.version; + } + else { + this.isBrowser = true; + this.isNode = true; + this.nodeVersion = "undefined"; + } + } + ; + return Environment; +})(); /// +/// var beautylog = require("beautylog")("os"); -var addToGlobal = function (objectArg, paramName) { - global[paramName] = objectArg; -}; var smartenv = {}; //create smartenv object smartenv.items = {}; // create the items object to store items to. -smartenv.makeGlobal = function () { - addToGlobal(smartenv, "smartenv"); //add object smartenv as global["smartenv"] +/* ----------------------------------------- * + * ----- Environment ----------------------- * + * ----------------------------------------- */ +var environment; +var setEnvironment = 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); }; -smartenv.info = {}; -smartenv.info.node = {}; -smartenv.info.node.version = process.version; -smartenv.info.print = function () { - var pck = require("./package.json"); - beautylog.log("node version is " + smartenv.info.node.version + " and smartenv version is " + pck.version); - beautylog.log("the smartenv module currently holds the following properties:"); +setEnvironment(); +smartenv.getEnv = function () { + return environment; +}; +/* ----------------------------------------- * + * ----- Info vars ------------------------- * + * ----------------------------------------- */ +smartenv.printEnv = function () { + if (environment.isNode) { + var smartenvVersion = require("./package.json").version; + beautylog.log("node version is " + environment.nodeVersion + " and smartenv version is " + smartenvVersion); + } + else { + beautylog.log("browser is " + environment.userAgent); + } + beautylog.log("the smartenv registration store currently holds the following properties:"); console.log(Object.getOwnPropertyNames(smartenv.items).sort()); }; smartenv.register = function (objectArg, paramName) { @@ -28,8 +68,4 @@ smartenv.register = function (objectArg, paramName) { smartenv.get = function (keyName) { return smartenv.items[keyName]; }; -smartenv.exportEnv = function () { -}; -smartenv.importEnv = function () { -}; module.exports = smartenv; diff --git a/test.js b/test.js index eda6993..e1fb14d 100644 --- a/test.js +++ b/test.js @@ -2,14 +2,13 @@ var smartenv = require("./index.js"); var beautylog = require("beautylog")("os"); beautylog.info("Now testing the smartenv module"); -smartenv.info.print(); +smartenv.printEnv(); beautylog.info("Now testing the smartenv module"); smartenv.register({ key1: "Peter" }, "docit"); -smartenv.info.print(); +smartenv.printEnv(); +beautylog.log(smartenv.get("docit").key1); beautylog.log(smartenv.get("docit").key1); -smartenv.makeGlobal(); -beautylog.log(global.smartenv.get("docit").key1); var key2 = "hello"; smartenv.get("docit").key2 = key2; -beautylog.log(global.smartenv.get("docit").key2); +beautylog.log(smartenv.get("docit").key2); beautylog.success("Success!"); diff --git a/ts/classes.js b/ts/classes.js new file mode 100644 index 0000000..63ad52b --- /dev/null +++ b/ts/classes.js @@ -0,0 +1,21 @@ +/// +var Environment = (function () { + function Environment(runtimeEnvArg, userAgentArg) { + if (userAgentArg === void 0) { userAgentArg = "undefined"; } + this.runtimeEnv = runtimeEnvArg; + this.userAgent = userAgentArg; + if (runtimeEnvArg == "node") { + this.isBrowser = false; + this.isNode = true; + this.nodeVersion = process.version; + } + else { + this.isBrowser = true; + this.isNode = true; + this.nodeVersion = "undefined"; + } + } + ; + return Environment; +})(); +//# sourceMappingURL=classes.js.map \ No newline at end of file diff --git a/ts/classes.js.map b/ts/classes.js.map new file mode 100644 index 0000000..681c131 --- /dev/null +++ b/ts/classes.js.map @@ -0,0 +1 @@ +{"version":3,"file":"classes.js","sourceRoot":"","sources":["classes.ts"],"names":["Environment","Environment.constructor"],"mappings":"AAAA,iCAAiC;AACjC;IAMIA,qBAAYA,aAAaA,EAACA,YAA0BA;QAA1BC,4BAA0BA,GAA1BA,0BAA0BA;QAChDA,IAAIA,CAACA,UAAUA,GAAGA,aAAaA,CAACA;QAChCA,IAAIA,CAACA,SAASA,GAAGA,YAAYA,CAACA;QAC9BA,EAAEA,CAAAA,CAACA,aAAaA,IAAIA,MAAMA,CAACA,CAAAA,CAACA;YACxBA,IAAIA,CAACA,SAASA,GAAGA,KAAKA,CAACA;YACvBA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA,CAACA;YACnBA,IAAIA,CAACA,WAAWA,GAAGA,OAAOA,CAACA,OAAOA,CAACA;QACvCA,CAACA;QAACA,IAAIA,CAACA,CAACA;YACJA,IAAIA,CAACA,SAASA,GAAGA,IAAIA,CAACA;YACtBA,IAAIA,CAACA,MAAMA,GAAGA,IAAIA,CAACA;YACnBA,IAAIA,CAACA,WAAWA,GAAGA,WAAWA,CAACA;QACnCA,CAACA;IACLA,CAACA;;IACLD,kBAACA;AAADA,CAACA,AAnBD,IAmBC"} \ No newline at end of file diff --git a/ts/classes.ts b/ts/classes.ts new file mode 100644 index 0000000..666eed5 --- /dev/null +++ b/ts/classes.ts @@ -0,0 +1,21 @@ +/// +class Environment { + public runtimeEnv:string; + public userAgent:string; + public nodeVersion; + public isBrowser:boolean; + public isNode:boolean; + constructor(runtimeEnvArg,userAgentArg = "undefined") { + this.runtimeEnv = runtimeEnvArg; + this.userAgent = userAgentArg; + if(runtimeEnvArg == "node"){ + this.isBrowser = false; + this.isNode = true; + this.nodeVersion = process.version; + } else { + this.isBrowser = true; + this.isNode = true; + this.nodeVersion = "undefined"; + } + }; +} \ No newline at end of file diff --git a/ts/index.js b/ts/index.js index 782a876..7c9ebb0 100644 --- a/ts/index.js +++ b/ts/index.js @@ -1,20 +1,40 @@ /// +/// var beautylog = require("beautylog")("os"); -var addToGlobal = function (objectArg, paramName) { - global[paramName] = objectArg; -}; var smartenv = {}; //create smartenv object smartenv.items = {}; // create the items object to store items to. -smartenv.makeGlobal = function () { - addToGlobal(smartenv, "smartenv"); //add object smartenv as global["smartenv"] +/* ----------------------------------------- * + * ----- Environment ----------------------- * + * ----------------------------------------- */ +var environment; +var setEnvironment = 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); }; -smartenv.info = {}; -smartenv.info.node = {}; -smartenv.info.node.version = process.version; -smartenv.info.print = function () { - var pck = require("./package.json"); - beautylog.log("node version is " + smartenv.info.node.version + " and smartenv version is " + pck.version); - beautylog.log("the smartenv module currently holds the following properties:"); +setEnvironment(); +smartenv.getEnv = function () { + return environment; +}; +/* ----------------------------------------- * + * ----- Info vars ------------------------- * + * ----------------------------------------- */ +smartenv.printEnv = function () { + if (environment.isNode) { + var smartenvVersion = require("./package.json").version; + beautylog.log("node version is " + environment.nodeVersion + " and smartenv version is " + smartenvVersion); + } + else { + beautylog.log("browser is " + environment.userAgent); + } + beautylog.log("the smartenv registration store currently holds the following properties:"); console.log(Object.getOwnPropertyNames(smartenv.items).sort()); }; smartenv.register = function (objectArg, paramName) { @@ -28,9 +48,5 @@ smartenv.register = function (objectArg, paramName) { smartenv.get = function (keyName) { return smartenv.items[keyName]; }; -smartenv.exportEnv = function () { -}; -smartenv.importEnv = function () { -}; module.exports = smartenv; //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/ts/index.js.map b/ts/index.js.map index 7bbcf63..ffd1a10 100644 --- a/ts/index.js.map +++ b/ts/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3C,IAAI,WAAW,GAAG,UAAS,SAAS,EAAC,SAAS;IAC1C,MAAM,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAClC,CAAC,CAAC;AACF,IAAI,QAAQ,GAAO,EAAE,CAAC,CAAC,wBAAwB;AAC/C,QAAQ,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,6CAA6C;AAClE,QAAQ,CAAC,UAAU,GAAG;IAClB,WAAW,CAAC,QAAQ,EAAC,UAAU,CAAC,CAAC,CAAA,2CAA2C;AAChF,CAAC,CAAC;AAGF,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC;AACnB,QAAQ,CAAC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;AACxB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AAC7C,QAAQ,CAAC,IAAI,CAAC,KAAK,GAAG;IAClB,IAAI,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACpC,SAAS,CAAC,GAAG,CAAC,kBAAkB,GAAG,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,2BAA2B,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;IAC3G,SAAS,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;IAC/E,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,mBAAmB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,C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C,CAAC;AACnC,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"} \ No newline at end of file diff --git a/ts/index.ts b/ts/index.ts index 898aa13..de9142c 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -1,22 +1,44 @@ /// +/// var beautylog = require("beautylog")("os"); -var addToGlobal = function(objectArg,paramName) { - global[paramName] = objectArg; -}; var smartenv:any = {}; //create smartenv object smartenv.items = {}; // create the items object to store items to. -smartenv.makeGlobal = function() { - addToGlobal(smartenv,"smartenv");//add object smartenv as global["smartenv"] + +/* ----------------------------------------- * + * ----- Environment ----------------------- * + * ----------------------------------------- */ +var environment:Environment; +var setEnvironment = 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); +}; +setEnvironment(); + + +smartenv.getEnv = function() { + return environment; }; +/* ----------------------------------------- * + * ----- Info vars ------------------------- * + * ----------------------------------------- */ -smartenv.info = {}; -smartenv.info.node = {}; -smartenv.info.node.version = process.version; -smartenv.info.print = function() { - var pck = require("./package.json"); - beautylog.log("node version is " + smartenv.info.node.version + " and smartenv version is " + pck.version); - beautylog.log("the smartenv module currently holds the following properties:"); + +smartenv.printEnv = function() { + if (environment.isNode) { + var smartenvVersion = require("./package.json").version; + beautylog.log("node version is " + environment.nodeVersion + " and smartenv version is " + smartenvVersion); + } else { + beautylog.log("browser is " + environment.userAgent) + } + beautylog.log("the smartenv registration store currently holds the following properties:"); console.log(Object.getOwnPropertyNames(smartenv.items).sort()); }; @@ -31,12 +53,4 @@ smartenv.get = function(keyName) { return smartenv.items[keyName]; }; -smartenv.exportEnv = function() { - -}; - -smartenv.importEnv = function() { - -}; - module.exports = smartenv; diff --git a/ts/test.js b/ts/test.js index fd0e17a..8de8496 100644 --- a/ts/test.js +++ b/ts/test.js @@ -2,15 +2,14 @@ var smartenv = require("./index.js"); var beautylog = require("beautylog")("os"); beautylog.info("Now testing the smartenv module"); -smartenv.info.print(); +smartenv.printEnv(); beautylog.info("Now testing the smartenv module"); smartenv.register({ key1: "Peter" }, "docit"); -smartenv.info.print(); +smartenv.printEnv(); +beautylog.log(smartenv.get("docit").key1); beautylog.log(smartenv.get("docit").key1); -smartenv.makeGlobal(); -beautylog.log(global.smartenv.get("docit").key1); var key2 = "hello"; smartenv.get("docit").key2 = key2; -beautylog.log(global.smartenv.get("docit").key2); +beautylog.log(smartenv.get("docit").key2); beautylog.success("Success!"); //# sourceMappingURL=test.js.map \ No newline at end of file diff --git a/ts/test.js.map b/ts/test.js.map index a4d9312..8de5334 100644 --- a/ts/test.js.map +++ b/ts/test.js.map @@ -1 +1 @@ -{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACrC,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3C,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AACtB,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,QAAQ,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,EAAC,OAAO,CAAC,CAAC;AAC1C,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;AACtB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAC1C,QAAQ,CAAC,UAAU,EAAE,CAAC;AACtB,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAEjD,IAAI,IAAI,GAAG,OAAO,CAAC;AACnB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AAClC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAEjD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC"} \ No newline at end of file +{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,IAAI,QAAQ,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;AACrC,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,CAAC;AAC3C,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,QAAQ,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,EAAC,OAAO,CAAC,CAAC;AAC1C,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAC1C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAE1C,IAAI,IAAI,GAAG,OAAO,CAAC;AACnB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AAClC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAE1C,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC"} \ No newline at end of file diff --git a/ts/test.ts b/ts/test.ts index 98ccae0..5de1477 100644 --- a/ts/test.ts +++ b/ts/test.ts @@ -2,16 +2,15 @@ var smartenv = require("./index.js"); var beautylog = require("beautylog")("os"); beautylog.info("Now testing the smartenv module"); -smartenv.info.print(); +smartenv.printEnv(); beautylog.info("Now testing the smartenv module"); smartenv.register({key1:"Peter"},"docit"); -smartenv.info.print(); +smartenv.printEnv(); +beautylog.log(smartenv.get("docit").key1); beautylog.log(smartenv.get("docit").key1); -smartenv.makeGlobal(); -beautylog.log(global.smartenv.get("docit").key1); var key2 = "hello"; smartenv.get("docit").key2 = key2; -beautylog.log(global.smartenv.get("docit").key2); +beautylog.log(smartenv.get("docit").key2); beautylog.success("Success!"); \ No newline at end of file