forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
msgpack.d.ts
83 lines (64 loc) · 1.92 KB
/
msgpack.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Type definitions for msgpack.js - MessagePack JavaScript Implementation
// Project: https://github.com/uupaa/msgpack.js/
// Definitions by: Shinya Mochizuki <https://github.com/enrapt-mochizuki/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface MsgPackStatic {
/**
* @param data string or ByteArray.
* @param toString return string value if true.
*
* @return string or ByteArray or false. pack failed if false.
*/
pack(data: any, toString?: boolean): any;
/**
* @param data string or ByteArray.
*
* @return string or ByteArray or undefined. unpack failed if undefined.
*/
unpack(data: any): any;
worker: string;
upload(url: string, option: MsgPackUploadOption, callback: MsgPackUploadCallback): void;
download(url: string, option: MsgPackDownloadOption, callback: MsgPackDownloadCallback): void;
}
interface MsgPackUploadOption {
/**
* string or ByteArray
*/
data: any;
/**
* use WebWorker if true.
*/
worker?: boolean;
/**
* timeout sec.
*/
timeout?: number;
before?: (xhr: XMLHttpRequest, option: MsgPackUploadOption) => void;
after?: (xhr: XMLHttpRequest, option: MsgPackUploadOption, result: MsgPackCallbackResult) => void;
}
interface MsgPackUploadCallback {
(data: string, option: MsgPackUploadOption, result: MsgPackCallbackResult): void;
}
interface MsgPackDownloadOption {
/**
* use WebWorker if true.
*/
worker?: boolean;
/**
* timeout sec.
*/
timeout?: number;
before?: (xhr: XMLHttpRequest, option: MsgPackDownloadOption) => void;
after?: (xhr: XMLHttpRequest, option: MsgPackDownloadOption, result: MsgPackCallbackResult) => void;
}
interface MsgPackDownloadCallback {
/**
* @param data string or ByteArray
*/
(data: any, option: MsgPackDownloadCallback, result: MsgPackCallbackResult): void;
}
interface MsgPackCallbackResult {
status: number;
ok: boolean;
}
declare var msgpack: MsgPackStatic;