UNPKG

s2-tools

Version:

A collection of geospatial tools primarily designed for WGS84, Web Mercator, and S2.

53 lines 1.51 kB
export * from './pmtiles'; /** Buffer writer is used on smaller datasets that are easy to write in memory. Faster then the Filesystem */ export class BufferWriter { #buffer = []; #textEncoder = new TextEncoder(); /** * Append data to the buffer * @param data - the data to append */ async append(data) { for (let i = 0; i < data.byteLength; i++) this.#buffer.push(data[i]); await true; } /** * Append string to the buffer * @param string - the string to append */ async appendString(string) { await this.append(this.#textEncoder.encode(string)); } /** * Append data to the buffer synchronously * @param data - the data to append */ appendSync(data) { for (let i = 0; i < data.byteLength; i++) this.#buffer.push(data[i]); } /** * Append string to the buffer synchronously * @param string - the string to append */ appendStringSync(string) { this.appendSync(this.#textEncoder.encode(string)); } /** * Write data to the buffer * @param data - the data to write * @param offset - where in the buffer to start */ async write(data, offset) { for (let i = 0; i < data.byteLength; i++) { this.#buffer[offset + i] = data[i]; } await true; } /** @returns - the buffer */ commit() { return new Uint8Array(this.#buffer); } } //# sourceMappingURL=index.js.map