Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
1737075753 | |||
1a74ee8bb6 | |||
28538001e9 | |||
9ec0b49716 |
18
index.js
18
index.js
@ -60,7 +60,7 @@ var SmartenvEnvironment;
|
|||||||
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:");
|
||||||
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete()));
|
console.log(Object.getOwnPropertyNames(smartenv.obs.getAll()));
|
||||||
};
|
};
|
||||||
SmartenvEnvironment.init = function (objectArg) {
|
SmartenvEnvironment.init = function (objectArg) {
|
||||||
objectArg.getEnv = getEnv;
|
objectArg.getEnv = getEnv;
|
||||||
@ -73,18 +73,22 @@ var SmartenvObjectStorage;
|
|||||||
function init() {
|
function init() {
|
||||||
var obs = {};
|
var obs = {};
|
||||||
var obsItems = {};
|
var obsItems = {};
|
||||||
obs.addItem = function (objectArg, paramName) {
|
obs.add = function (paramNameArg, objectArg) {
|
||||||
if (paramName === void 0) { paramName = "undefined"; }
|
if (paramNameArg === void 0) { paramNameArg = "undefined"; }
|
||||||
if (paramName == "undefined") {
|
if (objectArg === void 0) { objectArg = "undefined"; }
|
||||||
|
if (paramNameArg == "undefined") {
|
||||||
plugins.beautylog.error("paramName is undefined");
|
plugins.beautylog.error("paramName is undefined");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
obsItems[paramName] = objectArg;
|
if (objectArg == "undefined") {
|
||||||
|
plugins.beautylog.error("objectArg is undefined");
|
||||||
|
}
|
||||||
|
obsItems[paramNameArg] = objectArg;
|
||||||
};
|
};
|
||||||
obs.getItem = function (keyName) {
|
obs.get = function (keyName) {
|
||||||
return obsItems[keyName];
|
return obsItems[keyName];
|
||||||
};
|
};
|
||||||
obs.getComplete = function () {
|
obs.getAll = function () {
|
||||||
return obsItems;
|
return obsItems;
|
||||||
};
|
};
|
||||||
obs.addComplete = function (itemsArg) {
|
obs.addComplete = function (itemsArg) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "smartenv",
|
"name": "smartenv",
|
||||||
"version": "0.0.9",
|
"version": "0.0.11",
|
||||||
"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": {
|
||||||
|
10
test.js
10
test.js
@ -4,11 +4,11 @@ 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.addItem({ key1: "Peter" }, "docit");
|
smartenv.obs.add("docit", { key1: "Peter" });
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key1);
|
beautylog.log(smartenv.obs.get("docit").key1);
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key1);
|
beautylog.log(smartenv.obs.get("docit").key1);
|
||||||
var key2 = "hello";
|
var key2 = "hello";
|
||||||
smartenv.obs.getItem("docit").key2 = key2;
|
smartenv.obs.get("docit").key2 = key2;
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key2);
|
beautylog.log(smartenv.obs.get("docit").key2);
|
||||||
beautylog.success("Success!");
|
beautylog.success("Success!");
|
||||||
|
@ -39,7 +39,7 @@ module SmartenvEnvironment {
|
|||||||
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:");
|
||||||
console.log(Object.getOwnPropertyNames(smartenv.obs.getComplete()));
|
console.log(Object.getOwnPropertyNames(smartenv.obs.getAll()));
|
||||||
}
|
}
|
||||||
|
|
||||||
export var init = function(objectArg) {
|
export var init = function(objectArg) {
|
||||||
|
@ -3,17 +3,20 @@ module SmartenvObjectStorage {
|
|||||||
export function init() {
|
export function init() {
|
||||||
var obs:any = {};
|
var obs:any = {};
|
||||||
var obsItems:any = {};
|
var obsItems:any = {};
|
||||||
obs.addItem = function(objectArg,paramName = "undefined") {
|
obs.add = function(paramNameArg = "undefined",objectArg = "undefined") {
|
||||||
if (paramName == "undefined"){
|
if (paramNameArg == "undefined"){
|
||||||
plugins.beautylog.error("paramName is undefined");
|
plugins.beautylog.error("paramName is undefined");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
obsItems[paramName] = objectArg;
|
if (objectArg == "undefined"){
|
||||||
|
plugins.beautylog.error("objectArg is undefined");
|
||||||
|
}
|
||||||
|
obsItems[paramNameArg] = objectArg;
|
||||||
};
|
};
|
||||||
obs.getItem = function(keyName) {
|
obs.get = function(keyName) {
|
||||||
return obsItems[keyName];
|
return obsItems[keyName];
|
||||||
};
|
};
|
||||||
obs.getComplete = function () {
|
obs.getAll = function () {
|
||||||
return obsItems;
|
return obsItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
ts/test.js
10
ts/test.js
@ -4,12 +4,12 @@ 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.addItem({ key1: "Peter" }, "docit");
|
smartenv.obs.add("docit", { key1: "Peter" });
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key1);
|
beautylog.log(smartenv.obs.get("docit").key1);
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key1);
|
beautylog.log(smartenv.obs.get("docit").key1);
|
||||||
var key2 = "hello";
|
var key2 = "hello";
|
||||||
smartenv.obs.getItem("docit").key2 = key2;
|
smartenv.obs.get("docit").key2 = key2;
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key2);
|
beautylog.log(smartenv.obs.get("docit").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,OAAO,CAAC,EAAC,IAAI,EAAC,OAAO,EAAC,EAAC,OAAO,CAAC,CAAC;AAC7C,QAAQ,CAAC,QAAQ,EAAE,CAAC;AACpB,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAClD,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAElD,IAAI,IAAI,GAAG,OAAO,CAAC;AACnB,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC;AAC1C,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC;AAElD,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;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"}
|
10
ts/test.ts
10
ts/test.ts
@ -4,13 +4,13 @@ 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.addItem({key1:"Peter"},"docit");
|
smartenv.obs.add("docit",{key1:"Peter"});
|
||||||
smartenv.printEnv();
|
smartenv.printEnv();
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key1);
|
beautylog.log(smartenv.obs.get("docit").key1);
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key1);
|
beautylog.log(smartenv.obs.get("docit").key1);
|
||||||
|
|
||||||
var key2 = "hello";
|
var key2 = "hello";
|
||||||
smartenv.obs.getItem("docit").key2 = key2;
|
smartenv.obs.get("docit").key2 = key2;
|
||||||
beautylog.log(smartenv.obs.getItem("docit").key2);
|
beautylog.log(smartenv.obs.get("docit").key2);
|
||||||
|
|
||||||
beautylog.success("Success!");
|
beautylog.success("Success!");
|
Reference in New Issue
Block a user