A package for common files and functions between the various @openrailuk packages


3.4.03 years ago3 years agoMinified + gzip package size for @openrailuk/common in KB


country license npm (scoped) status pipeline coverage slack

A package for common files and functions between the various open rail UK packages


This repository is hosted on GitLab as common-nodejs. The GitHub repository is a downstream repository where all changes from GitLab are pushed. Please raise any issues or pull requests on the GitLab repository.


To use the common-nodejs package you need to import the required classes and functions in which your application needs, this can be done as follows:

import { Location, Station } from '@openrailuk/common';

or this for everything:

import * as common from '@openrailuk/common');

an example of using the classes:

import { Station } from '@openrailuk/common';

const station = new Station(stationRefDataJSON);


or if you want to convert a large array of stations 'stationArr' into there respective Station class:

import { Station } from '@openrailuk/common';

const stations = stationArr.map(station => new Station(station));

Mixins can be applied to all of the base models that this package provides. A sample mixin would be as follows:

const mixin = (SuperClass) => {
  return class StationMix extends SuperClass {
    constructor(payload) { super(payload); }

    newFunction(params) { return 'stuff'; }

and this can be applied by calling (re replacing station with the intended class to apply the mixin too:

import * as common from '@openrailuk/common';



You might be wondering where to find information about how to use this package, fear not all documentation for open rail packages can be found on the doc site and documentation specific to this package can be found under @openrailuk/common

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.