node-ntp-client icon indicating copy to clipboard operation
node-ntp-client copied to clipboard

Add NTP stratum info

Open SomKen opened this issue 1 year ago • 0 comments

  • Update library to provide access to the stratum info of the given NTP server.
  • Updated Readme to include how to get just the time (existing example) and how to get the stratum info too.
  • Fix error in Node 22+ with buffer allocation (See below)
  • Add test for stratum

This package seems dead, but as it's still available via npm, I'm making this PR in hopes that it will be added to the main project. I'm happy to update anything else requested, but this is enough to get me going with my own project.

Node error seen in v22:

(node:60851) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Unit test:

$ npm test

> [email protected] test
> grunt jshint nodeunit

Running "jshint:gruntfile" (jshint) task
>> 1 file lint free.

Running "jshint:lib" (jshint) task
>> 1 file lint free.

Running "jshint:test" (jshint) task
>> 1 file lint free.

Running "nodeunit:files" (nodeunit) task
Testing ntp-client_test.js..
System reported : Sun Dec 29 2024 17:39:36 GMT-0800 (Pacific Standard Time)
NTP Reported : Sun Dec 29 2024 17:39:36 GMT-0800 (Pacific Standard Time)
.
System reported : Sun Dec 29 2024 17:39:36 GMT-0800 (Pacific Standard Time)
NTP Reported : Sun Dec 29 2024 17:39:36 GMT-0800 (Pacific Standard Time)
Stratum Reported : 2
..OK
>> 11 assertions passed (5186ms)

Done.

SomKen avatar Dec 30 '24 01:12 SomKen