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

@loaders.gl/core

Package Overview
Dependencies
Maintainers
9
Versions
337
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/core - npm Package Compare versions

Comparing version 1.3.3 to 2.0.0-alpha.1

dist/es5/lib/load-in-batches.js

2

dist/dist.min.js

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

!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var n=r();for(var t in n)("object"==typeof exports?exports:e)[t]=n[t]}}(window,function(){return function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=5)}([function(e,r,n){"use strict";(function(e,t){n.d(r,"c",function(){return o}),n.d(r,"e",function(){return s}),n.d(r,"f",function(){return u}),n.d(r,"b",function(){return c}),n.d(r,"a",function(){return a}),n.d(r,"d",function(){return l});const o="object"!=typeof e||"[object process]"!==String(e)||e.browser,i={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document},s=i.self||i.window||i.global,u=i.window||i.self||i.global,c=i.global||i.self||i.window,a=i.document||{},f=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/),l=f&&parseFloat(f[1])||0}).call(this,n(6),n(4))},function(e,r){},function(e,r){},function(e,r){},function(e,r){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,r,n){(function(r){const t=n(7),o="undefined"==typeof window?r:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,t)}).call(this,n(4))},function(e,r){var n,t,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(r){try{return n.call(null,e,0)}catch(r){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{t="function"==typeof clearTimeout?clearTimeout:s}catch(e){t=s}}();var c,a=[],f=!1,l=-1;function d(){f&&c&&(f=!1,c.length?a=c.concat(a):l=-1,a.length&&y())}function y(){if(!f){var e=u(d);f=!0;for(var r=a.length;r;){for(c=a,a=[];++l<r;)c&&c[l].run();l=-1,r=a.length}c=null,f=!1,function(e){if(t===clearTimeout)return clearTimeout(e);if((t===s||!t)&&clearTimeout)return t=clearTimeout,clearTimeout(e);try{t(e)}catch(r){try{return t.call(null,e)}catch(r){return t.call(this,e)}}}(e)}}function h(e,r){this.fun=e,this.array=r}function p(){}o.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)r[n-1]=arguments[n];a.push(new h(e,r)),1!==a.length||f||u(y)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=p,o.addListener=p,o.once=p,o.off=p,o.removeListener=p,o.removeAllListeners=p,o.emit=p,o.prependListener=p,o.prependOnceListener=p,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,r,n){"use strict";n.r(r);var t={};function o(e,r){if(!e)throw new Error(r||"loader assertion failed.")}function i(e){if(!e)return!1;return Array.isArray(e)&&(e=e[0]),e.parseTextSync||e.parseSync||e.parse||e.loadAndParse||e.parseStream||e.parseInBatches||e.worker}function s(e){let r;return o(i(e)),Array.isArray(e)&&(r=e[1],e=e[0],e={...e,options:{...e.options,...r}}),e.extension&&(e.extensions=e.extensions||e.extension,delete e.extension),Array.isArray(e.extensions)||(e.extensions=[e.extensions]),o(e.extensions&&e.extensions.length>0&&e.extensions[0]),e.parseTextSync&&(e.text=!0),e.text||(e.binary=!0),e}n.r(t),n.d(t,"dirname",function(){return ce});class u{log(){}info(){}warn(){}error(){}}function c(e,r){return null===(e=Object.assign({},r&&r.DEFAULT_OPTIONS,r&&r.defaultOptions,r&&r.options,e,{dataType:"arraybuffer"})).log&&(e.log=new u),"log"in e||(e.log=console),e}const a=e=>"boolean"==typeof e,f=e=>"function"==typeof e,l=e=>null!==e&&"object"==typeof e,d=e=>l(e)&&f(e.then),y=e=>e&&"function"==typeof e[Symbol.iterator],h=e=>e&&"function"==typeof e[Symbol.asyncIterator],p=e=>e&&f(e.next),w=e=>"undefined"!=typeof Response&&e instanceof Response||e.arrayBuffer&&e.text&&e.json,b=e=>(e=>"undefined"!=typeof File&&e instanceof File)(e)||(e=>"undefined"!=typeof Blob&&e instanceof Blob)(e),g=e=>(e=>l(e)&&f(e.tee)&&f(e.cancel)&&f(e.pipeTo)&&f(e.getReader))(e)||(e=>l(e)&&f(e.read)&&f(e.pipe)&&a(e.readable))(e),m=e=>(e=>l(e)&&f(e.abort)&&f(e.getWriter))(e)||(e=>l(e)&&f(e.end)&&f(e.write)&&a(e.writable))(e);var x=n(0);function A(e){if(x.c||x.d>=10){if("function"==typeof e[Symbol.asyncIterator])return e;if("function"==typeof e.getIterator)return e.getIterator()}return x.c?async function*(e){const r=e.getReader();try{for(;;){const{done:e,value:n}=await r.read();if(e)return;yield n}}catch(e){r.releaseLock()}}(e):async function*(e){e=await e;for(;;){const r=e.read();if(null===r){if(e._readableState.ended)return;await S(e)}else yield r}}(e)}async function S(e){return new Promise(r=>{e.once("readable",r)})}class v{constructor(e){this._fileOrBlob=e,this.bodyUsed=!1}get headers(){return new Headers({"Content-Length":this._fileOrBlob.size,"Content-Type":this._fileOrBlob.type})}get ok(){return!0}get status(){return 200}url(){return this._fileOrBlob.name||""}async arrayBuffer(){const{reader:e,promise:r}=this._getFileReader();return e.readAsArrayBuffer(this._fileOrBlob),r}async text(){const{reader:e,promise:r}=this._getFileReader();return e.readAsText(this._fileOrBlob),r}async json(){const e=await this.text();return JSON.parse(e)}_getFileReader(){let e;o(!this.bodyUsed),this.bodyUsed=!0;const r=new Promise((r,n)=>{try{(e=new FileReader).onerror=e=>n(new Error(e)),e.onabort=()=>n(new Error("Read aborted.")),e.onload=()=>r(e.result)}catch(e){n(e)}});return{reader:e,promise:r}}}function T(e,r){return Promise.resolve(new v(e,r))}const B="Cannot convert supplied data type";function k(e,r){if(r.text&&"string"==typeof e)return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){const n=e.buffer||e;if(r.text&&!r.binary){return new TextDecoder("utf8").decode(n)}return n}throw new Error(B)}async function j(e,r){const n=(e=await e)instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||n)return k(e,r);if(b(e)&&(e=await T(e)),w(e))return await async function(e){if(!e.ok){let r=`fetch failed ${e.status} `;try{r+=await e.text()}catch(e){}throw new Error(r)}}(e),r.binary?await e.arrayBuffer():await e.text();throw new Error(B)}function _(e){return p(e)?e:w(e)&&e.body?(function(e){if(!e.ok)throw new Error(`fetch failed ${e.status}`)}(e),A(e.body)):g(e)?A(e):h(e)?e[Symbol.asyncIterator]():P(e)}function P(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return function*(){yield e.buffer||e}();if(p(e))return e;if(y(e))return e[Symbol.iterator]();throw new Error(B)}function F(e,r){return{fetch:"undefined"!=typeof window&&window.fetch,...e}}var I=n(3);function E(e){if(I.toArrayBuffer&&(e=Object(I.toArrayBuffer)(e)),e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const r=e;return(new TextEncoder).encode(r).buffer}return o(!1)}function O(e,r=!0,n=[]){if(e){if(e instanceof ArrayBuffer)n.push(e);else if(e.buffer&&e.buffer instanceof ArrayBuffer)n.push(e.buffer);else if(r&&"object"==typeof e)for(const t in e)O(e[t],r,n)}else;return n}const D=new Map;let C=0;function L({data:e,resolve:r}){r(e)}class M{constructor({source:e,name:r=`web-worker-${C++}`,onMessage:n}){const t=function(e){if(o("string"==typeof e,"worker source"),e.startsWith("url(")&&e.endsWith(")"))return e.match(/^url\((.*)\)$/)[1];let r=D.get(e);if(!r){const n=new Blob([e],{type:"application/javascript"});r=URL.createObjectURL(n),D.set(e,r)}return r}(e);this.worker=new Worker(t,{name:r}),this.name=r,this.onMessage=n||L}async process(e){return new Promise((r,n)=>{this.worker.onmessage=e=>this.onMessage({worker:this.worker,data:e.data,resolve:r,reject:n}),this.worker.onerror=e=>n(e);const t=O(e);this.worker.postMessage(e,t)})}destroy(){this.worker.terminate(),this.worker=null}}class R{constructor({source:e,name:r="unnamed",maxConcurrency:n=1,onMessage:t,onDebug:o=(()=>{})}){this.source=e,this.name=r,this.maxConcurrency=n,this.onMessage=t,this.onDebug=o,this.jobQueue=[],this.idleQueue=[],this.count=0,this.isDestroyed=!1}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}async process(e,r){return new Promise((n,t)=>{this.jobQueue.push({data:e,jobName:r,resolve:n,reject:t}),this._startQueuedJob()})}_startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const r=this.jobQueue.shift();this.onDebug({message:"processing",worker:e.name,job:r.jobName,backlog:this.jobQueue.length}),e.process(r.data).then(e=>r.resolve(e)).catch(e=>r.reject(e)).then(()=>this._onWorkerDone(e))}_onWorkerDone(e){this.isDestroyed?e.destroy():(this.idleQueue.push(e),this._startQueuedJob())}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift();if(this.count<this.maxConcurrency){this.count++;const e=`${this.name.toLowerCase()}-worker-${this.count}-of-${this.maxConcurrency}`;return new M({source:this.source,onMessage:this.onMessage,name:e})}return null}}const W=5;class ${constructor({maxConcurrency:e=W,onMessage:r,onDebug:n=(()=>{})}){this.maxConcurrency=e,this.onMessage=r,this.onDebug=n,this.workerPools=new Map}setProps(e){"maxConcurrency"in e&&(this.maxConcurrency=e.maxConcurrency),"onDebug"in e&&(this.onDebug=e.onDebug)}destroy(){this.workerPools.forEach(e=>e.destroy())}async process(e,r,n){return this._getWorkerPool(e,r).process(n)}_getWorkerPool(e,r){let n=this.workerPools.get(r);return n||(n=new R({source:e,name:r,onMessage:this.onMessage,maxConcurrency:this.maxConcurrency,onDebug:this.onDebug}),this.workerPools.set(r,n)),n}}let Q=null;async function U({worker:e,data:r,resolve:n,reject:t}){switch(r.type){case"done":n(r.result);break;case"process":try{const n=await X(r.arraybuffer,r.options,r.url);e.postMessage({type:"process-done",id:r.id,result:n},O(n))}catch(n){e.postMessage({type:"process-error",id:r.id,message:n.message})}break;case"error":t(r.message)}}function N(e,r,n,t={},o={}){const i=function(e={}){const r={};return e.maxConcurrency&&(r.maxConcurrency=e.maxConcurrency),e.onDebug&&(r.onDebug=e.onDebug),Q||(Q=new $({onMessage:U})),Q.setProps(r),Q}(t);return t=JSON.parse(JSON.stringify(t)),i.process(e,`loaders.gl-${r}`,{arraybuffer:E(n),options:t,source:"loaders.gl",type:"process"})}let J=[];function V(e){e=Array.isArray(e)?e:[e];for(const r of e){const e=s(r);J.find(r=>e===r)||J.unshift(e)}}function q(){J=[]}const z=/[^.]+$/;function H(e,r="",n=null,{nothrow:t=!1}={}){if(r=r||"",e&&!Array.isArray(e)){const r=e;return s(r),r}(function(e){for(const r of e)s(r)})(e=e||J),r=r.replace(/\?.*/,"");let o=null;if(!(o=(o=o||function(e,r){const n=r.match(z),t=n&&n[0];return t&&function(e,r){r=r.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===r)return n;return null}(e,t)}(e,r))||function(e,r){if(!r)return null;for(const n of e)if("string"==typeof r){if(G(r,n))return n}else if(ArrayBuffer.isView(r)){if(K(r.buffer,r.byteOffset,n))return n}else if(r instanceof ArrayBuffer){if(K(r,0,n))return n}return null}(e,n))){if(t)return null;throw new Error(`No valid loader found for ${r}`)}return o}function G(e,r){return r.testText&&r.testText(e)}function K(e,r,n){switch(Array.isArray(n.test)?"array":typeof n.test){case"function":return n.test(e,n);case"string":case"array":return(Array.isArray(n.test)?n.test:[n.test]).some(n=>{return n===function(e,r,n){if(e.byteLength<=r+n)return"";const t=new DataView(e);let o="";for(let e=0;e<n;e++)o+=String.fromCharCode(t.getUint8(r+e));return o}(e,r,n.length)});default:return!1}}async function X(e,r,n,t){!r||Array.isArray(r)||i(r)||(t=n,n=r,r=null),n=n||{};const s=function(e,r){return w(e)?r=r||e.url:b(r)&&(r=r.name),"string"==typeof r?r.replace(/\?.*/,""):r}(e,t),u=H(r,s,e);n=c(n,u);const a=F({url:s,parse:X});return await async function(e,r,n,t){if(r=await j(r,e),e.parseTextSync&&"string"==typeof r)return n.dataType="text",e.parseTextSync(r,n,t,e);if(e.parse)return await e.parse(r,n,t,e);if(e.parseSync)return e.parseSync(r,n,t,e);if(e.worker)return await N(e.worker,e.name,r,n,t);return o(!1)}(u,e,n,a)}function Y(e,r,n,t){Array.isArray(r)||i(r)||(t=n,n=r,r=null);const o=H(r,t,e);return o?function(e,r,n,t){if(r=k(r,e),e.parseTextSync&&"string"==typeof r)return e.parseTextSync(r,n,t,e);if(e.parseSync)return e.parseSync(r,n,t,e);throw new Error(`Could not parse ${t.url||"data"} using ${e.name} loader`)}(o,e,n=c(n,o),F({url:t,parseSync:Y})):null}let Z="";const ee={};function re(e){Z=e}function ne(){return Z}function te(e){for(const r in ee)if(e.startsWith(r)){const n=ee[r];return e.replace(r,n)}return e+=Z}async function oe(e,r){return b(e)?T(e,r):(e=te(e),fetch(e,r))}async function ie(e,r,n,t){Array.isArray(r)||i(r)||(t=n,n=r,r=null);const o=H(r,t,null);return function(e,r,n,t){if(e.parseInBatches){const o=_(r);return e.parseInBatches(o,n,t,e)}throw new Error("parseWithLoaderInBatchesSync not available")}(o,e,n=c(n,o),F({url:t}))}async function se(e,r,n){return ie(await oe(e,n),r,n,e)}async function ue(e,r,n){Array.isArray(r)||i(r)||(n=r,r=null);const t=H(r,b(e)?e.name:e,null,{nothrow:!0});if(t&&t.loadAndParse){const r=c(n,t);return await t.loadAndParse(e,r)}let o=e;return(b(o)||"string"==typeof o)&&(o=await oe(e,n)),X(o,r,n,e)}function ce(e){const r=e&&e.lastIndexOf("/");return r>=0?e.substr(0,r):""}var ae=n(2);const fe={dataType:"arraybuffer",nothrow:!0},le=e=>e.startsWith("data:");function de(e,r){return r=function(e={}){return(e=Object.assign({},fe,e)).responseType=e.responseType||e.dataType,e}(r),le(e),r.nothrow||o(!1),null}function ye(e,r={}){return e=te(e),!x.c&&ae.readFileSync?ae.readFileSync(e,r):de(e,r)}var he=n(1);function pe(e,r,n){return e=te(e),!x.c&&he.writeFile?he.writeFile(e,r,n):o(!1)}function we(e,r,n){return e=te(e),!x.c&&he.writeFileSync?he.writeFileSync(e,r,n):o(!1)}function be(e){return`Failed to fetch resource ${e.url}(${e.status}): ${e.statusText} `}async function ge(e){let r=`Failed to fetch resource ${e.url} (${e.status}): `;try{e.headers.get("Content-Type").includes("application/json")?r+=await e.text():r+=e.statusText}catch(e){return r}return r}async function me(e,r,n,t){Array.isArray(r)||i(r)||(t=n,n=r,r=null);const o=H(r,t,null);return function(e,r,n,t){if(e.parseInBatchesSync){const o=P(r);return e.parseInBatchesSync(o,n,t,e)}throw new Error("parseWithLoaderInBatchesSync not available")}(o,e,n=c(n,o),F({url:t}))}function xe(e,r,n,t){if(r.encode)return r.encode(e,n);if(r.encodeSync)return Promise.resolve(r.encodeSync(e,n));throw new Error("Writer could not encode data")}function Ae(e,r,n,t){if(r.encodeSync)return r.encodeSync(e,n);throw new Error("Writer could not synchronously encode data")}function Se(e,r,n,t){if(r.encodeInBatches)return r.encodeInBatches(e,n);throw new Error("Writer could not encode data in batches")}function ve(e,r,n,t){return pe(r,xe(e,n,t))}function Te(e,r,n,t){return we(r,Ae(e,n,t))}function Be(e,r){const n=e instanceof ArrayBuffer?new Uint8Array(e):e,t=r instanceof ArrayBuffer?new Uint8Array(r):r,o=new Uint8Array(n.byteLength+t.byteLength);return o.set(n,0),o.set(t,n.byteLength),o}async function ke(e,r){for(;;){const{done:n,value:t}=await e.next();if(n)return void e.return();if(r(t))return}}async function je(e){let r=new ArrayBuffer,n="";for await(const t of e)"string"==typeof t?n+=t:r=Be(r,t);return n||r}async function*_e(e,r){const n=new TextDecoder(r);for await(const r of e)yield"string"==typeof r?r:n.decode(r,{stream:!0})}async function*Pe(e){let r="";for await(const n of e){let e;for(r+=n;(e=r.indexOf("\n"))>=0;){const n=r.slice(0,e+1);r=r.slice(e+1),yield n}}r.length>0&&(yield r)}async function*Fe(e){let r=1;for await(const n of e)yield{counter:r,line:n},r++}async function Ie(e,r,n=(()=>{}),t=(()=>{})){if(!(e=await e).ok)return e;if(!e.body)return e;const o=e.headers.get("content-length"),i=o&&parseInt(o,10);if(!(o>0))return e;if("undefined"==typeof ReadableStream)return e;const s=new ReadableStream({start(o){!async function e(r,n,t,o,i,s,u){try{const{done:c,value:a}=await n.read();if(c)return s(),void r.close();t+=a.byteLength;const f=Math.round(t/o*100);i(f,{loadedBytes:t,totalBytes:o}),r.enqueue(a),await e(r,n,t,o,i,s,u)}catch(e){r.error(e),u(e)}}(o,e.body.getReader(),0,i,r,n,t)}});return new Response(s)}n.d(r,"TextEncoder",function(){return Ee}),n.d(r,"TextDecoder",function(){return Oe}),n.d(r,"createReadStream",function(){return De}),n.d(r,"parseFile",function(){return Ce}),n.d(r,"parseFileSync",function(){return Le}),n.d(r,"loadFile",function(){return Me}),n.d(r,"path",function(){return t}),n.d(r,"setPathPrefix",function(){return re}),n.d(r,"getPathPrefix",function(){return ne}),n.d(r,"resolvePath",function(){return te}),n.d(r,"fetchFile",function(){return oe}),n.d(r,"readFileSync",function(){return ye}),n.d(r,"writeFile",function(){return pe}),n.d(r,"writeFileSync",function(){return we}),n.d(r,"_getErrorMessageFromResponseSync",function(){return be}),n.d(r,"_getErrorMessageFromResponse",function(){return ge}),n.d(r,"registerLoaders",function(){return V}),n.d(r,"parse",function(){return X}),n.d(r,"parseSync",function(){return Y}),n.d(r,"parseInBatches",function(){return ie}),n.d(r,"parseInBatchesSync",function(){return me}),n.d(r,"load",function(){return ue}),n.d(r,"loadInBatches",function(){return se}),n.d(r,"encode",function(){return xe}),n.d(r,"encodeSync",function(){return Ae}),n.d(r,"encodeInBatches",function(){return Se}),n.d(r,"save",function(){return ve}),n.d(r,"saveSync",function(){return Te}),n.d(r,"isPromise",function(){return d}),n.d(r,"isIterable",function(){return y}),n.d(r,"isAsyncIterable",function(){return h}),n.d(r,"isIterator",function(){return p}),n.d(r,"isFetchResponse",function(){return w}),n.d(r,"isReadableStream",function(){return g}),n.d(r,"isWritableStream",function(){return m}),n.d(r,"toArrayBuffer",function(){return E}),n.d(r,"getStreamIterator",function(){return A}),n.d(r,"forEach",function(){return ke}),n.d(r,"concatenateAsyncIterator",function(){return je}),n.d(r,"lineAsyncIterator",function(){return Pe}),n.d(r,"textDecoderAsyncIterator",function(){return _e}),n.d(r,"numberedLineAsyncIterator",function(){return Fe}),n.d(r,"isBrowser",function(){return x.c}),n.d(r,"self",function(){return x.e}),n.d(r,"window",function(){return x.f}),n.d(r,"global",function(){return x.b}),n.d(r,"document",function(){return x.a}),n.d(r,"assert",function(){return o}),n.d(r,"_selectLoader",function(){return H}),n.d(r,"_WorkerThread",function(){return M}),n.d(r,"_WorkerFarm",function(){return $}),n.d(r,"_WorkerPool",function(){return R}),n.d(r,"_fetchProgress",function(){return Ie}),n.d(r,"_unregisterLoaders",function(){return q});const Ee=x.b.TextEncoder,Oe=x.b.TextDecoder;async function De(e,r){return console.warn("createReadStream() deprecated, use fetch().then(resp => resp.body)"),e=te(e),(await oe(e,r)).body}function Ce(...e){return console.warn("parse() deprecated, use parse()"),X(...e)}function Le(...e){return console.warn("parseSync() deprecated, use parseSync()"),Y(...e)}function Me(...e){return console.warn("loadFile() deprecated, use load()"),ue(...e)}}])});
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var n=r();for(var t in n)("object"==typeof exports?exports:e)[t]=n[t]}}(window,(function(){return function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=5)}([function(e,r,n){"use strict";(function(e,t){n.d(r,"c",(function(){return o})),n.d(r,"e",(function(){return i})),n.d(r,"f",(function(){return u})),n.d(r,"b",(function(){return c})),n.d(r,"a",(function(){return a})),n.d(r,"d",(function(){return l}));const o="object"!=typeof e||"[object process]"!==String(e)||e.browser,s={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==t&&t,document:"undefined"!=typeof document&&document},i=s.self||s.window||s.global,u=s.window||s.self||s.global,c=s.global||s.self||s.window,a=s.document||{},f=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/),l=f&&parseFloat(f[1])||0}).call(this,n(6),n(4))},function(e,r){},function(e,r){},function(e,r){},function(e,r){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,r,n){(function(r){const t=n(7),o="undefined"==typeof window?r:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,t)}).call(this,n(4))},function(e,r){var n,t,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(r){try{return n.call(null,e,0)}catch(r){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{t="function"==typeof clearTimeout?clearTimeout:i}catch(e){t=i}}();var c,a=[],f=!1,l=-1;function d(){f&&c&&(f=!1,c.length?a=c.concat(a):l=-1,a.length&&y())}function y(){if(!f){var e=u(d);f=!0;for(var r=a.length;r;){for(c=a,a=[];++l<r;)c&&c[l].run();l=-1,r=a.length}c=null,f=!1,function(e){if(t===clearTimeout)return clearTimeout(e);if((t===i||!t)&&clearTimeout)return t=clearTimeout,clearTimeout(e);try{t(e)}catch(r){try{return t.call(null,e)}catch(r){return t.call(this,e)}}}(e)}}function h(e,r){this.fun=e,this.array=r}function p(){}o.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)r[n-1]=arguments[n];a.push(new h(e,r)),1!==a.length||f||u(y)},h.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=p,o.addListener=p,o.once=p,o.off=p,o.removeListener=p,o.removeAllListeners=p,o.emit=p,o.prependListener=p,o.prependOnceListener=p,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,r,n){"use strict";n.r(r);var t={};function o(e,r){if(!e)throw new Error(r||"loader assertion failed.")}function s(e){if(!e)return!1;return Array.isArray(e)&&(e=e[0]),e.parseTextSync||e.parseSync||e.parse||e.parseStream||e.parseInBatches||e.worker}function i(e){let r;return o(s(e),"invalid loader"),Array.isArray(e)&&(r=e[1],e=e[0],e={...e,options:{...e.options,...r}}),e.extension&&(e.extensions=e.extensions||e.extension,delete e.extension),Array.isArray(e.extensions)||(e.extensions=[e.extensions]),o(e.extensions&&e.extensions.length>0&&e.extensions[0]),e.parseTextSync&&(e.text=!0),e.text||(e.binary=!0),e}n.r(t),n.d(t,"dirname",(function(){return fe}));class u{log(){return e=>{}}info(){return e=>{}}warn(){return e=>{}}error(){return e=>{}}}const c={log:new class{constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}}},a=e=>e&&"object"==typeof e&&e.constructor==={}.constructor;function f(e,r){const n=e&&(e.DEFAULT_OPTIONS||e.defaultOptions||e.options||{}),t={...c,...n,dataType:"arraybuffer",...r};null===t.log&&(t.log=new u);for(const e in r){const o=r[e];a(o)&&e in n&&(a(n[e])?t[e]={...n[e],...r[e]}:t.log.warn(`Nested option ${e} not recognized`)())}return t}const l=e=>"boolean"==typeof e,d=e=>"function"==typeof e,y=e=>null!==e&&"object"==typeof e,h=e=>y(e)&&d(e.then),p=e=>e&&"function"==typeof e[Symbol.iterator],w=e=>e&&"function"==typeof e[Symbol.asyncIterator],b=e=>e&&d(e.next),g=e=>"undefined"!=typeof Response&&e instanceof Response||e.arrayBuffer&&e.text&&e.json,m=e=>(e=>"undefined"!=typeof File&&e instanceof File)(e)||(e=>"undefined"!=typeof Blob&&e instanceof Blob)(e),x=e=>(e=>y(e)&&d(e.tee)&&d(e.cancel)&&d(e.pipeTo)&&d(e.getReader))(e)||(e=>y(e)&&d(e.read)&&d(e.pipe)&&l(e.readable))(e),A=e=>(e=>y(e)&&d(e.abort)&&d(e.getWriter))(e)||(e=>y(e)&&d(e.end)&&d(e.write)&&l(e.writable))(e);var S=n(0);function v(e){if(S.c||S.d>=10){if("function"==typeof e[Symbol.asyncIterator])return e;if("function"==typeof e.getIterator)return e.getIterator()}return S.c?async function*(e){const r=e.getReader();try{for(;;){const{done:e,value:n}=await r.read();if(e)return;yield n}}catch(e){r.releaseLock()}}(e):async function*(e){e=await e;for(;;){const r=e.read();if(null===r){if(e._readableState.ended)return;await B(e)}else yield r}}(e)}async function B(e){return new Promise(r=>{e.once("readable",r)})}class T{constructor(e){this._fileOrBlob=e,this.bodyUsed=!1}get headers(){return new Headers({"Content-Length":this._fileOrBlob.size,"Content-Type":this._fileOrBlob.type})}get ok(){return!0}get status(){return 200}get url(){return this._fileOrBlob.name||""}async arrayBuffer(){const{reader:e,promise:r}=this._getFileReader();return e.readAsArrayBuffer(this._fileOrBlob),r}async text(){const{reader:e,promise:r}=this._getFileReader();return e.readAsText(this._fileOrBlob),r}async json(){const e=await this.text();return JSON.parse(e)}_getFileReader(){let e;o(!this.bodyUsed),this.bodyUsed=!0;const r=new Promise((r,n)=>{try{(e=new FileReader).onerror=e=>n(new Error(e)),e.onabort=()=>n(new Error("Read aborted.")),e.onload=()=>r(e.result)}catch(e){n(e)}});return{reader:e,promise:r}}}function k(e,r){return Promise.resolve(new T(e,r))}const j="Cannot convert supplied data type";function _(e,r){if(r.text&&"string"==typeof e)return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){const n=e.buffer||e;if(r.text&&!r.binary){return new TextDecoder("utf8").decode(n)}return n}throw new Error(j)}async function F(e,r){const n=(e=await e)instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||n)return _(e,r);if(m(e)&&(e=await k(e)),g(e))return await async function(e){if(!e.ok){let r=`fetch failed ${e.status} `;try{r+=await e.text()}catch(e){}throw new Error(r)}}(e),r.binary?await e.arrayBuffer():await e.text();throw new Error(j)}function I(e){return b(e)?e:g(e)&&e.body?(function(e){if(!e.ok)throw new Error(`fetch failed ${e.status}`)}(e),v(e.body)):x(e)?v(e):w(e)?e[Symbol.asyncIterator]():E(e)}function E(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return function*(){yield e.buffer||e}();if(b(e))return e;if(p(e))return e[Symbol.iterator]();throw new Error(j)}function O(e,r,n){return n||(e={fetch:e.fetch||"undefined"!=typeof window&&window.fetch,...e},Array.isArray(e.loaders)||(e.loaders=null),e)}function P(e,r){if(!r&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),r&&r.loaders){const e=Array.isArray(r.loaders)?r.loaders:[r.loaders];n=n?[...n,...e]:e}return n&&n.length?n:null}var D=n(3);function L(e){if(D.toArrayBuffer&&(e=Object(D.toArrayBuffer)(e)),e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const r=e;return(new TextEncoder).encode(r).buffer}return o(!1)}function M(e,r=!0,n=[]){if(e){if(e instanceof ArrayBuffer)n.push(e);else if(e.buffer&&e.buffer instanceof ArrayBuffer)n.push(e.buffer);else if(r&&"object"==typeof e)for(const t in e)M(e[t],r,n)}else;return n}const C=new Map;let R=0;function W({data:e,resolve:r}){r(e)}class ${constructor({source:e,name:r=`web-worker-${R++}`,onMessage:n}){const t=function(e){if(o("string"==typeof e,"worker source"),e.startsWith("url(")&&e.endsWith(")"))return e.match(/^url\((.*)\)$/)[1];let r=C.get(e);if(!r){const n=new Blob([e],{type:"application/javascript"});r=URL.createObjectURL(n),C.set(e,r)}return r}(e);this.worker=new Worker(t,{name:r}),this.name=r,this.onMessage=n||W}async process(e){return new Promise((r,n)=>{this.worker.onmessage=e=>this.onMessage({worker:this.worker,data:e.data,resolve:r,reject:n}),this.worker.onerror=e=>n(e);const t=M(e);this.worker.postMessage(e,t)})}destroy(){this.worker.terminate(),this.worker=null}}class Q{constructor({source:e,name:r="unnamed",maxConcurrency:n=1,onMessage:t,onDebug:o=(()=>{})}){this.source=e,this.name=r,this.maxConcurrency=n,this.onMessage=t,this.onDebug=o,this.jobQueue=[],this.idleQueue=[],this.count=0,this.isDestroyed=!1}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}async process(e,r){return new Promise((n,t)=>{this.jobQueue.push({data:e,jobName:r,resolve:n,reject:t}),this._startQueuedJob()})}_startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const r=this.jobQueue.shift();this.onDebug({message:"processing",worker:e.name,job:r.jobName,backlog:this.jobQueue.length}),e.process(r.data).then(e=>r.resolve(e)).catch(e=>r.reject(e)).then(()=>this._onWorkerDone(e))}_onWorkerDone(e){this.isDestroyed?e.destroy():(this.idleQueue.push(e),this._startQueuedJob())}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift();if(this.count<this.maxConcurrency){this.count++;const e=`${this.name.toLowerCase()}-worker-${this.count}-of-${this.maxConcurrency}`;return new $({source:this.source,onMessage:this.onMessage,name:e})}return null}}const U=5;class N{constructor({maxConcurrency:e=U,onMessage:r,onDebug:n=(()=>{})}){this.maxConcurrency=e,this.onMessage=r,this.onDebug=n,this.workerPools=new Map}setProps(e){"maxConcurrency"in e&&(this.maxConcurrency=e.maxConcurrency),"onDebug"in e&&(this.onDebug=e.onDebug)}destroy(){this.workerPools.forEach(e=>e.destroy())}async process(e,r,n){return this._getWorkerPool(e,r).process(n)}_getWorkerPool(e,r){let n=this.workerPools.get(r);return n||(n=new Q({source:e,name:r,onMessage:this.onMessage,maxConcurrency:this.maxConcurrency,onDebug:this.onDebug}),this.workerPools.set(r,n)),n}}let V=null;async function J({worker:e,data:r,resolve:n,reject:t}){switch(r.type){case"done":n(r.result);break;case"process":try{const n=await re(r.arraybuffer,r.options,r.url);e.postMessage({type:"process-done",id:r.id,result:n},M(n))}catch(n){e.postMessage({type:"process-error",id:r.id,message:n.message})}break;case"error":t(r.message)}}function z(e,r,n,t={},o={}){const s=function(e={}){const r={};return e.maxConcurrency&&(r.maxConcurrency=e.maxConcurrency),e.onDebug&&(r.onDebug=e.onDebug),V||(V=new N({onMessage:J})),V.setProps(r),V}(t);return t=JSON.parse(JSON.stringify(t)),s.process(e,`loaders.gl-${r}`,{arraybuffer:L(n),options:t,source:"loaders.gl",type:"process"})}let q=[];function H(e){e=Array.isArray(e)?e:[e];for(const r of e){const e=i(r);q.find(r=>e===r)||q.unshift(e)}}function G(){q=[]}const K=/[^.]+$/;function X(e,r="",n=null,{nothrow:t=!1}={}){if(r=r||"",e&&!Array.isArray(e)){const r=e;return i(r),r}(function(e){for(const r of e)i(r)})(e=[...e||[],...q]),r=r.replace(/\?.*/,"");let o=null;if(!(o=(o=o||function(e,r){const n=r.match(K),t=n&&n[0];return t&&function(e,r){r=r.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===r)return n;return null}(e,t)}(e,r))||function(e,r){if(!r)return null;for(const n of e)if("string"==typeof r){if(Y(r,n))return n}else if(ArrayBuffer.isView(r)){if(Z(r.buffer,r.byteOffset,n))return n}else if(r instanceof ArrayBuffer){if(Z(r,0,n))return n}return null}(e,n))){if(t)return null;let e="No valid loader found";throw n&&(e+=` for data starting with "${function(e,r=5){if("string"==typeof e)return e.slice(0,r);if(ArrayBuffer.isView(e))return ee(e.buffer,e.byteOffset,r);if(e instanceof ArrayBuffer){return ee(e,0,r)}return""}(n)}"`),r&&(e+=` for ${r}`),new Error(e)}return o}function Y(e,r){return r.testText&&r.testText(e)}function Z(e,r,n){switch(Array.isArray(n.test)?"array":typeof n.test){case"function":return n.test(e,n);case"string":case"array":return(Array.isArray(n.test)?n.test:[n.test]).some(n=>{return n===ee(e,r,n.length)});default:return!1}}function ee(e,r,n){if(e.byteLength<=r+n)return"";const t=new DataView(e);let o="";for(let e=0;e<n;e++)o+=String.fromCharCode(t.getUint8(r+e));return o}async function re(e,r,n,t){Array.isArray(r)||s(r)||(t=n,n=r,r=null);let i="";"string"==typeof t&&(i=t,t=null),n=n||{};const u=function(e,r){return g(e)?r=r||e.url:m(r)&&(r=r.name),"string"==typeof r?r.replace(/\?.*/,""):r}(e,i),c=P(r,t),a=X(c,u,e);return a?(n=f(a,n),t=O({url:u,parse:re,loaders:c},0,t),await async function(e,r,n,t){if(r=await F(r,e),e.parseTextSync&&"string"==typeof r)return n.dataType="text",e.parseTextSync(r,n,t,e);if(e.parse)return await e.parse(r,n,t,e);if(e.parseSync)return e.parseSync(r,n,t,e);if(e.worker)return await z(e.worker,e.name,r,n,t);return o(!1)}(a,e,n,t)):null}function ne(e,r,n,t){Array.isArray(r)||s(r)||(t=n,n=r,r=null);let o="";"string"==typeof t&&(o=t,t=null),n=n||{};const i=X(P(r,t),o,e);return i?function(e,r,n,t){if(r=_(r,e),e.parseTextSync&&"string"==typeof r)return e.parseTextSync(r,n,t,e);if(e.parseSync)return e.parseSync(r,n,t,e);throw new Error(`${e.name}: Loader does not support 'parseSync' (${t.url||"data"})`)}(i,e,n=f(i,n),t=O({url:o,parseSync:ne,loaders:r})):null}let te="";const oe={};function se(e){te=e}function ie(){return te}function ue(e){for(const r in oe)if(e.startsWith(r)){const n=oe[r];return e.replace(r,n)}return e+=te}async function ce(e,r){return m(e)?k(e,r):(e=ue(e),fetch(e,r))}async function ae(e,r,n){Array.isArray(r)||s(r)||(n=r,r=null);let t=e;return"string"==typeof e&&(t=await ce(e,n)),m(e)&&(t=await ce(e,n),e=null),await re(t,r,n,e)}function fe(e){const r=e&&e.lastIndexOf("/");return r>=0?e.substr(0,r):""}var le=n(2);const de={dataType:"arraybuffer",nothrow:!0},ye=e=>e.startsWith("data:");function he(e,r){return r=function(e={}){return(e=Object.assign({},de,e)).responseType=e.responseType||e.dataType,e}(r),ye(e),r.nothrow||o(!1),null}function pe(e,r={}){return e=ue(e),!S.c&&le.readFileSync?le.readFileSync(e,r):he(e,r)}var we=n(1);function be(e,r,n){return e=ue(e),!S.c&&we.writeFile?we.writeFile(e,r,n):o(!1)}function ge(e,r,n){return e=ue(e),!S.c&&we.writeFileSync?we.writeFileSync(e,r,n):o(!1)}function me(e){return`Failed to fetch resource ${e.url}(${e.status}): ${e.statusText} `}async function xe(e){let r=`Failed to fetch resource ${e.url} (${e.status}): `;try{e.headers.get("Content-Type").includes("application/json")?r+=await e.text():r+=e.statusText}catch(e){return r}return r}async function Ae(e,r,n,t){Array.isArray(r)||s(r)||(t=n,n=r,r=null);const o=X(r,t,null);return function(e,r,n,t){if(e.parseInBatches){const o=I(r);return e.parseInBatches(o,n,t,e)}throw new Error("parseWithLoaderInBatchesSync not available")}(o,e,n=f(o,n),O({url:t,loaders:r}))}async function Se(e,r,n,t){Array.isArray(r)||s(r)||(t=n,n=r,r=null);const o=X(r,t,null);return function(e,r,n,t){if(e.parseInBatchesSync){const o=E(r);return e.parseInBatchesSync(o,n,t,e)}throw new Error("parseWithLoaderInBatchesSync not available")}(o,e,n=f(o,n),O({url:t,loaders:r}))}async function ve(e,r,n){return Ae(await ce(e,n),r,n,e)}function Be(e,r,n,t){if(r.encode)return r.encode(e,n);if(r.encodeSync)return Promise.resolve(r.encodeSync(e,n));throw new Error("Writer could not encode data")}function Te(e,r,n,t){if(r.encodeSync)return r.encodeSync(e,n);throw new Error("Writer could not synchronously encode data")}function ke(e,r,n,t){if(r.encodeInBatches)return r.encodeInBatches(e,n);throw new Error("Writer could not encode data in batches")}function je(e,r,n,t){return be(r,Be(e,n,t))}function _e(e,r,n,t){return ge(r,Te(e,n,t))}function Fe(e,r){const n=e instanceof ArrayBuffer?new Uint8Array(e):e,t=r instanceof ArrayBuffer?new Uint8Array(r):r,o=new Uint8Array(n.byteLength+t.byteLength);return o.set(n,0),o.set(t,n.byteLength),o}async function Ie(e,r){for(;;){const{done:n,value:t}=await e.next();if(n)return void e.return();if(r(t))return}}async function Ee(e){let r=new ArrayBuffer,n="";for await(const t of e)"string"==typeof t?n+=t:r=Fe(r,t);return n||r}async function*Oe(e,r){const n=new TextDecoder(r);for await(const r of e)yield"string"==typeof r?r:n.decode(r,{stream:!0})}async function*Pe(e){let r="";for await(const n of e){let e;for(r+=n;(e=r.indexOf("\n"))>=0;){const n=r.slice(0,e+1);r=r.slice(e+1),yield n}}r.length>0&&(yield r)}async function*De(e){let r=1;for await(const n of e)yield{counter:r,line:n},r++}async function Le(e,r,n=(()=>{}),t=(()=>{})){if(!(e=await e).ok)return e;if(!e.body)return e;const o=e.headers.get("content-length"),s=o&&parseInt(o,10);if(!(o>0))return e;if("undefined"==typeof ReadableStream)return e;const i=new ReadableStream({start(o){!async function e(r,n,t,o,s,i,u){try{const{done:c,value:a}=await n.read();if(c)return i(),void r.close();t+=a.byteLength;const f=Math.round(t/o*100);s(f,{loadedBytes:t,totalBytes:o}),r.enqueue(a),await e(r,n,t,o,s,i,u)}catch(e){r.error(e),u(e)}}(o,e.body.getReader(),0,s,r,n,t)}});return new Response(i)}n.d(r,"TextEncoder",(function(){return Me})),n.d(r,"TextDecoder",(function(){return Ce})),n.d(r,"createReadStream",(function(){return Re})),n.d(r,"parseFile",(function(){return We})),n.d(r,"parseFileSync",(function(){return $e})),n.d(r,"loadFile",(function(){return Qe})),n.d(r,"path",(function(){return t})),n.d(r,"setPathPrefix",(function(){return se})),n.d(r,"getPathPrefix",(function(){return ie})),n.d(r,"resolvePath",(function(){return ue})),n.d(r,"fetchFile",(function(){return ce})),n.d(r,"readFileSync",(function(){return pe})),n.d(r,"writeFile",(function(){return be})),n.d(r,"writeFileSync",(function(){return ge})),n.d(r,"_getErrorMessageFromResponseSync",(function(){return me})),n.d(r,"_getErrorMessageFromResponse",(function(){return xe})),n.d(r,"registerLoaders",(function(){return H})),n.d(r,"parse",(function(){return re})),n.d(r,"parseSync",(function(){return ne})),n.d(r,"parseInBatches",(function(){return Ae})),n.d(r,"parseInBatchesSync",(function(){return Se})),n.d(r,"load",(function(){return ae})),n.d(r,"loadInBatches",(function(){return ve})),n.d(r,"encode",(function(){return Be})),n.d(r,"encodeSync",(function(){return Te})),n.d(r,"encodeInBatches",(function(){return ke})),n.d(r,"save",(function(){return je})),n.d(r,"saveSync",(function(){return _e})),n.d(r,"isPromise",(function(){return h})),n.d(r,"isIterable",(function(){return p})),n.d(r,"isAsyncIterable",(function(){return w})),n.d(r,"isIterator",(function(){return b})),n.d(r,"isFetchResponse",(function(){return g})),n.d(r,"isReadableStream",(function(){return x})),n.d(r,"isWritableStream",(function(){return A})),n.d(r,"toArrayBuffer",(function(){return L})),n.d(r,"getStreamIterator",(function(){return v})),n.d(r,"forEach",(function(){return Ie})),n.d(r,"concatenateAsyncIterator",(function(){return Ee})),n.d(r,"lineAsyncIterator",(function(){return Pe})),n.d(r,"textDecoderAsyncIterator",(function(){return Oe})),n.d(r,"numberedLineAsyncIterator",(function(){return De})),n.d(r,"isBrowser",(function(){return S.c})),n.d(r,"self",(function(){return S.e})),n.d(r,"window",(function(){return S.f})),n.d(r,"global",(function(){return S.b})),n.d(r,"document",(function(){return S.a})),n.d(r,"assert",(function(){return o})),n.d(r,"_selectLoader",(function(){return X})),n.d(r,"_WorkerThread",(function(){return $})),n.d(r,"_WorkerFarm",(function(){return N})),n.d(r,"_WorkerPool",(function(){return Q})),n.d(r,"_fetchProgress",(function(){return Le})),n.d(r,"_unregisterLoaders",(function(){return G}));const Me=S.b.TextEncoder,Ce=S.b.TextDecoder;async function Re(e,r){return console.warn("createReadStream() deprecated, use fetch().then(resp => resp.body)"),e=ue(e),(await ce(e,r)).body}function We(...e){return console.warn("parse() deprecated, use parse()"),re(...e)}function $e(...e){return console.warn("parseSync() deprecated, use parseSync()"),ne(...e)}function Qe(...e){return console.warn("loadFile() deprecated, use load()"),ae(...e)}}])}));

@@ -38,8 +38,2 @@ "use strict";

});
Object.defineProperty(exports, "loadInBatches", {
enumerable: true,
get: function get() {
return _load.loadInBatches;
}
});
Object.defineProperty(exports, "isBrowser", {

@@ -147,2 +141,8 @@ enumerable: true,

});
Object.defineProperty(exports, "loadInBatches", {
enumerable: true,
get: function get() {
return _loadInBatches.loadInBatches;
}
});
Object.defineProperty(exports, "encode", {

@@ -334,2 +334,4 @@ enumerable: true,

var _loadInBatches = require("./lib/load-in-batches");
var _encode = require("./lib/encode");

@@ -336,0 +338,0 @@

@@ -28,7 +28,2 @@ "use strict";

(0, _createClass2["default"])(FileReadableResponse, [{
key: "url",
value: function url() {
return this._fileOrBlob.name || '';
}
}, {
key: "arrayBuffer",

@@ -167,2 +162,7 @@ value: function () {

}
}, {
key: "url",
get: function get() {
return this._fileOrBlob.name || '';
}
}]);

@@ -169,0 +169,0 @@ return FileReadableResponse;

@@ -8,3 +8,2 @@ "use strict";

});
exports.loadInBatches = loadInBatches;
exports.load = load;

