This library provides a utility for parsing Network Time Protocol (NTP) UDP response packets into a structured JavaScript object. It adheres to RFC 5905, focusing solely on data extraction rather than time validation or calculations. The current stable version is 0.5.0, with a release cadence that generally follows Node.js LTS cycles, providing support for Node.js 18, 20, and 22. It is actively maintained with recent updates addressing Node.js compatibility and dependency bumps. Its primary differentiator among NTP parsing utilities is its singular focus on robust packet parsing, providing a structured representation of all standard NTP fields without imposing further logic, leaving time synchronization calculations and network interactions to consumer libraries. This strict separation of concerns makes it a reliable low-level building block for higher-level NTP client implementations.
npm install ntp-packet-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import the `NtpPacketParser` and its `NtpPacket` type, then parse a mock raw UDP buffer representing an NTP response into a structured object, accessing its key properties.
Upgrade your Node.js runtime to version 18 or newer.
Upgrade your Node.js runtime to version 14 or newer for versions 0.3.x-0.4.x, or 18+ for 0.5.0+.
Always use version 0.4.1 or higher instead of 0.4.0.
Update to `ntp-packet-parser` version 0.2.1 or newer, especially if your build process includes `ts-node`.
Do not install or use `ntp-packet-parser@0.4.0`. Instead, install `ntp-packet-parser@0.4.1` or the latest version.
For ESM, use `import { NtpPacketParser } from 'ntp-packet-parser';`. For CommonJS, use `const { NtpPacketParser } = require('ntp-packet-parser');`.This library is primarily for Node.js. If you must use it in a browser-like environment, you will need to provide a `Buffer` polyfill (e.g., from `buffer` npm package) and configure your bundler (webpack, rollup, etc.) to use it. Alternatively, consider a browser-specific NTP client if available.
No dependency data recorded yet.