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

dvbjs-es6

v0.0.1

Published

A simple library wrapping queries to Dresden's public transport system for bus and tramstop data. Uses ES6 features and promises"

Downloads

9

Readme

dvbjs

travis-ci npmversion

An unofficial node module giving you a few options to query Dresden's public transport system for current bus- and tramstop data.

In case you're looking for something like this for Python, check out dvbpy.

Install and require the module to get started.

$ npm install dvbjs
var dvb = require('dvbjs');

Monitor a single stop

Monitor a single stop to see every bus or tram leaving this stop after the specified time offset.

var stopName = "Helmholtzstraße";
var timeOffset = 0; // how many minutes in the future, 0 for now
var numResults = 2;

dvb.monitor(stopName, timeOffset, numResults, function(err, data){
    if (!err) {
        console.log(data);
    }
});
[{
    line: '85',
    direction: 'Striesen',
    arrivaltime: 14
}, {
    line: '85',
    direction: 'Löbtau Süd',
    arrivaltime: 20
}]

Find routes

Query the server for possible routes from one stop to another. Returns multiple possible trips, the bus-/tramlines to be taken, the single stops, their arrival and departure times and their GPS coordinates.

var origin = "Helmholtzstraße";
var destination  = "Zellescher Weg";
var time = new Date();
var deparr = 0; // set to 0 for the time to be the departure time, 1 for arrival time

dvb.route(origin, destination, time, deparr, function(err, data){
    if (!err) {
        console.log(data);
    }
});
{
    "origin": "Dresden, Helmholtzstraße",
    "destination": "Dresden, Zellescher Weg",
    "trips": [{
        "departure": "13:34",
        "arrival": "13:56",
        "duration": "00:22",
        "interchange": 2,
        "nodes": [{
            "mode": "Stadtbus",
            "line": "85",
            "direction": "DD Löbtau Süd Mohorner Str.",
            "departure": {
                "stop": "Helmholtzstraße",
                "time": "13:34",
                "coords": [ 51.025549, 13.725457 ]
            },
            "arrival": {
                "stop": "Plauen Nöthnitzer Straße",
                "time": "13:36",
                "coords": [ 51.027625, 13.715769 ]
            },
            "path": [[ 51.02554, 13.725471 ],[ 51.02557, 13.725286 ], ...]
        },
        {...}
        ]
    }, {
        "departure": "14:02",
        "arrival": "14:11",
        "duration": "00:09",
        "interchange": 1,
        "nodes": [...]
    },
    {...}
    ]
}

The path property contains an array consisting of all the coordinates describing the path of this node. Useful for example to draw on a map.

A note: A simple console.log of the returned data will look slightly different as js objects will only be displayed as Object at a certain depth. They're still there though. Use console.log(JSON.stringify(data, null, 4)); for example to view it in your console.

Find stops

Search for a single stop in the network of the DVB. Returns an array of all possible hits including their GPS coordinates.

dvb.find('zellesch', function(err, data){
    if (!err) {
        console.log(data);
    }
});
[{
    stop: 'Zellescher Weg',
    coords: [51.028366, 13.745847]
}]

Other stuff

By the way, stop names in queries are very forgiving. As long as the server sees it as a unique hit, it'll work. 'Helmholtzstraße' finds the same data as 'helmholtzstrasse', 'Nürnberger Platz' = 'nuernbergerplatz' etc.

One last note, be sure not to run whatever it is you're building from inside the network of the TU Dresden (at least as far as I can tell). Calls to everything but dvb.monitor() will time out. If I could tell you why their site won't give me much info from inside eduroam I would.