What is @loaders.gl/loader-utils?
@loaders.gl/loader-utils is a utility library that provides a set of tools and helper functions for working with data loaders. It is part of the larger loaders.gl framework, which is designed to handle various data formats and provide efficient data loading and processing capabilities.
What are @loaders.gl/loader-utils's main functionalities?
Data Conversion
Converts various data types to ArrayBuffer. This is useful for standardizing data formats before processing.
const { toArrayBuffer } = require('@loaders.gl/loader-utils');
const buffer = toArrayBuffer(new Uint8Array([1, 2, 3]));
console.log(buffer);
Data Parsing
Parses JSON strings into JavaScript objects. This is useful for handling JSON data received from various sources.
const { parseJSON } = require('@loaders.gl/loader-utils');
const jsonData = parseJSON('{"key": "value"}');
console.log(jsonData);
Data Encoding
Encodes data into Base64 format. This is useful for encoding binary data into a text format that can be easily transmitted.
const { encodeBase64 } = require('@loaders.gl/loader-utils');
const base64String = encodeBase64(new Uint8Array([1, 2, 3]));
console.log(base64String);
Other packages similar to @loaders.gl/loader-utils
buffer
The 'buffer' package provides a way of handling binary data in Node.js. It offers similar functionalities for data conversion and manipulation, but it is more focused on low-level operations compared to the higher-level utilities provided by @loaders.gl/loader-utils.
json5
The 'json5' package allows for parsing and stringifying JSON with more features than the standard JSON object. It offers similar JSON parsing capabilities but with additional features like comments and trailing commas, which are not supported by @loaders.gl/loader-utils.
base64-js
The 'base64-js' package provides utilities for encoding and decoding Base64 data. It offers similar Base64 encoding functionalities but is more specialized and does not include the broader range of utilities found in @loaders.gl/loader-utils.
@loaders.gl/loader-utils
This module contains shared utilities for loaders.gl, a collection of framework-independent 3D and geospatial loaders (parsers).
For documentation please visit the website.