mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-23 04:47:24 +08:00
Merge pull request #14181 from yohei1126/fix_msgpack
msgpack: add module declaration
This commit is contained in:
147
types/msgpack/index.d.ts
vendored
147
types/msgpack/index.d.ts
vendored
@@ -3,81 +3,86 @@
|
||||
// Definitions by: Shinya Mochizuki <https://github.com/enrapt-mochizuki/>
|
||||
// Definitions: https://github.com/DefinitelyTyped/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;
|
||||
declare namespace msgpack {
|
||||
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;
|
||||
/**
|
||||
* @param data string or ByteArray.
|
||||
*
|
||||
* @return string or ByteArray or undefined. unpack failed if undefined.
|
||||
*/
|
||||
unpack(data: any): any;
|
||||
|
||||
worker: string;
|
||||
worker: string;
|
||||
|
||||
upload(url: string, option: MsgPackUploadOption, callback: MsgPackUploadCallback): void;
|
||||
upload(url: string, option: MsgPackUploadOption, callback: MsgPackUploadCallback): void;
|
||||
|
||||
download(url: string, option: MsgPackDownloadOption, callback: MsgPackDownloadCallback): 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;
|
||||
}
|
||||
}
|
||||
|
||||
interface MsgPackUploadOption {
|
||||
/**
|
||||
* string or ByteArray
|
||||
*/
|
||||
data: any;
|
||||
declare var msgpack: msgpack.MsgPackStatic;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
export = msgpack;
|
||||
export as namespace msgpack;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
|
||||
|
||||
var packed = msgpack.pack("");
|
||||
msgpack.unpack(packed);
|
||||
|
||||
@@ -12,17 +10,17 @@ var uploadOption = {
|
||||
data: "",
|
||||
worker: false,
|
||||
timeout: 10,
|
||||
before: (xhr: XMLHttpRequest, option: MsgPackUploadOption) => { },
|
||||
after: (xhr: XMLHttpRequest, option: MsgPackUploadOption, result: MsgPackCallbackResult) => { }
|
||||
before: (xhr: XMLHttpRequest, option: msgpack.MsgPackUploadOption) => { },
|
||||
after: (xhr: XMLHttpRequest, option: msgpack.MsgPackUploadOption, result: msgpack.MsgPackCallbackResult) => { }
|
||||
};
|
||||
var uploadCallback = (data: string, option: MsgPackUploadOption, result: MsgPackCallbackResult) => { };
|
||||
var uploadCallback = (data: string, option: msgpack.MsgPackUploadOption, result: msgpack.MsgPackCallbackResult) => { };
|
||||
msgpack.upload(url, uploadOption, uploadCallback);
|
||||
|
||||
var downloadOption = {
|
||||
worker: false,
|
||||
timeout: 10,
|
||||
before: (xhr: XMLHttpRequest, option: MsgPackDownloadOption) => { },
|
||||
after: (xhr: XMLHttpRequest, option: MsgPackDownloadOption, result: MsgPackCallbackResult) => { }
|
||||
before: (xhr: XMLHttpRequest, option: msgpack.MsgPackDownloadOption) => { },
|
||||
after: (xhr: XMLHttpRequest, option: msgpack.MsgPackDownloadOption, result: msgpack.MsgPackCallbackResult) => { }
|
||||
};
|
||||
var downloadCallback = (data: any, option: MsgPackDownloadOption, result: MsgPackCallbackResult) => { };
|
||||
var downloadCallback = (data: any, option: msgpack.MsgPackDownloadOption, result: msgpack.MsgPackCallbackResult) => { };
|
||||
msgpack.download(url, downloadOption, downloadCallback);
|
||||
|
||||
Reference in New Issue
Block a user