UNPKG

@splitsoftware/splitio-commons

Version:
41 lines (40 loc) 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.checkIfServerSide = exports.keyParser = exports.getBucketing = exports.getMatching = void 0; var lang_1 = require("../lang"); // function isSplitKeyObject(key: any): key is SplitIO.SplitKeyObject { // return key !== undefined && key !== null && typeof key.matchingKey === 'string'; // } // returns the matchingKey if the Key is defined as an object or the key itself if it is a string function getMatching(key) { return (0, lang_1.isObject)(key) ? key.matchingKey : key; } exports.getMatching = getMatching; // if the key is a string, there's no bucketingKey (undefined) function getBucketing(key) { return (0, lang_1.isObject)(key) ? key.bucketingKey : undefined; } exports.getBucketing = getBucketing; /** * Verify type of key and return a valid object key used for get treatment for a * specific split. */ function keyParser(key) { if ((0, lang_1.isObject)(key)) { return { matchingKey: key.matchingKey, bucketingKey: key.bucketingKey }; } else { return { matchingKey: key, bucketingKey: key }; } } exports.keyParser = keyParser; function checkIfServerSide(settings) { return !settings.core.key; } exports.checkIfServerSide = checkIfServerSide;