Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arquero with JS and Typescript #246

Open
stopyransky opened this issue Nov 23, 2021 · 0 comments
Open

Arquero with JS and Typescript #246

stopyransky opened this issue Nov 23, 2021 · 0 comments

Comments

@stopyransky
Copy link

stopyransky commented Nov 23, 2021

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant