# @digitransit-search-util/digitransit-search-util-query-utils

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

## verify

Verifies that the data for favourites is coherent and current and fixes errors

### Parameters

*   `stopStationMap`  
*   `favourites`  

## setRelayEnvironment

Set you Relay environment

### Parameters

*   `environment` **any** Your Relay environment

## getModesWithAlerts

Get alerts for modes

### Parameters

*   `currentTime` **[Number][1]** Epoch time
*   `feedIds` **[Array][2]** Array of feedId Strings (optional, default `null`)

## getStopAndStationsQuery

Returns Stop and station objects .

### Parameters

*   `favourites` **any** 

## filterStopsAndStationsByMode

Returns Stop and station objects filtered by given mode based on mode information
acquired from OTP by checking the modes of the departures on the given stops.

### Parameters

*   `stopsToFilter` **any** 
*   `mode` **[String][3]** 

## getRoutesByIds

Returns Route objects matching the provided GTFS IDs.

### Parameters

*   `ids` **[Array][2]<[String][3]>** Route GTFS IDs to query.
*   `pathOpts`  an object containing two properties routesPrefix and stopsPrefix to override the URL paths returned
    by this method

Returns **[Promise][4]<[Array][2]>** A promise resolving to the matching route objects.

## getFavouriteRoutesQuery

Returns Favourite Route objects depending on input

### Parameters

*   `favourites` **any** 
*   `input` **[String][3]** Search text, if empty no objects are returned
*   `transportMode` **[String][3]** If provided, all returned route objects are of this mode, e.g. 'BUS'
*   `pathOpts`  an object containing two properties routesPrefix and stopsPrefix to override the URL paths returned
    by this method

## getFavouriteVehicleRentalStationsQuery

Returns Favourite VehicleRentalStation objects depending on input

### Parameters

*   `favourites` **any** 
*   `input` **[String][3]** Search text, if empty no objects are returned

## getRoutesQuery

Returns Route objects depending on input

### Parameters

*   `input` **[String][3]** Search text, if empty no objects are returned
*   `feedIds` **any** 
*   `transportMode` **[String][3]** Filter routes with a transport mode, e.g. route-BUS
*   `pathOpts`  an object containing two properties routesPrefix and stopsPrefix to override the URL paths returned
    by this method

## filterSearchResultsByMode

Can be used to filter stops and stations by a given mode

### Parameters

*   `results` **any** search results from geocoding
*   `mode` **any** e.g 'BUS' or 'TRAM'
*   `type` **any** type of search results to filter, e.g 'Stops' or 'Routes'. This function only filters Stops because routes can be filtered with the query itself (optional, default `'Stops'`)

[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number

[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array

[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String

[4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise
---

This module is part of the Digitransit-ui project. It is maintained in the
[HSLdevcom/digitransit-ui](https://github.com/HSLdevcom/digitransit-ui) repository, where you can create
PRs and issues.

### Installation

Install this module individually:

```sh
$ npm install @digitransit-search-util/digitransit-search-util-query-utils
```
