Compare commits

...

24 Commits

Author SHA1 Message Date
1f4ffaff2a 0.0.14 2015-12-25 00:22:43 +01:00
101e7a86cd node vs browser env check is now working 2015-12-25 00:22:28 +01:00
acc0e5221b 0.0.13 2015-12-10 15:52:25 +01:00
a6839420f1 added merge and replace operations for objectstorage 2015-12-10 15:52:14 +01:00
2df7cf1467 0.0.12 2015-12-06 21:55:56 +01:00
bae4305dec update dependencies 2015-12-06 21:55:49 +01:00
1737075753 0.0.11 2015-12-06 21:50:05 +01:00
1a74ee8bb6 switched params for smartenv.obs.add() 2015-12-06 21:49:57 +01:00
28538001e9 0.0.10 2015-12-02 15:33:06 +01:00
9ec0b49716 refactored some functin names within obs module 2015-12-02 15:32:58 +01:00
cab52e1b02 0.0.9 2015-12-02 15:23:59 +01:00
d601a0eeb0 Merge branch 'master' of github.com:pushrocks/smartenv 2015-12-02 15:23:59 +01:00
491f22ffca clean up and fix some errors 2015-12-02 15:23:48 +01:00
1fec5323d9 closes #1 2015-12-01 08:29:58 +01:00
582afc0361 0.0.8 2015-11-30 20:01:08 +01:00
c054ecb0c7 cleaned up 2015-11-30 20:01:02 +01:00
249b626bb5 0.0.7 2015-11-30 19:58:41 +01:00
08d743477f further modularized code 2015-11-30 19:58:35 +01:00
fb64e8004d 0.0.6 2015-11-30 15:04:13 +01:00
f5e48e4fd3 now using classes, remove global funcionality to prevent bad habits 2015-11-30 15:04:04 +01:00
d2de8231cc 0.0.5 2015-11-28 14:50:05 +01:00
0f784e2d74 smartenv.exportEnv and smartenv.importEnv added 2015-11-28 14:49:44 +01:00
f994c34bc7 0.0.4 2015-11-28 14:36:57 +01:00
503f030089 updated smartenv.info 2015-11-28 14:36:47 +01:00
19 changed files with 25265 additions and 101 deletions

9
.gitignore vendored
View File

