web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
816 B

  1. "use strict";
  2. var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.getQueriesForElement = getQueriesForElement;
  7. var defaultQueries = _interopRequireWildcard(require("./queries"));
  8. /**
  9. * @typedef {{[key: string]: Function}} FuncMap
  10. */
  11. /**
  12. * @param {HTMLElement} element container
  13. * @param {FuncMap} queries object of functions
  14. * @param {Object} initialValue for reducer
  15. * @returns {FuncMap} returns object of functions bound to container
  16. */
  17. function getQueriesForElement(element, queries = defaultQueries, initialValue = {}) {
  18. return Object.keys(queries).reduce((helpers, key) => {
  19. const fn = queries[key];
  20. helpers[key] = fn.bind(null, element);
  21. return helpers;
  22. }, initialValue);
  23. }