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

dependency-validator.js 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. module.exports = function init(global, console, messages) {
  2. var interface = {
  3. checkBlobApi: checkBlobApi,
  4. checkFileReaderApi: checkFileReaderApi,
  5. checkFormDataInstance: checkFormDataInstance,
  6. checkTextEncoderApi: checkTextEncoderApi,
  7. logWarnings: logWarnings,
  8. };
  9. return interface;
  10. function logWarnings() {
  11. if (!global.FormData) {
  12. console.warn(messages.MISSING_FORMDATA_API);
  13. } else if (!global.FormData.prototype || !global.FormData.prototype.entries) {
  14. console.warn(messages.MISSING_FORMDATA_ENTRIES_API);
  15. }
  16. }
  17. function checkBlobApi() {
  18. if (!global.Blob || !global.Blob.prototype) {
  19. throw new Error(messages.MISSING_BLOB_API);
  20. }
  21. }
  22. function checkFileReaderApi() {
  23. if (!global.FileReader || !global.FileReader.prototype) {
  24. throw new Error(messages.MISSING_FILE_READER_API);
  25. }
  26. }
  27. function checkFormDataInstance(instance) {
  28. if (!instance || !instance.entries) {
  29. throw new Error(messages.MISSING_FORMDATA_ENTRIES_API);
  30. }
  31. }
  32. function checkTextEncoderApi() {
  33. if (!global.TextEncoder || !global.TextEncoder.prototype) {
  34. throw new Error(messages.MISSING_TEXT_ENCODER_API);
  35. }
  36. }
  37. };