UNPKG

@momentum-ui/react-collaboration

Version:

Cisco Momentum UI Framework for React Collaboration Applications

62 lines 2.3 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; /** * Combines every reaction with every skin tone * @param x reactions * @param y skin tones * @returns array containing an object with the cartesian between the two objects (x, y) */ export var cartesian = function (x, y) { return x.reduce(function (acc, xVal) { return acc.concat(__spreadArray([], y.map(function (yVal) { return ({ type: xVal, skinTone: yVal }); }), true)); }, []); }; /** * Generates object with all combinations between reactions and skin tones and applies a * mapping function to the key and value of the final object. * * Final object for mapping function that * just appends the skin tone to the reaction type will look like: * * ```js * { * "raise_hand_yellow": "raise_hand_yellow", * "raise_hand_light": "raise_hand_light", * "raise_hand_medium_light": "raise_hand_medium_light", * "raise_hand_medium": "raise_hand_medium", * "raise_hand_medium_dark": "raise_hand_dark", * ... * } * ``` * * @param grouping array with all the combinations between reactions and skin tones * @param mapping mapping function * @returns object with keys and value that represent valid reactions */ export var generateReactionsWithSkinTone = function (grouping, mapping) { return grouping.reduce(function (acc, _a) { var _b; var type = _a.type, skinTone = _a.skinTone; var key = mapping({ type: type, skinTone: skinTone }); return __assign(__assign({}, acc), (_b = {}, _b[key] = key, _b)); }, {}); }; //# sourceMappingURL=Reaction.util.js.map