a zip code crypto-currency system good for red ONLY

zone-patch-jsonp.js 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * @license
  3. * Copyright Google Inc. All Rights Reserved.
  4. *
  5. * Use of this source code is governed by an MIT-style license that can be
  6. * found in the LICENSE file at https://angular.io/license
  7. */
  8. (function (global, factory) {
  9. typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
  10. typeof define === 'function' && define.amd ? define(factory) :
  11. (factory());
  12. }(this, (function () { 'use strict';
  13. /**
  14. * @license
  15. * Copyright Google Inc. All Rights Reserved.
  16. *
  17. * Use of this source code is governed by an MIT-style license that can be
  18. * found in the LICENSE file at https://angular.io/license
  19. */
  20. Zone.__load_patch('jsonp', function (global, Zone, api) {
  21. Zone[Zone.__symbol__('jsonp')] = function patchJsonp(options) {
  22. if (!options || !options.jsonp || !options.sendFuncName) {
  23. return;
  24. }
  25. var noop = function () { };
  26. [options.successFuncName, options.failedFuncName].forEach(function (methodName) {
  27. if (!methodName) {
  28. return;
  29. }
  30. var oriFunc = global[methodName];
  31. if (oriFunc) {
  32. api.patchMethod(global, methodName, function (delegate) { return function (self, args) {
  33. var task = global[api.symbol('jsonTask')];
  34. if (task) {
  35. task.callback = delegate;
  36. return task.invoke.apply(self, args);
  37. }
  38. else {
  39. return delegate.apply(self, args);
  40. }
  41. }; });
  42. }
  43. else {
  44. Object.defineProperty(global, methodName, {
  45. configurable: true,
  46. enumerable: true,
  47. get: function () {
  48. return function () {
  49. var task = global[api.symbol('jsonpTask')];
  50. var delegate = global[api.symbol("jsonp" + methodName + "callback")];
  51. if (task) {
  52. if (delegate) {
  53. task.callback = delegate;
  54. }
  55. global[api.symbol('jsonpTask')] = undefined;
  56. return task.invoke.apply(this, arguments);
  57. }
  58. else {
  59. if (delegate) {
  60. return delegate.apply(this, arguments);
  61. }
  62. }
  63. return null;
  64. };
  65. },
  66. set: function (callback) {
  67. this[api.symbol("jsonp" + methodName + "callback")] = callback;
  68. }
  69. });
  70. }
  71. });
  72. api.patchMethod(options.jsonp, options.sendFuncName, function (delegate) { return function (self, args) {
  73. global[api.symbol('jsonpTask')] = Zone.current.scheduleMacroTask('jsonp', noop, {}, function (task) {
  74. return delegate.apply(self, args);
  75. }, noop);
  76. }; });
  77. };
  78. });
  79. })));