UNPKG

1.32 kBJavaScriptView Raw
1"use strict";
2var __rest = (this && this.__rest) || function (s, e) {
3 var t = {};
4 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5 t[p] = s[p];
6 if (s != null && typeof Object.getOwnPropertySymbols === "function")
7 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9 t[p[i]] = s[p[i]];
10 }
11 return t;
12};
13Object.defineProperty(exports, "__esModule", { value: true });
14exports.MaybeKey = void 0;
15const util_1 = require("@antv/util");
16const helper_1 = require("./utils/helper");
17/**
18 * Infer key for every element.
19 */
20const MaybeKey = () => {
21 return (I, mark) => {
22 const { encode } = mark;
23 const { key } = encode, rest = __rest(encode, ["key"]);
24 if (key !== undefined)
25 return [I, mark];
26 const values = Object.values(rest).map(({ value }) => value);
27 const K = I.map((i) => values
28 .filter(Array.isArray)
29 .map((V) => V[i])
30 .join('-'));
31 return [I, (0, util_1.deepMix)({}, mark, { encode: { key: (0, helper_1.column)(K) } })];
32 };
33};
34exports.MaybeKey = MaybeKey;
35exports.MaybeKey.props = {};
36//# sourceMappingURL=maybeKey.js.map
\No newline at end of file