npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lc-client

v0.1.3

Published

Linked Connections Client lets you plan public transit routes over the web of data

Downloads

37

Readme

Linked Connections Client for javascript

Status: Proof of Concept

A javascript library to use intermodal route planning advice in the browser or in your nodejs applications.

Install and use it

Install it:

npm install lc-client #for adding it to your $PATH add -g

For use on the command line:

# uses by default the config-example.json which comes with this repo
lcc -c config.json '{"arrivalStop" : "", "departureStop" : "", "departureTime": ""}'

You can also use the demo queries added in the queries folder.

Use it as a library:

var Client = require('lc-client');
var planner = new Client({"entrypoints" : ["http://belgianrail.linkedconnections.org/"]});
planner.query({"arrivalStop" : "", "departureStop" : "", "departureTime": ""}, function (resultStream, source) {
  resultStream.on('result', function (path) {
    console.log(path);
  });
  resultStream.on('data', function (connection) {
    console.log(connection);
    //if you're not interested anymore, you can stop the processing by doing this
    if (stop_condition) {
      source.close();
    }
  });
  //you can also count the number of HTTP requests done by the interface as follows
  source.on('request', function (url) {
    console.log('Requesting', url);
  });
  //you can also catch when a response is generated HTTP requests done by the interface as follows
  source.on('response', function (url) {
    console.log('Response received for', url);
  });
});

Using it in the browser works in a similar way, by e.g., using browserify to generate a build file that can be used in the browser

browserify lib/lc-client.js -d -p [minifyify --no-map] > dist/build.js

You can also use our latest compiled version:

<script src='http://demo.linkedconnections.org/lc-client-latest.js'></script>
<script>
var planner = new window.lc.Client({"entrypoints" : ["http://belgianrail.linkedconnections.org/"]});
//...
</script>

Within your script, you also use the Fetcher to have a stream of all connections:

//1. Instantiate a fetcher
var fetcher = new require('lc-client').Fetcher({"entrypoints" : ["http://belgianrail.linkedconnections.org/"]});
//2. Use an empty query to get all connections from the sources configured in the fetcher
fetcher.buildConnectionsStream({}, function (connectionsStream) {
  connectionsStream.on('data', function (connection) {
    //do something with connection here
  });
});

How it works

The Linked Connections client plans routes over Linked Connections. These are hydra-powered hypermedia APIs that describe their things uisng the Linked Connections vocabulary. Furthermore, the objects returned in the document are ordere by departureTime.

The Client will start downloading schedule data from publicly available and discoverable locations on the Web. It will follow links to discover new documents.

More info can be found at http://linkedconnections.org

License

The Linked Connections client is written by Pieter Colpaert, Brecht Van de Vyvere and colleagues.

This code is copyrighted by Ghent University – iMinds and released under the MIT license.