Skip to content

Commit

Permalink
v8: add a js class for Serializer/Deserializer
Browse files Browse the repository at this point in the history
Calling Serializer/Deserializer without new crashes node.
Adding a js class which just inherits cpp bindings.
Added regression tests.

Fixes: nodejs#13326
  • Loading branch information
zimbabao committed Jun 9, 2017
1 parent 9643c6c commit 955a1bb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/v8.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,20 @@
'use strict';

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

class Serializer extends serdesBindings.Serializer {}
// Calling exposed c++ functions directly throws exception as it expected to be
// called with new operator and caused an assert to fire.
// Creating JS wrapper so that it gets caught at JS layer.
class Serializer extends _Serializer { }

class Deserializer extends serdesBindings.Deserializer {}
class Deserializer extends _Deserializer { }

const {
cachedDataVersionTag,
Expand Down

0 comments on commit 955a1bb

Please sign in to comment.