UNPKG

@splitsoftware/splitio-commons

Version:
31 lines (30 loc) 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.clientCSDecorator = void 0; var objectAssign_1 = require("../utils/lang/objectAssign"); var clientAttributesDecoration_1 = require("./clientAttributesDecoration"); /** * Decorator that binds a key to client methods * * @param client - sync client instance * @param key - validated split key */ function clientCSDecorator(log, client, key) { var clientCS = (0, clientAttributesDecoration_1.clientAttributesDecoration)(log, client); return (0, objectAssign_1.objectAssign)(clientCS, { // In the client-side API, we bind a key to the client `getTreatment*` and `track` methods getTreatment: clientCS.getTreatment.bind(clientCS, key), getTreatmentWithConfig: clientCS.getTreatmentWithConfig.bind(clientCS, key), getTreatments: clientCS.getTreatments.bind(clientCS, key), getTreatmentsWithConfig: clientCS.getTreatmentsWithConfig.bind(clientCS, key), getTreatmentsByFlagSets: clientCS.getTreatmentsByFlagSets.bind(clientCS, key), getTreatmentsWithConfigByFlagSets: clientCS.getTreatmentsWithConfigByFlagSets.bind(clientCS, key), getTreatmentsByFlagSet: clientCS.getTreatmentsByFlagSet.bind(clientCS, key), getTreatmentsWithConfigByFlagSet: clientCS.getTreatmentsWithConfigByFlagSet.bind(clientCS, key), track: clientCS.track.bind(clientCS, key), // Not part of the public API. These properties are used to support other modules (e.g., Split Suite) isClientSide: true, key: key }); } exports.clientCSDecorator = clientCSDecorator;