Compare commits

...

81 Commits

Author SHA1 Message Date
47f840841c 2.0.6 2017-04-21 00:11:11 +02:00
fe2210dc9f update readme 2017-04-21 00:11:06 +02:00
489ebab6ee 2.0.5 2017-04-21 00:04:31 +02:00
46baf07551 now has a env vars feature 2017-04-21 00:04:28 +02:00
cf0aabfbfc 2.0.4 2017-04-19 20:18:19 +02:00
a5005aeb96 2.0.3 2017-04-19 20:06:25 +02:00
a7e9f1303d update ci 2017-04-19 20:06:21 +02:00
92a6508c6a 2.0.2 2017-04-19 20:05:11 +02:00
32f6b5cbf8 update 2017-04-19 20:05:05 +02:00
bdfbcead8d 2.0.1 2017-04-19 20:02:46 +02:00
e73e704886 update dependencies to latest standards 2017-04-19 20:02:43 +02:00
efa818680a 2.0.0 2016-11-21 18:29:08 +01:00
572d85b3d3 prepare new major version 2016-11-21 18:29:02 +01:00
41e1386a8d 1.2.11 2016-11-21 18:28:08 +01:00
98d6f9e483 reverse to ES5 2016-11-21 18:28:06 +01:00
f295776bea 1.2.10 2016-11-21 14:51:39 +01:00
cde63e95a8 update repo links 2016-11-21 14:51:35 +01:00
6e4804a5ad 1.2.9 2016-11-21 14:47:30 +01:00
137592a19b update types 2016-11-21 14:47:24 +01:00
b850bc48cd 1.2.8 2016-11-21 12:11:53 +01:00
e1ce867493 update README 2016-11-21 12:11:49 +01:00
8e94ca9a60 1.2.7 2016-11-21 12:05:00 +01:00
81eaaaca90 update tests 2016-11-21 12:04:57 +01:00
340e7716f0 1.2.6 2016-11-21 11:58:41 +01:00
af7b9c46d2 update to latest standards 2016-11-21 11:58:37 +01:00
56d4432d31 Update README.md 2016-05-19 06:55:05 +02:00
324abf821e 1.2.5 2016-05-02 01:43:11 +02:00
fde407a762 update travis.yml 2016-05-02 01:43:07 +02:00
c9ac84954f update travis.yml 2016-05-02 01:41:57 +02:00
e0b4a93f1c 1.2.4 2016-05-02 01:30:02 +02:00
70015b5ffc now bundles typings 2016-05-02 01:29:42 +02:00
5a4d47411a 1.2.3 2016-04-05 15:53:54 +02:00
1730706034 fix package.json 2016-04-05 15:53:51 +02:00
7ecf342548 prepare for npmts-g 2016-04-05 15:13:52 +02:00
7f10392757 update dependencies and add caret to npmts dependency 2016-04-05 12:34:03 +02:00
9e229eee85 1.2.2 2016-04-05 01:07:24 +02:00
74c2c87f22 updated deps 2016-04-05 01:07:24 +02:00
0e0ee89263 1.2.1 2016-04-04 18:24:30 +02:00
a0e8f2f5e2 updated deps 2016-04-04 18:24:22 +02:00
043c5a0c6e 1.2.0 2016-03-03 01:50:17 +01:00
a1d5b4fc4e add isC9 to env 2016-03-03 01:50:13 +01:00
cd0b8f18af 1.1.0 2016-02-23 17:23:39 +01:00
d5387ddc05 1.0.10 2016-02-23 16:33:22 +01:00
3487b348df update deps 2016-02-23 16:31:50 +01:00
81036f8da3 1.0.9 2016-02-23 15:03:19 +01:00
b1464d97bf resolve dependency loop 2016-02-23 15:03:14 +01:00
5636cf330e 1.0.8 2016-02-23 14:36:20 +01:00
2e8b49fa18 update deps 2016-02-23 14:36:03 +01:00
df6036fbf1 1.0.7 2016-02-23 14:33:16 +01:00
8ec33947b6 update deps 2016-02-23 14:33:08 +01:00
50100115a6 1.0.6 2016-02-20 10:55:24 +01:00
8251e878c2 update deps 2016-02-20 10:55:19 +01:00
4a18d648c6 1.0.5 2016-02-20 10:50:38 +01:00
f9b89cc9db update object assignment 2016-02-20 10:50:32 +01:00
190aab3a11 1.0.4 2016-02-20 10:21:12 +01:00
cd26fffaf2 update travis 2016-02-20 10:21:09 +01:00
c2e48fa8b9 1.0.3 2016-02-20 10:11:32 +01:00
0db5ec169a add CI questions to Environment 2016-02-20 10:11:25 +01:00
0a29fafaeb update structure 2016-02-18 13:27:45 +01:00
0806fa9714 1.0.2 2016-02-18 13:16:21 +01:00
ef00c0d180 small structure update 2016-02-18 13:16:12 +01:00
b79c5fa293 1.0.1 2016-02-17 21:51:01 +01:00
ae8a09c294 cleanup 2016-02-17 21:50:48 +01:00
32a00aff01 added coveralls 2016-02-17 21:50:16 +01:00
77d96aaeff 1.0.0 2016-02-17 21:45:29 +01:00
beb65789dc 0.1.0 2016-02-17 21:45:23 +01:00
4a63b6a2c6 cleanup 2016-02-17 21:45:16 +01:00
340e971738 update to commonjs module structure 2016-02-17 21:44:40 +01:00
1d488c308e cleaned up 2015-12-26 01:11:46 +01:00
bfb9ebb994 0.0.15 2015-12-25 00:24:02 +01:00
84c25f3a67 cleaned up 2015-12-25 00:23:53 +01:00
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
45 changed files with 2411 additions and 2457 deletions