@ -1,3 +1,10 @@
node_modules/
.settings/
.idea/
.idea/
#npm devug
npm-debug.log
ts/*.js
ts/*.js.map

154
index.js
View File

@ -1,28 +1,134 @@
/// <reference path="index.ts" />
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 if (runtimeEnvArg == "browser") {
this.isBrowser = true;
this.isNode = false;
this.nodeVersion = "undefined";
}
}
;
return Environment;
})();
/// <reference path="index.ts" />
/**
* Deals with the environment the current JS script is running in.
*/
var SmartenvEnvironment;
(function (SmartenvEnvironment) {
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);
})();
envDetermined = true; // ensure code above only runs once
}
;
return environment;
};
/**
* prints the environment to console
*/
var printEnv = function () {
if (this.getEnv().isNode) {
plugins.beautylog.ok("running on NODE");
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
}
else {
plugins.beautylog.ok("running on BROWSER");
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.getAll()));
};
SmartenvEnvironment.init = function (objectArg) {
objectArg.getEnv = getEnv;
objectArg.printEnv = printEnv;
};
})(SmartenvEnvironment || (SmartenvEnvironment = {}));
/// <reference path="index.ts" />
var SmartenvObjectStorage;
(function (SmartenvObjectStorage) {
function init() {
var obs = {
add: function (paramNameArg, objectArg) {
if (paramNameArg === void 0) { paramNameArg = "undefined"; }
if (objectArg === void 0) { objectArg = "undefined"; }
if (paramNameArg == "undefined") {
plugins.beautylog.error("paramName is undefined");
return;
}
if (objectArg == "undefined") {
plugins.beautylog.error("objectArg is undefined");
}
if (typeof obsItems[paramNameArg] === "undefined") {
obsItems[paramNameArg] = objectArg;
}
else {
plugins.beautylog.error("object is already present, so add operation has failed.");
}
return obsItems[paramNameArg];
},
replace: function (paramNameArg, objectArg) {
obsItems[paramNameArg] = objectArg;
},
merge: function (paramNameArg, objectArg) {
if (!(typeof obsItems[paramNameArg] === "undefined")) {
obsItems[paramNameArg] = plugins._.assign(obsItems[paramNameArg], objectArg);
}
else {
plugins.beautylog.error("object is not present, so there is nothing to merge");
}
},
get: function (keyName) {
return obsItems[keyName];
},
getAll: function () {
return obsItems;
},
addComplete: function (itemsArg) {
obsItems = plugins._.assign(obsItems, itemsArg);
return obsItems;
}
};
var obsItems = {};
return obs;
}
SmartenvObjectStorage.init = init;
})(SmartenvObjectStorage || (SmartenvObjectStorage = {}));
/// <reference path="typings/tsd.d.ts" />
var beautylog = require("beautylog")("os");
var addToGlobal = function (objectArg, paramName) {
global[paramName] = objectArg;
/// <reference path="smartenv.classes.ts" />
/// <reference path="smartenv.environment.ts" />
/// <reference path="smartenv.objectstorage.ts" />
var plugins = {
beautylog: require("beautylog")("os"),
_: require("lodash")
};
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"]
};
smartenv.info = function () {
var pck = require("./package.json");
beautylog.log("node version is " + process.version + " and smartenv version is " + pck.version);
beautylog.log("the smartenv module currently holds the following properties:");
console.log(Object.getOwnPropertyNames(smartenv.items).sort());
};
smartenv.register = function (objectArg, paramName) {
if (paramName === void 0) { paramName = "undefined"; }
if (paramName == "undefined") {
beautylog.error("paramName is undefined");
return;
}
smartenv.items[paramName] = objectArg;
};
smartenv.get = function (keyName) {
return smartenv.items[keyName];
};
SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init();
module.exports = smartenv;

View File

@ -1,13 +1,15 @@
{
"name": "smartenv",
"version": "0.0.3",
"version": "0.0.14",
"description": "store things about your environment and let them travel across modules",
"main": "index.js",
"scripts": {
"test": "(cd ts/compile && node compile.js) && (node test.js)",
"testbrowser": "(npm test) && (node testbrowser.js)",
"reinstall": "(rm -r node_modules && npm install)",
"release": "(git pull origin master && npm version patch && git push origin master && git checkout release && git merge master && git push origin release && git checkout master)",
"startdev": "(git checkout master && git pull origin master && npm install)"
"update": "(git checkout master && git pull origin master && npm install)",
"upgrade": "(npm run update) && (ncu upgradeAll && npm install)"
},
"repository": {
"type": "git",
@ -23,10 +25,13 @@
},
"homepage": "https://github.com/pushrocks/smartenv",
"dependencies": {
"beautylog": "^1.0.4"
"beautylog": "^1.0.7",
"lodash": "^3.10.1"
},
"devDependencies": {
"easyserve": "0.0.4",
"gulp": "^3.9.0",
"gulp-typescript": "^2.9.2"
"gulp-browser": "0.0.18",
"gulp-typescript": "^2.10.0"
}
}

22
test.js
View File

@ -2,10 +2,20 @@
var smartenv = require("./index.js");
var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module");
smartenv.info();
smartenv.register({ key1: "Peter" }, "docit");
smartenv.info();
beautylog.log(smartenv.get("docit").key1);
smartenv.makeGlobal();
beautylog.log(global.smartenv.get("docit").key1);
smartenv.printEnv();
beautylog.info("Now testing the smartenv module");
//test smartenv.obs.add
smartenv.obs.add("myTestObject", { key1: "Peter" });
smartenv.obs.add("myTestObject", { key1: "Klaus" }); //now trying to add a second
smartenv.printEnv();
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
//test smartenv.obs.replace
smartenv.obs.replace("myTestObject", { key1: "Klaus" });
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Klaus
//test smartenv.obs.merge
smartenv.obs.merge("myTestObject", { key2: "Peter" });
beautylog.log(smartenv.obs.get("myTestObject").key1 + smartenv.obs.get("myTestObject").key2); // this should be KlausPeter
var key2 = "hello";
smartenv.obs.get("myTestObject").key2 = key2;
beautylog.log(smartenv.obs.get("myTestObject").key2);
beautylog.success("Success!");

