Skip to content

Commit 259a6c9

Browse files
AnandChowdharyGitSquared
authored andcommitted
Add TypeScript usage docs with response type
1 parent d30a451 commit 259a6c9

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ dbWatcher.on('update', () => {
8383
dbWatcher.close();
8484
```
8585

86+
### Usage with TypeScript
87+
88+
This package includes its own types and you can pass the response type in `open`:
89+
90+
```ts
91+
import geolite2 from 'geolite2-redist';
92+
import maxmind, { CityResponse } from 'maxmind';
93+
94+
(async () => {
95+
let lookup = await geolite2.open<CityResponse>('GeoLite2-City', path => {
96+
return maxmind.open(path);
97+
});
98+
99+
let city = lookup.get('66.6.44.4');
100+
101+
// Call this when done to empty node's event loop
102+
lookup.close();
103+
})();
104+
```
105+
86106
## API
87107

88108
### Methods

0 commit comments

Comments
 (0)