Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

osrm-text-instructions

Package Overview
Dependencies
Maintainers
7
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

osrm-text-instructions

OSRM Text Instructions

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-0.96%
Maintainers
7
Weekly downloads
 
Created
Source

osrm-text-instructions

Build Status


WIP: This project is under heavy development and should not be integrated yet.

osrm-text-instructions transforms OSRM route responses into text instructions. It currently has only an implementation in JavaScript, with more to come.

Design goals

  • Cross platform Use a data-driven approach that makes implementations in other programming environments easy to write
  • Test suite Have a data-driven test suite with fixtures which can be used cross-platform
  • Translation Allow for translations via Transifex
  • Customization Users should be able to easily fork or monkey patch the results to adjust to their own likings

Javascript Usage

var version = 'v5';
var language = 'en';
var options = {};
var osrmTextInstructions = require('osrm-text-instructions')(version, language, options);

// make your request against the API

response.legs.forEach(function(leg) {
  leg.steps.forEach(function(step) {
    instruction = osrmTextInstructions.compile(step)
  });
});
parameterrequired?valuesdescription
versionrequiredv5Major OSRM version
languagerequireden de zh-Hans fr nlLanguage identifier
options.hooks.tokenizedIstructionoptionalfunction(instruction)A function to change the raw instruction string before tokens are replaced. Useful to inject custom markup for tokens

Development

Architecture
  • index.js holds the main transformation logic in javascript
  • instructions/ holds the translateable strings
Tests

Tests are data-driven integration tests for the english language.

To run them yourself for the JavaScript implementation:

npm install
npm test
Generate Fixtures

Fixtures can be programatically created and updated via scripts/generate_fixtures.js. To update the instructions in the fixture files, run UPDATE=1 npm test.

Translations

To add own translations:

  • Create a new file in instructions/
  • Translate the string values
  • Add the new instructions file to instructions.js
  • Add the new instructions file to the languages array in test/instructions_test.js
  • To manually look at your changes, run LANGUAGE=<language_tag> npm test. This will give you failing (since untranslated) tests
  • Make a PR
Release
  • git checkout master
  • Update CHANGELOG.md
  • Bump version in package.json
  • git commit -am "vx.y.z" with Changelog list in commit message
  • git tag vx.y.z -a with Changelog list in tag message
  • git push origin master; git push origin --tags
  • npm publish

FAQs

Package last updated on 17 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc