libxmljs
Version:
libxml bindings for v8 javascript engine
48 lines • 1.51 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.XMLReference = exports.createXMLReferenceOrThrow = exports.createXMLReference = void 0;
var getBindings = require("bindings");
var bindings = getBindings("xmljs");
var refMap = new WeakMap();
function createXMLReference(constructorFn, _ref) {
if (_ref === null) {
return null;
}
var instance = refMap.get(_ref);
if (!instance) {
instance = new constructorFn(_ref);
refMap.set(_ref, instance);
}
return instance;
}
exports.createXMLReference = createXMLReference;
function createXMLReferenceOrThrow(constructorFn, _ref, error) {
var ref = createXMLReference(constructorFn, _ref);
if (ref === null) {
throw new Error(error);
}
return ref;
}
exports.createXMLReferenceOrThrow = createXMLReferenceOrThrow;
var XMLReference = (function () {
function XMLReference(_ref) {
this._ref = _ref;
}
XMLReference.prototype.getNativeReference = function () {
if (this._ref === null) {
throw new Error("Unexpected null reference");
}
return this._ref;
};
XMLReference.prototype.setNativeReference = function (ref) {
if (ref === null) {
throw new Error("Unexpected null reference");
}
this._ref = ref;
refMap.set(ref, this);
};
return XMLReference;
}());
exports.XMLReference = XMLReference;
exports.default = bindings;
//# sourceMappingURL=index.js.map
;