@gmod/bed
Version:
A BED file format parser with autoSql support
24 lines • 981 B
JavaScript
/*
* adds some type annotations to the autoSql schema for numeric fields ['uint',
* 'int', 'float', 'long'] "isNumeric" is added for array types "isArray" is
* added for numeric array types "isArray" and "arrayIsNumeric" is set
*
* @param autoSql - an autoSql schema from the peg parser
* @return autoSql with type annotations added
*/
export function detectTypes(autoSql) {
const numericTypes = new Set(['uint', 'int', 'float', 'long']);
return {
...autoSql,
fields: autoSql.fields
.map(autoField => ({
...autoField,
isArray: autoField.size && autoField.type !== 'char',
arrayIsNumeric: autoField.size && numericTypes.has(autoField.type),
isNumeric: !autoField.size && numericTypes.has(autoField.type),
}))
// this is needed because the autoSql doesn't properly parse comments in the autoSql
.filter(f => !!f.name),
};
}
//# sourceMappingURL=util.js.map