Merge pull request #33603 from adamzerella/types/sntp

[sntp] Add typing for sntp
This commit is contained in:
Gabriela Britto
2019-03-06 11:34:46 -08:00
committed by GitHub
4 changed files with 87 additions and 0 deletions

41
types/sntp/index.d.ts vendored Normal file
View File

@@ -0,0 +1,41 @@
// Type definitions for sntp 3.0
// Project: https://github.com/hueniverse/sntp
// Definitions by: Adam Zerella <https://github.com/adamzerella>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface Options {
host?: string;
port?: number;
resolveReference?: boolean;
timeout?: number;
}
export interface TimeOptions {
isValid: boolean;
leapIndicator: string;
version: number;
mode: string;
stratum: string;
pollInterval: number;
precision: number;
rootDelay: number;
rootDispersion: number;
referenceId: string;
referenceTimestamp: number;
originateTimestamp: number;
receiveTimestamp: number;
transmitTimestamp: number;
d: number;
t: number;
receivedLocally: number;
}
export function start(options?: Options): Promise<void>;
export function stop(): void;
export function offset(): Promise<number>;
export function time(options?: Options): Promise<TimeOptions>;
export function now(): number;

18
types/sntp/sntp-tests.ts Normal file
View File

@@ -0,0 +1,18 @@
import Sntp = require('sntp');
const options = {
host: 'abc',
port: 123,
};
Sntp.now();
Sntp.start(options);
Sntp.start();
Sntp.stop();
Sntp.time(options);
Sntp.time();
Sntp.offset();

25
types/sntp/tsconfig.json Normal file
View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [
],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"sntp-tests.ts"
]
}

3
types/sntp/tslint.json Normal file
View File

@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}