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

visgl / loaders.gl / 24139120841

08 Apr 2026 01:53PM UTC coverage: 65.319% (+30.2%) from 35.137%
24139120841

push

github

web-flow
chore: Replace puppeteer with playwright (#3350)

14216 of 18890 branches covered (75.26%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 1 file covered. (100.0%)

3248 existing lines in 369 files now uncovered.

73509 of 115413 relevant lines covered (63.69%)

5763.45 hits per line

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

71.28
/modules/core/src/lib/api/encode-table.ts
1
// loaders.gl
1✔
2
// SPDX-License-Identifier: MIT
1✔
3
// Copyright (c) vis.gl contributors
1✔
4
// Copyright 2022 Foursquare Labs, Inc
27✔
5

27✔
6
/* global TextEncoder, TextDecoder */
27✔
7
import {
27✔
8
  concatenateArrayBuffers,
27✔
9
  ensureArrayBuffer,
27✔
10
  WriterOptionsType,
27✔
11
  WriterWithEncoder
27✔
12
} from '@loaders.gl/loader-utils';
27!
UNCOV
13
import type {Table} from '@loaders.gl/schema';
×
UNCOV
14

×
15
export async function encodeTable<WriterT extends WriterWithEncoder = WriterWithEncoder>(
✔
16
  data: Table,
27✔
17
  writer: WriterT,
27✔
18
  options?: WriterOptionsType<WriterT>
27✔
19
): Promise<ArrayBuffer> {
27✔
20
  if (writer.encode) {
27✔
21
    return await writer.encode(data, options);
27✔
22
  }
27✔
23

×
24
  if (writer.encodeText) {
×
25
    const text = await writer.encodeText(data, options);
×
26
    return ensureArrayBuffer(new TextEncoder().encode(text));
×
27
  }
×
28

×
29
  if (writer.encodeInBatches) {
×
30
    // Create an iterator representing the data
×
31
    // TODO - Assumes this is a table
×
32
    const batches = encodeTableInBatches(data, writer, options);
✔
33

27✔
34
    // Concatenate the output
27✔
35
    const chunks: ArrayBuffer[] = [];
27!
36
    for await (const batch of batches) {
27✔
37
      chunks.push(batch);
27✔
38
    }
27✔
39
    return concatenateArrayBuffers(...chunks);
27✔
40
  }
27✔
41

27✔
42
  throw new Error('Writer could not encode data');
27!
43
}
×
UNCOV
44

×
45
export async function encodeTableAsText<WriterT extends WriterWithEncoder = WriterWithEncoder>(
✔
46
  data: Table,
27✔
47
  writer: WriterT,
27✔
48
  options?: WriterOptionsType<WriterT>
27✔
49
): Promise<string> {
1✔
50
  if (writer.text && writer.encodeText) {
1!
51
    return await writer.encodeText(data, options);
1✔
52
  }
1✔
53

1✔
54
  if (writer.text) {
1✔
55
    const arrayBuffer = await encodeTable(data, writer, options);
1!
56
    return new TextDecoder().decode(arrayBuffer);
1✔
57
  }
27✔
58
  throw new Error(`Writer ${writer.name} could not encode data as text`);
1!
59
}
1✔
60

1✔
61
export function encodeTableInBatches<WriterT extends WriterWithEncoder = WriterWithEncoder>(
1✔
62
  data: Table,
1✔
63
  writer: WriterT,
1✔
64
  options?: WriterOptionsType<WriterT>
1✔
65
): AsyncIterable<ArrayBuffer> {
1✔
66
  if (writer.encodeInBatches) {
1✔
67
    const dataIterator = getIterator(data);
1✔
68
    // @ts-expect-error
1✔
69
    return writer.encodeInBatches(dataIterator, options);
1✔
70
  }
1✔
71
  // TODO -fall back to atomic encode?
×
72
  throw new Error('Writer could not encode data in batches');
×
73
}
×
74

1✔
75
function getIterator(data: any): Iterable<{start: number; end: number}> {
1✔
76
  const dataIterator = [{...data, start: 0, end: data.length}];
1✔
77
  return dataIterator;
1✔
78
}
1✔
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