[Enhancement] Make lookup() method accept named params
Opened this issue · 3 comments
prescience-data commented
Currently, the main lookup method is configured to accept a series of params:
async lookup(ip?: string, selectField?: string, fields?: string[])
The issue is if you are wanting to set only one of these, you need to pass undefined
to the preceding params.
A common pattern to help solve this scenario would be:
export interface LookupParams {
ip?: string
selectField?: string
fields?: string[]
}
// ... main class
{
async lookup({ ip, selectField, fields }: LookupParams = {}) {
// ... lookup logic
}
}
Naturally, changing the shape of the method signature is a tricky undertaking, so potentially you could run a type check on the first param and keep the existing ones to allow backward compatibility?
Berand-cod commented
Great!
jonathan-kosgei commented
@thomasconner thoughts?
thomasconner commented
Yes this would be much better. I think a major version bump would be better to help people opt in rather then trying to maintain backwards compatibility. I can work on making this change this week.