Skip to main content

LoaderOptions

APIs in @loaders.gl/core takes an options?: LoaderOptions parameter. The options are documented on this page.

Loader specific options

The options object can contain loader specific options. The options for each loader are supplied in a sub object, see the documentation for each loader for details:

{
csv: {
shape: 'row-object-table'
},
json: {
shape: 'row-object-table'
}
}

Top-level options

Top level options are interpreted by the core API and apply to all loaders.

OptionTypeDefaultDescription
options.fetchobject or function-Specifies either a RequestInit object containing options to pass to fetchFile, or a function that is called in place of fetchFile to fetch data in any subloaders.
options.nothrowbooleanfalseSpecifies either an object with options to pass to fetchFile, or a function that is called in place of fetchFile to fetch data in any subloaders.
options.mimeTypestring-Loader selection will first look for a loader matching mimeType. A specific loaders can be specified using 'application/x-<loader.id>'
options.fallbackMimeTypestring-Loader selection a fallback mimeType in case not provided by server. A specific loader can be specified with 'application/x-<loader.id>'
options.logobjectconsoleBy default set to a console wrapper. Setting log to null will turn off logging.
options.workerbooleantrueRuns the loader on a worker thread, if the selected loader and the runtime environment support it.
options.maxConcurrencynumber3How many worker instances should be created for each loader. Note that setting this higher than roughly the number CPU cores on your current machine will not provide much benefit and may create extra overhead.
option.maxMobileConcurrencynumber1How many worker instances should be created for each loader on mobile devices. Mobile devicee have fewer cores and less memory available.
options.reuseWorkersbooleantrueBy default, worker threads are kept in memory and reused. But if reuseWorkers is false workers will be automatically terminated after job completion and reloaded for each job.
options.<loader-id>.workerUrlstringper-loaderIf the corresponding loader can parse on a worker, the url to the worker script can be controller with this option.
options.modulesobject-Supply bundled modules (like draco3d) instead of loading from CDN.
options.CDN (🚧 experimental)string-Controls certain script loading from CDN. true loads from unpkg.com/@loaders.gl. false load from local urls. string alternate CDN url.

Batched parsing options

| Option | Type | Default | Description | | ---------------------------- | --------- | ------- | --------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | | options.metadata | boolean | false | An initial batch with batchType: 'metadata' will be added with information about the data being loaded. | | options.batches.chunkSize? | number | N/A | When set, "atomic" inputs (like ArrayBuffer or string) are chunked, enabling batched parsing. | No effect if input is already an iterator or stream. | | options.transforms | *[] | [] | An array with transform functions that can be applied to the input data before parsing. |

Notes:

  • transforms is an array functions that accept and return an AsyncIterable<ArrayBuffer>