Comparing version 3.1.2 to 4.0.0
@@ -22,7 +22,7 @@ 'use strict'; | ||
const team = new Teamwork(); | ||
const team = new Teamwork.Team(); | ||
// Set timeout | ||
const timeoutId = (settings.timeout ? setTimeout(() => team.attend(new Boom('Timeout')), settings.timeout) : null); | ||
const timeoutId = settings.timeout ? setTimeout(() => team.attend(new Boom.Boom('Timeout')), settings.timeout) : null; | ||
@@ -43,3 +43,3 @@ // Create UDP socket | ||
if (!message.isValid) { | ||
const error = new Boom('Invalid server response'); | ||
const error = new Boom.Boom('Invalid server response'); | ||
error.time = message; | ||
@@ -50,3 +50,3 @@ return team.attend(error); | ||
if (message.originateTimestamp !== sent) { | ||
const error = new Boom('Wrong originate timestamp'); | ||
const error = new Boom.Boom('Wrong originate timestamp'); | ||
error.time = message; | ||
@@ -108,3 +108,3 @@ return team.attend(error); | ||
return team.attend(err || new Boom('Could not send entire message')); | ||
return team.attend(err || new Boom.Boom('Could not send entire message')); | ||
} | ||
@@ -111,0 +111,0 @@ }); |
@@ -1,2 +0,2 @@ | ||
Copyright (c) 2012-2019, Sideway Inc, and project contributors | ||
Copyright (c) 2012-2020, Sideway Inc, and project contributors | ||
All rights reserved. | ||
@@ -3,0 +3,0 @@ |
{ | ||
"name": "@hapi/sntp", | ||
"description": "SNTP Client", | ||
"version": "3.1.2", | ||
"version": "4.0.0", | ||
"repository": "git://github.com/hapijs/sntp", | ||
"main": "lib/index.js", | ||
"files": [ | ||
"lib" | ||
], | ||
"keywords": [ | ||
@@ -13,10 +16,10 @@ "sntp", | ||
"dependencies": { | ||
"@hapi/boom": "7.x.x", | ||
"@hapi/bounce": "1.x.x", | ||
"@hapi/hoek": "8.x.x", | ||
"@hapi/teamwork": "3.x.x" | ||
"@hapi/boom": "9.x.x", | ||
"@hapi/bounce": "2.x.x", | ||
"@hapi/hoek": "9.x.x", | ||
"@hapi/teamwork": "4.x.x" | ||
}, | ||
"devDependencies": { | ||
"@hapi/code": "6.x.x", | ||
"@hapi/lab": "20.x.x" | ||
"@hapi/code": "8.x.x", | ||
"@hapi/lab": "22.x.x" | ||
}, | ||
@@ -23,0 +26,0 @@ "scripts": { |
@@ -1,77 +0,17 @@ | ||
<a href="http://hapijs.com"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a> | ||
<a href="https://hapi.dev"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a> | ||
# sntp | ||
# @hapi/sntp | ||
An SNTP v4 client (RFC4330) for node. Simpy connects to the NTP or SNTP server requested and returns the server time | ||
along with the roundtrip duration and clock offset. To adjust the local time to the NTP time, add the returned `t` offset | ||
to the local time. | ||
#### SNTP client (REF4330) for node. | ||
[![Build Status](https://secure.travis-ci.org/hapijs/sntp.svg?branch=master)](http://travis-ci.org/hapijs/sntp) | ||
**sntp** is part of the **hapi** ecosystem and was designed to work seamlessly with the [hapi web framework](https://hapi.dev) and its other components (but works great on its own or with other frameworks). If you are using a different web framework and find this module useful, check out [hapi](https://hapi.dev) – they work even better together. | ||
# Usage | ||
### Visit the [hapi.dev](https://hapi.dev) Developer Portal for tutorials, documentation, and support | ||
```javascript | ||
const Sntp = require('@hapi/sntp'); | ||
## Useful resources | ||
// All options are optional | ||
const options = { | ||
host: 'nist1-sj.ustiming.org', // Defaults to pool.ntp.org | ||
port: 123, // Defaults to 123 (NTP) | ||
resolveReference: true, // Default to false (not resolving) | ||
timeout: 1000 // Defaults to zero (no timeout) | ||
}; | ||
// Request server time | ||
const exec = async function () { | ||
try { | ||
const time = await Sntp.time(options); | ||
console.log('Local clock is off by: ' + time.t + ' milliseconds'); | ||
process.exit(0); | ||
} | ||
catch (err) { | ||
console.log('Failed: ' + err.message); | ||
process.exit(1); | ||
} | ||
}; | ||
exec(); | ||
``` | ||
If an application needs to maintain continuous time synchronization, the module provides a stateful method for | ||
querying the current offset only when the last one is too old (defaults to daily). | ||
```javascript | ||
// Request offset once | ||
const exec = async function () { | ||
const offset1 = await Sntp.offset(); | ||
console.log(offset1); // New (served fresh) | ||
// Request offset again | ||
const offset2 = await Sntp.offset(); | ||
console.log(offset2); // Identical (served from cache) | ||
}; | ||
exec(); | ||
``` | ||
To set a background offset refresh, start the interval and use the provided now() method. If for any reason the | ||
client fails to obtain an up-to-date offset, the current system clock is used. | ||
```javascript | ||
const before = Sntp.now(); // System time without offset | ||
const exec = async function () { | ||
await Sntp.start(); | ||
const now = Sntp.now(); // With offset | ||
Sntp.stop(); | ||
}; | ||
exec(); | ||
``` | ||
- [Documentation and API](https://hapi.dev/family/sntp/) | ||
- [Versions status](https://hapi.dev/resources/status/#sntp) (builds, dependencies, node versions, licenses, eol) | ||
- [Changelog](https://hapi.dev/family/sntp/changelog/) | ||
- [Project policies](https://hapi.dev/policies/) | ||
- [Free and commercial support options](https://hapi.dev/support/) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12399
4
18
+ Added@hapi/boom@9.1.4(transitive)
+ Added@hapi/bounce@2.0.0(transitive)
+ Added@hapi/hoek@9.3.0(transitive)
+ Added@hapi/teamwork@4.0.0(transitive)
- Removed@hapi/boom@7.4.11(transitive)
- Removed@hapi/bounce@1.3.2(transitive)
- Removed@hapi/hoek@8.5.1(transitive)
- Removed@hapi/teamwork@3.3.1(transitive)
Updated@hapi/boom@9.x.x
Updated@hapi/bounce@2.x.x
Updated@hapi/hoek@9.x.x
Updated@hapi/teamwork@4.x.x