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

visgl / loaders.gl / 25798238260

13 May 2026 12:10PM UTC coverage: 60.607% (+0.3%) from 60.27%
25798238260

push

github

web-flow
feat(json) GeoJSON -> geoarrow, schema, logging  (#3399)

13466 of 24516 branches covered (54.93%)

Branch coverage included in aggregate %.

448 of 541 new or added lines in 12 files covered. (82.81%)

1264 existing lines in 117 files now uncovered.

27516 of 43103 relevant lines covered (63.84%)

15056.99 hits per line

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

100.0
/modules/polyfills/src/images/encode-image-node.ts
1
// Use stackgl modules for DOM-less reading and writing of images
2

3
import savePixels from 'save-pixels';
4
import ndarray from 'ndarray';
5
import {bufferToArrayBuffer} from '../buffer/to-array-buffer.node';
6

7
/**
8
 * Returns data bytes representing a compressed image in PNG or JPG format,
9
 * This data can be saved using file system (f) methods or
10
 * used in a request.
11
 * @param image to save
12
 * @param options
13
 * @param options.type='png' - png, jpg or image/png, image/jpg are valid
14
 * @param options.dataURI - Whether to include a data URI header
15
 * @return {*} bytes
16
 */
17
export function encodeImageToStreamNode(
18
  image: {data: any; width: number; height: number},
19
  options: {type?: string; dataURI?: string}
20
) {
21
  // Support MIME type strings
UNCOV
22
  const type = options.type ? options.type.replace('image/', '') : 'jpeg';
3✔
UNCOV
23
  const pixels = ndarray(image.data, [image.width, image.height, 4], [4, image.width * 4, 1], 0);
3✔
24

25
  // Note: savePixels returns a stream
UNCOV
26
  return savePixels(pixels, type, options);
3✔
27
}
28

29
export function encodeImageNode(image, options) {
UNCOV
30
  const imageStream = encodeImageToStreamNode(image, options);
3✔
31

UNCOV
32
  return new Promise(resolve => {
3✔
UNCOV
33
    const buffers: any[] = [];
3✔
UNCOV
34
    imageStream.on('data', buffer => buffers.push(buffer));
7✔
35
    // TODO - convert to arraybuffer?
UNCOV
36
    imageStream.on('end', () => {
3✔
UNCOV
37
      const buffer = Buffer.concat(buffers);
3✔
UNCOV
38
      resolve(bufferToArrayBuffer(buffer));
3✔
39
    });
40
  });
41
}
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