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.

index.js 633B

1234567891011121314151617181920212223242526
  1. 'use strict';
  2. const lazy = (mod, fn, id) => mod === undefined ? fn(id) : mod;
  3. module.exports = fn => {
  4. return id => {
  5. let mod;
  6. const handler = {
  7. get: (target, property) => {
  8. mod = lazy(mod, fn, id);
  9. return Reflect.get(mod, property);
  10. },
  11. apply: (target, thisArg, argumentsList) => {
  12. mod = lazy(mod, fn, id);
  13. return Reflect.apply(mod, thisArg, argumentsList);
  14. },
  15. construct: (target, argumentsList) => {
  16. mod = lazy(mod, fn, id);
  17. return Reflect.construct(mod, argumentsList);
  18. }
  19. };
  20. // eslint-disable-next-line prefer-arrow-callback
  21. return new Proxy(function () {}, handler);
  22. };
  23. };