diffusion
Version:
Diffusion JavaScript client
62 lines (61 loc) • 2.38 kB
JavaScript
;
/**
* @module diffusion.datatypes
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.JSONDataTypeImpl = void 0;
var abstract_datatype_1 = require("./../../data/abstract-datatype");
var json_impl_1 = require("./../../data/json/json-impl");
var function_1 = require("./../../util/function");
/**
* A data type for JSON values
*/
var JSONDataTypeImpl = /** @class */ (function (_super) {
__extends(JSONDataTypeImpl, _super);
/**
* Create a new JSONDataTypeImpl instance
*/
function JSONDataTypeImpl() {
var _this = _super.call(this, 'json', json_impl_1.JSONImpl, json_impl_1.JSONImpl, json_impl_1.JSONImpl.from, function_1.identity, [], true) || this;
/**
* The implementation of the underlying value type
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
_this.JSON = json_impl_1.JSONImpl;
return _this;
}
JSONDataTypeImpl.prototype.fromJsonString = function (value) {
return json_impl_1.JSONImpl.from(JSON.parse(value));
};
/**
* Create a new JSON instance from data
*
* @param value the CBOR data containing the record
* @return a new JSON instance
*/
JSONDataTypeImpl.prototype.from = function (object) {
return json_impl_1.JSONImpl.from(object);
};
/**
* @inheritdoc
*/
JSONDataTypeImpl.prototype.validate = function () {
// no-op. This data type validates on read.
};
return JSONDataTypeImpl;
}(abstract_datatype_1.AbstractDataType));
exports.JSONDataTypeImpl = JSONDataTypeImpl;