Seal: support function-style ctor use; "render" to JSON
This commit is contained in:
parent
aad64bf33c
commit
4f8a1622ea
|
@ -20,9 +20,21 @@
|
||||||
var Struct = require('./struct.js');
|
var Struct = require('./struct.js');
|
||||||
|
|
||||||
function Seal(contents) {
|
function Seal(contents) {
|
||||||
|
if (this === void 0) {
|
||||||
|
return new Seal(contents);
|
||||||
|
}
|
||||||
|
|
||||||
this.contents = 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.Observe = Struct.makeConstructor('Observe', ['specification']);
|
||||||
module.exports.Seal = Seal;
|
module.exports.Seal = Seal;
|
||||||
module.exports.Inbound = Struct.makeConstructor('Inbound', ['assertion']);
|
module.exports.Inbound = Struct.makeConstructor('Inbound', ['assertion']);
|
||||||
|
|
Loading…
Reference in New Issue