Home

Awesome

search-flix-locations

Search for Flix/Flixbus/Meinfernbus regions & stations.

asciicast

npm version build status ISC-licensed chat on gitter support me on Patreon

Installing

npm install search-flix-locations

Usage

autocomplete(query, limit = 6, fuzzy = false, completion = true)
const pick = require('lodash.pick')
const search = require('search-flix-locations')

console.log(search('berlin', 5))
[ {
    id: '88',
    name: 'Berlin',
    type: 'region',
    relevance: 3.455855112783178,
    score: 27.984681385568972,
    weight: 531
}, {
    id: '1224',
    name: 'Berlin Alexanderplatz',
    type: 'station',
    relevance: 1.727927556391589,
    score: 7.743542752920189,
    weight: 90
}, {
    id: '481',
    name: 'Berlin Südkreuz',
    type: 'station',
    relevance: 1.727927556391589,
    score: 7.445414138704126,
    weight: 80
}, {
    id: '471',
    name: 'Berlin SXF',
    type: 'station',
    relevance: 1.727927556391589,
    score: 7.121282437290776,
    weight: 70
}, {
    id: '2825',
    name: 'Berlin Zoo',
    type: 'station',
    relevance: 1.727927556391589,
    score: 5.369072671153364,
    weight: 30
} ]

If you set fuzzy to true, words with a Levenshtein distance <= 3 will be taken into account. This is a lot slower though.

Contributing

If you have a question, found a bug or want to propose a feature, have a look at the issues page.