# sparse-geonames-search

> search through processed geonames cities data without downloading the whole archive

Latest version **1.0.1** (published 2022-07-17) · bsd license · 0 weekly downloads

## Install

```sh
npm install sparse-geonames-search
pnpm add sparse-geonames-search
yarn add sparse-geonames-search
bun add sparse-geonames-search
```

Provides the command `sparse-geonames-search`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-07-17 |
| First published | 2022-06-21 |
| Weekly downloads | 0 |
| License | bsd |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 9.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | substack |

## Links

- npm: https://www.npmjs.com/package/sparse-geonames-search
- npm.io page: https://npm.io/package/sparse-geonames-search

## Dependencies (4)

- [from2](https://npm.io/package/from2.md) ^2.3.0
- [varint](https://npm.io/package/varint.md) ^6.0.0
- [minimist](https://npm.io/package/minimist.md) ^1.2.6
- [length-prefixed-buffers](https://npm.io/package/length-prefixed-buffers.md) ^1.1.0

## Recent versions

- 1.0.1 (latest) — 2022-07-17
- 1.0.0 — 2022-06-21

## README

# sparse-geonames-search

search through [sparse geonames data][sparse-geonames-ingest] without downloading the whole archive

[sparse-geonames-ingest]: https://github.com/peermaps/sparse-geonames-ingest

# example

``` js
var { Transform, pipeline } = require('stream')
var fs = require('fs')
var path = require('path')
var dir = process.argv[2]

var cities = require('sparse-geonames-search')({
  read: (file,cb) => fs.readFile(path.join(dir,file),cb)
})
pipeline(
  cities.search(process.argv.slice(3).join(' ')),
  Transform({
    objectMode: true,
    transform: (row,enc,next) => next(null, JSON.stringify(row)+'\n')
  }),
  process.stdout,
  (err) => { if (err) console.error(err) }
)
```

# usage

```
usage: sparse-geonames-search DIR [QUERY...]

Search for records matching QUERY based on the data located in DIR.

```

# api

``` js
var search = require('sparse-geonames-search')
```

## var s = search(opts)

Create a new instance `s` from:

* `opts.read(file, cb)` - read the complete contents of `file`,
providing the result in `cb(err, buf)`.

## var stream = s.search(query)

Return a readable `stream` of geoname results in objectMode for geonames data matching the string
`query`.

Each `row` from the stream has these fields: 

* row.id
* row.name
* row.longitude
* row.latitude
* row.countryCode
* row.cc2
* row.admin1
* row.admin2
* row.admin3
* row.admin4
* row.population
* row.elevation

## s.getRecord(id, cb)

Get a record by its `id` as `cb(err, record)`.

# install

```
npm install sparse-geonames-search
```

# license

bsd

---
_Source: https://npm.io/package/sparse-geonames-search · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
