@loaders.gl/loader-utils
Version:
Framework-independent loaders for 3D graphics formats
27 lines (26 loc) • 749 B
JavaScript
// __VERSION__ is injected by babel-plugin-version-inline
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
const VERSION = typeof "4.3.2" !== 'undefined' ? "4.3.2" : 'latest';
/**
* A JSON Micro loader (minimal bundle size)
* Alternative to `@loaders.gl/json`
*/
export const JSONLoader = {
dataType: null,
batchType: null,
name: 'JSON',
id: 'json',
module: 'json',
version: VERSION,
extensions: ['json', 'geojson'],
mimeTypes: ['application/json'],
category: 'json',
text: true,
parseTextSync,
parse: async (arrayBuffer) => parseTextSync(new TextDecoder().decode(arrayBuffer)),
options: {}
};
// TODO - Better error handling!
function parseTextSync(text) {
return JSON.parse(text);
}