Socket
Socket
Sign inDemoInstall

csa

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csa

Route Planner on top of data published using Connections


Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Connection Scan Algorithm for JavaScript

Build Status

State:

  • basic csa without footpaths is functional

  • merger that combines different streams of connections is functional

The Connection Scan Algorithm (CSA) for Javascript takes a stream of "connections" and transforms it into a stream of solutions to get from a certain stop to a certain stop. The algorithm will find the earliest arrival times first, and will return alternatives as long as the stream runs.

Use it

You can install the library using npm:

npm install csa

And include it in your nodejs application

var csa = require('csa');
var planner = new csa.BasicCSA({departureStop: "...", arrivalStop: "...",departureTime:new Date()});
connectionsReadStream.pipe(planner);
planner.on("result", function (result) {
    console.log("Path found:",result);
    connectionsReadStream.close();
});
planner.on("data", function (connection) {
    //Access to a minimum spanning tree of connections being built up
    //May be useful for e.g., creating isochrone maps
});

Multiple connection streams

Instead of using one stream of connections, you can combine multiple streams as input by using MergeStream

var connectionsStreams = [
	[ 'stream1', connectionsReadStream1 ],
	[ 'stream2', connectionsReadStream2 ],
	...
];

var connectionsReadStream = new csa.MergeStream(connectionsStreams, query.departureTime);

You can add streams by setting an eventlistener on the MergeStream instance. To remove a stream, just end the stream itself.

connectionsReadStream.on("data", function (connection) {
	connectionsReadStream.addConnectionsStream('newStream', newConnectionsReadStream);
});

Protip: you can use browserify on this repo to use CSA in the browser

Keywords

FAQs

Package last updated on 26 Jan 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