File diff suppressed because it is too large Load Diff

6
test/browser/index.html Normal file
View File

@ -0,0 +1,6 @@
<head>
<script async src="browserified/index.js"></script>
</head>
<body>
</body>

2
test/browser/index.js Normal file
View File

@ -0,0 +1,2 @@
var smartenv = require("./index.js");
smartenv.printEnv();

18
testbrowser.js Normal file
View File

@ -0,0 +1,18 @@
/// <reference path="typings/tsd.d.ts" />
var plugins = {
beautylog: require("beautylog")("os"),
gulp: require("gulp"),
gulpBrowser: require("gulp-browser"),
easyserve: require("easyserve")
};
plugins.gulp.task('compileBrowserJS', function () {
var stream = plugins.gulp.src('test/browser/index.js')
.pipe(plugins.gulpBrowser.browserify())
.pipe(plugins.gulp.dest("test/browser/browserified/"));
return stream;
});
plugins.gulp.task('default', ['compileBrowserJS'], function () {
plugins.beautylog.success('browserJS has been browserified');
plugins.easyserve("test/browser/");
});
plugins.gulp.start.apply(plugins.gulp, ['default']);

View File

@ -21,7 +21,16 @@ gulp.task('compileTestTS', function() {
return stream;
});
gulp.task('default',['compileTS','compileTestTS'], function() {
gulp.task('compileTestBrowserTS', function() {
var stream = gulp.src('../testbrowser.ts')
.pipe(gulpTypescript({
out: "testbrowser.js"
}))
.pipe(gulp.dest("../../"));
return stream;
});
gulp.task('default',['compileTS','compileTestTS','compileTestBrowserTS'], function() {
bl.success('Typescript compiled');
});

View File

@ -1,29 +1,13 @@
/// <reference path="typings/tsd.d.ts" />
var beautylog = require("beautylog")("os");
var addToGlobal = function (objectArg, paramName) {
global[paramName] = objectArg;
/// <reference path="smartenv.classes.ts" />
/// <reference path="smartenv.environment.ts" />
/// <reference path="smartenv.objectstorage.ts" />
var plugins = {
beautylog: require("beautylog")("os"),
_: require("lodash")
};
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"]
};
smartenv.info = function () {
var pck = require("./package.json");
beautylog.log("node version is " + process.version + " and smartenv version is " + pck.version);
beautylog.log("the smartenv module currently holds the following properties:");
console.log(Object.getOwnPropertyNames(smartenv.items).sort());
};
smartenv.register = function (objectArg, paramName) {
if (paramName === void 0) { paramName = "undefined"; }
if (paramName == "undefined") {
beautylog.error("paramName is undefined");
return;
}
smartenv.items[paramName] = objectArg;
};
smartenv.get = function (keyName) {
return smartenv.items[keyName];
};
SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init();
module.exports = smartenv;
//# sourceMappingURL=index.js.map

View File

@ -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;IACZ,IAAI,GAAG,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACpC,SAAS,CAAC,GAAG,CAAC,kBAAkB,GAAG,OAAO,CAAC,OAAO,GAAG,2BAA2B,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;IAChG,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,CAAC;AACnE,CAAC,CAAC;AAEF,QAAQ,CAAC,QAAQ,GAAG,UAAS,SAAS,EAAC,SAAuB;IAAvB,yBAAuB,GAAvB,uBAAuB;IAC1D,EAAE,CAAC,CAAC,SAAS,IAAI,WAAW,CAAC,CAAA,CAAC;QAC1B,SAAS,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC1C,MAAM,CAAC;IACX,CAAC;IACD,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAC1C,CAAC,CAAC;AACF,QAAQ,CAAC,GAAG,GAAG,UAAS,OAAO;IAC3B,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC,CAAA;AAED,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"}

View File

@ -1,31 +1,16 @@
/// <reference path="typings/tsd.d.ts" />
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"]
};
smartenv.info = function() {
var pck = require("./package.json");
beautylog.log("node version is " + process.version + " and smartenv version is " + pck.version);
beautylog.log("the smartenv module currently holds the following properties:");
console.log(Object.getOwnPropertyNames(smartenv.items).sort());
};
smartenv.register = function(objectArg,paramName = "undefined") {
if (paramName == "undefined"){
beautylog.error("paramName is undefined");
return;
}
smartenv.items[paramName] = objectArg;
};
smartenv.get = function(keyName) {
return smartenv.items[keyName];
/// <reference path="smartenv.classes.ts" />
/// <reference path="smartenv.environment.ts" />
/// <reference path="smartenv.objectstorage.ts" />
var plugins = {
beautylog: require("beautylog")("os"),
_: require("lodash")
}
var smartenv:any = {}; //create smartenv object
SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init();
module.exports = smartenv;

21
ts/smartenv.classes.ts Normal file
View File

@ -0,0 +1,21 @@
/// <reference path="index.ts" />
class Environment {
public runtimeEnv:string;
public userAgent:string;
public nodeVersion:string;
public isBrowser:boolean;
public isNode:boolean;
constructor(runtimeEnvArg:string,userAgentArg:string = "undefined") {
this.runtimeEnv = runtimeEnvArg;
this.userAgent = userAgentArg;
if(runtimeEnvArg == "node"){
this.isBrowser = false;
this.isNode = true;
this.nodeVersion = process.version;
} else if (runtimeEnvArg == "browser") {
this.isBrowser = true;
this.isNode = false;
this.nodeVersion = "undefined";
}
};
}

View File

@ -0,0 +1,52 @@
/// <reference path="index.ts" />
/**
* Deals with the environment the current JS script is running in.
*/
module SmartenvEnvironment {
var environment:Environment;
var envDetermined:boolean = 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);
})();
envDetermined = true; // ensure code above only runs once
};
return environment;
};
/**
* prints the environment to console
*/
var printEnv = function() {
if (this.getEnv().isNode) {
plugins.beautylog.ok("running on NODE");
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
} else {
plugins.beautylog.ok("running on BROWSER");
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.getAll()));
}
export var init = function(objectArg) {
objectArg.getEnv = getEnv;
objectArg.printEnv = printEnv;
}
}

