Dev Helpers
← Back

Preserve a typed array

Preserve a typed array using Node.js.

Open this example in the interactive library

Source code

import { serialize, deserialize, Serializer, Deserializer } from "node:v8";
const roundTrip = (value) => deserialize(serialize(value));
console.log([...roundTrip(new Uint16Array([1000, 2000]))]);

Sample output

[ 1000, 2000 ]