mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
add msgpack support
This commit is contained in:
parent
440aea6922
commit
d386bda2d6
@ -168,6 +168,7 @@ List of Definitions
|
||||
* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield))
|
||||
* [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee))
|
||||
* [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz))
|
||||
* [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki))
|
||||
* [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Node.js](http://nodejs.org/) (from TypeScript samples)
|
||||
* [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
|
||||
28
msgpack/msgpack-tests.ts
Normal file
28
msgpack/msgpack-tests.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/// <reference path="msgpack.d.ts" />
|
||||
|
||||
var packed = msgpack.pack("");
|
||||
msgpack.unpack(packed);
|
||||
|
||||
var packedString = msgpack.pack("", true);
|
||||
msgpack.unpack(packedString);
|
||||
|
||||
var url = "http://example.com";
|
||||
|
||||
var uploadOption = {
|
||||
data: "",
|
||||
worker: false,
|
||||
timeout: 10,
|
||||
before: (xhr: XMLHttpRequest, option: MsgPackUploadOption) => { },
|
||||
after: (xhr: XMLHttpRequest, option: MsgPackUploadOption, result: MsgPackCallbackResult) => { }
|
||||
};
|
||||
var uploadCallback = (data: string, option: MsgPackUploadOption, result: MsgPackCallbackResult) => { };
|
||||
msgpack.upload(url, uploadOption, uploadCallback);
|
||||
|
||||
var downloadOption = {
|
||||
worker: false,
|
||||
timeout: 10,
|
||||
before: (xhr: XMLHttpRequest, option: MsgPackDownloadOption) => { },
|
||||
after: (xhr: XMLHttpRequest, option: MsgPackDownloadOption, result: MsgPackCallbackResult) => { }
|
||||
};
|
||||
var downloadCallback = (data: any, option: MsgPackDownloadOption, result: MsgPackCallbackResult) => { };
|
||||
msgpack.download(url, downloadOption, downloadCallback);
|
||||
83
msgpack/msgpack.d.ts
vendored
Normal file
83
msgpack/msgpack.d.ts
vendored
Normal file
@ -0,0 +1,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;
|
||||
Loading…
Reference in New Issue
Block a user