View File

@ -0,0 +1,44 @@
/// <reference path="index.ts" />
module SmartenvObjectStorage {
export function init() {
var obs:any = {
add: function(paramNameArg = "undefined",objectArg = "undefined") {
if (paramNameArg == "undefined"){
plugins.beautylog.error("paramName is undefined");
return;
}
if (objectArg == "undefined"){
plugins.beautylog.error("objectArg is undefined");
}
if (typeof obsItems[paramNameArg] === "undefined"){
obsItems[paramNameArg] = objectArg;
} else {
plugins.beautylog.error("object is already present, so add operation has failed.");
}
return obsItems[paramNameArg];
},
replace: function(paramNameArg,objectArg){
obsItems[paramNameArg] = objectArg;
},
merge: function(paramNameArg,objectArg){
if(!(typeof obsItems[paramNameArg] === "undefined")){
obsItems[paramNameArg] = plugins._.assign(obsItems[paramNameArg],objectArg);
} else {
plugins.beautylog.error("object is not present, so there is nothing to merge");
}
},
get: function(keyName) {
return obsItems[keyName];
},
getAll: function () {
return obsItems;
},
addComplete: function(itemsArg) {
obsItems = plugins._.assign(obsItems,itemsArg);
return obsItems;
}
};
var obsItems:any = {};
return obs;
}
}

