initial
This commit is contained in:
7
ts/classes.js
Normal file
7
ts/classes.js
Normal file
@ -0,0 +1,7 @@
|
||||
/// <reference path="index.ts" />
|
||||
var Environment = (function () {
|
||||
function Environment() {
|
||||
}
|
||||
return Environment;
|
||||
})();
|
||||
//# sourceMappingURL=classes.js.map
|
1
ts/classes.js.map
Normal file
1
ts/classes.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"classes.js","sourceRoot":"","sources":["classes.ts"],"names":["Environment","Environment.constructor"],"mappings":"AAAA,iCAAiC;AACjC;IAAAA;IAKAC,CAACA;IAADD,kBAACA;AAADA,CAACA,AALD,IAKC"}
|
7
ts/classes.ts
Normal file
7
ts/classes.ts
Normal file
@ -0,0 +1,7 @@
|
||||
/// <reference path="index.ts" />
|
||||
class Environment {
|
||||
runtimeEnv:string;
|
||||
isBrowser:boolean;
|
||||
isNode:boolean;
|
||||
|
||||
}
|
28
ts/compile/compile.js
Normal file
28
ts/compile/compile.js
Normal file
@ -0,0 +1,28 @@
|
||||
// import gulp
|
||||
var gulp = require("gulp");
|
||||
var gulpTypescript = require("gulp-typescript");
|
||||
var bl = require("beautylog")("os");
|
||||
|
||||
gulp.task('compileTS', function() {
|
||||
var stream = gulp.src('../index.ts')
|
||||
.pipe(gulpTypescript({
|
||||
out: "index.js"
|
||||
}))
|
||||
.pipe(gulp.dest("../../"));
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('compileTestTS', function() {
|
||||
var stream = gulp.src('../test.ts')
|
||||
.pipe(gulpTypescript({
|
||||
out: "test.js"
|
||||
}))
|
||||
.pipe(gulp.dest("../../"));
|
||||
return stream;
|
||||
});
|
||||
|
||||
gulp.task('default',['compileTS','compileTestTS'], function() {
|
||||
bl.success('Typescript compiled');
|
||||
});
|
||||
|
||||
gulp.start.apply(gulp, ['default']);
|
2
ts/compile/readme.md
Normal file
2
ts/compile/readme.md
Normal file
@ -0,0 +1,2 @@
|
||||
# How to compile.
|
||||
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.
|
50
ts/index.js
Normal file
50
ts/index.js
Normal file
@ -0,0 +1,50 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
/// <reference path="classes.ts" />
|
||||
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"]
|
||||
};
|
||||
smartenv.info = {};
|
||||
smartenv.info.jsenv = function () {
|
||||
var app = {
|
||||
env: '',
|
||||
agent: ''
|
||||
};
|
||||
if (window) {
|
||||
app.env = 'browser';
|
||||
app.agent = navigator.userAgent;
|
||||
}
|
||||
else if (process) {
|
||||
app.env = 'node';
|
||||
}
|
||||
};
|
||||
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:");
|
||||
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];
|
||||
};
|
||||
smartenv.exportEnv = function () {
|
||||
};
|
||||
smartenv.importEnv = function () {
|
||||
};
|
||||
module.exports = smartenv;
|
||||
//# sourceMappingURL=index.js.map
|
1
ts/index.js.map
Normal file
1
ts/index.js.map
Normal file
@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":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,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,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,CAAC;AAEF,QAAQ,CAAC,SAAS,GAAG;AAErB,CAAC,CAAC;AAEF,QAAQ,CAAC,SAAS,GAAG;AAErB,CAAC,CAAC;AAEF,MAAM,CAAC,OAAO,GAAG,QAAQ,CAAC"}
|
56
ts/index.ts
Normal file
56
ts/index.ts
Normal file
@ -0,0 +1,56 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
/// <reference path="classes.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 = {};
|
||||
smartenv.info.jsenv = function() {
|
||||
var app = {
|
||||
env: '',
|
||||
agent: ''
|
||||
};
|
||||
|
||||
if (window) {
|
||||
app.env = 'browser';
|
||||
app.agent = navigator.userAgent;
|
||||
} else if (process) {
|
||||
app.env = 'node';
|
||||
}
|
||||
};
|
||||
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:");
|
||||
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];
|
||||
};
|
||||
|
||||
smartenv.exportEnv = function() {
|
||||
|
||||
};
|
||||
|
||||
smartenv.importEnv = function() {
|
||||
|
||||
};
|
||||
|
||||
module.exports = smartenv;
|
16
ts/test.js
Normal file
16
ts/test.js
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var smartenv = require("./index.js");
|
||||
var beautylog = require("beautylog")("os");
|
||||
beautylog.info("Now testing the smartenv module");
|
||||
smartenv.info.print();
|
||||
beautylog.info("Now testing the smartenv module");
|
||||
smartenv.register({ key1: "Peter" }, "docit");
|
||||
smartenv.info.print();
|
||||
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.success("Success!");
|
||||
//# sourceMappingURL=test.js.map
|
1
ts/test.js.map
Normal file
1
ts/test.js.map
Normal file
@ -0,0 +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"}
|
17
ts/test.ts
Normal file
17
ts/test.ts
Normal file
@ -0,0 +1,17 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
var smartenv = require("./index.js");
|
||||
var beautylog = require("beautylog")("os");
|
||||
beautylog.info("Now testing the smartenv module");
|
||||
smartenv.info.print();
|
||||
beautylog.info("Now testing the smartenv module");
|
||||
smartenv.register({key1:"Peter"},"docit");
|
||||
smartenv.info.print();
|
||||
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.success("Success!");
|
12
ts/tsd.json
Normal file
12
ts/tsd.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": "v4",
|
||||
"repo": "borisyankov/DefinitelyTyped",
|
||||
"ref": "master",
|
||||
"path": "typings",
|
||||
"bundle": "typings/tsd.d.ts",
|
||||
"installed": {
|
||||
"node/node.d.ts": {
|
||||
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
|
||||
}
|
||||
}
|
||||
}
|
2079
ts/typings/node/node.d.ts
vendored
Normal file
2079
ts/typings/node/node.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1
ts/typings/tsd.d.ts
vendored
Normal file
1
ts/typings/tsd.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference path="node/node.d.ts" />
|
Reference in New Issue
Block a user