Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: handle Float16Array in node:v8 serdes #55996

Merged
merged 11 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ function arrayBufferViewTypeToIndex(abView) {
// Index 10 is FastBuffer.
if (type === '[object BigInt64Array]') return 11;
if (type === '[object BigUint64Array]') return 12;
if (type === '[object Float16Array]') return 13;
return -1;
}

Expand All @@ -306,6 +307,9 @@ function arrayBufferViewIndexToType(index) {
if (index === 10) return FastBuffer;
if (index === 11) return BigInt64Array;
if (index === 12) return BigUint64Array;
// TODO(bartlomieju): use a primordial, once `Float16Array` is available in stable V8
// eslint-disable-line no-undef
if (index === 13) return Float16Array;
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
return undefined;
}

Expand Down
5 changes: 4 additions & 1 deletion test/parallel/test-v8-serdes.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Flags: --expose-internals
// Flags: --expose-internals --js-float16array

'use strict';

Expand Down Expand Up @@ -26,6 +26,9 @@
Buffer.from([1, 2, 3, 4]),
new BigInt64Array([42n]),
new BigUint64Array([42n]),
// TODO(bartlomieju): once `Float16Array` is available in stable V8, remove the lint below and `--js-float16array` flag up top

Check failure on line 29 in test/parallel/test-v8-serdes.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

This line has a length of 128. Maximum allowed is 120
bartlomieju marked this conversation as resolved.
Show resolved Hide resolved
// eslint-disable-line no-undef
new Float16Array([1, 2, 3, 4]),
undefined,
null,
42,
Expand Down
Loading