Skip to content

[Enhancement] Make lookup() method accept named params #27

Description

@prescience-data

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?

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions