From 4f8a1622ea259b0a939cc4a399476b87d9bd7ead Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sun, 4 Nov 2018 19:30:54 +0000 Subject: [PATCH] Seal: support function-style ctor use; "render" to JSON --- packages/core/src/assertions.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/core/src/assertions.js b/packages/core/src/assertions.js index bbf22a1..a978e66 100644 --- a/packages/core/src/assertions.js +++ b/packages/core/src/assertions.js @@ -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']);