@gatling.io/core
Version:
Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).
32 lines (31 loc) • 1.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEnvironmentVariable = exports.getOption = exports.getParameter = void 0;
const jvm_types_1 = require("@gatling.io/jvm-types");
/**
* Gets the parameter indicated by the specified name.
*
* Parameters can be specified in the `gatling run` command by passing arguments with the format `key=value`, e.g.
* `gatling run parameter1=foo parameter2=bar`. You would then retrieve them in your simulation by calling
* `getParameter("parameter1")` and `getParameter("parameter2")`.
*
* @param key - the key of the parameter.
* @param defaultValue - a default value
* @returns the string value of the parameter if it is defined, or else `defaultValue` if provided, or else `undefined`.
*/
const getParameter = (key, defaultValue) => getOrElse(jvm_types_1.System.getProperty(key), defaultValue);
exports.getParameter = getParameter;
/**
* @deprecated Use {@link getParameter} instead.
*/
exports.getOption = exports.getParameter;
/**
* Gets the environment variable indicated by the specified name.
*
* @param name - the name of the environment variable.
* @param defaultValue - a default value
* @returns the string value of the environment variable if it is defined, or else `defaultValue` if provided, or else `undefined`.
*/
const getEnvironmentVariable = (name, defaultValue) => getOrElse(jvm_types_1.System.getenv(name), defaultValue);
exports.getEnvironmentVariable = getEnvironmentVariable;
const getOrElse = (value, defaultValue) => typeof value === "string" ? value : defaultValue;