• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

visgl / loaders.gl / 25070233425

28 Apr 2026 06:20PM UTC coverage: 59.434% (+0.01%) from 59.423%
25070233425

push

github

web-flow
website: Add tabs for navigating between format docs (#3407)

11310 of 20887 branches covered (54.15%)

Branch coverage included in aggregate %.

89 of 136 new or added lines in 13 files covered. (65.44%)

1742 existing lines in 132 files now uncovered.

23500 of 37682 relevant lines covered (62.36%)

16296.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/modules/compression/src/lib/compression.ts
1
// loaders.gl
2
// SPDX-License-Identifier: MIT
3
// Copyright (c) vis.gl contributors
4

5
// Compression interface
6
import {concatenateArrayBuffersAsync, registerJSModules} from '@loaders.gl/loader-utils';
7

8
/** Compression options */
9
export type CompressionOptions = {
10
  // operation: 'compress' | 'decompress';
11
  modules?: {[moduleName: string]: any};
12
};
13

14
/** Compression */
15
export abstract class Compression {
16
  abstract readonly name: string;
17
  abstract readonly extensions: string[];
18
  abstract readonly contentEncodings: string[];
19
  abstract readonly isSupported: boolean;
20

21
  constructor(options?: CompressionOptions) {
22
    this.compressBatches = this.compressBatches.bind(this);
156✔
23
    this.decompressBatches = this.decompressBatches.bind(this);
156✔
24
  }
25

26
  /** Preloads any dynamic libraries. May enable sync functions */
27
  async preload(modules: Record<string, any> = {}): Promise<void> {
651✔
28
    registerJSModules(modules);
651✔
29
    return;
651✔
30
  }
31

32
  /** Asynchronously compress data */
33
  async compress(input: ArrayBuffer): Promise<ArrayBuffer> {
34
    await this.preload();
36✔
35
    return this.compressSync(input);
36✔
36
  }
37

38
  /** Asynchronously decompress data */
39
  async decompress(input: ArrayBuffer, size?: number): Promise<ArrayBuffer> {
40
    await this.preload();
291✔
41
    return this.decompressSync(input, size);
291✔
42
  }
43

44
  /** Synchronously compress data */
45
  compressSync(input: ArrayBuffer): ArrayBuffer {
46
    throw new Error(`${this.name}: sync compression not supported`);
×
47
  }
48

49
  /** Synchronously compress data */
50
  decompressSync(input: ArrayBuffer, size?: number): ArrayBuffer {
51
    throw new Error(`${this.name}: sync decompression not supported`);
×
52
  }
53

54
  /** Compress batches */
55
  async *compressBatches(
56
    asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>
57
  ): AsyncIterable<ArrayBuffer> {
58
    // TODO - implement incremental compression
UNCOV
59
    const input = await this.concatenate(asyncIterator);
12✔
UNCOV
60
    yield this.compress(input);
12✔
61
  }
62

63
  /** Decompress batches */
64
  async *decompressBatches(
65
    asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>
66
  ): AsyncIterable<ArrayBuffer> {
67
    // TODO - implement incremental compression
UNCOV
68
    const input = await this.concatenate(asyncIterator);
6✔
UNCOV
69
    yield this.decompress(input);
6✔
70
  }
71

72
  // HELPERS
73

74
  protected concatenate(asyncIterator): Promise<ArrayBuffer> {
UNCOV
75
    return concatenateArrayBuffersAsync(asyncIterator);
18✔
76
  }
77

78
  protected improveError(error) {
79
    if (!error.message.includes(this.name)) {
×
80
      error.message = `${this.name} ${error.message}`;
×
81
    }
82
    return error;
×
83
  }
84
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc