Comparing version
@@ -16,2 +16,3 @@ /// <reference types="node" /> | ||
encode(): Promise<Buffer>; | ||
verifyRecord(): void; | ||
} | ||
@@ -18,0 +19,0 @@ export declare function AvroSchema({ name, namespace }?: { |
@@ -34,3 +34,2 @@ "use strict"; | ||
encode() { | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -43,8 +42,3 @@ const ctor = this[CTOR]; | ||
catch (err) { | ||
const fields = (_c = (_b = (_a = ctor) === null || _a === void 0 ? void 0 : _a['schema']) === null || _b === void 0 ? void 0 : _b['_fieldsByName']) !== null && _c !== void 0 ? _c : {}; | ||
for (const field in fields) { | ||
if (typeof this[field] === 'undefined') { | ||
throw new Error(`${ctor.name} has no value defined for "${field}"`); | ||
} | ||
} | ||
this.verifyRecord(); | ||
throw err; | ||
@@ -54,2 +48,12 @@ } | ||
} | ||
verifyRecord() { | ||
var _a, _b; | ||
const ctor = this[CTOR]; | ||
const fields = (_b = (_a = ctor.schema) === null || _a === void 0 ? void 0 : _a._fieldsByName) !== null && _b !== void 0 ? _b : {}; | ||
for (const field in fields) { | ||
if (typeof this[field] === 'undefined') { | ||
throw new Error(`${ctor.name} has no value defined for "${field}"`); | ||
} | ||
} | ||
} | ||
} | ||
@@ -56,0 +60,0 @@ exports.Avro = Avro; |
{ | ||
"name": "avsc-tsc", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Utility library to encode and decode typescript classes in Avro format", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
18536
0.57%244
2.09%