6
.gitignore vendored
View File

@ -1,10 +1,14 @@
node_modules/ node_modules/
.settings/ .settings/
.idea/ .idea/
coverage/
docs/
#npm devug #npm devug
npm-debug.log npm-debug.log
ts/*.js ts/*.js
ts/*.js.map ts/*.js.map
ts/typings/
test/browser/browserified/

71
.gitlab-ci.yml Normal file
View File

@ -0,0 +1,71 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
cache:
paths:
- .yarn/
key: "$CI_BUILD_STAGE"
stages:
- test
- release
- trigger
- pages
testLEGACY:
stage: test
script:
- npmci test legacy
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
allow_failure: true
testLTS:
stage: test
script:
- npmci test lts
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
testSTABLE:
stage: test
script:
- npmci test stable
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
release:
stage: release
script:
- npmci publish
only:
- tags
tags:
- docker
trigger:
stage: trigger
script:
- npmci trigger
only:
- tags
tags:
- docker
pages:
image: hosttoday/ht-docker-node:npmci
stage: pages
script:
- npmci command yarn global add npmpage
- npmci command npmpage --publish gitlab
tags:
- docker
only:
- tags
artifacts:
expire_in: 1 week
paths:
- public

6
.idea/vcs.xml generated
View File

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

4
.npmignore Normal file
View File

@ -0,0 +1,4 @@
node_modules/
coverage/
test/
ts/typings/

View File

@ -1,16 +0,0 @@
language: node_js
node_js:
- 4.2.2
before_install:
- npm install -g tsd
deploy:
provider: npm
email: npm@smart-coordination.com
api_key:
secure: uNjLbNelm8nj9R/tRlwRvcXWLS1QtA0QEbDKPDTWHNo68wAHgdwXIdzkVkNcihZYVasR/LqGuSLfzoD4H8mKmCXD+v85h048VmmtWniZQRp/OVWl0uzRwDDryhiYlhY5U9oOFEQsMO96C8qPqcGchq+DA7Gi3ZnAl7pmeb54xp9H+7jmLyZTyO8Hq00anV5PopBOW23mZEnWHznzYeg83BlWmLdbyfyZKT4W5Urg1BAMgxt9PdtrQoiPy4LP6AHXG88kvY3Iz8OBG+h/06bura8MPfeupGoktodN9krb+sRE/COybATWImMh9Z5gI5TWqUR7tp7XivpgolYY41gaN93oUQ9EOTdJ5kFku1dnPrNFqXO/97slVTMR6fMMgRXwzTz6BiKI1NsAZeW7oLUONw06APZ6VBhVY6Po3Rioun8OE9Q0wXm/BvnRqVHt3sew4MIgmEBwQSQE14gLJGGgNojzmcPstc0czQp+kzV5DpGiW3IWIWZ7MsBJOOJ13RHeb6koFdBR7JZj0QzzBcWD7juJVOS45MlP7hU/sKRDO/fN3nu8TNwHvJab6XYP5/gqlbh/3h2vb7bxyDXiKGi2Ds8hZOHoyWoCrU3sbH3eKKkKo+LFI3J7PbY11T6TkSAdszLsQzcvC2QlsGQRWVywYMm32R6BVfxF3AlLX5a8JsI=
on:
tags: true
repo: pushrocks/smartenv
notifications:
slack:
secure: f5Uss0z9RPl/QcA/DroB8loyE93aOYI6bqCkrsiUscmZtlv/TVQtT4dxqGA6uvcG6iTQDBi3Ul88dQxWkRm4IqbhY35/iMaV2dHW4FVYMAh8GQMbsfL2sALCcufxD9blw47awv3iFcwhV1EeyesscjgL0JIjduk96v/7G/6QIO2838M1lzlgtj+kRUkim8qkaEs1je3gRrhMUIjLuAdscMXyUKYFMjWo9ACSjVUl30R/ZNemb18itIja6i92GotreBgcfEMczvy58ovDC7xdJUsY8LjMI01DwY+WPRnI0tAhsuI8moBwwcdM4e3bAjKjucQRjO33O5bMWRZ6QCiYd0DnCEFyCPQLJ4GSy/tkD00n8ijLHAOSV3AH1zNbdK1EAdSPQXDvlI36KJn/2hyQLoitGHVUPr76ujJWP82ypO2tgIp3XQU0dJVCxDuHnwJO2+hjdI+gCPqxNTpjeujHx3UdkTGNRjuuf9dlZ/D08fApjYxy2fxItTqo3QjP/nrqvBXUOPP8yPHpjIT4H2t5Pr4SJjBGI6X4qhKyFj6s9rA/Xu1rL+45zu1C3uC3z+u3T9UwrbzJ/cZM6r6UQvQmUvIfBNaMlg4I/diQCDIPL+Rhop2nylY3IcHmJnk2itn7kOqj1tohCpFEml5pRuSZy4udWywkdtyBAsHWFLF7oiQ=

View File

@ -1,6 +1,6 @@
The MIT License (MIT) The MIT License (MIT)
Copyright (c) 2015 Push.Rocks Copyright (c) 2015 Lossless GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal of this software and associated documentation files (the "Software"), to deal

View File

@ -1,28 +1,29 @@
# smartenv # smartenv
store things about your environment and let them travel across modules store things about your environment and let them travel across modules
## Status ## Availabililty
[![Build Status](https://travis-ci.org/pushrocks/smartenv.svg?branch=release)](https://travis-ci.org/pushrocks/smartenv) [![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/smartenv)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/smartenv)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/smartenv)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/smartenv/)
## Status for master
[![build status](https://GitLab.com/pushrocks/smartenv/badges/master/build.svg)](https://GitLab.com/pushrocks/smartenv/commits/master)
[![coverage report](https://GitLab.com/pushrocks/smartenv/badges/master/coverage.svg)](https://GitLab.com/pushrocks/smartenv/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/smartenv.svg)](https://www.npmjs.com/package/smartenv)
[![Dependency Status](https://david-dm.org/pushrocks/smartenv.svg)](https://david-dm.org/pushrocks/smartenv) [![Dependency Status](https://david-dm.org/pushrocks/smartenv.svg)](https://david-dm.org/pushrocks/smartenv)
[![devDependency Status](https://david-dm.org/pushrocks/smartenv/dev-status.svg)](https://david-dm.org/pushrocks/smartenv#info=devDependencies)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartenv/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartenv/master/dependencies/npm) [![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartenv/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartenv/master/dependencies/npm)
[![bitHound Overalll Score](https://www.bithound.io/github/pushrocks/smartenv/badges/score.svg)](https://www.bithound.io/github/pushrocks/smartenv) [![bitHound Code](https://www.bithound.io/github/pushrocks/smartenv/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartenv)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
## Install [![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
Install the package through npm [![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
```
npm install smartenv
```
## Usage ## Usage
Use TypeScript for best in class instellisense.
```javascript For further information read the linked docs at the top of this README.
var smartenv = require("smartenv");
smartenv.info(); //prints an output about your current environment and registered objects > MIT licensed | **&copy;** [Lossless GmbH](https://lossless.gmbh)
smartenv.register({akey:"a text"},"somevalue"); // register a new object | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
smartenv.makeGlobal() // make smartenv available from gobal.smartenv
smartenv.get("somevalue").akey; // returns "a text" [![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
smartenv.items.somevalue.akey; // also returns "a text"
```

3
dist/index.d.ts vendored Normal file
View File

@ -0,0 +1,3 @@
import { getEnv, printEnv, getEnvVars } from './smartenv.export';
import { obs } from './smartenv.objectstorage';
export { getEnv, getEnvVars, printEnv, obs };

9
dist/index.js vendored Normal file
View File

@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const smartenv_export_1 = require("./smartenv.export");
exports.getEnv = smartenv_export_1.getEnv;
exports.printEnv = smartenv_export_1.printEnv;
exports.getEnvVars = smartenv_export_1.getEnvVars;
const smartenv_objectstorage_1 = require("./smartenv.objectstorage");
exports.obs = smartenv_objectstorage_1.obs;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBLHVEQUE4RDtBQUs1RCxpQkFMTSx3QkFBTSxDQUtOO0FBRU4sbUJBUGMsMEJBQVEsQ0FPZDtBQURSLHFCQU53Qiw0QkFBVSxDQU14QjtBQUxaLHFFQUE4QztBQU81QyxjQVBPLDRCQUFHLENBT1AifQ==

11
dist/smartenv.classes.environment.d.ts vendored Normal file
View File

@ -0,0 +1,11 @@
export declare class Environment {
runtimeEnv: string;
isBrowser: boolean;
userAgent: string;
isNode: boolean;
nodeVersion: string;
isCI: boolean;
isTravis: boolean;
isC9: boolean;
constructor();
}

18
dist/smartenv.classes.environment.js vendored Normal file
View File

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const helpers = require("./smartenv.envhelpers");
class Environment {
constructor() {
this.runtimeEnv = helpers.getEnvString();
this.isBrowser = helpers.isBrowser();
this.userAgent = helpers.getUserAgentString();
this.isNode = helpers.isNode();
this.nodeVersion = helpers.getNodeVersion();
this.isCI = helpers.isCI();
this.isTravis = helpers.isTravis();
this.isC9 = helpers.isC9();
}
;
}
exports.Environment = Environment;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuY2xhc3Nlcy5lbnZpcm9ubWVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmNsYXNzZXMuZW52aXJvbm1lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxpREFBaUQ7QUFFakQ7SUFTRTtRQUNFLElBQUksQ0FBQyxVQUFVLEdBQUcsT0FBTyxDQUFDLFlBQVksRUFBRSxDQUFBO1FBQ3hDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLFNBQVMsRUFBRSxDQUFBO1FBQ3BDLElBQUksQ0FBQyxTQUFTLEdBQUcsT0FBTyxDQUFDLGtCQUFrQixFQUFFLENBQUE7UUFDN0MsSUFBSSxDQUFDLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxFQUFFLENBQUE7UUFDOUIsSUFBSSxDQUFDLFdBQVcsR0FBRyxPQUFPLENBQUMsY0FBYyxFQUFFLENBQUE7UUFDM0MsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUE7UUFDMUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxPQUFPLENBQUMsUUFBUSxFQUFFLENBQUE7UUFDbEMsSUFBSSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUMsSUFBSSxFQUFFLENBQUE7SUFDNUIsQ0FBQztJQUFBLENBQUM7Q0FDSDtBQW5CRCxrQ0FtQkMifQ==

8
dist/smartenv.envhelpers.d.ts vendored Normal file
View File

@ -0,0 +1,8 @@
export declare let getEnvString: () => string;
export declare let getUserAgentString: () => string;
export declare let isNode: () => boolean;
export declare let getNodeVersion: () => string;
export declare let isBrowser: () => boolean;
export declare let isCI: () => boolean;
export declare let isC9: () => boolean;
export declare let isTravis: () => boolean;

54
dist/smartenv.envhelpers.js vendored Normal file
View File

@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnvString = function () {
if (typeof window !== 'undefined') {
return 'browser';
}
else if (typeof process !== 'undefined') {
return 'node';
}
};
exports.getUserAgentString = function () {
if (exports.isBrowser()) {
return navigator.userAgent;
}
else {
return undefined;
}
};
exports.isNode = function () {
return exports.getEnvString() === 'node';
};
exports.getNodeVersion = function () {
return process.version;
};
exports.isBrowser = function () {
return !exports.isNode();
};
exports.isCI = function () {
if (process.env.CI) {
return true;
}
else {
return false;
}
;
};
exports.isC9 = function () {
if (process.env.C9_HOSTNAME) {
return true;
}
else {
return false;
}
};
exports.isTravis = function () {
if (process.env.TRAVIS) {
return true;
}
else {
return false;
}
;
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZW52aGVscGVycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LmVudmhlbHBlcnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFDVyxRQUFBLFlBQVksR0FBRztJQUN4QixFQUFFLENBQUMsQ0FBQyxPQUFPLE1BQU0sS0FBSyxXQUFXLENBQUMsQ0FBQyxDQUFDO1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QSxJQUFJLEdBQUc7SUFDaEIsRUFBRSxDQUFDLENBQUMsT0FBTyxDQUFDLEdBQUcsQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQzVCLE1BQU0sQ0FBQyxJQUFJLENBQUE7SUFDYixDQUFDO0lBQUMsSUFBSSxDQUFDLENBQUM7UUFDTixNQUFNLENBQUMsS0FBSyxDQUFBO0lBQ2QsQ0FBQztBQUNILENBQUMsQ0FBQTtBQUVVLFFBQUEsUUFBUSxHQUFHO0lBQ3BCLEVBQUUsQ0FBQyxDQUFDLE9BQU8sQ0FBQyxHQUFHLENBQUMsTUFBTSxDQUFDLENBQUMsQ0FBQztRQUN2QixNQUFNLENBQUMsSUFBSSxDQUFBO0lBQ2IsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ04sTUFBTSxDQUFDLEtBQUssQ0FBQTtJQUNkLENBQUM7SUFBQSxDQUFDO0FBQ0osQ0FBQyxDQUFBIn0=

15
dist/smartenv.export.d.ts vendored Normal file
View File

@ -0,0 +1,15 @@
import * as classes from './smartenv.classes.environment';
/**
* returns the environment
* @returns {Environment}
*/
export declare let getEnv: () => classes.Environment;
/**
* prints the environment to console
*/
export declare let printEnv: () => void;
export interface IEnvObject {
name: string;
value: string;
}
export declare let getEnvVars: (regexArg: RegExp) => Promise<IEnvObject[]>;

53
dist/smartenv.export.js vendored Normal file
View File

@ -0,0 +1,53 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const classes = require("./smartenv.classes.environment");
const objectStorage = require("./smartenv.objectstorage");
let environment = null;
/**
* returns the environment
* @returns {Environment}
*/
exports.getEnv = function () {
if (!environment) {
environment = new classes.Environment();
}
;
return environment;
};
/**
* prints the environment to console
*/
exports.printEnv = function () {
if (this.getEnv().isNode) {
console.log('running on NODE');
let smartenvVersion = require('../package.json').version;
console.log('node version is ' + this.getEnv().nodeVersion + ' and smartenv version is ' + smartenvVersion);
}
else {
console.log('running on BROWSER');
console.log('browser is ' + this.getEnv().userAgent);
}
console.log('the smartenv registration store currently holds the following properties:');
console.log(Object.getOwnPropertyNames(objectStorage.obs.getAll()));
};
exports.getEnvVars = (regexArg) => __awaiter(this, void 0, void 0, function* () {
let resultArray = [];
for (let key in process.env) {
if (regexArg.test(key)) {
resultArray.push({
name: key,
value: process.env[key]
});
}
}
return resultArray;
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYuZXhwb3J0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvc21hcnRlbnYuZXhwb3J0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7QUFJQSwwREFBeUQ7QUFDekQsMERBQXlEO0FBR3pELElBQUksV0FBVyxHQUF3QixJQUFJLENBQUE7QUFFM0M7OztHQUdHO0FBQ1EsUUFBQSxNQUFNLEdBQUc7SUFDbEIsRUFBRSxDQUFDLENBQUMsQ0FBQyxXQUFXLENBQUMsQ0FBQyxDQUFDO1FBQ2pCLFdBQVcsR0FBRyxJQUFJLE9BQU8sQ0FBQyxXQUFXLEVBQUUsQ0FBQTtJQUN6QyxDQUFDO0lBQUEsQ0FBQztJQUNGLE1BQU0sQ0FBQyxXQUFXLENBQUE7QUFDcEIsQ0FBQyxDQUFBO0FBSUQ7O0dBRUc7QUFDUSxRQUFBLFFBQVEsR0FBRztJQUNwQixFQUFFLENBQUMsQ0FBQyxJQUFJLENBQUMsTUFBTSxFQUFFLENBQUMsTUFBTSxDQUFDLEN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SyxFQUFFLE9BQU8sQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDO2FBQ3hCLENBQUMsQ0FBQTtRQUNKLENBQUM7SUFDSCxDQUFDO0lBQ0QsTUFBTSxDQUFDLFdBQVcsQ0FBQTtBQUNwQixDQUFDLENBQUEsQ0FBQSJ9

5
dist/smartenv.objectstorage.d.ts vendored Normal file
View File

@ -0,0 +1,5 @@
export declare let obsItems: any;
/**
* Objectstorage allows easy sharing of objects within node
*/
export declare let obs: any;

47
dist/smartenv.objectstorage.js vendored Normal file
View File

@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const plugins = require("./smartenv.plugins");
exports.obsItems = {};
/**
* Objectstorage allows easy sharing of objects within node
*/
exports.obs = {
add: (keyNameArg, objectArg) => {
if (!keyNameArg) {
console.log('keyName is undefined');
return;
}
if (!objectArg) {
console.log('objectArg is undefined');
}
if (!(exports.obsItems[keyNameArg])) {
exports.obsItems[keyNameArg] = objectArg;
}
else {
console.log('object is already present, so add operation has failed.');
}
return exports.obsItems[keyNameArg];
},
replace: function (paramNameArg, objectArg) {
exports.obsItems[paramNameArg] = objectArg;
},
merge: function (paramNameArg, objectArg) {
if (!(typeof exports.obsItems[paramNameArg] === 'undefined')) {
exports.obsItems[paramNameArg] = plugins.lodash.assign(exports.obsItems[paramNameArg], objectArg);
}
else {
console.log('object is not present, so there is nothing to merge');
}
},
get: function (keyName) {
return exports.obsItems[keyName];
},
getAll: function () {
return exports.obsItems;
},
addComplete: function (itemsArg) {
exports.obsItems = plugins.lodash.assign(exports.obsItems, itemsArg);
return exports.obsItems;
}
};
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYub2JqZWN0c3RvcmFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52Lm9iamVjdHN0b3JhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5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UFXLENBQUMsQ0FBQyxDQUFDLENBQUM7WUFDdkQsZ0JBQVEsQ0FBRSxZQUFZLENBQUUsR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLE1BQU0sQ0FBQyxnQkFBUSxDQUFFLFlBQVksQ0FBRSxFQUFFLFNBQVMsQ0FBQyxDQUFBO1FBQ3ZGLENBQUM7UUFBQyxJQUFJLENBQUMsQ0FBQztZQUNOLE9BQU8sQ0FBQyxHQUFHLENBQUMscURBQXFELENBQUMsQ0FBQTtRQUNwRSxDQUFDO0lBQ0gsQ0FBQztJQUNELEdBQUcsRUFBRSxVQUFVLE9BQU87UUFDcEIsTUFBTSxDQUFDLGdCQUFRLENBQUUsT0FBTyxDQUFFLENBQUE7SUFDNUIsQ0FBQztJQUNELE1BQU0sRUFBRTtRQUNOLE1BQU0sQ0FBQyxnQkFBUSxDQUFBO0lBQ2pCLENBQUM7SUFDRCxXQUFXLEVBQUUsVUFBVSxRQUFRO1FBQzdCLGdCQUFRLEdBQUcsT0FBTyxDQUFDLE1BQU0sQ0FBQyxNQUFNLENBQUMsZ0JBQVEsRUFBRSxRQUFRLENBQUMsQ0FBQTtRQUNwRCxNQUFNLENBQUMsZ0JBQVEsQ0FBQTtJQUNqQixDQUFDO0NBQ0YsQ0FBQSJ9

4
dist/smartenv.plugins.d.ts vendored Normal file
View File

@ -0,0 +1,4 @@
import 'typings-global';
import * as smartq from 'smartq';
import * as lodash from 'lodash';
export { smartq, lodash };

8
dist/smartenv.plugins.js vendored Normal file
View File

@ -0,0 +1,8 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
require("typings-global");
const smartq = require("smartq");
exports.smartq = smartq;
const lodash = require("lodash");
exports.lodash = lodash;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRlbnYucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0ZW52LnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSwwQkFBdUI7QUFDdkIsaUNBQWdDO0FBSTVCLHdCQUFNO0FBSFYsaUNBQWdDO0FBSTVCLHdCQUFNIn0=

109
index.js
View File

@ -1,109 +0,0 @@
/// <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 {
this.isBrowser = true;
this.isNode = true;
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);
})();
}
;
return environment;
};
/**
* prints the environment to console
*/
var printEnv = function () {
if (this.getEnv().isNode) {
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
}
else {
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.getComplete()));
};
SmartenvEnvironment.init = function (objectArg) {
objectArg.getEnv = getEnv;
objectArg.printEnv = printEnv;
};
})(SmartenvEnvironment || (SmartenvEnvironment = {}));
/// <reference path="index.ts" />
var SmartenvObjectStorage;
(function (SmartenvObjectStorage) {
function init() {
var obs = {};
var obsItems = {};
obs.addItem = function (objectArg, paramName) {
if (paramName === void 0) { paramName = "undefined"; }
if (paramName == "undefined") {
plugins.beautylog.error("paramName is undefined");
return;
}
obsItems[paramName] = objectArg;
};
obs.getItem = function (keyName) {
return obsItems[keyName];
};
obs.getComplete = function () {
return obsItems;
};
obs.addComplete = function (itemsArg) {
obsItems = plugins._.assign(obsItems, itemsArg);
return obsItems;
};
return obs;
}
SmartenvObjectStorage.init = init;
})(SmartenvObjectStorage || (SmartenvObjectStorage = {}));
/// <reference path="typings/tsd.d.ts" />
/// <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
SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init();
module.exports = smartenv;

