mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
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:
Vendored
+27
@@ -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;
|
||||
@@ -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
|
||||
});
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user