utils.js 1.2 KB

123456789101112131415161718192021222324252627282930313233
  1. var __rest = (this && this.__rest) || function (s, e) {
  2. var t = {};
  3. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  4. t[p] = s[p];
  5. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  6. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
  7. if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
  8. t[p[i]] = s[p[i]];
  9. }
  10. return t;
  11. };
  12. import { deepMix } from '@antv/util';
  13. /**
  14. * Adaptor return default options for raw options.
  15. */
  16. export function useDefaultAdaptor(adaptor) {
  17. return (options, ...rest) => deepMix({}, adaptor(options, ...rest), options);
  18. }
  19. /**
  20. * Adaptor return options override raw options.
  21. */
  22. export function useOverrideAdaptor(adaptor) {
  23. return (options, ...rest) => deepMix({}, options, adaptor(options, ...rest));
  24. }
  25. export function mergeData(dataDescriptor, dataValue) {
  26. if (!dataDescriptor)
  27. return dataValue;
  28. if (Array.isArray(dataDescriptor))
  29. return dataDescriptor;
  30. const { value = dataValue } = dataDescriptor, rest = __rest(dataDescriptor, ["value"]);
  31. return Object.assign(Object.assign({}, rest), { value });
  32. }
  33. //# sourceMappingURL=utils.js.map