@@ -22,17 +21,11 @@

var _normalizeOptions = require("./loader-utils/normalize-options");
var _selectLoader = require("./select-loader");
var _parse = require("./parse");
var _parseInBatches = require("./parse-in-batches");
function loadInBatches(_x, _x2, _x3) {
return _loadInBatches.apply(this, arguments);
function load(_x, _x2, _x3) {
return _load.apply(this, arguments);
}
function _loadInBatches() {
_loadInBatches = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(url, loaders, options) {
var response;
function _load() {
_load = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(url, loaders, options) {
var data;
return _regenerator["default"].wrap(function _callee$(_context) {

@@ -42,30 +35,2 @@ while (1) {

case 0:
_context.next = 2;
return (0, _fetchFile.fetchFile)(url, options);
case 2:
response = _context.sent;
return _context.abrupt("return", (0, _parseInBatches.parseInBatches)(response, loaders, options, url));
case 4:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _loadInBatches.apply(this, arguments);
}
function load(_x4, _x5, _x6) {
return _load.apply(this, arguments);
}
function _load() {
_load = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(url, loaders, options) {
var autoUrl, loader, loaderOptions, data;
return _regenerator["default"].wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (!Array.isArray(loaders) && !(0, _normalizeLoader.isLoaderObject)(loaders)) {

@@ -76,47 +41,41 @@ options = loaders;

autoUrl = (0, _isType.isFileReadable)(url) ? url.name : url;
loader = (0, _selectLoader.selectLoader)(loaders, autoUrl, null, {
nothrow: true
});
data = url;
if (!loader) {
_context2.next = 9;
if (!(typeof url === 'string')) {
_context.next = 6;
break;
}
if (!loader.loadAndParse) {
_context2.next = 9;
_context.next = 5;
return (0, _fetchFile.fetchFile)(url, options);
case 5:
data = _context.sent;
case 6:
if (!(0, _isType.isFileReadable)(url)) {
_context.next = 11;
break;
}
loaderOptions = (0, _normalizeOptions.mergeLoaderAndUserOptions)(options, loader);
_context2.next = 8;
return loader.loadAndParse(url, loaderOptions);
_context.next = 9;
return (0, _fetchFile.fetchFile)(url, options);
case 8:
return _context2.abrupt("return", _context2.sent);
case 9:
data = url;
data = _context.sent;
url = null;
if (!((0, _isType.isFileReadable)(data) || typeof data === 'string')) {
_context2.next = 14;
break;
}
case 11:
_context.next = 13;
return (0, _parse.parse)(data, loaders, options, url);
_context2.next = 13;
return (0, _fetchFile.fetchFile)(url, options);
case 13:
data = _context2.sent;
return _context.abrupt("return", _context.sent);
case 14:
return _context2.abrupt("return", (0, _parse.parse)(data, loaders, options, url));
case 15:
case "end":
return _context2.stop();
return _context.stop();
}
}
}, _callee2);
}, _callee);
}));

@@ -123,0 +82,0 @@ return _load.apply(this, arguments);

@@ -9,3 +9,6 @@ "use strict";

exports.getLoaderContext = getLoaderContext;
exports.getLoaders = getLoaders;
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

@@ -17,7 +20,36 @@

function getLoaderContext(context, options) {
return _objectSpread({
fetch: typeof window !== 'undefined' && window.fetch
function getLoaderContext(context, options, previousContext) {
if (previousContext) {
return previousContext;
}
context = _objectSpread({
fetch: context.fetch || typeof window !== 'undefined' && window.fetch
}, context);
if (!Array.isArray(context.loaders)) {
context.loaders = null;
}
return context;
}
function getLoaders(loaders, context) {
if (!context && !Array.isArray(loaders)) {
return loaders;
}
var candidateLoaders;
if (loaders) {
candidateLoaders = Array.isArray(loaders) ? loaders : [loaders];
}
if (context && context.loaders) {
var contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
candidateLoaders = candidateLoaders ? [].concat((0, _toConsumableArray2["default"])(candidateLoaders), (0, _toConsumableArray2["default"])(contextLoaders)) : contextLoaders;
}
return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
}
//# sourceMappingURL=get-loader-context.js.map

@@ -28,3 +28,3 @@ "use strict";

var hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.loadAndParse || loader.parseStream || loader.parseInBatches || loader.worker;
var hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches || loader.worker;
return hasParser;

@@ -34,3 +34,3 @@ }

function normalizeLoader(loader) {
(0, _assert["default"])(isLoaderObject(loader));
(0, _assert["default"])(isLoaderObject(loader), 'invalid loader');
var options;

@@ -37,0 +37,0 @@

@@ -16,3 +16,3 @@ "use strict";

var _normalizeOptions = require("./loader-utils/normalize-options");
var _mergeOptions = require("./loader-utils/merge-options");

@@ -43,5 +43,6 @@ var _getData = require("./loader-utils/get-data");

loader = (0, _selectLoader.selectLoader)(loaders, url, null);
options = (0, _normalizeOptions.mergeLoaderAndUserOptions)(options, loader);
options = (0, _mergeOptions.mergeOptions)(loader, options);
context = (0, _getLoaderContext.getLoaderContext)({
url: url
url: url,
loaders: loaders
}, options);

@@ -48,0 +49,0 @@ return _context.abrupt("return", parseWithLoaderInBatchesSync(loader, data, options, context));

@@ -16,3 +16,3 @@ "use strict";

var _normalizeOptions = require("./loader-utils/normalize-options");
var _mergeOptions = require("./loader-utils/merge-options");

@@ -43,5 +43,6 @@ var _getData = require("./loader-utils/get-data");

loader = (0, _selectLoader.selectLoader)(loaders, url, null);
options = (0, _normalizeOptions.mergeLoaderAndUserOptions)(options, loader);
options = (0, _mergeOptions.mergeOptions)(loader, options);
context = (0, _getLoaderContext.getLoaderContext)({
url: url
url: url,
loaders: loaders
}, options);

@@ -48,0 +49,0 @@ return _context.abrupt("return", parseWithLoaderInBatches(loader, data, options, context));

@@ -12,3 +12,3 @@ "use strict";

var _normalizeOptions = require("./loader-utils/normalize-options");
var _mergeOptions = require("./loader-utils/merge-options");

@@ -19,5 +19,5 @@ var _getData = require("./loader-utils/get-data");

function parseSync(data, loaders, options, url) {
function parseSync(data, loaders, options, context) {
if (!Array.isArray(loaders) && !(0, _normalizeLoader.isLoaderObject)(loaders)) {
url = options;
context = options;
options = loaders;

@@ -27,4 +27,13 @@ loaders = null;

var loader = (0, _selectLoader.selectLoader)(loaders, url, data);
var url = '';
if (typeof context === 'string') {
url = context;
context = null;
}
options = options || {};
var candidateLoaders = (0, _getLoaderContext.getLoaders)(loaders, context);
var loader = (0, _selectLoader.selectLoader)(candidateLoaders, url, data);
if (!loader) {

@@ -34,6 +43,7 @@ return null;

options = (0, _normalizeOptions.mergeLoaderAndUserOptions)(options, loader);
var context = (0, _getLoaderContext.getLoaderContext)({
options = (0, _mergeOptions.mergeOptions)(loader, options);
context = (0, _getLoaderContext.getLoaderContext)({
url: url,
parseSync: parseSync
parseSync: parseSync,
loaders: loaders
}, options);

@@ -54,4 +64,4 @@ return parseWithLoaderSync(loader, data, options, context);

throw new Error("Could not parse ".concat(context.url || 'data', " using ").concat(loader.name, " loader"));
throw new Error("".concat(loader.name, ": Loader does not support 'parseSync' (").concat(context.url || 'data', ")"));
}
//# sourceMappingURL=parse-sync.js.map

@@ -18,3 +18,3 @@ "use strict";

var _normalizeOptions = require("./loader-utils/normalize-options");
var _mergeOptions = require("./loader-utils/merge-options");

@@ -34,4 +34,4 @@ var _getData = require("./loader-utils/get-data");

function _parse() {
_parse = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(data, loaders, options, url) {
var autoUrl, loader, context;
_parse = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(data, loaders, options, context) {
var url, autoUrl, candidateLoaders, loader;
return _regenerator["default"].wrap(function _callee$(_context) {

@@ -41,4 +41,4 @@ while (1) {

case 0:
if (loaders && !Array.isArray(loaders) && !(0, _normalizeLoader.isLoaderObject)(loaders)) {
url = options;
if (!Array.isArray(loaders) && !(0, _normalizeLoader.isLoaderObject)(loaders)) {
context = options;
options = loaders;

@@ -48,17 +48,35 @@ loaders = null;

url = '';
if (typeof context === 'string') {
url = context;
context = null;
}
options = options || {};
autoUrl = (0, _getData.getUrlFromData)(data, url);
loader = (0, _selectLoader.selectLoader)(loaders, autoUrl, data);
options = (0, _normalizeOptions.mergeLoaderAndUserOptions)(options, loader);
candidateLoaders = (0, _getLoaderContext.getLoaders)(loaders, context);
loader = (0, _selectLoader.selectLoader)(candidateLoaders, autoUrl, data);
if (loader) {
_context.next = 9;
break;
}
return _context.abrupt("return", null);
case 9:
options = (0, _mergeOptions.mergeOptions)(loader, options);
context = (0, _getLoaderContext.getLoaderContext)({
url: autoUrl,
parse: parse
}, options);
_context.next = 8;
parse: parse,
loaders: candidateLoaders
}, options, context);
_context.next = 13;
return parseWithLoader(loader, data, options, context);
case 8:
case 13:
return _context.abrupt("return", _context.sent);
case 9:
case 14:
case "end":

@@ -65,0 +83,0 @@ return _context.stop();

@@ -12,2 +12,4 @@ "use strict";

var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
var _registerLoaders = require("./register-loaders");

@@ -35,3 +37,3 @@

loaders = loaders || (0, _registerLoaders.getRegisteredLoaders)();
loaders = [].concat((0, _toConsumableArray2["default"])(loaders || []), (0, _toConsumableArray2["default"])((0, _registerLoaders.getRegisteredLoaders)()));
normalizeLoaders(loaders);

@@ -48,3 +50,13 @@ url = url.replace(/\?.*/, '');

throw new Error("No valid loader found for ".concat(url));
var message = 'No valid loader found';
if (data) {
message += " for data starting with \"".concat(getFirstCharacters(data), "\"");
}
if (url) {
message += " for ".concat(url);
}
throw new Error(message);
}

@@ -213,2 +225,17 @@

function getFirstCharacters(data) {
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
if (typeof data === 'string') {
return data.slice(0, length);
} else if (ArrayBuffer.isView(data)) {
return getMagicString(data.buffer, data.byteOffset, length);
} else if (data instanceof ArrayBuffer) {
var byteOffset = 0;
return getMagicString(data, byteOffset, length);
}
return '';
}
function getMagicString(arrayBuffer, byteOffset, length) {

@@ -215,0 +242,0 @@ if (arrayBuffer.byteLength <= byteOffset + length) {

@@ -19,3 +19,4 @@ import { parse } from './lib/parse';

export { parseInBatchesSync } from './lib/parse-in-batches-sync';
export { load, loadInBatches } from './lib/load';
export { load } from './lib/load';
export { loadInBatches } from './lib/load-in-batches';
export { encode, encodeSync, encodeInBatches } from './lib/encode';

@@ -22,0 +23,0 @@ export { save, saveSync } from './lib/save';

@@ -24,3 +24,3 @@ import assert from '../../utils/assert';

url() {
get url() {
return this._fileOrBlob.name || '';

@@ -27,0 +27,0 @@ }

import { isFileReadable } from '../javascript-utils/is-type';
import { fetchFile } from './fetch/fetch-file';
import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { selectLoader } from './select-loader';
import { parse } from './parse';
import { parseInBatches } from './parse-in-batches';
export async function loadInBatches(url, loaders, options) {
const response = await fetchFile(url, options);
return parseInBatches(response, loaders, options, url);
}
export async function load(url, loaders, options) {

@@ -18,22 +11,15 @@ if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {

const autoUrl = isFileReadable(url) ? url.name : url;
const loader = selectLoader(loaders, autoUrl, null, {
nothrow: true
});
let data = url;
if (loader) {
if (loader.loadAndParse) {
const loaderOptions = mergeLoaderAndUserOptions(options, loader);
return await loader.loadAndParse(url, loaderOptions);
}
if (typeof url === 'string') {
data = await fetchFile(url, options);
}
let data = url;
if (isFileReadable(data) || typeof data === 'string') {
if (isFileReadable(url)) {
data = await fetchFile(url, options);
url = null;
}
return parse(data, loaders, options, url);
return await parse(data, loaders, options, url);
}
//# sourceMappingURL=load.js.map

@@ -7,7 +7,35 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

export function getLoaderContext(context, options) {
return _objectSpread({
fetch: typeof window !== 'undefined' && window.fetch
export function getLoaderContext(context, options, previousContext) {
if (previousContext) {
return previousContext;
}
context = _objectSpread({
fetch: context.fetch || typeof window !== 'undefined' && window.fetch
}, context);
if (!Array.isArray(context.loaders)) {
context.loaders = null;
}
return context;
}
export function getLoaders(loaders, context) {
if (!context && !Array.isArray(loaders)) {
return loaders;
}
let candidateLoaders;
if (loaders) {
candidateLoaders = Array.isArray(loaders) ? loaders : [loaders];
}
if (context && context.loaders) {
const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
}
return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
}
//# sourceMappingURL=get-loader-context.js.map

@@ -17,7 +17,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

const hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.loadAndParse || loader.parseStream || loader.parseInBatches || loader.worker;
const hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches || loader.worker;
return hasParser;
}
export function normalizeLoader(loader) {
assert(isLoaderObject(loader));
assert(isLoaderObject(loader), 'invalid loader');
let options;

@@ -24,0 +24,0 @@

import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { mergeOptions } from './loader-utils/merge-options';
import { getIteratorFromData } from './loader-utils/get-data';

@@ -14,5 +14,6 @@ import { getLoaderContext } from './loader-utils/get-loader-context';

const loader = selectLoader(loaders, url, null);
options = mergeLoaderAndUserOptions(options, loader);
options = mergeOptions(loader, options);
const context = getLoaderContext({
url
url,
loaders
}, options);

@@ -19,0 +20,0 @@ return parseWithLoaderInBatchesSync(loader, data, options, context);

import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { mergeOptions } from './loader-utils/merge-options';
import { getAsyncIteratorFromData } from './loader-utils/get-data';

@@ -14,5 +14,6 @@ import { getLoaderContext } from './loader-utils/get-loader-context';

const loader = selectLoader(loaders, url, null);
options = mergeLoaderAndUserOptions(options, loader);
options = mergeOptions(loader, options);
const context = getLoaderContext({
url
url,
loaders
}, options);

@@ -19,0 +20,0 @@ return parseWithLoaderInBatches(loader, data, options, context);

import { selectLoader } from './select-loader';
import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { mergeOptions } from './loader-utils/merge-options';
import { getArrayBufferOrStringFromDataSync } from './loader-utils/get-data';
import { getLoaderContext } from './loader-utils/get-loader-context';
export function parseSync(data, loaders, options, url) {
import { getLoaders, getLoaderContext } from './loader-utils/get-loader-context';
export function parseSync(data, loaders, options, context) {
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
url = options;
context = options;
options = loaders;

@@ -13,4 +13,13 @@ loaders = null;

const loader = selectLoader(loaders, url, data);
let url = '';
if (typeof context === 'string') {
url = context;
context = null;
}
options = options || {};
const candidateLoaders = getLoaders(loaders, context);
const loader = selectLoader(candidateLoaders, url, data);
if (!loader) {

@@ -20,6 +29,7 @@ return null;

options = mergeLoaderAndUserOptions(options, loader);
const context = getLoaderContext({
options = mergeOptions(loader, options);
context = getLoaderContext({
url,
parseSync
parseSync,
loaders
}, options);

@@ -40,4 +50,4 @@ return parseWithLoaderSync(loader, data, options, context);

throw new Error("Could not parse ".concat(context.url || 'data', " using ").concat(loader.name, " loader"));
throw new Error("".concat(loader.name, ": Loader does not support 'parseSync' (").concat(context.url || 'data', ")"));
}
//# sourceMappingURL=parse-sync.js.map
import assert from '../utils/assert';
import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { mergeOptions } from './loader-utils/merge-options';
import { getUrlFromData } from './loader-utils/get-data';
import { getArrayBufferOrStringFromData } from './loader-utils/get-data';
import { getLoaderContext } from './loader-utils/get-loader-context';
import { getLoaders, getLoaderContext } from './loader-utils/get-loader-context';
import parseWithWorker from './loader-utils/parse-with-worker';
import { selectLoader } from './select-loader';
export async function parse(data, loaders, options, url) {
if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
url = options;
export async function parse(data, loaders, options, context) {
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
context = options;
options = loaders;

@@ -16,10 +16,24 @@ loaders = null;

let url = '';
if (typeof context === 'string') {
url = context;
context = null;
}
options = options || {};
const autoUrl = getUrlFromData(data, url);
const loader = selectLoader(loaders, autoUrl, data);
options = mergeLoaderAndUserOptions(options, loader);
const context = getLoaderContext({
const candidateLoaders = getLoaders(loaders, context);
const loader = selectLoader(candidateLoaders, autoUrl, data);
if (!loader) {
return null;
}
options = mergeOptions(loader, options);
context = getLoaderContext({
url: autoUrl,
parse
}, options);
parse,
loaders: candidateLoaders
}, options, context);
return await parseWithLoader(loader, data, options, context);

@@ -26,0 +40,0 @@ }

@@ -15,3 +15,3 @@ import { getRegisteredLoaders } from './register-loaders';

loaders = loaders || getRegisteredLoaders();
loaders = [...(loaders || []), ...getRegisteredLoaders()];
normalizeLoaders(loaders);

@@ -28,3 +28,13 @@ url = url.replace(/\?.*/, '');

throw new Error("No valid loader found for ".concat(url));
let message = 'No valid loader found';
if (data) {
message += " for data starting with \"".concat(getFirstCharacters(data), "\"");
}
if (url) {
message += " for ".concat(url);
}
throw new Error(message);
}

@@ -112,2 +122,15 @@

function getFirstCharacters(data, length = 5) {
if (typeof data === 'string') {
return data.slice(0, length);
} else if (ArrayBuffer.isView(data)) {
return getMagicString(data.buffer, data.byteOffset, length);
} else if (data instanceof ArrayBuffer) {
const byteOffset = 0;
return getMagicString(data, byteOffset, length);
}
return '';
}
function getMagicString(arrayBuffer, byteOffset, length) {

@@ -114,0 +137,0 @@ if (arrayBuffer.byteLength <= byteOffset + length) {

@@ -21,3 +21,4 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

export { parseInBatchesSync } from './lib/parse-in-batches-sync';
export { load, loadInBatches } from './lib/load';
export { load } from './lib/load';
export { loadInBatches } from './lib/load-in-batches';
export { encode, encodeSync, encodeInBatches } from './lib/encode';

@@ -24,0 +25,0 @@ export { save, saveSync } from './lib/save';

@@ -16,7 +16,2 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

_createClass(FileReadableResponse, [{
key: "url",
value: function url() {
return this._fileOrBlob.name || '';
}
}, {
key: "arrayBuffer",

@@ -155,2 +150,7 @@ value: function () {

}
}, {
key: "url",
get: function get() {
return this._fileOrBlob.name || '';
}
}]);

@@ -157,0 +157,0 @@

@@ -6,13 +6,10 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { selectLoader } from './select-loader';
import { parse } from './parse';
import { parseInBatches } from './parse-in-batches';
export function loadInBatches(_x, _x2, _x3) {
return _loadInBatches.apply(this, arguments);
export function load(_x, _x2, _x3) {
return _load.apply(this, arguments);
}
function _loadInBatches() {
_loadInBatches = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(url, loaders, options) {
var response;
function _load() {
_load = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(url, loaders, options) {
var data;
return _regeneratorRuntime.wrap(function _callee$(_context) {

@@ -22,30 +19,2 @@ while (1) {

case 0:
_context.next = 2;
return fetchFile(url, options);
case 2:
response = _context.sent;
return _context.abrupt("return", parseInBatches(response, loaders, options, url));
case 4:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _loadInBatches.apply(this, arguments);
}
export function load(_x4, _x5, _x6) {
return _load.apply(this, arguments);
}
function _load() {
_load = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(url, loaders, options) {
var autoUrl, loader, loaderOptions, data;
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {

@@ -56,47 +25,41 @@ options = loaders;

autoUrl = isFileReadable(url) ? url.name : url;
loader = selectLoader(loaders, autoUrl, null, {
nothrow: true
});
data = url;
if (!loader) {
_context2.next = 9;
if (!(typeof url === 'string')) {
_context.next = 6;
break;
}
if (!loader.loadAndParse) {
_context2.next = 9;
_context.next = 5;
return fetchFile(url, options);
case 5:
data = _context.sent;
case 6:
if (!isFileReadable(url)) {
_context.next = 11;
break;
}
loaderOptions = mergeLoaderAndUserOptions(options, loader);
_context2.next = 8;
return loader.loadAndParse(url, loaderOptions);
_context.next = 9;
return fetchFile(url, options);
case 8:
return _context2.abrupt("return", _context2.sent);
case 9:
data = url;
data = _context.sent;
url = null;
if (!(isFileReadable(data) || typeof data === 'string')) {
_context2.next = 14;
break;
}
case 11:
_context.next = 13;
return parse(data, loaders, options, url);
_context2.next = 13;
return fetchFile(url, options);
case 13:
data = _context2.sent;
return _context.abrupt("return", _context.sent);
case 14:
return _context2.abrupt("return", parse(data, loaders, options, url));
case 15:
case "end":
return _context2.stop();
return _context.stop();
}
}
}, _callee2);
}, _callee);
}));

@@ -103,0 +66,0 @@ return _load.apply(this, arguments);

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

import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

@@ -7,7 +8,35 @@

export function getLoaderContext(context, options) {
return _objectSpread({
fetch: typeof window !== 'undefined' && window.fetch
export function getLoaderContext(context, options, previousContext) {
if (previousContext) {
return previousContext;
}
context = _objectSpread({
fetch: context.fetch || typeof window !== 'undefined' && window.fetch
}, context);
if (!Array.isArray(context.loaders)) {
context.loaders = null;
}
return context;
}
export function getLoaders(loaders, context) {
if (!context && !Array.isArray(loaders)) {
return loaders;
}
var candidateLoaders;
if (loaders) {
candidateLoaders = Array.isArray(loaders) ? loaders : [loaders];
}
if (context && context.loaders) {
var contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
candidateLoaders = candidateLoaders ? [].concat(_toConsumableArray(candidateLoaders), _toConsumableArray(contextLoaders)) : contextLoaders;
}
return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
}
//# sourceMappingURL=get-loader-context.js.map

@@ -17,7 +17,7 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

var hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.loadAndParse || loader.parseStream || loader.parseInBatches || loader.worker;
var hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches || loader.worker;
return hasParser;
}
export function normalizeLoader(loader) {
assert(isLoaderObject(loader));
assert(isLoaderObject(loader), 'invalid loader');
var options;

@@ -24,0 +24,0 @@

import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { mergeOptions } from './loader-utils/merge-options';
import { getIteratorFromData } from './loader-utils/get-data';

@@ -26,5 +26,6 @@ import { getLoaderContext } from './loader-utils/get-loader-context';

loader = selectLoader(loaders, url, null);
options = mergeLoaderAndUserOptions(options, loader);
options = mergeOptions(loader, options);
context = getLoaderContext({
url: url
url: url,
loaders: loaders
}, options);

@@ -31,0 +32,0 @@ return _context.abrupt("return", parseWithLoaderInBatchesSync(loader, data, options, context));

import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { mergeOptions } from './loader-utils/merge-options';
import { getAsyncIteratorFromData } from './loader-utils/get-data';

@@ -26,5 +26,6 @@ import { getLoaderContext } from './loader-utils/get-loader-context';

loader = selectLoader(loaders, url, null);
options = mergeLoaderAndUserOptions(options, loader);
options = mergeOptions(loader, options);
context = getLoaderContext({
url: url
url: url,
loaders: loaders
}, options);

@@ -31,0 +32,0 @@ return _context.abrupt("return", parseWithLoaderInBatches(loader, data, options, context));

import { selectLoader } from './select-loader';
import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { mergeOptions } from './loader-utils/merge-options';
import { getArrayBufferOrStringFromDataSync } from './loader-utils/get-data';
import { getLoaderContext } from './loader-utils/get-loader-context';
export function parseSync(data, loaders, options, url) {
import { getLoaders, getLoaderContext } from './loader-utils/get-loader-context';
export function parseSync(data, loaders, options, context) {
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
url = options;
context = options;
options = loaders;

@@ -13,4 +13,13 @@ loaders = null;

var loader = selectLoader(loaders, url, data);
var url = '';
if (typeof context === 'string') {
url = context;
context = null;
}
options = options || {};
var candidateLoaders = getLoaders(loaders, context);
var loader = selectLoader(candidateLoaders, url, data);
if (!loader) {

@@ -20,6 +29,7 @@ return null;

options = mergeLoaderAndUserOptions(options, loader);
var context = getLoaderContext({
options = mergeOptions(loader, options);
context = getLoaderContext({
url: url,
parseSync: parseSync
parseSync: parseSync,
loaders: loaders
}, options);

@@ -40,4 +50,4 @@ return parseWithLoaderSync(loader, data, options, context);

throw new Error("Could not parse ".concat(context.url || 'data', " using ").concat(loader.name, " loader"));
throw new Error("".concat(loader.name, ": Loader does not support 'parseSync' (").concat(context.url || 'data', ")"));
}
//# sourceMappingURL=parse-sync.js.map

@@ -5,6 +5,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

import { isLoaderObject } from './loader-utils/normalize-loader';
import { mergeLoaderAndUserOptions } from './loader-utils/normalize-options';
import { mergeOptions } from './loader-utils/merge-options';
import { getUrlFromData } from './loader-utils/get-data';
import { getArrayBufferOrStringFromData } from './loader-utils/get-data';
import { getLoaderContext } from './loader-utils/get-loader-context';
import { getLoaders, getLoaderContext } from './loader-utils/get-loader-context';
import parseWithWorker from './loader-utils/parse-with-worker';

@@ -17,4 +17,4 @@ import { selectLoader } from './select-loader';

function _parse() {
_parse = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(data, loaders, options, url) {
var autoUrl, loader, context;
_parse = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(data, loaders, options, context) {
var url, autoUrl, candidateLoaders, loader;
return _regeneratorRuntime.wrap(function _callee$(_context) {

@@ -24,4 +24,4 @@ while (1) {

case 0:
if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
url = options;
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
context = options;
options = loaders;

@@ -31,17 +31,35 @@ loaders = null;

url = '';
if (typeof context === 'string') {
url = context;
context = null;
}
options = options || {};
autoUrl = getUrlFromData(data, url);
loader = selectLoader(loaders, autoUrl, data);
options = mergeLoaderAndUserOptions(options, loader);
candidateLoaders = getLoaders(loaders, context);
loader = selectLoader(candidateLoaders, autoUrl, data);
if (loader) {
_context.next = 9;
break;
}
return _context.abrupt("return", null);
case 9:
options = mergeOptions(loader, options);
context = getLoaderContext({
url: autoUrl,
parse: parse
}, options);
_context.next = 8;
parse: parse,
loaders: candidateLoaders
}, options, context);
_context.next = 13;
return parseWithLoader(loader, data, options, context);
case 8:
case 13:
return _context.abrupt("return", _context.sent);
case 9:
case 14:
case "end":

@@ -48,0 +66,0 @@ return _context.stop();

import _typeof from "@babel/runtime/helpers/esm/typeof";
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
import { getRegisteredLoaders } from './register-loaders';

@@ -21,3 +22,3 @@ import { normalizeLoader } from './loader-utils/normalize-loader';

loaders = loaders || getRegisteredLoaders();
loaders = [].concat(_toConsumableArray(loaders || []), _toConsumableArray(getRegisteredLoaders()));
normalizeLoaders(loaders);

@@ -34,3 +35,13 @@ url = url.replace(/\?.*/, '');

throw new Error("No valid loader found for ".concat(url));
var message = 'No valid loader found';
if (data) {
message += " for data starting with \"".concat(getFirstCharacters(data), "\"");
}
if (url) {
message += " for ".concat(url);
}
throw new Error(message);
}

@@ -199,2 +210,17 @@

function getFirstCharacters(data) {
var length = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 5;
if (typeof data === 'string') {
return data.slice(0, length);
} else if (ArrayBuffer.isView(data)) {
return getMagicString(data.buffer, data.byteOffset, length);
} else if (data instanceof ArrayBuffer) {
var byteOffset = 0;
return getMagicString(data, byteOffset, length);
}
return '';
}
function getMagicString(arrayBuffer, byteOffset, length) {

@@ -201,0 +227,0 @@ if (arrayBuffer.byteLength <= byteOffset + length) {

{
"name": "@loaders.gl/core",
"version": "1.3.3",
"version": "2.0.0-alpha.1",
"description": "Framework-independent loaders for 3D graphics formats",

@@ -55,3 +55,3 @@ "license": "MIT",

},
"gitHead": "6a8d559e11613dc1dd94a12e4ea5df05c0184ae6"
"gitHead": "cff57d05c0495fa661119005cffd886ed6ed1025"
}

@@ -31,4 +31,6 @@ import {parse} from './lib/parse';

export {parseInBatchesSync} from './lib/parse-in-batches-sync';
export {load, loadInBatches} from './lib/load';
export {load} from './lib/load';
export {loadInBatches} from './lib/load-in-batches';
// ENCODING AND SAVING

@@ -35,0 +37,0 @@ export {encode, encodeSync, encodeInBatches} from './lib/encode';

@@ -26,3 +26,3 @@ /* global FileReader, Headers */

url() {
get url() {
// Note: This is just the file name without path information

@@ -29,0 +29,0 @@ // Note: File has `name` field but the Blob baseclass does not

import {isFileReadable} from '../javascript-utils/is-type';
import {fetchFile} from './fetch/fetch-file';
import {isLoaderObject} from './loader-utils/normalize-loader';
import {mergeLoaderAndUserOptions} from './loader-utils/normalize-options';
import {selectLoader} from './select-loader';
import {parse} from './parse';
import {parseInBatches} from './parse-in-batches';
export async function loadInBatches(url, loaders, options) {
const response = await fetchFile(url, options);
return parseInBatches(response, loaders, options, url);
}
// Note: Load does duplicate a lot of parse.
// Works like parse but can call `loadAndParse` for parsers that need to do their own loading
// it can also call fetchFile on string urls, which `parse` won't do.

@@ -25,29 +16,19 @@ export async function load(url, loaders, options) {

// Extract a url for auto detection
const autoUrl = isFileReadable(url) ? url.name : url;
// at this point, `url` could be already loaded binary data
let data = url;
// Initial loader autodection (Use registered loaders if none provided)
// This only uses URL extensions to detect loaders.
const loader = selectLoader(loaders, autoUrl, null, {nothrow: true});
if (loader) {
// Some loaders do not separate reading and parsing of data (e.g ImageLoader)
// These can only be handled by `load`, not `parse`
// TODO - ImageLoaders can be rewritten to separate load and parse, phase out this variant?
if (loader.loadAndParse) {
const loaderOptions = mergeLoaderAndUserOptions(options, loader);
return await loader.loadAndParse(url, loaderOptions);
}
// url is a string, fetch the url
if (typeof url === 'string') {
data = await fetchFile(url, options);
}
// at this point, data can be binary or text
let data = url;
if (isFileReadable(data) || typeof data === 'string') {
// URL is Blob or File, fetchFile handles it (alt: we could generate ObjectURL here)
if (isFileReadable(url)) {
// The fetch response object will contain blob.name
data = await fetchFile(url, options);
url = null;
}
// Fall back to parse
// Note: An improved round of autodetection is possible now that data has been loaded
// This means that another loader might be selected
return parse(data, loaders, options, url);
// Data is loaded (at least we have a `Response` object) so time to hand over to `parse`
return await parse(data, loaders, options, url);
}

@@ -1,6 +0,42 @@

export function getLoaderContext(context, options) {
return {
fetch: typeof window !== 'undefined' && window.fetch,
// "sub" loaders invoked by other loaders get a "context" injected on `this`
// The context will inject core methods like `parse` and contain information
// about loaders and options passed in to the top-level `parse` call.
export function getLoaderContext(context, options, previousContext) {
// For recursive calls, we already have a context
// TODO - add any additional loaders to context?
if (previousContext) {
return previousContext;
}
context = {
// TODO - determine how to inject fetch, fetch in options etc
fetch: context.fetch || (typeof window !== 'undefined' && window.fetch),
...context
};
// Recursive loading does not use single loader
if (!Array.isArray(context.loaders)) {
context.loaders = null;
}
return context;
}
export function getLoaders(loaders, context) {
// A single non-array loader is force selected, but only on top-level (context === null)
if (!context && !Array.isArray(loaders)) {
return loaders;
}
// Create a merged list
let candidateLoaders;
if (loaders) {
candidateLoaders = Array.isArray(loaders) ? loaders : [loaders];
}
if (context && context.loaders) {
const contextLoaders = Array.isArray(context.loaders) ? context.loaders : [context.loaders];
candidateLoaders = candidateLoaders ? [...candidateLoaders, ...contextLoaders] : contextLoaders;
}
// If no loaders, return null to look in globally registered loaders
return candidateLoaders && candidateLoaders.length ? candidateLoaders : null;
}

@@ -16,3 +16,2 @@ import assert from '../../utils/assert';

loader.parse ||
loader.loadAndParse ||
loader.parseStream || // TODO Replace with parseInBatches

@@ -27,3 +26,6 @@ loader.parseInBatches ||

export function normalizeLoader(loader) {
assert(isLoaderObject(loader));
// This error is fairly easy to trigger by mixing up import statments etc
// So we make an exception and add a developer error message for this case
// To help new users from getting stuck here
assert(isLoaderObject(loader), 'invalid loader');

@@ -30,0 +32,0 @@ // NORMALIZE [LOADER, OPTIONS] => LOADER

import {isLoaderObject} from './loader-utils/normalize-loader';
import {mergeLoaderAndUserOptions} from './loader-utils/normalize-options';
import {mergeOptions} from './loader-utils/merge-options';
import {getIteratorFromData} from './loader-utils/get-data';

@@ -22,5 +22,5 @@ import {getLoaderContext} from './loader-utils/get-loader-context';

// Normalize options
options = mergeLoaderAndUserOptions(options, loader);
options = mergeOptions(loader, options);
const context = getLoaderContext({url}, options);
const context = getLoaderContext({url, loaders}, options);

@@ -27,0 +27,0 @@ return parseWithLoaderInBatchesSync(loader, data, options, context);

import {isLoaderObject} from './loader-utils/normalize-loader';
import {mergeLoaderAndUserOptions} from './loader-utils/normalize-options';
import {mergeOptions} from './loader-utils/merge-options';
import {getAsyncIteratorFromData} from './loader-utils/get-data';

@@ -21,5 +21,5 @@ import {getLoaderContext} from './loader-utils/get-loader-context';

// Normalize options
options = mergeLoaderAndUserOptions(options, loader);
options = mergeOptions(loader, options);
const context = getLoaderContext({url}, options);
const context = getLoaderContext({url, loaders}, options);

@@ -26,0 +26,0 @@ return parseWithLoaderInBatches(loader, data, options, context);

import {selectLoader} from './select-loader';
import {isLoaderObject} from './loader-utils/normalize-loader';
import {mergeLoaderAndUserOptions} from './loader-utils/normalize-options';
import {mergeOptions} from './loader-utils/merge-options';
import {getArrayBufferOrStringFromDataSync} from './loader-utils/get-data';
import {getLoaderContext} from './loader-utils/get-loader-context';
import {getLoaders, getLoaderContext} from './loader-utils/get-loader-context';
export function parseSync(data, loaders, options, url) {
export function parseSync(data, loaders, options, context) {
// Signature: parseSync(data, options, url)
// Uses registered loaders
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
url = options;
context = options;
options = loaders;

@@ -16,4 +16,15 @@ loaders = null;

// Chooses a loader and normalize it
const loader = selectLoader(loaders, url, data);
// DEPRECATED - backwards compatibility, last param can be URL...
let url = '';
if (typeof context === 'string') {
url = context;
context = null;
}
options = options || {};
// Chooses a loader (and normalizes it)
// Also use any loaders in the context, new loaders take priority
const candidateLoaders = getLoaders(loaders, context);
const loader = selectLoader(candidateLoaders, url, data);
// Note: if nothrow option was set, it is possible that no loader was found, if so just return null

@@ -25,5 +36,5 @@ if (!loader) {

// Normalize options
options = mergeLoaderAndUserOptions(options, loader);
options = mergeOptions(loader, options);
const context = getLoaderContext({url, parseSync}, options);
context = getLoaderContext({url, parseSync, loaders}, options);

@@ -46,3 +57,3 @@ return parseWithLoaderSync(loader, data, options, context);

// TBD - If synchronous parser not available, return null
throw new Error(`Could not parse ${context.url || 'data'} using ${loader.name} loader`);
throw new Error(`${loader.name}: Loader does not support 'parseSync' (${context.url || 'data'})`);
}
import assert from '../utils/assert';
import {isLoaderObject} from './loader-utils/normalize-loader';
import {mergeLoaderAndUserOptions} from './loader-utils/normalize-options';
import {mergeOptions} from './loader-utils/merge-options';
import {getUrlFromData} from './loader-utils/get-data';
import {getArrayBufferOrStringFromData} from './loader-utils/get-data';
import {getLoaderContext} from './loader-utils/get-loader-context';
import {getLoaders, getLoaderContext} from './loader-utils/get-loader-context';
import parseWithWorker from './loader-utils/parse-with-worker';
import {selectLoader} from './select-loader';
export async function parse(data, loaders, options, url) {
// Signature: parse(data, options, url)
export async function parse(data, loaders, options, context) {
// Signature: parse(data, options, context | url)
// Uses registered loaders
if (loaders && !Array.isArray(loaders) && !isLoaderObject(loaders)) {
url = options;
if (!Array.isArray(loaders) && !isLoaderObject(loaders)) {
context = options;
options = loaders;

@@ -19,2 +19,9 @@ loaders = null;

// DEPRECATED - backwards compatibility, last param can be URL...
let url = '';
if (typeof context === 'string') {
url = context;
context = null;
}
options = options || {};

@@ -25,9 +32,16 @@

// Chooses a loader and normalize it
const loader = selectLoader(loaders, autoUrl, data);
// Chooses a loader (and normalizes it)
// Also use any loaders in the context, new loaders take priority
const candidateLoaders = getLoaders(loaders, context);
const loader = selectLoader(candidateLoaders, autoUrl, data);
// Note: if nothrow option was set, it is possible that no loader was found, if so just return null
if (!loader) {
return null;
}
// Normalize options
options = mergeLoaderAndUserOptions(options, loader);
options = mergeOptions(loader, options);
const context = getLoaderContext({url: autoUrl, parse}, options);
// Get a context (if already present, will be unchanged)
context = getLoaderContext({url: autoUrl, parse, loaders: candidateLoaders}, options, context);

@@ -64,4 +78,3 @@ return await parseWithLoader(loader, data, options, context);

// TBD - If asynchronous parser not available, return null
// => This loader does not work on loaded data and only supports `loadAndParseAsync`
return assert(false);
}

@@ -14,2 +14,3 @@ import {getRegisteredLoaders} from './register-loaders';

// eslint-disable-next-line complexity
export function selectLoader(loaders, url = '', data = null, {nothrow = false} = {}) {

@@ -27,3 +28,3 @@ url = url || '';

// If no loaders provided, get the registered loaders
loaders = loaders || getRegisteredLoaders();
loaders = [...(loaders || []), ...getRegisteredLoaders()];
normalizeLoaders(loaders);

@@ -41,3 +42,10 @@

}
throw new Error(`No valid loader found for ${url}`);
let message = 'No valid loader found';
if (data) {
message += ` for data starting with "${getFirstCharacters(data)}"`;
}
if (url) {
message += ` for ${url}`;
}
throw new Error(message);
}

@@ -128,2 +136,15 @@

function getFirstCharacters(data, length = 5) {
if (typeof data === 'string') {
return data.slice(0, length);
} else if (ArrayBuffer.isView(data)) {
// Typed Arrays can have offsets into underlying buffer
return getMagicString(data.buffer, data.byteOffset, length);
} else if (data instanceof ArrayBuffer) {
const byteOffset = 0;
return getMagicString(data, byteOffset, length);
}
return '';
}
function getMagicString(arrayBuffer, byteOffset, length) {

@@ -130,0 +151,0 @@ if (arrayBuffer.byteLength <= byteOffset + length) {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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