@jsonjoy.com/json-type
Version:
High-performance JSON Pointer implementation
47 lines (46 loc) • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Value = void 0;
const tree_dump_1 = require("tree-dump");
class Value {
constructor(type, data) {
this.type = type;
this.data = data;
}
// /**
// * @deprecated
// * @todo Remove this method in the future.
// */
// public encode(codec: JsonValueCodec): void {
// const value = this.data;
// const type = this.type;
// if (value === undefined) return;
// const encoder = codec.encoder;
// if (!type) encoder.writeAny(value);
// else type.encoder(codec.format)(value, encoder);
// }
toString(tab = '') {
return 'Value' + (0, tree_dump_1.printTree)(tab, [(tab) => this.type.toString(tab)]);
}
}
exports.Value = Value;
// if (process.env.NODE_ENV !== 'production') {
// const encode = Value.prototype.encode;
// Value.prototype.encode = function (codec: JsonValueCodec): void {
// try {
// encode.call(this, codec);
// } catch (error) {
// try {
// // tslint:disable-next-line no-console
// console.error(error);
// const type = this.type;
// if (type) {
// const err = type.validator('object')(this.data);
// // tslint:disable-next-line no-console
// console.error(err);
// }
// } catch {}
// throw error;
// }
// };
// }