Seal: support function-style ctor use; "render" to JSON

This commit is contained in:
Tony Garnock-Jones 2018-11-04 19:30:54 +00:00
parent aad64bf33c
commit 4f8a1622ea
1 changed files with 12 additions and 0 deletions

View File

@ -20,9 +20,21 @@
var Struct = require('./struct.js');
function Seal(contents) {
if (this === void 0) {
return new Seal(contents);
}
this.contents = contents;
}
Seal.prototype.toJSON = function () {
// This definition is useless for actual transport, of course, but
// useful for debugging, inasmuch as it seals off the contents from
// the view of the JSON renderer, which has trouble with e.g. cyclic
// data.
return { '@seal': 0 };
};
module.exports.Observe = Struct.makeConstructor('Observe', ['specification']);
module.exports.Seal = Seal;
module.exports.Inbound = Struct.makeConstructor('Inbound', ['assertion']);