
Product
Introducing Custom Tabs for Org Alerts
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.
mode-s-decoder
Advanced tools
A library to decode a binary Mode S message to an easy to use JavaScript object
A library to decode a binary Mode S message to an easy to use JavaScript object.
npm install mode-s-decoder --save
const Decoder = require('mode-s-decoder')
const decoder = new Decoder()
const data = new Uint8Array([0x8f, 0x46, 0x1f, 0x36, 0x60, 0x4d, 0x74, 0x82, 0xe4, 0x4d, 0x97, 0xbc, 0xd6, 0x4e])
const message = decoder.parse(data)
console.log(message)
Decoder.UNIT_FEETA constant indicating that the unit used is feet. Used to check the unit
of the message using the message.unit property.
Decoder.UNIT_METERSA constant indicating that the unit used is meters. Used to check the
unit of the message using the message.unit property.
decoder = new Decoder([options])Initialize a new decoder object.
Arguments:
options - An optional options objectThe available options are:
fixErrors - Set to false to disable automatic error correction
(default: true)aggressive - Set to true to enable aggressive error correction
algorithm. Only used if fixErrors is true (default: false)message = decoder.parse(data[, crcOnly])Parse a binary Mode S message into an easy to use JavaScript object.
Arguments:
data - A binary Mode S message (e.g. a Buffer or Uint8Array object)crcOnly - Optional boolean indicating if the decoder should only
validate the checksum. If true, the returned message object will
only contain the properties msg, msgtype, msgbits, crc, and
crcOk (default: false)Returns a message object containing the decoded message.
It's recommended to use this module together with the mode-s-aircraft-store module. This allows you easy access to the decoded latitude and longitude as this information cannot be read from a single Mode S message, but needs multiple concurrent messages in order to be properly decoded:
const message = decoder.parse(data)
// store is an instance of AircraftStore from the mode-s-aircraft-store module
store.addMessage(message)
// ...
// later after storing multiple messages, output list of aircrafts:
store.getAircrafts().forEach(function (aircraft) {
const unit = aircraft.unit === Decoder.UNIT_FEET ? 'feet' : 'meters'
console.log('Aircraft:\n' +
` ID: ${aircraft.icao}\n` +
` Altitude: ${aircraft.altitude} ${unit}\n` +
` Speed: ${aircraft.speed}\n` +
` Heading: ${aircraft.heading}\n` +
` Latitude: ${aircraft.lat}\n` +
` Longitude: ${aircraft.lng}\n`)
})
MIT
FAQs
A library to decode a binary Mode S message to an easy to use JavaScript object
The npm package mode-s-decoder receives a total of 59 weekly downloads. As such, mode-s-decoder popularity was classified as not popular.
We found that mode-s-decoder demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Product
Create and share saved alert views with custom tabs on the org alerts page, making it easier for teams to return to consistent, named filter sets.

Product
Socket’s Rust and Cargo support is now generally available, providing dependency analysis and supply chain visibility for Rust projects.

Security News
Chrome 144 introduces the Temporal API, a modern approach to date and time handling designed to fix long-standing issues with JavaScript’s Date object.