Add an initial definition for

This commit is contained in:
heycalmdown
2016-11-14 11:24:49 +09:00
parent 33ae2bd878
commit b8fb1fb2f1
3 changed files with 78 additions and 0 deletions

52
msgpack5/index.d.ts vendored Normal file
View File

@@ -0,0 +1,52 @@
// Type definitions for msgpack5 v3.4.0
// Project: https://github.com/mcollina/msgpack5/
// Definitions by: Wonshik Kim <https://github.com/wokim/>
// Definitions by: Kei Son <https://github.com/heycalmdown/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import stream = require('stream');
import bl = require('bl');
interface Options {
forceFloat64: boolean;
compatibilityMode: boolean;
}
declare namespace msgpack5 {
interface Options {
header?: boolean;
msgpack?: any;
}
class Base extends stream.Transform {
protected _header: any;
protected _msgpack: any;
}
class Encoder extends Base {
constructor(opts?: Options);
public _transform(obj: any, enc: any, done: Function): any;
}
class Decoder extends Base {
constructor(opts?: Options);
public _chunks: bl;
public _length: number;
public _transform(buf: any, enc: any, done: Function): any;
}
interface MessagePack {
encode(obj: any): bl;
decode<T>(buf: Buffer): T;
decode<T>(buf: bl): T;
register(type: number, $constructor: any, encode: (obj: any) => Buffer, decode: (data: Buffer) => any): any;
registerEncoder(check: (obj: any) => boolean, encode: (obj: any) => Buffer): any;
registerDecoder(type: number, decode: (data: Buffer) => any): any;
encoder(opts?: Options): Encoder;
decoder(opts?: Options): Decoder;
}
}
declare function msgpack5(opts?: Options): msgpack5.MessagePack;
export = msgpack5;

View File

@@ -0,0 +1,6 @@
import * as msgpack5 from 'msgpack5';
const packer = msgpack5();
const IN = {};
const OUT = packer.decode(packer.encode(IN));

20
msgpack5/tsconfig.json Normal file
View File

@@ -0,0 +1,20 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"msgpack5-test.ts"
]
}