Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
bfb9ebb994 | |||
84c25f3a67 | |||
1f4ffaff2a | |||
101e7a86cd | |||
acc0e5221b | |||
a6839420f1 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -8,3 +8,5 @@ npm-debug.log
|
|||||||
|
|
||||||
ts/*.js
|
ts/*.js
|
||||||
ts/*.js.map
|
ts/*.js.map
|
||||||
|
|
||||||
|
test/browser/browserified/
|
75
index.js
75
index.js
@ -9,9 +9,9 @@ var Environment = (function () {
|
|||||||
this.isNode = true;
|
this.isNode = true;
|
||||||
this.nodeVersion = process.version;
|
this.nodeVersion = process.version;
|
||||||
}
|
}
|
||||||
else {
|
else if (runtimeEnvArg == "browser") {
|
||||||
this.isBrowser = true;
|
this.isBrowser = true;
|
||||||
this.isNode = true;
|
this.isNode = false;
|
||||||
this.nodeVersion = "undefined";
|
this.nodeVersion = "undefined";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -35,15 +35,16 @@ var SmartenvEnvironment;
|
|||||||
(function () {
|
(function () {
|
||||||
var localRunTimeEnv = "undefined";
|
var localRunTimeEnv = "undefined";
|
||||||
var localUserAgent = "undefined";
|
var localUserAgent = "undefined";
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== "undefined") {
|
||||||
localRunTimeEnv = 'browser';
|
localRunTimeEnv = 'browser';
|
||||||
localUserAgent = navigator.userAgent;
|
localUserAgent = navigator.userAgent;
|
||||||
}
|
}
|
||||||
else if (typeof process !== 'undefined') {
|
else if (typeof process !== "undefined") {
|
||||||
localRunTimeEnv = 'node';
|
localRunTimeEnv = 'node';
|
||||||
}
|
}
|
||||||
environment = new Environment(localRunTimeEnv, localUserAgent);
|
environment = new Environment(localRunTimeEnv, localUserAgent);
|
||||||
})();
|
})();
|
||||||
|
envDetermined = true; // ensure code above only runs once
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
return environment;
|
return environment;
|
||||||
@ -53,10 +54,12 @@ var SmartenvEnvironment;
|
|||||||
*/
|
*/
|
||||||
var printEnv = function () {
|
var printEnv = function () {
|
||||||
if (this.getEnv().isNode) {
|
if (this.getEnv().isNode) {
|
||||||
|
plugins.beautylog.ok("running on NODE");
|
||||||
var smartenvVersion = require("./package.json").version;
|
var smartenvVersion = require("./package.json").version;
|
||||||
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
plugins.beautylog.ok("running on BROWSER");
|
||||||
plugins.beautylog.log("browser is " + this.getEnv().userAgent);
|
plugins.beautylog.log("browser is " + this.getEnv().userAgent);
|
||||||
}
|
}
|
||||||
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
||||||
@ -71,30 +74,48 @@ var SmartenvEnvironment;
|
|||||||
var SmartenvObjectStorage;
|
var SmartenvObjectStorage;
|
||||||
(function (SmartenvObjectStorage) {
|
(function (SmartenvObjectStorage) {
|
||||||
function init() {
|
function init() {
|
||||||
var obs = {};
|
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 = {};
|
var obsItems = {};
|
||||||
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");
|
|
||||||
}
|
|
||||||
obsItems[paramNameArg] = objectArg;
|
|
||||||
};
|
|
||||||
obs.get = function (keyName) {
|
|
||||||
return obsItems[keyName];
|
|
||||||
};
|
|
||||||
obs.getAll = function () {
|
|
||||||
return obsItems;
|
|
||||||
};
|
|
||||||
obs.addComplete = function (itemsArg) {
|
|
||||||
obsItems = plugins._.assign(obsItems, itemsArg);
|
|
||||||
return obsItems;
|
|
||||||
};
|
|
||||||
return obs;
|
return obs;
|
||||||
}
|
}
|
||||||
SmartenvObjectStorage.init = init;
|
SmartenvObjectStorage.init = init;
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "smartenv",
|
"name": "smartenv",
|
||||||
"version": "0.0.12",
|
"version": "0.0.15",
|
||||||
"description": "store things about your environment and let them travel across modules",
|
"description": "store things about your environment and let them travel across modules",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(cd ts/compile && node compile.js) && (node test.js)",
|
"test": "(cd ts/compile && node compile.js) && (node test.js)",
|
||||||
|
"testbrowser": "(npm test) && (node testbrowser.js)",
|
||||||
"reinstall": "(rm -r node_modules && npm install)",
|
"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)",
|
"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)",
|
||||||
"update": "(git checkout master && git pull origin master && npm install)",
|
"update": "(git checkout master && git pull origin master && npm install)",
|
||||||
@ -24,11 +25,13 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/pushrocks/smartenv",
|
"homepage": "https://github.com/pushrocks/smartenv",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"beautylog": "^1.0.6",
|
"beautylog": "^1.0.7",
|
||||||
"lodash": "^3.10.1"
|
"lodash": "^3.10.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"easyserve": "0.0.4",
|
||||||
"gulp": "^3.9.0",
|
"gulp": "^3.9.0",
|
||||||
|
"gulp-browser": "0.0.18",
|
||||||
"gulp-typescript": "^2.10.0"
|
"gulp-typescript": "^2.10.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
17
test.js
17
test.js
@ -4,11 +4,18 @@ var beautylog = require("beautylog")("os");
|
|||||||
beautylog.info("Now testing the smartenv module");
|
beautylog.info("Now testing the smartenv module");
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.info("Now testing the smartenv module");
|
beautylog.info("Now testing the smartenv module");
|
||||||
smartenv.obs.add("docit", { key1: "Peter" });
|
//test smartenv.obs.add
|
||||||
|
smartenv.obs.add("myTestObject", { key1: "Peter" });
|
||||||
|
smartenv.obs.add("myTestObject", { key1: "Klaus" }); //now trying to add a second
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.log(smartenv.obs.get("docit").key1);
|
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
|
||||||
beautylog.log(smartenv.obs.get("docit").key1);
|
//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";
|
var key2 = "hello";
|
||||||
smartenv.obs.get("docit").key2 = key2;
|
smartenv.obs.get("myTestObject").key2 = key2;
|
||||||
beautylog.log(smartenv.obs.get("docit").key2);
|
beautylog.log(smartenv.obs.get("myTestObject").key2);
|
||||||
beautylog.success("Success!");
|
beautylog.success("Success!");
|
||||||
|
6
test/browser/index.html
Normal file
6
test/browser/index.html
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<head>
|
||||||
|
<script async src="browserified/index.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
</body>
|
2
test/browser/index.js
Normal file
2
test/browser/index.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var smartenv = require("./index.js");
|
||||||
|
smartenv.printEnv();
|
18
testbrowser.js
Normal file
18
testbrowser.js
Normal 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']);
|
@ -21,7 +21,16 @@ gulp.task('compileTestTS', function() {
|
|||||||
return stream;
|
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');
|
bl.success('Typescript compiled');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -5,16 +5,16 @@ class Environment {
|
|||||||
public nodeVersion:string;
|
public nodeVersion:string;
|
||||||
public isBrowser:boolean;
|
public isBrowser:boolean;
|
||||||
public isNode:boolean;
|
public isNode:boolean;
|
||||||
constructor(runtimeEnvArg,userAgentArg = "undefined") {
|
constructor(runtimeEnvArg:string,userAgentArg:string = "undefined") {
|
||||||
this.runtimeEnv = runtimeEnvArg;
|
this.runtimeEnv = runtimeEnvArg;
|
||||||
this.userAgent = userAgentArg;
|
this.userAgent = userAgentArg;
|
||||||
if(runtimeEnvArg == "node"){
|
if(runtimeEnvArg == "node"){
|
||||||
this.isBrowser = false;
|
this.isBrowser = false;
|
||||||
this.isNode = true;
|
this.isNode = true;
|
||||||
this.nodeVersion = process.version;
|
this.nodeVersion = process.version;
|
||||||
} else {
|
} else if (runtimeEnvArg == "browser") {
|
||||||
this.isBrowser = true;
|
this.isBrowser = true;
|
||||||
this.isNode = true;
|
this.isNode = false;
|
||||||
this.nodeVersion = "undefined";
|
this.nodeVersion = "undefined";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -16,14 +16,15 @@ module SmartenvEnvironment {
|
|||||||
(function() {
|
(function() {
|
||||||
var localRunTimeEnv = "undefined";
|
var localRunTimeEnv = "undefined";
|
||||||
var localUserAgent = "undefined";
|
var localUserAgent = "undefined";
|
||||||
if (typeof window !== 'undefined') {
|
if (typeof window !== "undefined") {
|
||||||
localRunTimeEnv = 'browser';
|
localRunTimeEnv = 'browser';
|
||||||
localUserAgent = navigator.userAgent;
|
localUserAgent = navigator.userAgent;
|
||||||
} else if (typeof process !== 'undefined') {
|
} else if (typeof process !== "undefined") {
|
||||||
localRunTimeEnv = 'node';
|
localRunTimeEnv = 'node';
|
||||||
}
|
}
|
||||||
environment = new Environment(localRunTimeEnv,localUserAgent);
|
environment = new Environment(localRunTimeEnv,localUserAgent);
|
||||||
})();
|
})();
|
||||||
|
envDetermined = true; // ensure code above only runs once
|
||||||
};
|
};
|
||||||
return environment;
|
return environment;
|
||||||
};
|
};
|
||||||
@ -33,10 +34,12 @@ module SmartenvEnvironment {
|
|||||||
*/
|
*/
|
||||||
var printEnv = function() {
|
var printEnv = function() {
|
||||||
if (this.getEnv().isNode) {
|
if (this.getEnv().isNode) {
|
||||||
|
plugins.beautylog.ok("running on NODE");
|
||||||
var smartenvVersion = require("./package.json").version;
|
var smartenvVersion = require("./package.json").version;
|
||||||
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
|
||||||
} else {
|
} else {
|
||||||
plugins.beautylog.log("browser is " + this.getEnv().userAgent)
|
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:");
|
plugins.beautylog.log("the smartenv registration store currently holds the following properties:");
|
||||||
console.log(Object.getOwnPropertyNames(smartenv.obs.getAll()));
|
console.log(Object.getOwnPropertyNames(smartenv.obs.getAll()));
|
||||||
|
@ -1,29 +1,44 @@
|
|||||||
/// <reference path="index.ts" />
|
/// <reference path="index.ts" />
|
||||||
module SmartenvObjectStorage {
|
module SmartenvObjectStorage {
|
||||||
export function init() {
|
export function init() {
|
||||||
var obs:any = {};
|
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 = {};
|
var obsItems:any = {};
|
||||||
obs.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");
|
|
||||||
}
|
|
||||||
obsItems[paramNameArg] = objectArg;
|
|
||||||
};
|
|
||||||
obs.get = function(keyName) {
|
|
||||||
return obsItems[keyName];
|
|
||||||
};
|
|
||||||
obs.getAll = function () {
|
|
||||||
return obsItems;
|
|
||||||
}
|
|
||||||
|
|
||||||
obs.addComplete = function(itemsArg) {
|
|
||||||
obsItems = plugins._.assign(obsItems,itemsArg);
|
|
||||||
return obsItems;
|
|
||||||
};
|
|
||||||
return obs;
|
return obs;
|
||||||
}
|
}
|
||||||
}
|
}
|
17
ts/test.js
17
ts/test.js
@ -4,12 +4,19 @@ var beautylog = require("beautylog")("os");
|
|||||||
beautylog.info("Now testing the smartenv module");
|
beautylog.info("Now testing the smartenv module");
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.info("Now testing the smartenv module");
|
beautylog.info("Now testing the smartenv module");
|
||||||
smartenv.obs.add("docit", { key1: "Peter" });
|
//test smartenv.obs.add
|
||||||
|
smartenv.obs.add("myTestObject", { key1: "Peter" });
|
||||||
|
smartenv.obs.add("myTestObject", { key1: "Klaus" }); //now trying to add a second
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.log(smartenv.obs.get("docit").key1);
|
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
|
||||||
beautylog.log(smartenv.obs.get("docit").key1);
|
//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";
|
var key2 = "hello";
|
||||||
smartenv.obs.get("docit").key2 = key2;
|
smartenv.obs.get("myTestObject").key2 = key2;
|
||||||
beautylog.log(smartenv.obs.get("docit").key2);
|
beautylog.log(smartenv.obs.get("myTestObject").key2);
|
||||||
beautylog.success("Success!");
|
beautylog.success("Success!");
|
||||||
//# sourceMappingURL=test.js.map
|
//# sourceMappingURL=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,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;AAClD,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,EAAC,EAAC,IAAI,EAAC,OAAO,EAAC,CAAC,CAAC;AACzC,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAC9C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAE9C,IAAI,IAAI,GAAG,OAAO,CAAC;AACnB,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AACtC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAE9C,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"}
|
20
ts/test.ts
20
ts/test.ts
@ -4,13 +4,23 @@ var beautylog = require("beautylog")("os");
|
|||||||
beautylog.info("Now testing the smartenv module");
|
beautylog.info("Now testing the smartenv module");
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.info("Now testing the smartenv module");
|
beautylog.info("Now testing the smartenv module");
|
||||||
smartenv.obs.add("docit",{key1:"Peter"});
|
|
||||||
|
//test smartenv.obs.add
|
||||||
|
smartenv.obs.add("myTestObject",{key1:"Peter"});
|
||||||
|
smartenv.obs.add("myTestObject",{key1:"Klaus"}); //now trying to add a second
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.log(smartenv.obs.get("docit").key1);
|
beautylog.log(smartenv.obs.get("myTestObject").key1); // this should be Peter
|
||||||
beautylog.log(smartenv.obs.get("docit").key1);
|
|
||||||
|
//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";
|
var key2 = "hello";
|
||||||
smartenv.obs.get("docit").key2 = key2;
|
smartenv.obs.get("myTestObject").key2 = key2;
|
||||||
beautylog.log(smartenv.obs.get("docit").key2);
|
beautylog.log(smartenv.obs.get("myTestObject").key2);
|
||||||
|
|
||||||
beautylog.success("Success!");
|
beautylog.success("Success!");
|
21
ts/testbrowser.ts
Normal file
21
ts/testbrowser.ts
Normal 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']);
|
Reference in New Issue
Block a user