Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";
/** Define {@link Env} and associated helpers. */
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * The environment in which a piece of code runs.
 */
var Env;
(function (Env) {
    /** The local environment, on a developer's work machine. */
    Env[Env["Local"] = 0] = "Local";
    /** The continuous integration test server. */
    Env[Env["Test"] = 1] = "Test";
    /** The staging system is a small-scale copy of the {@link Env.Live} system, used for manual testing and exploration. */
    Env[Env["Staging"] = 2] = "Staging";
    /** The live system is the one which serves user traffic and with which people interact. */
    Env[Env["Live"] = 3] = "Live";
})(Env = exports.Env || (exports.Env = {}));
/**
 * Transform a string representation of an env into a {@link Env} value.
 * @param env - The string representation of the environment.
 * @returns A {@link Env} value corresponding to the string representation.
 * @throws If the string can't be transformed to a {@link Env} value, throws an {@link Error}.
 */
function parseEnv(env) {
    if (env === undefined)
        throw new Error('Environment is not defined');
    switch (env.toUpperCase()) {
        case 'LOCAL':
            return Env.Local;
        case 'TEST':
            return Env.Test;
        case 'STAGING':
            return Env.Staging;
        case 'LIVE':
            return Env.Live;
        default:
            throw new Error(`Invalid environment ${env}`);
    }
}
exports.parseEnv = parseEnv;
/**
 * @returns A string representation of env.
 */
function envToString(env) {
    switch (env) {
        case Env.Local:
            return 'LOCAL';
        case Env.Test:
            return 'TEST';
        case Env.Staging:
            return 'STAGING';
        case Env.Live:
            return 'LIVE';
    }
}
exports.envToString = envToString;
/**
 * Checks whether an environment is local or not.
 * @param env - The given environment.
 * @returns A boolean value, indicating whether this is the {@link Env.Local} environment or not.
 */
function isLocal(env) {
    return env == Env.Local;
}
exports.isLocal = isLocal;
/**
 * Checks whether an environment is for "development" or not.
 * @note Currently the only non-development environment is the {@link Env.Live} one. The idea is
 * that this method is used to check whether some testing or debugging code should be enabled.
 * @param env - The given environment.
 * @returns A boolean value, indicating whether this is such an environment or not.
 */
function isForDevelopment(env) {
    return env == Env.Local || env == Env.Test || env == Env.Staging;
}
exports.isForDevelopment = isForDevelopment;
/**
 * Checks whether an environment is "controlled" or not.
 * @param env - The given environment.
 * @returns A boolean value, indicating whether this is the {@link Env.Locale or {@link Env.Test} environment.
 */
function isNotOnServer(env) {
    return !isOnServer(env);
}
exports.isNotOnServer = isNotOnServer;
/**
 * Checks whether an environment is "server-side" or not.
 * @param env - The given environment.
 * @returns A boolean value, indicating whether this is the {@link Env.Staging} or {@link Env.Live} environments.
 */
function isOnServer(env) {
    return env == Env.Staging || env == Env.Live;
}
exports.isOnServer = isOnServer;
//# sourceMappingURL=env.js.map