Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-preloader

Package Overview
Dependencies
Maintainers
1
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-preloader - npm Package Compare versions

Comparing version 4.3.0 to 4.4.0

2

lib/async-preloader.umd.js

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("fontfaceobserver-es")):"function"==typeof define&&define.amd?define(["exports","tslib","fontfaceobserver-es"],t):t(e.AsyncPreloader={},e.tslib,e.FontFaceObserver)}(this,function(e,s,r){"use strict";var o,t;(t=o||(o={})).Json="Json",t.ArrayBuffer="ArrayBuffer",t.Blob="Blob",t.FormData="FormData",t.Text="Text",t.Image="Image",t.Video="Video",t.Audio="Audio",t.Xml="Xml",t.Font="Font";var n=function(){function i(){var e=this;this.items=new Map,this.defaultBodyMethod="blob",this.defaultLoader=o.Text,this.loadItems=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,Promise.all(t.map(this.loadItem))];case 1:return[2,e.sent()]}})})},this.loadItem=function(r){return s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return t=i.getFileExtension(r.src),[4,this["load"+(r.loader||i.getLoaderKey(t))](r)];case 1:return n=e.sent(),this.items.set(r.id||r.src,n),[2,n]}})})},this.loadManifest=function(r,o){return void 0===o&&(o="items"),s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return[4,this.loadJson({src:r})];case 1:return t=e.sent(),n=i.getProp(t,o),[4,this.loadItems(n)];case 2:return[2,e.sent()]}})})},this.loadText=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().text()];case 2:return[2,e.sent()]}})})},this.loadJson=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},this.loadArrayBuffer=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().arrayBuffer()];case 2:return[2,e.sent()]}})})},this.loadBlob=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().blob()];case 2:return[2,e.sent()]}})})},this.loadFormData=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().formData()];case 2:return[2,e.sent()]}})})},this.loadImage=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:(o=new Image,[4,new Promise(function(t,n){o.addEventListener("load",function e(){o.removeEventListener("load",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)}),o.src=URL.createObjectURL(r)})]);case 3:return[2,e.sent()]}})})},this.loadVideo=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:(o=document.createElement("video"),[4,new Promise(function(t,n){o.addEventListener("canplaythrough",function e(){o.removeEventListener("canplaythrough",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)});try{o.srcObject=r}catch(e){o.src=URL.createObjectURL(r)}o.load()})]);case 3:return[2,e.sent()]}})})},this.loadAudio=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:((o=document.createElement("audio")).autoplay=!1,o.preload="auto",[4,new Promise(function(t,n){o.addEventListener("canplaythrough",function e(){o.removeEventListener("canplaythrough",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)});try{o.srcObject=r}catch(e){o.src=URL.createObjectURL(r)}o.load()})]);case 3:return[2,e.sent()]}})})},this.loadXml=function(r){return s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return r.mimeType||(t=i.getFileExtension(r.src),r=s.__assign({},r,{mimeType:i.getMimeType(o.Xml,t)})),[4,i.fetchItem(r)];case 1:return[4,e.sent().text()];case 2:return n=e.sent(),[2,i.domParser.parseFromString(n,r.mimeType)]}})})},this.loadFont=function(n){return s.__awaiter(e,void 0,void 0,function(){var t;return s.__generator(this,function(e){switch(e.label){case 0:return t=n.id,[4,new r(t,n.options||{}).load()];case 1:return e.sent(),[2,t]}})})}}return i.fetchItem=function(e){return fetch(e.src,e.options||{})},i.getProp=function(e,t){var n=Array.isArray(t)?t:t.split(".").filter(function(e){return e.length});return n.length?i.getProp(e[n.shift()],n):e},i.getFileExtension=function(e){return(e.match(/[^\\\/]\.([^.\\\/]+)$/)||[null]).pop()},i.getLoaderKey=function(t){var e=Array.from(i.loaders).find(function(e){return e[1].extensions.includes(t)});return e?e[0]:o.Text},i.getMimeType=function(e,t){var n=i.loaders.get(e);return n.mimeType[t]||n.defaultMimeType},i.loaders=(new Map).set(o.Text,{extensions:["txt"]}).set(o.Json,{extensions:["json"]}).set(o.Image,{extensions:["jpeg","jpg","gif","png","webp"]}).set(o.Video,{extensions:["webm","ogg","mp4"]}).set(o.Audio,{extensions:["webm","ogg","mp3","wav","flac"]}).set(o.Xml,{extensions:["xml","svg","html"],mimeType:{xml:"application/xml",svg:"image/svg+xml",html:"text/html"},defaultMimeType:"xml"}).set(o.Font,{extensions:["woff2","woff","ttf","otf","eot"]}),i.domParser=new DOMParser,i}(),i=new n;e.AsyncPreloader=n,e.default=i,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("tslib"),require("fontfaceobserver-es")):"function"==typeof define&&define.amd?define(["exports","tslib","fontfaceobserver-es"],t):t((e=e||self).AsyncPreloader={},e.tslib,e.FontFaceObserver)}(this,function(e,s,r){"use strict";var o,t;(t=o||(o={})).Json="Json",t.ArrayBuffer="ArrayBuffer",t.Blob="Blob",t.FormData="FormData",t.Text="Text",t.Image="Image",t.Video="Video",t.Audio="Audio",t.Xml="Xml",t.Font="Font";var n=function(){function i(){var e=this;this.items=new Map,this.defaultBodyMethod="blob",this.defaultLoader=o.Text,this.loadItems=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,Promise.all(t.map(this.loadItem))];case 1:return[2,e.sent()]}})})},this.loadItem=function(r){return s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return t=i.getFileExtension(r.src),[4,this["load"+(r.loader||i.getLoaderKey(t))](r)];case 1:return n=e.sent(),this.items.set(r.id||r.src,n),[2,n]}})})},this.loadManifest=function(r,o){return void 0===o&&(o="items"),s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return[4,this.loadJson({src:r})];case 1:return t=e.sent(),n=i.getProp(t,o),[4,this.loadItems(n)];case 2:return[2,e.sent()]}})})},this.loadText=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().text()];case 2:return[2,e.sent()]}})})},this.loadJson=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().json()];case 2:return[2,e.sent()]}})})},this.loadArrayBuffer=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().arrayBuffer()];case 2:return[2,e.sent()]}})})},this.loadBlob=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().blob()];case 2:return[2,e.sent()]}})})},this.loadFormData=function(t){return s.__awaiter(e,void 0,void 0,function(){return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent().formData()];case 2:return[2,e.sent()]}})})},this.loadImage=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:(o=new Image,[4,new Promise(function(t,n){o.addEventListener("load",function e(){o.removeEventListener("load",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)}),o.src=URL.createObjectURL(r)})]);case 3:return[2,e.sent()]}})})},this.loadVideo=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:(o=document.createElement("video"),[4,new Promise(function(t,n){o.addEventListener("canplaythrough",function e(){o.removeEventListener("canplaythrough",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)});try{o.srcObject=r}catch(e){o.src=URL.createObjectURL(r)}o.load()})]);case 3:return[2,e.sent()]}})})},this.loadAudio=function(t){return s.__awaiter(e,void 0,void 0,function(){var r,o;return s.__generator(this,function(e){switch(e.label){case 0:return[4,i.fetchItem(t)];case 1:return[4,e.sent()[t.body||this.defaultBodyMethod]()];case 2:return r=e.sent(),t.body?[2,r]:((o=document.createElement("audio")).autoplay=!1,o.preload="auto",[4,new Promise(function(t,n){o.addEventListener("canplaythrough",function e(){o.removeEventListener("canplaythrough",e),t(o)}),o.addEventListener("error",function e(){o.removeEventListener("error",e),n(o)});try{o.srcObject=r}catch(e){o.src=URL.createObjectURL(r)}o.load()})]);case 3:return[2,e.sent()]}})})},this.loadXml=function(r){return s.__awaiter(e,void 0,void 0,function(){var t,n;return s.__generator(this,function(e){switch(e.label){case 0:return r.mimeType||(t=i.getFileExtension(r.src),r=s.__assign({},r,{mimeType:i.getMimeType(o.Xml,t)})),[4,i.fetchItem(r)];case 1:return[4,e.sent().text()];case 2:return n=e.sent(),[2,i.domParser.parseFromString(n,r.mimeType)]}})})},this.loadFont=function(n){return s.__awaiter(e,void 0,void 0,function(){var t;return s.__generator(this,function(e){switch(e.label){case 0:return t=n.id,[4,new r(t,n.options||{}).load()];case 1:return e.sent(),[2,t]}})})}}return i.fetchItem=function(e){return fetch(e.src,e.options||{})},i.getProp=function(e,t){var n=Array.isArray(t)?t:t.split(".").filter(function(e){return e.length});return n.length?i.getProp(e[n.shift()],n):e},i.getFileExtension=function(e){return(e.match(/[^\\\/]\.([^.\\\/]+)$/)||[null]).pop()},i.getLoaderKey=function(t){var e=Array.from(i.loaders).find(function(e){return e[1].extensions.includes(t)});return e?e[0]:o.Text},i.getMimeType=function(e,t){var n=i.loaders.get(e);return n.mimeType[t]||n.defaultMimeType},i.loaders=(new Map).set(o.Text,{extensions:["txt"]}).set(o.Json,{extensions:["json"]}).set(o.Image,{extensions:["jpeg","jpg","gif","png","webp"]}).set(o.Video,{extensions:["webm","ogg","mp4"]}).set(o.Audio,{extensions:["webm","ogg","mp3","wav","flac"]}).set(o.Xml,{extensions:["xml","svg","html"],mimeType:{xml:"application/xml",svg:"image/svg+xml",html:"text/html"},defaultMimeType:"xml"}).set(o.Font,{extensions:["woff2","woff","ttf","otf","eot"]}),i.domParser=new DOMParser,i}(),i=new n;e.AsyncPreloader=n,e.default=i,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "async-preloader",
"version": "4.3.0",
"version": "4.4.0",
"description": "Assets preloader using ES2017 async/await and fetch.",

@@ -65,17 +65,17 @@ "main": "lib/async-preloader.cjs.js",

"devDependencies": {
"@types/jest": "^23.3.9",
"@types/node": "^10.12.5",
"@types/jest": "^23.3.13",
"@types/node": "^10.12.18",
"jest": "^23.6.0",
"jsdom": "^13.0.0",
"node-fetch": "^2.2.1",
"prettier": "^1.15.1",
"rollup": "^0.67.0",
"jsdom": "^13.1.0",
"node-fetch": "^2.3.0",
"prettier": "^1.15.3",
"rollup": "^1.1.1",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-typescript2": "^0.17.2",
"rollup-plugin-uglify": "^6.0.0",
"ts-jest": "^23.10.4",
"tslint": "^5.11.0",
"typedoc": "^0.13.0",
"typescript": "^3.1.6",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-typescript2": "^0.19.2",
"rollup-plugin-uglify": "^6.0.1",
"ts-jest": "^23.10.5",
"tslint": "^5.12.1",
"typedoc": "^0.14.2",
"typescript": "^3.2.4",
"xmldom": "^0.1.27"

@@ -82,0 +82,0 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc