arquero
arquero copied to clipboard
Arquero with JS and Typescript
I came by to a nice example of using custom table methods in this issue and it raised some further questions on how to use arquero with JS and Typescript. I hope this is valid place to raise this question.
Assuming I am importing arquero in a js module:
import * as aq from 'arquero'
and add following helper method:
aq.addTableMethod('distinctArray', (table, columnName) => {
return table.rollup({ values: aq.op.array_agg_distinct(columnName) }).get('values', 0);
});
Then using it in a table:
const dt = aq.table({ risk: [ 1, 3, 3, 2]});
when I try using it as in example in the same file
dt.distinctArray('risk')
the typescript raises error 'distinctArray not found on ColumnTable'.
Questions:
How i can add this definition so TS is happy?
Another question what if I want to use the distinctArray
in other modules?
Do I need to redefine it every time I import * as aq
, what is the proper approach here?
Is aq a singleton, so no matter how many times i import it it will be the same instance?