mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-08-25 11:11:46 +08:00
Merge pull request #1619 from Bartvds/def/q-io
Created definitions for 'q-io'
This commit is contained in:
@@ -207,6 +207,8 @@ List of Definitions
|
||||
* [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH))
|
||||
* [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/))
|
||||
* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar)
|
||||
* [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei))
|
||||
* [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo))
|
||||
* [Rickshaw](http://code.shutterstock.com/rickshaw/) (by [Blake Niemyjski](https://github.com/niemyjski))
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
/// <reference path="../q/Q.d.ts" />
|
||||
/// <reference path="Q-io.d.ts" />
|
||||
|
||||
var fs:typeof QioFS = require('q-io/fs');
|
||||
var http:typeof QioHTTP = require('q-io/http');
|
||||
|
||||
var bool:boolean;
|
||||
var num:number;
|
||||
var x:any;
|
||||
var path:string;
|
||||
var buffer:NodeBuffer;
|
||||
var str:string;
|
||||
var strArr:string[];
|
||||
var source:string;
|
||||
var target:string;
|
||||
var type:string;
|
||||
|
||||
var options:any;
|
||||
var strArrQ:Q.Promise<string[]>;
|
||||
var voidQ:Q.Promise<void>;
|
||||
var anyQ:Q.Promise<any>;
|
||||
var strQ:Q.Promise<string>;
|
||||
var boolQ:Q.Promise<boolean>;
|
||||
var dateQ:Q.Promise<Date>;
|
||||
var bufferQ:Q.Promise<NodeBuffer>;
|
||||
|
||||
var statsQ:Q.Promise<QioFS.Stats>;
|
||||
var readQ:Q.Promise<Qio.Reader>;
|
||||
var writeQ:Q.Promise<Qio.Writer>;
|
||||
|
||||
var headers:QioHTTP.Headers;
|
||||
var reader:Qio.Reader;
|
||||
var writer:Qio.Writer;
|
||||
var stream:Qio.Stream;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
fs.open(path, options).then((x) => {
|
||||
});
|
||||
//fs.open(path, options):Q.Promise<Qio.Reader>;
|
||||
//fs.open(path, options):Q.Promise<Qio.Writer>;
|
||||
//fs.open(path, options):Q.Promise<NodeBuffer>;
|
||||
|
||||
//TODO how to define the multiple return types? use any for now?
|
||||
anyQ = fs.read(path, options);
|
||||
//strQ = fs.read(path, options);
|
||||
//fs.read(path, options):Q.Promise<NodeBuffer>;
|
||||
|
||||
voidQ = fs.write(path, buffer, options);
|
||||
voidQ = fs.write(path, str, options);
|
||||
|
||||
voidQ = fs.append(path, buffer, options);
|
||||
voidQ = fs.append(path, str, options);
|
||||
|
||||
voidQ = fs.copy(source, target);
|
||||
voidQ = fs.copyTree(source, target);
|
||||
|
||||
strArrQ = fs.list(path);
|
||||
strArrQ = fs.listTree(path, (path, x) => {
|
||||
return true;
|
||||
});
|
||||
strArrQ = fs.listDirectoryTree(path);
|
||||
|
||||
voidQ = fs.makeDirectory(path, str);
|
||||
voidQ = fs.makeDirectory(path, num);
|
||||
voidQ = fs.makeTree(path, str);
|
||||
voidQ = fs.makeTree(path, num);
|
||||
|
||||
voidQ = fs.remove(path);
|
||||
voidQ = fs.removeTree(path);
|
||||
|
||||
voidQ = fs.rename(source, target);
|
||||
voidQ = fs.move(source, target);
|
||||
|
||||
voidQ = fs.link(source, target);
|
||||
|
||||
voidQ = fs.symbolicCopy(source, target, type);
|
||||
voidQ = fs.symbolicLink(target, str, type);
|
||||
|
||||
voidQ = fs.chown(path, num, num);
|
||||
voidQ = fs.chmod(path, str);
|
||||
voidQ = fs.chmod(path, num);
|
||||
|
||||
statsQ = fs.stat(path)
|
||||
statsQ = fs.statLink(path);
|
||||
statsQ = fs.statFd(num);
|
||||
|
||||
boolQ = fs.exists(path);
|
||||
|
||||
boolQ = fs.isFile(path);
|
||||
boolQ = fs.isDirectory(path);
|
||||
boolQ = fs.isSymbolicLink(path);
|
||||
|
||||
dateQ = fs.lastModified(path);
|
||||
dateQ = fs.lastAccessed(path);
|
||||
|
||||
strArr = fs.split(path);
|
||||
str = fs.join(str, str);
|
||||
str = fs.join(strArr);
|
||||
str = fs.resolve(str, str);
|
||||
str = fs.resolve(strArr);
|
||||
str = fs.normal(str, str);
|
||||
str = fs.normal(strArr);
|
||||
str = fs.absolute(path);
|
||||
|
||||
strQ = fs.canonical(path);
|
||||
strQ = fs.readLink(path);
|
||||
|
||||
bool = fs.contains(str, str);
|
||||
|
||||
strQ = fs.relative(source, target);
|
||||
|
||||
str = fs.relativeFromFile(source, target);
|
||||
str = fs.relativeFromDirectory(source, target);
|
||||
|
||||
bool = fs.isAbsolute(path);
|
||||
bool = fs.isRelative(path);
|
||||
bool = fs.isRoot(path);
|
||||
|
||||
str = fs.root(path);
|
||||
str = fs.directory(path);
|
||||
str = fs.base(path, str);
|
||||
str = fs.extension(path);
|
||||
|
||||
//this should return a q-io/fs-mock MockFS
|
||||
//fs = fs.reroot(str);
|
||||
x = fs.toObject(str);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
var request:QioHTTP.Request;
|
||||
var headers:QioHTTP.Headers;
|
||||
|
||||
str = request.url;
|
||||
str = request.path;
|
||||
str = request.scriptName;
|
||||
str = request.pathInfo;
|
||||
strArr = request.version;
|
||||
str = request.method;
|
||||
str = request.scheme;
|
||||
|
||||
str = request.host;
|
||||
num = request.port;
|
||||
str = request.remoteHost;
|
||||
num = request.remotePort;
|
||||
|
||||
headers = request.headers;
|
||||
x = request.agent;
|
||||
x = request.body;
|
||||
x = request.node;
|
||||
|
||||
str = headers['foo'];
|
||||
|
||||
var response:QioHTTP.Response;
|
||||
var responseQ:Q.Promise<QioHTTP.Response>;
|
||||
|
||||
responseQ = http.request(request);
|
||||
responseQ = http.request(str);
|
||||
|
||||
strQ = http.read(request);
|
||||
strQ = http.read(str);
|
||||
|
||||
request = http.normalizeRequest(request);
|
||||
request = http.normalizeRequest(str);
|
||||
response = http.normalizeResponse(response);
|
||||
|
||||
num = response.status;
|
||||
headers = response.headers;
|
||||
reader = response.body;
|
||||
response.onclose = () => {
|
||||
|
||||
};
|
||||
x = response.node;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
strQ = reader.read(str);
|
||||
bufferQ = reader.read();
|
||||
reader.close();
|
||||
x = reader.node;
|
||||
voidQ = reader.forEach((chunk:any) => {
|
||||
return anyQ;
|
||||
});
|
||||
|
||||
writer.write(str);
|
||||
writer.write(buffer);
|
||||
writer.flush();
|
||||
writer.close();
|
||||
x = writer.node;
|
||||
|
||||
strQ = stream.read(str);
|
||||
bufferQ = stream.read();
|
||||
stream.write(str);
|
||||
stream.write(buffer);
|
||||
stream.flush();
|
||||
stream.close();
|
||||
x = stream.node;
|
||||
voidQ = reader.forEach((chunk:any) => {
|
||||
return anyQ;
|
||||
});
|
||||
Vendored
+257
@@ -0,0 +1,257 @@
|
||||
// Type definitions for Q-io
|
||||
// Project:https://github.com/kriskowal/q-io
|
||||
// Definitions by:Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions:https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
///<reference path="../node/node.d.ts" />
|
||||
///<reference path="../q/Q.d.ts" />
|
||||
|
||||
//TODO add support for q-io/http-apps
|
||||
//TODO add verified support for q-io/fs-mock
|
||||
//TODO fix Readers/Writers properly
|
||||
//TODO find solution for overloaded return types (QioFS.open/QioFS.read)
|
||||
// for some ideas see https://typescript.codeplex.com/discussions/461587#post1105930
|
||||
|
||||
declare module QioFS {
|
||||
|
||||
//TODO how to define the multiple return types? use any for now?
|
||||
export function open(path:string, options?:any):Q.Promise<any>;
|
||||
//export function open(path:string, options?:any):Q.Promise<Qio.Reader>;
|
||||
//export function open(path:string, options?:any):Q.Promise<Qio.Writer>;
|
||||
//export function open(path:string, options?:any):Q.Promise<NodeBuffer>;
|
||||
|
||||
//TODO how to define the multiple return types? use any for now?
|
||||
export function read(path:string, options?:any):Q.Promise<any>;
|
||||
//export function read(path:string, options?:any):Q.Promise<string>;
|
||||
//export function read(path:string, options?:any):Q.Promise<NodeBuffer>;
|
||||
|
||||
export function write(path:string, content:NodeBuffer, options?:any):Q.Promise<void>;
|
||||
export function write(path:string, content:string, options?:any):Q.Promise<void>;
|
||||
|
||||
export function append(path:string, content:NodeBuffer, options?:any):Q.Promise<void>;
|
||||
export function append(path:string, content:string, options?:any):Q.Promise<void>;
|
||||
|
||||
export function copy(source:string, target:string):Q.Promise<void>;
|
||||
export function copyTree(source:string, target:string):Q.Promise<void>;
|
||||
|
||||
export function list(path:string):Q.Promise<string[]>;
|
||||
export function listTree(path:string, guard?:(path:string, stat:any) => boolean):Q.Promise<string[]>;
|
||||
export function listDirectoryTree(path:string):Q.Promise<string[]>;
|
||||
|
||||
export function makeDirectory(path:string, mode?:string):Q.Promise<void>;
|
||||
export function makeDirectory(path:string, mode?:number):Q.Promise<void>;
|
||||
export function makeTree(path:string, mode?:string):Q.Promise<void>;
|
||||
export function makeTree(path:string, mode?:number):Q.Promise<void>;
|
||||
|
||||
export function remove(path:string):Q.Promise<void>;
|
||||
export function removeTree(path:string):Q.Promise<void>;
|
||||
|
||||
export function rename(source:string, target:string):Q.Promise<void>;
|
||||
export function move(source:string, target:string):Q.Promise<void>;
|
||||
|
||||
export function link(source:string, target:any):Q.Promise<void>;
|
||||
|
||||
export function symbolicCopy(source:string, target:string, type:string):Q.Promise<void>;
|
||||
export function symbolicLink(target:string, link:string, type:string):Q.Promise<void>;
|
||||
|
||||
export function chown(path:string, uid:number, gid:number):Q.Promise<void>;
|
||||
export function chmod(path:string, mode?:string):Q.Promise<void>;
|
||||
export function chmod(path:string, mode?:number):Q.Promise<void>;
|
||||
|
||||
export function stat(path:string):Q.Promise<Stats>;
|
||||
export function statLink(path:string):Q.Promise<Stats>;
|
||||
export function statFd(fd:number):Q.Promise<Stats>;
|
||||
|
||||
export function exists(path:string):Q.Promise<boolean>;
|
||||
|
||||
export function isFile(path:string):Q.Promise<boolean>;
|
||||
export function isDirectory(path:string):Q.Promise<boolean>;
|
||||
export function isSymbolicLink(path:string):Q.Promise<boolean>;
|
||||
|
||||
export function lastModified(path:string):Q.Promise<Date>;
|
||||
export function lastAccessed(path:string):Q.Promise<Date>;
|
||||
|
||||
export function split(path:string):string[];
|
||||
export function join(...paths:string[]):string;
|
||||
export function join(paths:string[]):string;
|
||||
export function resolve(...path:string[]):string;
|
||||
export function resolve(paths:string[]):string;
|
||||
export function normal(...path:string[]):string;
|
||||
export function normal(paths:string[]):string;
|
||||
export function absolute(path:string):string;
|
||||
|
||||
export function canonical(path:string):Q.Promise<string>;
|
||||
export function readLink(path:string):Q.Promise<string>;
|
||||
|
||||
export function contains(parent:string, child:string):boolean;
|
||||
|
||||
export function relative(source:string, target:string):Q.Promise<string>;
|
||||
|
||||
export function relativeFromFile(source:string, target:string):string;
|
||||
export function relativeFromDirectory(source:string, target:string):string;
|
||||
|
||||
export function isAbsolute(path:string):boolean;
|
||||
export function isRelative(path:string):boolean;
|
||||
export function isRoot(path:string):boolean;
|
||||
|
||||
export function root(path:string):string;
|
||||
export function directory(path:string):string;
|
||||
export function base(path:string, extension:string):string;
|
||||
export function extension(path:string):string;
|
||||
|
||||
//this should return a q-io/fs-mock MockFS
|
||||
export function reroot(path:string):typeof QioFS;
|
||||
|
||||
export function toObject(path:string):{[path:string]:NodeBuffer};
|
||||
|
||||
//listed but not implemented by Q-io
|
||||
//export function glob(pattern):Q.Promise<string[]>;
|
||||
//export function match(pattern, path:string):Q.Promise<string[]>;
|
||||
|
||||
//TODO link this to node.js FS module (no lazy clones)
|
||||
interface Stats {
|
||||
node:NodeStats;
|
||||
size:number;
|
||||
}
|
||||
interface NodeStats {
|
||||
isFile():boolean;
|
||||
isDirectory():boolean;
|
||||
isBlockDevice():boolean;
|
||||
isCharacterDevice():boolean;
|
||||
isSymbolicLink():boolean;
|
||||
isFIFO():boolean;
|
||||
isSocket():boolean;
|
||||
node:NodeStats;
|
||||
dev:number;
|
||||
ino:number;
|
||||
mode:number;
|
||||
nlink:number;
|
||||
uid:number;
|
||||
gid:number;
|
||||
rdev:number;
|
||||
size:number;
|
||||
blksize:number;
|
||||
blocks:number;
|
||||
atime:Date;
|
||||
mtime:Date;
|
||||
ctime:Date;
|
||||
}
|
||||
}
|
||||
|
||||
declare module QioHTTP {
|
||||
export function request(request:Request):Q.Promise<Response>;
|
||||
export function request(url:string):Q.Promise<Response>;
|
||||
|
||||
export function read(request:Request):Q.Promise<string>;
|
||||
export function read(url:string):Q.Promise<string >;
|
||||
|
||||
export function normalizeRequest(request:Request):Request;
|
||||
export function normalizeRequest(url:string):Request;
|
||||
export function normalizeResponse(response:Response):Response;
|
||||
|
||||
interface Request {
|
||||
url:string;
|
||||
path:string;
|
||||
scriptName:string;
|
||||
pathInfo:string;
|
||||
version:string[];
|
||||
method:string;
|
||||
scheme:string;
|
||||
|
||||
host:string;
|
||||
port:number;
|
||||
remoteHost:string;
|
||||
remotePort:number;
|
||||
|
||||
headers:Headers;
|
||||
agent:any;
|
||||
body:any;
|
||||
node:any;
|
||||
}
|
||||
interface Response {
|
||||
status:number;
|
||||
headers:Headers;
|
||||
body:Qio.Reader
|
||||
onclose:() => void;
|
||||
node:any;
|
||||
}
|
||||
interface Headers {
|
||||
[name:string]:any;
|
||||
[name:string]:any[];
|
||||
}
|
||||
interface Body extends Qio.Stream {
|
||||
|
||||
}
|
||||
interface Application {
|
||||
(req:Request):Q.Promise<any>;
|
||||
}
|
||||
}
|
||||
|
||||
declare module Qio {
|
||||
interface ForEachCallback {
|
||||
(chunk:NodeBuffer):Q.Promise<any>;
|
||||
(chunk:string):Q.Promise<any>;
|
||||
}
|
||||
interface ForEach {
|
||||
forEach(callback:ForEachCallback):Q.Promise<void>;
|
||||
}
|
||||
|
||||
interface Reader extends ForEach {
|
||||
read(charset:string):Q.Promise<string>;
|
||||
read():Q.Promise<NodeBuffer>;
|
||||
close():void;
|
||||
node:ReadableStream;
|
||||
}
|
||||
interface Writer {
|
||||
write(content:string):void;
|
||||
write(content:NodeBuffer):void;
|
||||
flush():Q.Promise<void>;
|
||||
close():void;
|
||||
destroy():void;
|
||||
node:WritableStream;
|
||||
}
|
||||
|
||||
interface Stream {
|
||||
read(charset:string):Q.Promise<string>;
|
||||
read():Q.Promise<NodeBuffer>;
|
||||
write(content:string):void;
|
||||
write(content:NodeBuffer):void;
|
||||
flush():Q.Promise<void>;
|
||||
close():void;
|
||||
destroy():void;
|
||||
node:any;
|
||||
}
|
||||
|
||||
interface BufferReader extends QioBufferReader {
|
||||
|
||||
}
|
||||
}
|
||||
interface QioBufferReader {
|
||||
new ():Qio.Reader;
|
||||
read(stream:Qio.Reader, charset:string):string;
|
||||
read(stream:Qio.Reader):NodeBuffer;
|
||||
join(buffers:NodeBuffer[]):NodeBuffer;
|
||||
}
|
||||
interface QioBufferWriter {
|
||||
(writer:NodeBuffer):Qio.Writer;
|
||||
Writer:Qio.Writer;
|
||||
}
|
||||
interface QioBufferStream {
|
||||
(buffer:NodeBuffer, encoding:string):Qio.Stream
|
||||
}
|
||||
|
||||
declare module "q-io/http" {
|
||||
export = QioHTTP;
|
||||
}
|
||||
declare module "q-io/fs" {
|
||||
export = QioFS;
|
||||
}
|
||||
declare module "q-io/reader" {
|
||||
export = QioBufferReader;
|
||||
}
|
||||
declare module "q-io/writer" {
|
||||
export = QioBufferWriter;
|
||||
}
|
||||
declare module "q-io/buffer-stream" {
|
||||
export = QioBufferStream;
|
||||
}
|
||||
Reference in New Issue
Block a user