UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 780 B
import w from"./is-mobile";import y from"./is-webview";import{loadBlob as B}from"./loadBlob";import{loadImage as I}from"./loadImage";const f=w||y,l=f?8:512,d=f?100:0;async function b(e,o){const t=e.preferred?await o(e.preferred):null;return t||(e.fallback?o(e.fallback):null)}async function m(e,o,t,a){if(!e.size)return new Map;const c=Array.from(e.entries()),r=new Map;for(let n=0;n<c.length;n+=t){const p=c.slice(n,n+t),u=await Promise.all(p.map(async([i,s])=>[i,await b(s,o)]));for(const[i,s]of u)s&&r.set(i,s);a&&await new Promise(i=>setTimeout(i,a))}return r}export async function loadImagesInBatchesById(e,o=l,t=d){return m(e,I,o,t)}export async function loadBlobsInBatchesById(e,o=l,t=d){const a=new Map;return m(e,r=>{let n=a.get(r);return n||(n=B(r),a.set(r,n)),n},o,t)}