7
npmextra.json Normal file
View File

@ -0,0 +1,7 @@
{
"npmci": {
"globalNpmTools": [
"npmts"
]
}
}

4
npmts.json Normal file
View File

@ -0,0 +1,4 @@
{
"mode":"default",
"coverageTreshold":75
}

View File

@ -1,33 +1,33 @@
{ {
"name": "smartenv", "name": "smartenv",
"version": "0.0.9", "version": "2.0.6",
"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": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "(cd ts/compile && node compile.js) && (node test.js)", "test": "(npmts)",
"reinstall": "(rm -r node_modules && npm install)", "testbrowser": "(npm test) && (node testbrowser.js)"
"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)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
"url": "https://github.com/pushrocks/smartenv.git" "url": "https://gitlab.com/pushrocks/smartenv.git"
}, },
"keywords": [ "keywords": [
"environment" "environment"
], ],
"author": "Smart Coordination GmbH <office@push.rocks> (https://push.rocks)", "author": "Lossless GmbH <hello@lossless.support> (https://lossless.com)",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https://github.com/pushrocks/smartenv/issues" "url": "https://gitlab.com/pushrocks/smartenv/issues"
}, },
"homepage": "https://github.com/pushrocks/smartenv", "homepage": "https://gitlab.com/pushrocks/smartenv",
"dependencies": { "dependencies": {
"beautylog": "^1.0.4", "lodash": "^4.17.4",
"lodash": "^3.10.1" "smartq": "^1.1.1",
"typings-global": "^1.0.14"
}, },
"devDependencies": { "devDependencies": {
"gulp": "^3.9.0", "beautylog": "^6.1.5",
"gulp-typescript": "^2.9.2" "tapbundle": "^1.0.5"
} }
} }

