Type definitions for parity-pmd 0.4.0 (#23901)

* Type definitions for parity-pmd 0.4.0

* Contributors list update

* Removed unnecessary reference to node
This commit is contained in:
Vilim Stubičan
2018-02-26 08:31:11 -08:00
committed by Andy
parent 67e122d7f6
commit 9d85a0c773
4 changed files with 78 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for parity-pmd 0.4
// Project: https://github.com/paritytrading/node-parity-pmd#readme
// Definitions by: Leonard Vujanić <https://github.com/leovujanic>
// Vilim Stubičan <https://github.com/jewbre>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="node" />
/**
* Declares Parity PMD message structure
* Full reference can be found here https://github.com/paritytrading/parity/blob/master/libraries/net/doc/PMD.md
*/
export interface PMDMessage {
messageType: string;
version?: string;
timestamp?: number;
orderNumber?: number;
side?: string;
instrument?: string;
quantity?: number;
price?: number;
}
export function format(message: PMDMessage): Buffer;
export function parse(buffer: Buffer): PMDMessage;
+27
View File
@@ -0,0 +1,27 @@
import { format, parse, PMDMessage } from 'parity-pmd';
// Arrange
const buffer = new Buffer(5);
buffer.writeUInt8(0x56, 0);
buffer.writeUInt32BE(70, 1);
const parsedContent: PMDMessage = parse(buffer);
// Act & Assert
// $ExpectType PMDMessage
parse(buffer);
// $ExpectType Buffer
format(parsedContent);
// Invalid type
// $ExpectError
parse('');
// $ExpectError
format({});
// Invalid sub type
// $ExpectError
format({
messageType: 1
});
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"parity-pmd-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }