@gatling.io/core
Version:
Gatling JS is a JavaScript/TypeScript interface for the [Gatling load testing tool](https://gatling.io/).
20 lines (19 loc) • 982 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GlobalStore = void 0;
const ConcurrentHashMap = Java.type("java.util.concurrent.ConcurrentHashMap");
const javaStore = new ConcurrentHashMap();
/**
* A global store which can be used to share data between different virtual users.
*/
exports.GlobalStore = {
put: (key, value) => nullToUndefined(javaStore.put(key, value)),
update: (key, updateFunction) => nullToUndefined(javaStore.compute(key, (_, oldValue) => undefinedToNull(updateFunction(nullToUndefined(oldValue))))),
get: (key) => nullToUndefined(javaStore.get(key)),
getOrDefault: (key, defaultValue) => javaStore.getOrDefault(key, defaultValue),
containsKey: (key) => javaStore.containsKey(key),
remove: (key) => nullToUndefined(javaStore.remove(key)),
clear: () => javaStore.clear()
};
const nullToUndefined = (x) => (x === null ? undefined : x);
const undefinedToNull = (x) => (x === undefined ? null : x);