14
test.js
View File

@ -1,14 +0,0 @@
/// <reference path="typings/tsd.d.ts" />
var smartenv = require("./index.js");
var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module");
smartenv.printEnv();
beautylog.info("Now testing the smartenv module");
smartenv.obs.addItem({ key1: "Peter" }, "docit");
smartenv.printEnv();
beautylog.log(smartenv.obs.getItem("docit").key1);
beautylog.log(smartenv.obs.getItem("docit").key1);
var key2 = "hello";
smartenv.obs.getItem("docit").key2 = key2;
beautylog.log(smartenv.obs.getItem("docit").key2);
beautylog.success("Success!");

38
test/test.ts Normal file
View File

@ -0,0 +1,38 @@
import * as smartenv from '../dist/index.js'
import * as beautylog from 'beautylog'
import { tap, expect } from 'tapbundle'
tap.test('should print env', async () => {
smartenv.printEnv()
}).catch(tap.threw)
// test smartenv.obs.add
tap.test('obs add something', async () => {
smartenv.obs.add('myTestObject', { key1: 'Peter' })
smartenv.obs.add('myTestObject', { key1: 'Klaus' }) // now trying to add a second
return expect(smartenv.obs.get('myTestObject').key1).to.equal('Peter')
})
// test smartenv.obs.replace
tap.test('', async () => {
smartenv.obs.replace('myTestObject', { key1: 'Klaus' })
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
})
tap.test('should merge things', async () => {
smartenv.obs.merge('myTestObject', { key2: 'Peter' })
expect(smartenv.obs.get('myTestObject').key1).to.equal('Klaus')
return expect(smartenv.obs.get('myTestObject').key2).to.equal('Peter')
})
tap.test('set via get', async () => {
smartenv.obs.get('myTestObject').key2 = 'hello'
return expect(smartenv.obs.get('myTestObject').key2).to.equal('hello')
})
tap.test('should get regex env array', async () => {
process.env.CUSTOM = 'some'
let resultArray = await smartenv.getEnvVars(/CUSTOM/)
return expect(resultArray).to.be.length(1)
})

View File

@ -1,28 +0,0 @@
// 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']);

View File

@ -1,2 +0,0 @@
# How to compile.
Make sure gulp and gulp-taypescript from npm are available. Then run the gulpfile in this directory.

View File

@ -1,13 +0,0 @@
/// <reference path="typings/tsd.d.ts" />
/// <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
SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init();
module.exports = smartenv;
//# sourceMappingURL=index.js.map

View File

@ -1 +0,0 @@
{"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,16 +1,10 @@
/// <reference path="typings/tsd.d.ts" /> import {getEnv, printEnv, getEnvVars} from './smartenv.export'
/// <reference path="smartenv.classes.ts" /> import { obs } from './smartenv.objectstorage'
/// <reference path="smartenv.environment.ts" />
/// <reference path="smartenv.objectstorage.ts" />
var plugins = { export {
beautylog: require("beautylog")("os"), getEnv,
_: require("lodash") getEnvVars,
printEnv,
obs
} }
var smartenv:any = {}; //create smartenv object
SmartenvEnvironment.init(smartenv);
smartenv.obs = SmartenvObjectStorage.init();
module.exports = smartenv;

View File

@ -0,0 +1,22 @@
import helpers = require('./smartenv.envhelpers')
export class Environment {
runtimeEnv: string
isBrowser: boolean
userAgent: string
isNode: boolean
nodeVersion: string
isCI: boolean
isTravis: boolean
isC9: boolean
constructor () {
this.runtimeEnv = helpers.getEnvString()
this.isBrowser = helpers.isBrowser()
this.userAgent = helpers.getUserAgentString()
this.isNode = helpers.isNode()
this.nodeVersion = helpers.getNodeVersion()
this.isCI = helpers.isCI()
this.isTravis = helpers.isTravis()
this.isC9 = helpers.isC9()
};
}

View File

@ -1,21 +0,0 @@
/// <reference path="index.ts" />
class Environment {
public runtimeEnv:string;
public userAgent:string;
public nodeVersion:string;
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";
}
};
}

