Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
6 changes: 5 additions & 1 deletion lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
'use strict';

const { Buffer } = require('buffer');
const { Serializer, Deserializer } = process.binding('serdes');
const serdesBindings = process.binding('serdes');
const { copy } = process.binding('buffer');
const { objectToString } = require('internal/util');
const { FastBuffer } = require('internal/buffer');

class Serializer extends serdesBindings.Serializer {}

class Deserializer extends serdesBindings.Deserializer {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer something like:

const { Serializer: _Serializer, Deserializer: _Deserializer } = process.binding('serdes');
// ...

class Serializer extends _Serializer { }
class Deserializer extends _Deserializer { }

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will resend.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jasnell : Made changes and added a note.


const {
cachedDataVersionTag,
setFlagsFromString,
Expand Down
16 changes: 16 additions & 0 deletions test/parallel/test-v8-serdes.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,19 @@ const objects = [

assert.deepStrictEqual(v8.deserialize(buf), expectedResult);
}

{
try {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use assert.throws() for these.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cjihrig : Made suggested changes.

v8.Serializer();
} catch (e) {
const m = "Class constructor Serializer cannot be invoked without 'new'";
assert.strictEqual(e.message, m);
}

try {
v8.Deserializer();
} catch (e) {
const m = "Class constructor Deserializer cannot be invoked without 'new'";
assert.strictEqual(e.message, m);
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should likely also add a note to the documentation clarifying the requirement