I've been able to write to stdout using the fs phantomjs module, thus being able to write as binary:

var fs = require('fs');
var stream = fs.open('/dev/stdout', 'wb');
stream.write(String.fromCharCode(128));
stream.flush();

It is still pretty slow for large volume of data, for some reason.

Answer from julien_c on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Uint8ClampedArray
Uint8ClampedArray - JavaScript - MDN Web Docs
July 10, 2025 - // From a length const uint8c = new Uint8ClampedArray(2); uint8c[0] = 42; uint8c[1] = 1337; console.log(uint8c[0]); // 42 console.log(uint8c[1]); // 255 (clamped) console.log(uint8c.length); // 2 console.log(uint8c.BYTES_PER_ELEMENT); // 1 // From an array const x = new Uint8ClampedArray([21, 31]); console.log(x[1]); // 31 // From another TypedArray const y = new Uint8ClampedArray(x); console.log(y[0]); // 21 // From an ArrayBuffer const buffer = new ArrayBuffer(8); const z = new Uint8ClampedArray(buffer, 1, 4); console.log(z.byteOffset); // 1 // From an iterable const iterable = (function* () { yield* [1, 2, 3]; })(); const uint8cFromIterable = new Uint8ClampedArray(iterable); console.log(uint8cFromIterable); // Uint8ClampedArray [1, 2, 3] Polyfill of Uint8ClampedArray in core-js · JavaScript typed arrays guide · TypedArray · ArrayBuffer · DataView · Was this page helpful to you?
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Uint8ClampedArray › Uint8ClampedArray
Uint8ClampedArray() constructor - JavaScript - MDN Web Docs
July 10, 2025 - // From a length const uint8c = new Uint8ClampedArray(2); uint8c[0] = 42; uint8c[1] = 1337; console.log(uint8c[0]); // 42 console.log(uint8c[1]); // 255 (clamped) console.log(uint8c.length); // 2 console.log(uint8c.BYTES_PER_ELEMENT); // 1 // From an array const x = new Uint8ClampedArray([21, 31]); console.log(x[1]); // 31 // From another TypedArray const y = new Uint8ClampedArray(x); console.log(y[0]); // 21 // From an ArrayBuffer const buffer = new ArrayBuffer(8); const z = new Uint8ClampedArray(buffer, 1, 4); console.log(z.byteOffset); // 1 // From an iterable const iterable = (function* () { yield* [1, 2, 3]; })(); const uint8cFromIterable = new Uint8ClampedArray(iterable); console.log(uint8cFromIterable); // Uint8ClampedArray [1, 2, 3] Polyfill of Uint8ClampedArray in core-js · JavaScript typed arrays guide · TypedArray · ArrayBuffer · DataView · Was this page helpful to you?
🌐
Tabnine
tabnine.com › home › code library
Code Library - Tabnine
July 25, 2024 - Get the answers and suggestions you need from our AI code assistant. Get started in minutes with a free 90 day trial of Tabnine Pro.
🌐
MDN
mdn2.netlify.app › en-us › docs › web › javascript › reference › global_objects › uint8clampedarray
Uint8ClampedArray - JavaScript | MDN
February 18, 2022 - // From a length var uintc8 = new Uint8ClampedArray(2); uintc8[0] = 42; uintc8[1] = 1337; console.log(uintc8[0]); // 42 console.log(uintc8[1]); // 255 (clamped) console.log(uintc8.length); // 2 console.log(uintc8.BYTES_PER_ELEMENT); // 1 // From an array var arr = new Uint8ClampedArray([21,31]); console.log(arr[1]); // 31 // From another TypedArray var x = new Uint8ClampedArray([21, 31]); var y = new Uint8ClampedArray(x); console.log(y[0]); // 21 // From an ArrayBuffer var buffer = new ArrayBuffer(8); var z = new Uint8ClampedArray(buffer, 1, 4); // From an iterable var iterable = function*(){ yield* [1,2,3]; }(); var uintc8 = new Uint8ClampedArray(iterable); // Uint8ClampedArray[1, 2, 3] ... Want to fix the problem yourself?
🌐
JavaScripture
javascripture.com › Uint8ClampedArray
Uint8ClampedArray JavaScript API
Gets and sets the element in this at index. index should be between 0 and this.length - 1. Setting an element to a value less than 0 will store 0 and greater than 255 will store 255 in the array. ... Returns the underlying buffer for this Uint8ClampedArray.
🌐
W3cubDocs
docs.w3cub.com › javascript › global_objects › uint8clampedarray
Uint8ClampedArray - JavaScript - W3cubDocs
August 7, 2022 - // From a length const uint8c = new Uint8ClampedArray(2); uint8c[0] = 42; uint8c[1] = 1337; console.log(uint8c[0]); // 42 console.log(uint8c[1]); // 255 (clamped) console.log(uint8c.length); // 2 console.log(uint8c.BYTES_PER_ELEMENT); // 1 // From an array const x = new Uint8ClampedArray([21, 31]); console.log(x[1]); // 31 // From another TypedArray const y = new Uint8ClampedArray(x); console.log(y[0]); // 21 // From an ArrayBuffer const buffer = new ArrayBuffer(8); const z = new Uint8ClampedArray(buffer, 1, 4); console.log(z.byteOffset); // 1 // From an iterable const iterable = (function* () { yield* [1, 2, 3]; })(); const uint8cFromIterable = new Uint8ClampedArray(iterable); console.log(uint8cFromIterable); // Uint8ClampedArray [1, 2, 3] Polyfill of Uint8ClampedArray in core-js · JavaScript typed arrays guide ·
🌐
Java2s
java2s.com › ref › javascript › javascript-uint8clampedarray-buffer.html
Javascript Uint8ClampedArray buffer
The Javascript Uint8ClampedArray buffer property returns the ArrayBuffer referenced by a Uint8ClampedArray.
Find elsewhere
🌐
MDN
mdn2.netlify.app › en-us › docs › web › javascript › reference › global_objects › uint8clampedarray › uint8clampedarray
Uint8ClampedArray() constructor - JavaScript | MDN
February 18, 2022 - // From a length var uintc8 = new Uint8ClampedArray(2); uintc8[0] = 42; uintc8[1] = 1337; console.log(uintc8[0]); // 42 console.log(uintc8[1]); // 255 (clamped) console.log(uintc8.length); // 2 console.log(uintc8.BYTES_PER_ELEMENT); // 1 // From an array var arr = new Uint8ClampedArray([21,31]); console.log(arr[1]); // 31 // From another TypedArray var x = new Uint8ClampedArray([21, 31]); var y = new Uint8ClampedArray(x); console.log(y[0]); // 21 // From an ArrayBuffer var buffer = new ArrayBuffer(8); var z = new Uint8ClampedArray(buffer, 1, 4); // From an iterable var iterable = function*(){ yield* [1,2,3]; }(); var uintc8 = new Uint8ClampedArray(iterable); // Uint8ClampedArray[1, 2, 3] BCD tables only load in the browser · Starting with ECMAScript 2015, Uint8ClampedArray constructors require to be constructed with a new operator.
🌐
GitHub
github.com › stdlib-js › array-uint8c
GitHub - stdlib-js/array-uint8c: Uint8ClampedArray. · GitHub
Creates a new typed array view over the same underlying ArrayBuffer and with the same underlying data type as the host array. var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); var arr2 = arr1.subarray(); // returns <Uint8ClampedArray>[ 1, 2, ...
Author: stdlib-js
🌐
GitHub
github.com › lovell › sharp › issues › 549
Pipe buffer image data into Uint8ClampedArray format · Issue #549 · lovell/sharp
August 22, 2016 - The .data property of the ImageData object appears to be a Uint8ClampedArray that reads [r1, g1, b1, a1, r2, g2, b2, a2.....] Looking at the pattern, every fourth number is 255 which makes sense as none of the image is transparent at all. I am trying to get this to work in Node.JS in a similar fashion, except I am getting my image data from a buffer generated by smarp see code below:
Author: lovell
🌐
UDN Web Docs
udn.realityripple.com › docs › Mozilla › js-ctypes › Using_js-ctypes › Working_with_ArrayBuffers
Working with ArrayBuffers - UDN Web Docs: MDN Backup
// pixelBuffer is a pointer to ... imgHeight = 400; var myImgDat = new ImageData(imgWidth, imgHeight); One method is to get into a js-ctypes array, and then set it into the ImageData, as illustrated by the following code example....
🌐
JavaScript.info
javascript.info › tutorial › binary data, files
ArrayBuffer, binary arrays
July 11, 2022 - let arr8 = new Uint8Array([0, 1, ... – for integer numbers of 8, 16 and 32 bits. Uint8ClampedArray – for 8-bit integers, “clamps” them on assignment (see below)....
🌐
Bun
bun.sh › guides › binary › arraybuffer-to-typedarray
Convert an ArrayBuffer to a Uint8Array - Bun
const buffer = new ArrayBuffer(64); const arr = new Uint8Array(buffer);
🌐
Reality Ripple
udn.realityripple.com › docs › Web › JavaScript › Reference › Global_Objects › Uint8ClampedArray
Uint8ClampedArray - JavaScript - UDN Web Docs: MDN Backup
// From a length var uintc8 = new Uint8ClampedArray(2); uintc8[0] = 42; uintc8[1] = 1337; console.log(uintc8[0]); // 42 console.log(uintc8[1]); // 255 (clamped) console.log(uintc8.length); // 2 console.log(uintc8.BYTES_PER_ELEMENT); // 1 // From an array var arr = new Uint8ClampedArray([21,31]); console.log(arr[1]); // 31 // From another TypedArray var x = new Uint8ClampedArray([21, 31]); var y = new Uint8ClampedArray(x); console.log(y[0]); // 21 // From an ArrayBuffer var buffer = new ArrayBuffer(8); var z = new Uint8ClampedArray(buffer, 1, 4); // From an iterable var iterable = function*(){ yield* [1,2,3]; }(); var uintc8 = new Uint8ClampedArray(iterable); // Uint8ClampedArray[1, 2, 3] The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
🌐
Rust
docs.rs › js-sys › latest › js_sys › struct.Uint8ClampedArray.html
Uint8ClampedArray in js_sys - Rust
An Uint8ClampedArray() which creates an array with the given buffer but is a view starting at byte_offset for length elements. ... The fill() method fills all the elements of an array from a start index to an end index with a static value.