52
ts/smartenv.envhelpers.ts Normal file
View File

@ -0,0 +1,52 @@
import * as plugins from './smartenv.plugins'
export let getEnvString = function (): string {
if (typeof window !== 'undefined') {
return 'browser'
} else if (typeof process !== 'undefined') {
return 'node'
}
}
export let getUserAgentString = function (): string {
if (isBrowser()) {
return navigator.userAgent
} else {
return undefined
}
}
export let isNode = function (): boolean {
return getEnvString() === 'node'
}
export let getNodeVersion = function (): string {
return process.version
}
export let isBrowser = function (): boolean {
return !isNode()
}
export let isCI = function () {
if (process.env.CI) {
return true
} else {
return false
};
}
export let isC9 = function () {
if (process.env.C9_HOSTNAME) {
return true
} else {
return false
}
}
export let isTravis = function () {
if (process.env.TRAVIS) {
return true
} else {
return false
};
}

View File

@ -1,49 +0,0 @@
/// <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);
})();
};
return environment;
};
/**
* prints the environment to console
*/
var printEnv = function() {
if (this.getEnv().isNode) {
var smartenvVersion = require("./package.json").version;
plugins.beautylog.log("node version is " + this.getEnv().nodeVersion + " and smartenv version is " + smartenvVersion);
} else {
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.getComplete()));
}
export var init = function(objectArg) {
objectArg.getEnv = getEnv;
objectArg.printEnv = printEnv;
}
}

56
ts/smartenv.export.ts Normal file
View File

