2.1.2 • Published 6 years ago

openraildata-common v2.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

openraildata-common

npm GitHub issues GitHub release GitHub license David David Maintainability Test Coverage Known Vulnerabilities

A package for common files and functions between the various openraildata packages

usage

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

const { Location, Station } = require('openraildata-common');

or this for everything:

const common = require('openraildata-common');

the currently available classes that can be used are listed below

an example of using the classes are:

const station = new Station(stationRefDataJSON);

console.log(station.plannedTimeOfArrival);

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

const stations = stationArr.map(station => new common.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(parms) { return 'stuff'; }
  };
};

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

const common = require('openraildata-common);

common.stationMixer(mixin);

all the functions for this are documented in the API docs

2.1.2

6 years ago

2.1.1

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.7.0

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.1

7 years ago

1.5.0

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.2

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.0

7 years ago