暫無描述

index.js 721B

123456789101112131415161718192021222324252627282930313233343536373839
  1. var deprecated = {
  2. method: function(msg, log, fn) {
  3. var called = false;
  4. return function(){
  5. if (!called) {
  6. called = true;
  7. log(msg);
  8. }
  9. return fn.apply(this, arguments);
  10. };
  11. },
  12. field: function(msg, log, parent, field, val) {
  13. var called = false;
  14. var getter = function(){
  15. if (!called) {
  16. called = true;
  17. log(msg);
  18. }
  19. return val;
  20. };
  21. var setter = function(v) {
  22. if (!called) {
  23. called = true;
  24. log(msg);
  25. }
  26. val = v;
  27. return v;
  28. };
  29. Object.defineProperty(parent, field, {
  30. get: getter,
  31. set: setter,
  32. enumerable: true
  33. });
  34. return;
  35. }
  36. };
  37. module.exports = deprecated;