@ -0,0 +1,56 @@
/**
* Deals with the environment the current JS script is running in.
*/
import * as plugins from './smartenv.plugins'
import * as classes from './smartenv.classes.environment'
import * as objectStorage from './smartenv.objectstorage'
let environment: classes.Environment = null
/**
* returns the environment
* @returns {Environment}
*/
export let getEnv = function () {
if (!environment) {
environment = new classes.Environment()
};
return environment
}
/**
* prints the environment to console
*/
export let printEnv = function () {
if (this.getEnv().isNode) {
console.log('running on NODE')
let smartenvVersion = require('../package.json').version
console.log('node version is ' + this.getEnv().nodeVersion + ' and smartenv version is ' + smartenvVersion)
} else {
console.log('running on BROWSER')
console.log('browser is ' + this.getEnv().userAgent)
}
console.log('the smartenv registration store currently holds the following properties:')
console.log(Object.getOwnPropertyNames(objectStorage.obs.getAll()))
}
export interface IEnvObject {
name: string
value: string
}
export let getEnvVars = async (regexArg: RegExp) => {
let resultArray: IEnvObject[] = []
for (let key in process.env) {
if (regexArg.test(key)) {
resultArray.push({
name: key,
value: process.env[key]
})
}
}
return resultArray
}

View File

@ -1,26 +1,44 @@
/// <reference path="index.ts" /> import plugins = require('./smartenv.plugins')
module SmartenvObjectStorage {
export function init() {
var obs:any = {};
var obsItems:any = {};
obs.addItem = function(objectArg,paramName = "undefined") {
if (paramName == "undefined"){
plugins.beautylog.error("paramName is undefined");
return;
}
obsItems[paramName] = objectArg;
};
obs.getItem = function(keyName) {
return obsItems[keyName];
};
obs.getComplete = function () {
return obsItems;
}
obs.addComplete = function(itemsArg) { export let obsItems: any = {}
obsItems = plugins._.assign(obsItems,itemsArg);
return obsItems; /**
}; * Objectstorage allows easy sharing of objects within node
return obs; */
export let obs: any = {
add: (keyNameArg, objectArg) => {
if (!keyNameArg) {
console.log('keyName is undefined')
return
} }
} if (!objectArg) {
console.log('objectArg is undefined')
}
if (!(obsItems[ keyNameArg ])) {
obsItems[ keyNameArg ] = objectArg
} else {
console.log('object is already present, so add operation has failed.')
}
return obsItems[ keyNameArg ]
},
replace: function (paramNameArg, objectArg) {
obsItems[ paramNameArg ] = objectArg
},
merge: function (paramNameArg, objectArg) {
if (!(typeof obsItems[ paramNameArg ] === 'undefined')) {
obsItems[ paramNameArg ] = plugins.lodash.assign(obsItems[ paramNameArg ], objectArg)
} else {
console.log('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.lodash.assign(obsItems, itemsArg)
return obsItems
}
}

8
ts/smartenv.plugins.ts Normal file
View File

@ -0,0 +1,8 @@
import 'typings-global'
import * as smartq from 'smartq'
import * as lodash from 'lodash'
export {
smartq,
lodash
}

View File

@ -1,15 +0,0 @@
/// <reference path="typings/tsd.d.ts" />
var smartenv = require("./index.js");
var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module");
smartenv.printEnv();
beautylog.info("Now testing the smartenv module");
smartenv.obs.addItem({ key1: "Peter" }, "docit");
smartenv.printEnv();
beautylog.log(smartenv.obs.getItem("docit").key1);
beautylog.log(smartenv.obs.getItem("docit").key1);
var key2 = "hello";
smartenv.obs.getItem("docit").key2 = key2;
beautylog.log(smartenv.obs.getItem("docit").key2);
beautylog.success("Success!");
//# sourceMappingURL=test.js.map

View File

@ -1 +0,0 @@
{"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"}

View File

@ -1,16 +0,0 @@
/// <reference path="typings/tsd.d.ts" />
var smartenv = require("./index.js");
var beautylog = require("beautylog")("os");
beautylog.info("Now testing the smartenv module");
smartenv.printEnv();
beautylog.info("Now testing the smartenv module");
smartenv.obs.addItem({key1:"Peter"},"docit");
smartenv.printEnv();
beautylog.log(smartenv.obs.getItem("docit").key1);
beautylog.log(smartenv.obs.getItem("docit").key1);
var key2 = "hello";
smartenv.obs.getItem("docit").key2 = key2;
beautylog.log(smartenv.obs.getItem("docit").key2);
beautylog.success("Success!");

View File

@ -1,12 +0,0 @@
{
"version": "v4",
"repo": "borisyankov/DefinitelyTyped",
"ref": "master",
"path": "typings",
"bundle": "typings/tsd.d.ts",
"installed": {
"node/node.d.ts": {
"commit": "efa0c1196d7280640e624ac1e7fa604502e7bd63"
}
}
}

File diff suppressed because it is too large Load Diff

1
ts/typings/tsd.d.ts vendored
View File

@ -1 +0,0 @@
/// <reference path="node/node.d.ts" />

3
tslint.json Normal file
View File

@ -0,0 +1,3 @@
{
"extends": "tslint-config-standard"
}

1820
yarn.lock Normal file

File diff suppressed because it is too large Load Diff