diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2024-03-18 13:48:55 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-18 13:48:55 +0530 |
commit | bd6938ac7070bbfb367f0a41b20a18bfa27e8ee8 (patch) | |
tree | fa08a196e9342814aedd776d551829c72eba5e6b /ext/node/polyfills/v8.ts | |
parent | becdad531f2b56684133b3b7ea25169c7102f765 (diff) |
fix(node): implement v8 serialize and deserialize (#22975)
Fixes https://github.com/denoland/deno/issues/22971
Diffstat (limited to 'ext/node/polyfills/v8.ts')
-rw-r--r-- | ext/node/polyfills/v8.ts | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/node/polyfills/v8.ts b/ext/node/polyfills/v8.ts index a1ea16430..cad00bd7f 100644 --- a/ext/node/polyfills/v8.ts +++ b/ext/node/polyfills/v8.ts @@ -1,14 +1,19 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // Copyright Joyent and Node contributors. All rights reserved. MIT license. +/// <reference path="../../core/internal.d.ts" /> + // TODO(petamoriken): enable prefer-primordials for node polyfills // deno-lint-ignore-file prefer-primordials +import { core } from "ext:core/mod.js"; import { op_v8_cached_data_version_tag, op_v8_get_heap_statistics, } from "ext:core/ops"; +import { Buffer } from "node:buffer"; + import { notImplemented } from "ext:deno_node/_utils.ts"; export function cachedDataVersionTag() { @@ -66,11 +71,11 @@ export function takeCoverage() { export function writeHeapSnapshot() { notImplemented("v8.writeHeapSnapshot"); } -export function serialize() { - notImplemented("v8.serialize"); +export function serialize(value) { + return Buffer.from(core.serialize(value)); } -export function deserialize() { - notImplemented("v8.deserialize"); +export function deserialize(data) { + return core.deserialize(data); } export class Serializer { constructor() { |