Installations
npm install osrm-text-instructions
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
16.20.2
NPM Version
8.19.4
Score
93.8
Supply Chain
92.7
Quality
84
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
Project-OSRM
Download Statistics
Total Downloads
2,197,730
Last Day
735
Last Week
9,953
Last Month
63,018
Last Year
688,085
GitHub Statistics
89 Stars
621 Commits
64 Forks
60 Watching
19 Branches
56 Contributors
Package Meta Information
Latest Version
0.15.0
Package Id
osrm-text-instructions@0.15.0
Unpacked Size
2.51 MB
Size
278.16 kB
File Count
844
NPM Version
8.19.4
Node Version
16.20.2
Publised On
03 Mar 2024
Total Downloads
Cumulative downloads
Total Downloads
2,197,730
Last day
-72.8%
735
Compared to previous day
Last week
-31.3%
9,953
Compared to previous week
Last month
-0.8%
63,018
Compared to previous month
Last year
44.5%
688,085
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
5
OSRM Text Instructions
OSRM Text Instructions is a Node.js library that transforms route data generated by OSRM into localized turn instructions to be displayed visually or read aloud by a text-to-speech engine. OSRM Text Instructions is the basis of guidance instructions in osrm-frontend, the Mapbox Directions API, and the Mapbox Navigation SDK.
- Global: Text instructions are available in over a dozen languages via Transifex. Abbreviations and advanced grammatical transformations are available in some languages.
- Customizable: Flexible options allow you to format and tweak the results to your liking.
- Cross-platform: A data-driven approach facilitates implementations in other programming languages. OSRM Text Instructions is also available in Swift and Objective-C (for iOS, macOS, tvOS, and watchOS) and in Java (for Android and Java SE).
- Well-tested: A data-driven test suite ensures compatibility across languages and platforms.
Usage
1var version = 'v5'; 2var osrmTextInstructions = require('osrm-text-instructions')(version); 3 4response.legs.forEach(function(leg) { 5 leg.steps.forEach(function(step) { 6 instruction = osrmTextInstructions.compile('en', step, options) 7 }); 8});
If you are unsure if the user's locale is supported by osrm-text-inustrctions, use @mapbox/locale-utils for finding the best fitting language.
Parameters require('osrm-text-instructions')(version)
parameter | required? | values | description |
---|---|---|---|
version | required | v5 | Major OSRM version |
Parameters compile(language, step, options)
parameter | required? | values | description |
---|---|---|---|
language | required | en de zh-Hans fr nl ru and more | Compiling instructions for the selected language code. |
step | required | OSRM route step object | The RouteStep as it comes out of OSRM |
options | optional | Object | See below |
Options
key | type | description |
---|---|---|
legCount | integer | Number of legs in the route |
legIndex | integer | Zero-based index of the leg containing the step; together with legCount , this option determines which waypoint the user has arrived at |
formatToken | function | Function that formats the given token value after grammaticalization and capitalization but before the value is inserted into the instruction string; useful for wrapping tokens in markup |
waypointName | string | Optional custom name for the leg's destination, replaces "your {nth} destination" |
formatToken
takes two parameters:
token
: A string that indicates the kind of token, such asway_name
ordirection
value
: A grammatical string for this token, capitalized if the token appears at the beginning of the instruction
and returns a string.
Architecture
- index.js contains the main transformation logic in JavaScript.
- languages/ contains the localization files, including raw format strings, abbreviation files, and grammar rules.
- languages.js loads the localizations and contains some localization-related helper functions.
- test/ contains data-driven integration tests and test fixtures for all supported languages.
Contributing
We welcome feedback, code contributions, and translations! Please see CONTRIBUTING.md for details.
No vulnerabilities found.
Reason
all changesets reviewed
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Info: FSF or OSI recognized license: BSD 2-Clause "Simplified" License: LICENSE.txt:0
Reason
3 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Score
4.5
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More