avro-typescript
Version:
TypeScript code generator for Apache Avro types
41 lines (40 loc) • 1.06 kB
JavaScript
;
/**** Contains the Interfaces and Type Guards for Avro schema */
Object.defineProperty(exports, "__esModule", { value: true });
exports.isRecordType = isRecordType;
exports.isArrayType = isArrayType;
exports.isMapType = isMapType;
exports.isEnumType = isEnumType;
exports.isFixedType = isFixedType;
exports.isUnion = isUnion;
exports.isOptional = isOptional;
exports.isLogicalType = isLogicalType;
function isRecordType(type) {
return type.type === "record";
}
function isArrayType(type) {
return type.type === "array";
}
function isMapType(type) {
return type.type === "map";
}
function isEnumType(type) {
return type.type === "enum";
}
function isFixedType(type) {
return type.type === "fixed";
}
function isUnion(type) {
return type instanceof Array;
}
function isOptional(type) {
if (isUnion(type)) {
var t1 = type[0];
if (typeof t1 === "string") {
return t1 === "null";
}
}
}
function isLogicalType(type) {
return typeof type !== "string" && "logicalType" in type;
}