Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

ponyfills.js 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. cordova.define("cordova-plugin-advanced-http.ponyfills", function(require, exports, module) {
  2. module.exports = function init(global) {
  3. var interface = { FormData: FormData };
  4. // expose all constructor functions for testing purposes
  5. if (init.debug) {
  6. interface.Iterator = Iterator;
  7. }
  8. function FormData() {
  9. this.__items = [];
  10. }
  11. FormData.prototype.append = function(name, value, filename) {
  12. if (global.File && value instanceof global.File) {
  13. // nothing to do
  14. } else if (global.Blob && value instanceof global.Blob) {
  15. // mimic File instance by adding missing properties
  16. value.lastModifiedDate = new Date();
  17. value.name = filename !== undefined ? filename : 'blob';
  18. } else {
  19. value = String(value);
  20. }
  21. this.__items.push([ name, value ]);
  22. };
  23. FormData.prototype.entries = function() {
  24. return new Iterator(this.__items);
  25. };
  26. function Iterator(items) {
  27. this.__items = items;
  28. this.__position = -1;
  29. }
  30. Iterator.prototype.next = function() {
  31. this.__position += 1;
  32. if (this.__position < this.__items.length) {
  33. return { done: false, value: this.__items[this.__position] };
  34. }
  35. return { done: true, value: undefined };
  36. }
  37. return interface;
  38. };
  39. });