View File

@ -2,12 +2,21 @@
var smartenv = require("./index.js");
var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module");
smartenv.info();
smartenv.printEnv();
beautylog.info("Now testing the smartenv module");
smartenv.register({ key1: "Peter" }, "docit");
smartenv.info();
beautylog.log(smartenv.get("docit").key1);
smartenv.makeGlobal();
beautylog.log(global.smartenv.get("docit").key1);
//test smartenv.obs.add
smartenv.obs.add("myTestObject", { key1: "Peter" });
smartenv.obs.add("myTestObject", { key1: "Klaus" }); //now trying to add a second
smartenv.printEnv();
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
//test smartenv.obs.replace
smartenv.obs.replace("myTestObject", { key1: "Klaus" });
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Klaus
//test smartenv.obs.merge
smartenv.obs.merge("myTestObject", { key2: "Peter" });
beautylog.log(smartenv.obs.get("myTestObject").key1 + smartenv.obs.get("myTestObject").key2); // this should be KlausPeter
var key2 = "hello";
smartenv.obs.get("myTestObject").key2 = key2;
beautylog.log(smartenv.obs.get("myTestObject").key2);
beautylog.success("Success!");
//# sourceMappingURL=test.js.map

View File

@ -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,EAAE,CAAC;AAChB,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,EAAE,CAAC;AAChB,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;AACjD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC"}
{"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;AAElD,uBAAuB;AACvB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AAChD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC,CAAC,4BAA4B;AAC7E,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,uBAAuB;AAE7E,2BAA2B;AAC3B,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AACpD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,uBAAuB;AAE7E,yBAAyB;AACzB,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AAClD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,4BAA4B;AAE1H,IAAI,IAAI,GAAG,OAAO,CAAC;AACnB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AAC7C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC;AAErD,SAAS,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC"}

View File

@ -2,11 +2,25 @@
var smartenv = require("./index.js");
var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module");
smartenv.info();
smartenv.printEnv();
beautylog.info("Now testing the smartenv module");
smartenv.register({key1:"Peter"},"docit");
smartenv.info();
beautylog.log(smartenv.get("docit").key1);
smartenv.makeGlobal();
beautylog.log(global.smartenv.get("docit").key1);
//test smartenv.obs.add
smartenv.obs.add("myTestObject",{key1:"Peter"});
smartenv.obs.add("myTestObject",{key1:"Klaus"}); //now trying to add a second
smartenv.printEnv();
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
//test smartenv.obs.replace
smartenv.obs.replace("myTestObject",{key1:"Klaus"});
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Klaus
//test smartenv.obs.merge
smartenv.obs.merge("myTestObject",{key2:"Peter"});
beautylog.log(smartenv.obs.get("myTestObject").key1 + smartenv.obs.get("myTestObject").key2); // this should be KlausPeter
var key2 = "hello";
smartenv.obs.get("myTestObject").key2 = key2;
beautylog.log(smartenv.obs.get("myTestObject").key2);
beautylog.success("Success!");

21
ts/testbrowser.ts Normal file
View File

@ -0,0 +1,21 @@
/// <reference path="typings/tsd.d.ts" />
var plugins = {
beautylog: require("beautylog")("os"),
gulp: require("gulp"),
gulpBrowser: require("gulp-browser"),
easyserve: require("easyserve")
};
plugins.gulp.task('compileBrowserJS', function() {
var stream = plugins.gulp.src('test/browser/index.js')
.pipe(plugins.gulpBrowser.browserify())
.pipe(plugins.gulp.dest("test/browser/browserified/"));
return stream;
});
plugins.gulp.task('default',['compileBrowserJS'], function() {
plugins.beautylog.success('browserJS has been browserified');
plugins.easyserve("test/browser/");
});
plugins.gulp.start.apply(plugins.gulp, ['default']);