smartenv/dist/smartenv.classes.helpers.js
2016-04-04 18:24:22 +02:00

56 lines
4.2 KiB
JavaScript

/// <reference path="typings/main.d.ts" />
"use strict";
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0ZW52LmNsYXNzZXMuaGVscGVycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwwQ0FBMEM7O0FBRS9CLG9CQUFZLEdBQUc7SUFDdEIsRUFBRSxDQUFDLENBQUMsT0FBTyxNQUFNLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQztRQUNoQyxNQUFNLENBQUMsU0FBUyxDQUFDO0lBQ3JCLENBQUM7SUFBQyxJQUFJLENBQUMsRUFBRSxDQUFDLENBQUMsT0FBTyxPQUFPLEtBQUssV0FBVyxDQUFDLENBQUMsQ0FBQztRQUN4QyxNQUFNLENBQUMsTUFBTSxDQUFDO0lBQ2xCLENBQUM7QUFDTCxDQUFDLENBQUM7QUFFUywwQkFBa0IsR0FBRztJQUM1QixFQUFFLENBQUEsQ0FBQyxpQkFBUyxFQUFFLENBQUMsQ0FBQSxDQUFDO1FBQ1osTUFBTSxDQUFFLFNBQVMsQ0FBQyxTQUFTLENBQUM7SUFDaEMsQ0FBQztJQUFDLElBQUksQ0FBQyxDQUFDO1FBQ0osTUFBT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