vbb-find-stations
Advanced tools
Comparing version 1.5.0 to 1.6.0
14
index.js
@@ -14,9 +14,15 @@ 'use strict' | ||
const exact = (query) => filter.obj((station) => { | ||
const exact = (query) => through.obj(function (station, _, cb) { | ||
const tokens = Array.from(station.tokens) | ||
for (let fragment of query) { | ||
const i = tokens.indexOf(fragment) | ||
if (i < 0) {tokens.splice(i, 1); return false} | ||
if (i < 0) { | ||
tokens.splice(i, 1) | ||
return cb() | ||
} | ||
} | ||
return true | ||
station = Object.assign({type: 'station'}, station) | ||
this.push(station) | ||
cb() | ||
}) | ||
@@ -47,3 +53,3 @@ | ||
} | ||
station = Object.assign({relevance}, station) | ||
station = Object.assign({type: 'station', relevance}, station) | ||
this.push(station) | ||
@@ -50,0 +56,0 @@ cb() |
{ | ||
"name": "vbb-find-stations", | ||
"description": "Search for stations of VBB.", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "files": ["index.js", "stations.ndjson"], |
@@ -5,8 +5,6 @@ # vbb-find-stations | ||
*Note*: [*vbb-stations-autocomplete*](https://github.com/derhuerst/vbb-stations-autocomplete) devilers the `n` most relevant stations for a query, this module returns all that match the query. | ||
*Note*: [*vbb-stations-autocomplete*](https://github.com/derhuerst/vbb-stations-autocomplete) delivers the `n` most relevant stations for a query, this module returns all that match the query. | ||
[![npm version](https://img.shields.io/npm/v/vbb-find-stations.svg)](https://www.npmjs.com/package/vbb-find-stations) | ||
[![build status](https://img.shields.io/travis/derhuerst/vbb-find-stations.svg)](https://travis-ci.org/derhuerst/vbb-find-stations) | ||
[![dependency status](https://img.shields.io/david/derhuerst/vbb-find-stations.svg)](https://david-dm.org/derhuerst/vbb-find-stations) | ||
[![dev dependency status](https://img.shields.io/david/dev/derhuerst/vbb-find-stations.svg)](https://david-dm.org/derhuerst/vbb-find-stations#info=devDependencies) | ||
![ISC-licensed](https://img.shields.io/github/license/derhuerst/vbb-find-stations.svg) | ||
@@ -33,12 +31,39 @@ [![gitter channel](https://badges.gitter.im/derhuerst/vbb-rest.svg)](https://gitter.im/derhuerst/vbb-rest) | ||
findStations('U Steglitz') | ||
.on('data', (s) => console.log(s.id, s.name)) | ||
.on('data', console.log) | ||
``` | ||
The stream emits stations in the [*Friendly Public Transport Format*](https://github.com/public-transport/friendly-public-transport-format). | ||
```js | ||
{ | ||
type: 'station', | ||
id: '900000062202', | ||
name: 'S+U Rathaus Steglitz (Berlin)', | ||
tokens: ['sbahn', 'ubahn', 'rathaus', 'steglitz', 'berlin'] | ||
} | ||
{ | ||
type: 'station', | ||
id: '900000062282', | ||
name: 'S+U Rathaus Steglitz/Kreisel (Berlin)', | ||
tokens: ['sbahn', 'ubahn', 'rathaus', 'steglitz', 'kreisel', 'berlin'] | ||
} | ||
{ | ||
type: 'station', | ||
id: '900000062781', | ||
name: 'S+U Rathaus Steglitz (Berlin) [U9]', | ||
tokens: ['sbahn', 'ubahn', 'rathaus', 'steglitz', 'berlin', 'u9'] | ||
} | ||
{ | ||
type: 'station', | ||
id: '900000062782', | ||
name: 'S+U Rathaus Steglitz (Berlin) [Bus Schloßstr.]', | ||
tokens: ['sbahn', 'ubahn', 'rathaus', 'steglitz', 'berlin', 'bus', 'schloss', 'strasse'] | ||
} | ||
{ | ||
type: 'station', | ||
id: '900000062784', | ||
name: 'S+U Rathaus Steglitz (Berlin) [Bus Albrechtstr.]', | ||
tokens: ['sbahn', 'ubahn', 'rathaus', 'steglitz', 'berlin', 'bus', 'albrecht', 'strasse'] | ||
} | ||
``` | ||
900000062202 S+U Rathaus Steglitz (Berlin) | ||
900000062282 S+U Rathaus Steglitz/Kreisel (Berlin) | ||
900000062781 S+U Rathaus Steglitz (Berlin) [U9] | ||
900000062782 S+U Rathaus Steglitz (Berlin) [Bus Schloßstr.] | ||
900000062784 S+U Rathaus Steglitz (Berlin) [Bus Albrechtstr.] | ||
``` | ||
@@ -45,0 +70,0 @@ |
1251672
57
72