From 1975cba549763a5f35db7e0845e0075c75db64c0 Mon Sep 17 00:00:00 2001 From: "Omid K. Rad" Date: Wed, 16 Apr 2014 15:54:26 -0700 Subject: [PATCH 01/24] Added definitions for Handlebars Runtime --- handlebars/handlebars.d.ts | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/handlebars/handlebars.d.ts b/handlebars/handlebars.d.ts index ceff78663..0c8fdbf0f 100644 --- a/handlebars/handlebars.d.ts +++ b/handlebars/handlebars.d.ts @@ -4,22 +4,45 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Use either HandlebarsStatic or HandlebarsRuntimeStatic declare var Handlebars: HandlebarsStatic; +//declare var Handlebars: HandlebarsRuntimeStatic; -interface HandlebarsStatic { +/** +* Implement this interface on your MVW/MVVM/MVC views such as Backbone.View +**/ +interface HandlebarsTemplatable { + template: HandlebarsTemplateDelegate; +} + +interface HandlebarsTemplateDelegate { + (context: any, options?: any): string; +} + +interface HandlebarsCommon { registerHelper(name: string, fn: Function, inverse?: boolean): void; registerPartial(name: string, str: any): void; K(): void; createFrame(object: any): any; + Exception(message: string): void; SafeString: typeof SafeString; - parse(input: string): boolean; + logger: Logger; log(level: number, obj: any): void; - compile(input: any, options?: any): (context?: any, options?: any) => string; Logger: typeof Logger; } +interface HandlebarsStatic extends HandlebarsCommon { + parse(input: string): boolean; + compile(input: any, options?: any): HandlebarsTemplateDelegate; +} + +interface HandlebarsRuntimeStatic extends HandlebarsCommon { + // Handlebars.templates is the default template namespace in precompiler. + templates: { (s: string): HandlebarsTemplateDelegate }[]; +} + declare class SafeString { constructor(str: string); static toString(): string; From 63c560a05f51ac7796031627db215e3bb990f000 Mon Sep 17 00:00:00 2001 From: Seon-Wook Park Date: Tue, 22 Apr 2014 15:43:58 +0200 Subject: [PATCH 02/24] Add definitions for github.com/sandeepmistry/noble --- CONTRIBUTORS.md | 1 + noble/noble-tests.ts | 83 ++++++++++++++++++++++++++++++++++ noble/noble.d.ts | 105 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 189 insertions(+) create mode 100644 noble/noble-tests.ts create mode 100644 noble/noble.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 54ae0cdc8..b26e55b1b 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -200,6 +200,7 @@ All definitions files include a header with the author and editors, so at some p * [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)) +* [noble](https://github.com/sandeepmistry/noble) (by [Seon-Wook Park](https://github.com/swook)) * [Node.js](http://nodejs.org/) (from TypeScript samples) * [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov)) * [node-ffi](https://github.com/rbranson/node-ffi) (by [Paul Loyd](https://github.com/loyd)) diff --git a/noble/noble-tests.ts b/noble/noble-tests.ts new file mode 100644 index 000000000..3e7b4afaf --- /dev/null +++ b/noble/noble-tests.ts @@ -0,0 +1,83 @@ +/// + +import noble = require("noble"); + +function test_startScanning(): void { + "use strict"; + noble.startScanning(); + noble.startScanning(["0x180d"]); + noble.startScanning(["0x180d"], true); +} +test_startScanning(); + +function test_stopScanning(): void { + "use strict"; + noble.stopScanning(); +} +test_stopScanning(); + +noble.on("stateChange", (state: string): void => {}); +noble.on("scanStart", (): void => {}); +noble.on("scanStop", (): void => {}); +noble.on("discover", (peripheral: noble.Peripheral): void => { + peripheral.connect((error: string): void => {}); + peripheral.disconnect((): void => {}); +}); + +var peripheral: noble.Peripheral = new noble.Peripheral(); +peripheral.uuid = "12ad4e81"; +peripheral.advertisement = { + localName: "device", + serviceData: new Buffer(1), + txPowerLevel: 1, + manufacturerData: new Buffer(1), + serviceUuids: ["0x180a", "0x180d"] +}; +peripheral.connect((error: string): void => {}); +peripheral.disconnect((): void => {}); +peripheral.discoverServices(["180d"], (error: string, services: noble.Service[]): void => {}); +peripheral.discoverAllServicesAndCharacteristics((error: string, services: noble.Service[], characteristics: noble.Characteristic[]): void => {}); +peripheral.discoverSomeServicesAndCharacteristics(["180d"], ["2a38"], (error: string, services: noble.Service[], characteristics: noble.Characteristic[]): void => {}); +peripheral.readHandle(new Buffer(1), (error: string, data: NodeBuffer): void => {}); +peripheral.writeHandle(new Buffer(1), new Buffer(1), true, (error: string): void => {}); +peripheral.on("connect", (error: string): void => {}); +peripheral.on("disconnect", (error: string): void => {}); +peripheral.on("rssiUpdate", (rssi: number): void => {}); +peripheral.on("servicesDiscover", (services: noble.Service[]): void => {}); + +var service: noble.Service = new noble.Service(); +service.uuid = "180a"; +service.name = ""; +service.type = ""; +service.includedServiceUuids = ["180d"]; +service.discoverIncludedServices(["180d"], (error: string, includedServiceUuids: string[]): void => {}); +service.discoverCharacteristics(["2a38"], (error: string, characteristics: noble.Characteristic[]): void => {}); +service.on("includedServicesDiscover", (includedServiceUuids: string[]): void => {}); +service.on("characteristicsDiscover", (characteristics: noble.Characteristic[]): void => {}); + +var characteristic: noble.Characteristic = new noble.Characteristic(); +characteristic.uuid = "2a37"; +characteristic.name = ""; +characteristic.type = ""; +characteristic.properties = ["read", "notify"]; +characteristic.read((error: string, data: NodeBuffer): void => {}); +characteristic.write(new Buffer(1), true, (error: string): void => {}); +characteristic.broadcast(true, (error: string): void => {}); +characteristic.notify(true, (error: string): void => {}); +characteristic.discoverDescriptors((error: string, descriptors: noble.Descriptor[]): void => {}); +characteristic.on("read", (data: NodeBuffer, isNotification: boolean): void => {}); +characteristic.on("write", true, (error: string): void => {}); +characteristic.on("broadcast", (state: string): void => {}); +characteristic.on("notify", (state: string): void => {}); +characteristic.on("descriptorsDiscover", (descriptors: noble.Descriptor[]): void => {}); + +var descriptor: noble.Descriptor = new noble.Descriptor(); +descriptor.uuid = ""; +descriptor.name = ""; +descriptor.type = ""; +descriptor.readValue((error: string, data: NodeBuffer): void => {}); +descriptor.writeValue(new Buffer(1), (error: string): void => {}); +descriptor.on("valueRead", (error: string, data: NodeBuffer): void => {}); +descriptor.on("valueWrite", (error: string): void => {}); + +// vim expandtab shiftwidth=4 diff --git a/noble/noble.d.ts b/noble/noble.d.ts new file mode 100644 index 000000000..12ffb08bb --- /dev/null +++ b/noble/noble.d.ts @@ -0,0 +1,105 @@ +// Type definitions for noble +// Project: https://github.com/sandeepmistry/noble +// Definitions by: Seon-Wook Park +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "noble" { + export function startScanning(): void; + export function startScanning(serviceUUIDs: string[]): void; + export function startScanning(serviceUUIDs: string[], allowDuplicates: boolean): void; + export function stopScanning(): void; + + export function on(event: string, callback: Function): void; + export function on(event: "stateChange", callback: (state: string) => void): void; + export function on(event: "scanStart", callback: () => void): void; + export function on(event: "scanStop", callback: () => void): void; + export function on(event: "discover", callback: (peripheral: Peripheral) => void): void; + + export class Peripheral { + uuid: string; + advertisement: Advertisement; + rssi: number; + services: string[]; + + connect(callback: (error: string) => void): void; + disconnect(callback: () => void): void; + discoverServices(serviceUUIDs: string[], callback: (error: string, services: Service[]) => void): void; + discoverAllServicesAndCharacteristics(callback: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; + discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; + + readHandle(handle: NodeBuffer, callback: (error: string, data: NodeBuffer) => void): void; + writeHandle(handle: NodeBuffer, data: NodeBuffer, withoutResponse: boolean, callback: (error: string) => void): void; + toString(): string; + + on(event: string, callback: Function): void; + on(event: "connect", callback: (error: string) => void): void; + on(event: "disconnect", callback: (error: string) => void): void; + on(event: "rssiUpdate", callback: (rssi: number) => void): void; + on(event: "servicesDiscover", callback: (services: Service[]) => void): void; + } + + export interface Advertisement { + localName: string; + serviceData: NodeBuffer; + txPowerLevel: number; + manufacturerData: NodeBuffer; + serviceUuids: string[]; + } + + export class Service { + uuid: string; + name: string; + type: string; + includedServiceUuids: string[]; + characteristics: Characteristic[]; + + discoverIncludedServices(serviceUUIDs: string[], callback: (error: string, includedServiceUuids: string[]) => void): void; + discoverCharacteristics(characteristicUUIDs: string[], callback: (error: string, characteristics: Characteristic[]) => void): void; + toString(): string; + + on(event: string, callback: Function): void; + on(event: "includedServicesDiscover", callback: (includedServiceUuids: string[]) => void): void; + on(event: "characteristicsDiscover", callback: (characteristics: Characteristic[]) => void): void; + } + + export class Characteristic { + uuid: string; + name: string; + type: string; + properties: string[]; + descriptors: Descriptor[]; + + read(callback: (error: string, data: NodeBuffer) => void): void; + write(data: NodeBuffer, notify: boolean, callback: (error: string) => void): void; + broadcast(broadcast: boolean, callback: (error: string) => void): void; + notify(notify: boolean, callback: (error: string) => void): void; + discoverDescriptors(callback: (error: string, descriptors: Descriptor[]) => void): void; + toString(): string; + + on(event: string, callback: Function): void; + on(event: string, option: boolean, callback: Function): void; + on(event: "read", callback: (data: NodeBuffer, isNotification: boolean) => void): void; + on(event: "write", withoutResponse: boolean, callback: (error: string) => void): void; + on(event: "broadcast", callback: (state: string) => void): void; + on(event: "notify", callback: (state: string) => void): void; + on(event: "descriptorsDiscover", callback: (descriptors: Descriptor[]) => void): void; + } + + export class Descriptor { + uuid: string; + name: string; + type: string; + + readValue(callback: (error: string, data: NodeBuffer) => void): void; + writeValue(data: NodeBuffer, callback: (error: string) => void): void; + toString(): string; + + on(event: string, callback: Function): void; + on(event: "valueRead", callback: (error: string, data: NodeBuffer) => void): void; + on(event: "valueWrite", callback: (error: string) => void): void; + } +} + +// vim expandtab shiftwidth=4 From 09f3d7a8dc79f448b538862c3ad5872f75112d60 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Tue, 22 Apr 2014 22:09:35 +0200 Subject: [PATCH 03/24] imported 25 definitions from typescript-node-definitions first batch: the easy pickings - as per https://github.com/borisyankov/DefinitelyTyped/issues/115 - added DT headers (scraped creators from git history) - added tests - some modifications - added CONTRIBUTORS.md for the substantial defs (>50 LOC) --- CONTRIBUTORS.md | 9 + atpl/atpl-tests.ts | 25 + atpl/atpl.d.ts | 20 + aws-sdk/aws-sdk-tests.ts | 13 + aws-sdk/aws-sdk.d.ts | 909 +++++++++++++++++++++++++++++ consolidate/consolidate-tests.ts | 27 + consolidate/consolidate.d.ts | 30 + fibers/fibers-tests.ts | 13 + fibers/fibers.d.ts | 24 + form-data/form-data-tests.ts | 8 + form-data/form-data.d.ts | 15 + fs-extra/fs-extra-tests.ts | 229 ++++++++ fs-extra/fs-extra.d.ts | 187 ++++++ gently/gently-tests.ts | 14 + gently/gently.d.ts | 26 + imagemagick/imagemagick-tests.ts | 27 + imagemagick/imagemagick.d.ts | 59 ++ memory-cache/memory-cache-tests.ts | 24 + memory-cache/memory-cache.d.ts | 20 + mime/mime-tests.ts | 13 + mime/mime.d.ts | 19 + mu2/mu2-tests.ts | 32 + mu2/mu2.d.ts | 29 + nconf/nconf-tests.ts | 101 ++++ nconf/nconf.d.ts | 100 ++++ nock/nock-tests.ts | 60 ++ nock/nock.d.ts | 54 ++ nodeunit/nodeunit-tests.ts | 59 ++ nodeunit/nodeunit.d.ts | 59 ++ optimist/optimist-tests.ts | 46 ++ optimist/optimist.d.ts | 53 ++ redis/redis-tests.ts | 62 ++ redis/redis.d.ts | 224 +++++++ rimraf/rimraf-tests.ts | 11 + rimraf/rimraf.d.ts | 16 + sprintf/sprintf-tests.ts | 14 + sprintf/sprintf.d.ts | 11 + swig/swig-tests.ts | 25 + swig/swig.d.ts | 24 + swiz/swiz-tests.ts | 172 ++++++ swiz/swiz.d.ts | 195 +++++++ timezone-js/timezone-js-tests.ts | 26 + timezone-js/timezone-js.d.ts | 45 ++ twig/twig-tests.ts | 45 ++ twig/twig.d.ts | 37 ++ watch/watch-tests.ts | 32 + watch/watch.d.ts | 35 ++ winston/winston-tests.ts | 40 ++ winston/winston.d.ts | 39 ++ wrench/wrench-tests.ts | 36 ++ wrench/wrench.d.ts | 27 + 51 files changed, 3420 insertions(+) create mode 100644 atpl/atpl-tests.ts create mode 100644 atpl/atpl.d.ts create mode 100644 aws-sdk/aws-sdk-tests.ts create mode 100644 aws-sdk/aws-sdk.d.ts create mode 100644 consolidate/consolidate-tests.ts create mode 100644 consolidate/consolidate.d.ts create mode 100644 fibers/fibers-tests.ts create mode 100644 fibers/fibers.d.ts create mode 100644 form-data/form-data-tests.ts create mode 100644 form-data/form-data.d.ts create mode 100644 fs-extra/fs-extra-tests.ts create mode 100644 fs-extra/fs-extra.d.ts create mode 100644 gently/gently-tests.ts create mode 100644 gently/gently.d.ts create mode 100644 imagemagick/imagemagick-tests.ts create mode 100644 imagemagick/imagemagick.d.ts create mode 100644 memory-cache/memory-cache-tests.ts create mode 100644 memory-cache/memory-cache.d.ts create mode 100644 mime/mime-tests.ts create mode 100644 mime/mime.d.ts create mode 100644 mu2/mu2-tests.ts create mode 100644 mu2/mu2.d.ts create mode 100644 nconf/nconf-tests.ts create mode 100644 nconf/nconf.d.ts create mode 100644 nock/nock-tests.ts create mode 100644 nock/nock.d.ts create mode 100644 nodeunit/nodeunit-tests.ts create mode 100644 nodeunit/nodeunit.d.ts create mode 100644 optimist/optimist-tests.ts create mode 100644 optimist/optimist.d.ts create mode 100644 redis/redis-tests.ts create mode 100644 redis/redis.d.ts create mode 100644 rimraf/rimraf-tests.ts create mode 100644 rimraf/rimraf.d.ts create mode 100644 sprintf/sprintf-tests.ts create mode 100644 sprintf/sprintf.d.ts create mode 100644 swig/swig-tests.ts create mode 100644 swig/swig.d.ts create mode 100644 swiz/swiz-tests.ts create mode 100644 swiz/swiz.d.ts create mode 100644 timezone-js/timezone-js-tests.ts create mode 100644 timezone-js/timezone-js.d.ts create mode 100644 twig/twig-tests.ts create mode 100644 twig/twig.d.ts create mode 100644 watch/watch-tests.ts create mode 100644 watch/watch.d.ts create mode 100644 winston/winston-tests.ts create mode 100644 winston/winston.d.ts create mode 100644 wrench/wrench-tests.ts create mode 100644 wrench/wrench.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 54ae0cdc8..9f4f84f19 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -20,6 +20,7 @@ All definitions files include a header with the author and editors, so at some p * [assert](https://github.com/Jxck/assert) (by [vvakame](https://github.com/vvakame)) * [async](https://github.com/caolan/async) (by [Boris Yankov](https://github.com/borisyankov)) * [Atom](https://atom.io/) (by [vvakame](https://github.com/vvakame)) +* [aws-sdk-js](https://github.com/aws/aws-sdk-js) (by [midknight41](https://github.com/midknight41)) * [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Backbone Relational](http://backbonerelational.org/) (by [Eirik Hoem](https://github.com/eirikhm)) * [BigScreen](http://brad.is/coding/BigScreen/) (by [Douglas Eichelberger](https://github.com/dduugg)) @@ -75,6 +76,7 @@ All definitions files include a header with the author and editors, so at some p * [Flight by Twitter](http://flightjs.github.com/flight/) (by [Jonathan Hedrén](https://github.com/jonathanhedren)) * [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [FPSMeter](http://darsa.in/fpsmeter/) (by [Aaron Lampros](https://github.com/alampros)) +* [fs-extra](https://github.com/jprichardson/node-fs-extra) (by [midknight41](https://github.com/midknight41)) * [FullCalendar](http://arshaw.com/fullcalendar/) (by [Neil Stalker](https://github.com/nestalk)) * [Gamepad](http://www.w3.org/TR/gamepad/) (by [Kon](http://phyzkit.net/)) * [Giraffe](https://github.com/barc/backbone.giraffe) (by [Matt McCray](https://github.com/darthapo)) @@ -106,6 +108,7 @@ All definitions files include a header with the author and editors, so at some p * [i18next](http://i18next.com/) (by [Maarten Docter](https://github.com/mdocter)) * [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz)) * [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov)) +* [Imagemagick](http://github.com/rsms/node-imagemagick) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) * [iScroll](http://cubiq.org/iscroll-4) (by [Boris Yankov](https://github.com/borisyankov) and [Christiaan Rakowski](https://github.com/csrakowski)) * [IxJS (Interactive extensions)](https://github.com/Reactive-Extensions/IxJS) (by [Igor Oleinikov](https://github.com/Igorbek)) * [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/)) @@ -200,16 +203,20 @@ All definitions files include a header with the author and editors, so at some p * [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)) +* [nconf](https://github.com/flatiron/nconf) (by [Jeff Goddard](https://github.com/jedigo)) +* [nock](https://github.com/pgte/nock) (by [bonnici](https://github.com/bonnici)) * [Node.js](http://nodejs.org/) (from TypeScript samples) * [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov)) * [node-ffi](https://github.com/rbranson/node-ffi) (by [Paul Loyd](https://github.com/loyd)) * [node-git](https://github.com/christkv/node-git) (by [vvakame](https://github.com/vvakame)) +* [nodeunit](https://github.com/caolan/nodeunit) (by [Jeff Goddard](https://github.com/jedigo)) * [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown)) * [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) * [notify.js](https://github.com/alexgibson/notify.js) (by [soundTricker](https://github.com/soundTricker)) * [NProgress](https://github.com/rstacruz/nprogress) (by [Judah Gabriel Himango](https://github.com/judahgabriel)) * [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/)) * [OpenLayers](https://github.com/openlayers/openlayers) (by [Ilya Bolkhovsky](https://github.com/bolhovsky/)) +* [Optimist](https://github.com/substack/node-optimist) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) * [Passport](http://passportjs.org/) (by [Hiroki Horiuchi](https://github.com/horiuchi/)) * [pathwatcher](http://atom.github.io/node-pathwatcher/) (by [vvakame](https://github.com/vvakame)) * [Parallel.js](https://github.com/adambom/parallel.js) (by [Josh Baldwin](https://github.com/jbaldwin)) @@ -230,6 +237,7 @@ All definitions files include a header with the author and editors, so at some p * [Rickshaw](http://code.shutterstock.com/rickshaw/) (by [Blake Niemyjski](https://github.com/niemyjski)) * [Riot.js](https://github.com/moot/riotjs) (by [vvakame](https://github.com/vvakame)) * [Restify](https://github.com/mcavage/node-restify) (by [Bret Little](https://github.com/blittle)) +* [Redis](https://github.com/mranney/node_redis) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) * [Royalslider](http://dimsemenov.com/plugins/royal-slider/) (by [Christiaan Rakowski](https://github.com/csrakowski)) * [Rx.js](http://rx.codeplex.com/) (by [gsino](http://www.codeplex.com/site/users/view/gsino), [Igor Oleinikov](https://github.com/Igorbek), [Carl de Billy](http://carl.debilly.net/), [zoetrope](https://github.com/zoetrope)) * [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall)) @@ -256,6 +264,7 @@ All definitions files include a header with the author and editors, so at some p * [Sugar](http://sugarjs.com/) (by [Josh Baldwin](https://github.com/jbaldwin/)) * [Swiper](http://www.idangero.us/sliders/swiper) (by [Sebastián Galiano](https://github.com/sgaliano)) * [SwipeView](http://cubiq.org/swipeview) (by [Boris Yankov](https://github.com/borisyankov)) +* [Swiz](https://github.com/racker/node-swiz) (by [Jeff Goddard](https://github.com/jedigo)) * [TV4](https://github.com/geraintluff/tv4) (by [Bart van der Schoor](https://github.com/Bartvds)) * [Tags Manager](http://welldonethings.com/tags/manager) (by [Vincent Bortone](https://github.com/vbortone)) * [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com)) diff --git a/atpl/atpl-tests.ts b/atpl/atpl-tests.ts new file mode 100644 index 000000000..f1751d901 --- /dev/null +++ b/atpl/atpl-tests.ts @@ -0,0 +1,25 @@ +/// + +import atpl = require('atpl'); + +var bool: boolean; +var str: string; +var err: Error; +var items: any; +var options: Object; +var callback: Function; + +atpl.compile(str, options); +atpl.__express(str, options, callback); + +atpl.registerExtension(items); +atpl.registerTags(items); +atpl.registerFunctions(items); +atpl.registerFilters(items); +atpl.registerTests(items); + +atpl.registerTags(null); +atpl.renderFile(str, str, options, bool, (e, res?) => { + err = err; + str = res; +}); diff --git a/atpl/atpl.d.ts b/atpl/atpl.d.ts new file mode 100644 index 000000000..7eae246a8 --- /dev/null +++ b/atpl/atpl.d.ts @@ -0,0 +1,20 @@ +// Type definitions for atpl +// Project: https://github.com/soywiz/atpl.js +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/atpl.d.ts + +declare module "atpl" { + export function compile(templateString: string, options: any): (context:any) => string; + export function __express(filename: string, options: any, callback: Function): any; + + export function registerExtension(items: any): void; + export function registerTags(items: any): void; + export function registerFunctions(items: any): void; + export function registerFilters(items: any): void; + export function registerTests(items: any): void; + + export function renderFileSync(viewsPath: string, filename: string, parameters: any, cache: boolean ): string; + export function renderFile(viewsPath: string, filename: string, parameters: any, cache: boolean, done: (err: Error, result?: string) => void): void; +} diff --git a/aws-sdk/aws-sdk-tests.ts b/aws-sdk/aws-sdk-tests.ts new file mode 100644 index 000000000..8a3464a6d --- /dev/null +++ b/aws-sdk/aws-sdk-tests.ts @@ -0,0 +1,13 @@ +/// + +import awsSdk = require('aws-sdk'); + +var str: string; + +var creds: awsSdk.Credentials; + +creds = new awsSdk.Credentials(str, str); +creds = new awsSdk.Credentials(str, str, str); +str = creds.accessKeyId; + +// more diff --git a/aws-sdk/aws-sdk.d.ts b/aws-sdk/aws-sdk.d.ts new file mode 100644 index 000000000..3ae6778b5 --- /dev/null +++ b/aws-sdk/aws-sdk.d.ts @@ -0,0 +1,909 @@ +// Type definitions for aws-sdk +// Project: https://github.com/aws/aws-sdk-js +// Definitions by: midknight41 +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/aws-sdk.d.ts + +/// + +declare module "aws-sdk" { + + export var config: ClientConfig; + + export function Config(json: any): void; + + export class Credentials { + constructor(accessKeyId: string, secretAccessKey: string, sessionToken?: string); + accessKeyId: string; + } + + export interface ClientConfig { + credentials: Credentials; + region: string; + } + + export class SQS { + constructor(options?: any); + public client: Sqs.Client; + } + + export class SES { + constructor(options?: any); + public client: Ses.Client; + } + + export class SNS { + constructor(options?: any); + public client: Sns.Client; + } + + export class SimpleWorkflow { + constructor(options?: any); + public client: Swf.Client; + } + + export class S3 { + constructor(options?: any); + public client: s3.Client; + } + + export module Sqs { + + export interface Client { + config: ClientConfig; + + sendMessage(params: SendMessageRequest, callback: (err: any, data: SendMessageResult) => void): void; + sendMessageBatch(params: SendMessageBatchRequest, callback: (err: any, data: SendMessageBatchResult) => void): void; + receiveMessage(params: ReceiveMessageRequest, callback: (err: any, data: ReceiveMessageResult) => void): void; + deleteMessage(params: DeleteMessageRequest, callback: (err: any, data: any) => void): void; + deleteMessageBatch(params: DeleteMessageBatchRequest, callback: (err: any, data: DeleteMessageBatchResult) => void): void; + createQueue(params: CreateQueueRequest, callback: (err: any, data: CreateQueueResult) => void): void; + deleteQueue(params: DeleteQueueRequest, callback: (err: any, data: any) => void): void; + } + + export interface SendMessageRequest { + QueueUrl?: string; + MessageBody?: string; + DelaySeconds?: number; + } + + export interface ReceiveMessageRequest { + QueueUrl?: string; + MaxNumberOfMessages?: number; + VisibilityTimeout?: number; + AttributeNames?: string[]; + } + + export interface DeleteMessageBatchRequest { + QueueUrl?: string; + Entries?: DeleteMessageBatchRequestEntry[]; + } + + export interface DeleteMessageBatchRequestEntry { + Id: string; + ReceiptHandle: string; + } + + export interface DeleteMessageRequest { + QueueUrl?: string; + ReceiptHandle?: string; + } + + export class Attribute { + Name: string; + Value: string; + } + + export interface SendMessageBatchRequest { + QueueUrl?: string; + Entries?: SendMessageBatchRequestEntry[]; + } + + export class SendMessageBatchRequestEntry { + Id: string; + MessageBody: string; + DelaySeconds: number; + } + + export interface CreateQueueRequest { + QueueName?: string; + DefaultVisibilityTimeout?: number; + DelaySeconds?: number; + Attributes?: Attribute[]; + } + + export interface DeleteQueueRequest { + QueueUrl?: string; + } + + export class SendMessageResult { + MessageId: string; + MD5OfMessageBody: string; + } + + export class ReceiveMessageResult { + Messages: Message[]; + } + + export class Message { + MessageId: string; + ReceiptHandle: string; + MD5OfBody: string; + Body: string; + Attributes: Attribute[]; + } + + export class DeleteMessageBatchResult { + Successful: DeleteMessageBatchResultEntry[]; + Failed: BatchResultErrorEntry[]; + } + + export class DeleteMessageBatchResultEntry { + Id: string; + } + + export class BatchResultErrorEntry { + Id: string; + Code: string; + Message: string; + SenderFault: string; + } + + export class SendMessageBatchResult { + Successful: SendMessageBatchResultEntry[]; + Failed: BatchResultErrorEntry[]; + } + + export class SendMessageBatchResultEntry { + Id: string; + MessageId: string; + MD5OfMessageBody: string; + } + + export class CreateQueueResult { + QueueUrl: string; + } + + } + + export module Ses { + + export interface Client { + config: ClientConfig; + + sendEmail(params: any, callback: (err: any, data: SendEmailResult) => void): void; + } + + export interface SendEmailRequest { + Source: string; + Destination: Destination; + Message: Message; + ReplyToAddresses: string[]; + ReturnPath: string; + } + + export class Destination { + ToAddresses: string[]; + CcAddresses: string[]; + BccAddresses: string[]; + } + + export class Message { + Subject: Content; + Body: Body; + } + + export class Content { + Data: string; + Charset: string; + } + + export class Body { + Text: Content; + Html: Content; + } + + export class SendEmailResult { + MessageId: string; + } + + } + + export module Swf { + + export class Client { + //constructor(options?: any); + public config: ClientConfig; + + countClosedWorkflowExecutions(params: any, callback: (err: any, data: any) => void): void; + countOpenWorkflowExecutions(params: any, callback: (err: any, data: any) => void): void; + countPendingActivityTasks(params: any, callback: (err: any, data: any) => void): void; + countPendingDecisionTasks(params: any, callback: (err: any, data: any) => void): void; + deprecateActivityType(params: any, callback: (err: any, data: any) => void): void; + deprecateDomain(params: any, callback: (err: any, data: any) => void): void; + deprecateWorkflowType(params: any, callback: (err: any, data: any) => void): void; + describeActivityType(params: any, callback: (err: any, data: any) => void): void; + describeDomain(params: any, callback: (err: any, data: any) => void): void; + describeWorkflowExecution(params: any, callback: (err: any, data: any) => void): void; + describeWorkflowType(params: any, callback: (err: any, data: any) => void): void; + getWorkflowExecutionHistory(params: any, callback: (err: any, data: any) => void): void; + listActivityTypes(params: any, callback: (err: any, data: any) => void): void; + listClosedWorkflowExecutions(params: any, callback: (err: any, data: any) => void): void; + listDomains(params: any, callback: (err: any, data: any) => void): void; + listOpenWorkflowExecutions(params: any, callback: (err: any, data: any) => void): void; + listWorkflowTypes(params: any, callback: (err: any, data: any) => void): void; + pollForActivityTask(params: any, callback: (err: any, data: ActivityTask) => void): void; + pollForDecisionTask(params: any, callback: (err: any, data: DecisionTask) => void): void; + recordActivityTaskHeartbeat(params: any, callback: (err: any, data: any) => void): void; + registerActivityType(params: any, callback: (err: any, data: any) => void): void; + registerDomain(params: any, callback: (err: any, data: any) => void): void; + registerWorkflowType(params: any, callback: (err: any, data: any) => void): void; + requestCancelWorkflowExecution(params: any, callback: (err: any, data: any) => void): void; + respondActivityTaskCanceled(params: RespondActivityTaskCanceledRequest, callback: (err: any, data: any) => void): void; + respondActivityTaskCompleted(params: RespondActivityTaskCompletedRequest, callback: (err: any, data: any) => void): void; + respondActivityTaskFailed(params: RespondActivityTaskFailedRequest, callback: (err: any, data: any) => void): void; + respondDecisionTaskCompleted(params: RespondDecisionTaskCompletedRequest, callback: (err: any, data: any) => void): void; + signalWorkflowExecution(params: any, callback: (err: any, data: any) => void): void; + startWorkflowExecution(params: any, callback: (err: any, data: StartWorkflowExecutionResult) => void): void; + terminateWorkflowExecution(params: any, callback: (err: any, data: any) => void): void; + } + + export interface PollForActivityTaskRequest { + domain?: string; + taskList?: TaskList; + identity?: string; + } + + export interface TaskList { + name?: string; + } + + export interface PollForDecisionTaskRequest { + domain?: string; + taskList?: TaskList; + identity?: string; + nextPageToken?: string; + maximumPageSize?: number; + reverseOrder?: Boolean; + } + + export interface StartWorkflowExecutionRequest { + domain?: string; + workflowId?: string; + workflowType?: WorkflowType; + taskList?: TaskList; + input?: string; + executionStartToCloseTimeout?: string; + tagList?: string[]; + taskStartToCloseTimeout?: string; + childPolicy?: string; + } + + export interface WorkflowType { + name?: string; + version?: string; + } + + export interface RespondDecisionTaskCompletedRequest { + taskToken?: string; + decisions?: Decision[]; + executionContext?: string; + } + + export interface Decision { + decisionType?: string; + scheduleActivityTaskDecisionAttributes?: ScheduleActivityTaskDecisionAttributes; + requestCancelActivityTaskDecisionAttributes?: RequestCancelActivityTaskDecisionAttributes; + completeWorkflowExecutionDecisionAttributes?: CompleteWorkflowExecutionDecisionAttributes; + failWorkflowExecutionDecisionAttributes?: FailWorkflowExecutionDecisionAttributes; + cancelWorkflowExecutionDecisionAttributes?: CancelWorkflowExecutionDecisionAttributes; + continueAsNewWorkflowExecutionDecisionAttributes?: ContinueAsNewWorkflowExecutionDecisionAttributes; + recordMarkerDecisionAttributes?: RecordMarkerDecisionAttributes; + startTimerDecisionAttributes?: StartTimerDecisionAttributes; + cancelTimerDecisionAttributes?: CancelTimerDecisionAttributes; + signalExternalWorkflowExecutionDecisionAttributes?: SignalExternalWorkflowExecutionDecisionAttributes; + requestCancelExternalWorkflowExecutionDecisionAttributes?: RequestCancelExternalWorkflowExecutionDecisionAttributes; + startChildWorkflowExecutionDecisionAttributes?: StartChildWorkflowExecutionDecisionAttributes; + } + + export interface ScheduleActivityTaskDecisionAttributes { + activityType?: ActivityType; + activityId?: string; + control?: string; + input?: string; + scheduleToCloseTimeout?: string; + taskList?: TaskList; + scheduleToStartTimeout?: string; + startToCloseTimeout?: string; + heartbeatTimeout?: string; + } + + export interface ActivityType { + name?: string; + version?: string; + } + + export interface RequestCancelActivityTaskDecisionAttributes { + activityId?: string; + } + + export interface CompleteWorkflowExecutionDecisionAttributes { + result?: string; + } + + export interface FailWorkflowExecutionDecisionAttributes { + reason?: string; + details?: string; + } + + export interface CancelWorkflowExecutionDecisionAttributes { + details?: string; + } + + export interface ContinueAsNewWorkflowExecutionDecisionAttributes { + input?: string; + executionStartToCloseTimeout?: string; + taskList?: TaskList; + taskStartToCloseTimeout?: string; + childPolicy?: string; + tagList?: string[]; + workflowTypeVersion?: string; + } + + export interface RecordMarkerDecisionAttributes { + markerName?: string; + details?: string; + } + + export interface StartTimerDecisionAttributes { + timerId?: string; + control?: string; + startToFireTimeout?: string; + } + + export interface CancelTimerDecisionAttributes { + timerId?: string; + } + + export interface SignalExternalWorkflowExecutionDecisionAttributes { + workflowId?: string; + runId?: string; + signalName?: string; + input?: string; + control?: string; + } + + export interface RequestCancelExternalWorkflowExecutionDecisionAttributes { + workflowId?: string; + runId?: string; + control?: string; + } + + export interface StartChildWorkflowExecutionDecisionAttributes { + workflowType?: WorkflowType; + workflowId?: string; + control?: string; + input?: string; + executionStartToCloseTimeout?: string; + taskList?: TaskList; + taskStartToCloseTimeout?: string; + childPolicy?: string; + tagList?: string[]; + } + + export interface RespondActivityTaskCompletedRequest { + taskToken?: string; + result?: string; + } + + export interface RespondActivityTaskFailedRequest { + taskToken?: string; + reason?: string; + details?: string; + } + + export interface RespondActivityTaskCanceledRequest { + taskToken?: string; + details?: string; + } + + export interface DecisionTask { + taskToken?: string; + startedEventId?: number; + workflowExecution?: WorkflowExecution; + workflowType?: WorkflowType; + events?: HistoryEvent[]; + nextPageToken?: string; + previousStartedEventId?: number; + } + + export interface WorkflowExecution { + workflowId?: string; + runId?: string; + } + + export interface HistoryEvent { + eventTimestamp?: any; + eventType?: string; + eventId?: number; + workflowExecutionStartedEventAttributes?: WorkflowExecutionStartedEventAttributes; + workflowExecutionCompletedEventAttributes?: WorkflowExecutionCompletedEventAttributes; + completeWorkflowExecutionFailedEventAttributes?: CompleteWorkflowExecutionFailedEventAttributes; + workflowExecutionFailedEventAttributes?: WorkflowExecutionFailedEventAttributes; + failWorkflowExecutionFailedEventAttributes?: FailWorkflowExecutionFailedEventAttributes; + workflowExecutionTimedOutEventAttributes?: WorkflowExecutionTimedOutEventAttributes; + workflowExecutionCanceledEventAttributes?: WorkflowExecutionCanceledEventAttributes; + cancelWorkflowExecutionFailedEventAttributes?: CancelWorkflowExecutionFailedEventAttributes; + workflowExecutionContinuedAsNewEventAttributes?: WorkflowExecutionContinuedAsNewEventAttributes; + continueAsNewWorkflowExecutionFailedEventAttributes?: ContinueAsNewWorkflowExecutionFailedEventAttributes; + workflowExecutionTerminatedEventAttributes?: WorkflowExecutionTerminatedEventAttributes; + workflowExecutionCancelRequestedEventAttributes?: WorkflowExecutionCancelRequestedEventAttributes; + decisionTaskScheduledEventAttributes?: DecisionTaskScheduledEventAttributes; + decisionTaskStartedEventAttributes?: DecisionTaskStartedEventAttributes; + decisionTaskCompletedEventAttributes?: DecisionTaskCompletedEventAttributes; + decisionTaskTimedOutEventAttributes?: DecisionTaskTimedOutEventAttributes; + activityTaskScheduledEventAttributes?: ActivityTaskScheduledEventAttributes; + activityTaskStartedEventAttributes?: ActivityTaskStartedEventAttributes; + activityTaskCompletedEventAttributes?: ActivityTaskCompletedEventAttributes; + activityTaskFailedEventAttributes?: ActivityTaskFailedEventAttributes; + activityTaskTimedOutEventAttributes?: ActivityTaskTimedOutEventAttributes; + activityTaskCanceledEventAttributes?: ActivityTaskCanceledEventAttributes; + activityTaskCancelRequestedEventAttributes?: ActivityTaskCancelRequestedEventAttributes; + workflowExecutionSignaledEventAttributes?: WorkflowExecutionSignaledEventAttributes; + markerRecordedEventAttributes?: MarkerRecordedEventAttributes; + timerStartedEventAttributes?: TimerStartedEventAttributes; + timerFiredEventAttributes?: TimerFiredEventAttributes; + timerCanceledEventAttributes?: TimerCanceledEventAttributes; + startChildWorkflowExecutionInitiatedEventAttributes?: StartChildWorkflowExecutionInitiatedEventAttributes; + childWorkflowExecutionStartedEventAttributes?: ChildWorkflowExecutionStartedEventAttributes; + childWorkflowExecutionCompletedEventAttributes?: ChildWorkflowExecutionCompletedEventAttributes; + childWorkflowExecutionFailedEventAttributes?: ChildWorkflowExecutionFailedEventAttributes; + childWorkflowExecutionTimedOutEventAttributes?: ChildWorkflowExecutionTimedOutEventAttributes; + childWorkflowExecutionCanceledEventAttributes?: ChildWorkflowExecutionCanceledEventAttributes; + childWorkflowExecutionTerminatedEventAttributes?: ChildWorkflowExecutionTerminatedEventAttributes; + signalExternalWorkflowExecutionInitiatedEventAttributes?: SignalExternalWorkflowExecutionInitiatedEventAttributes; + externalWorkflowExecutionSignaledEventAttributes?: ExternalWorkflowExecutionSignaledEventAttributes; + signalExternalWorkflowExecutionFailedEventAttributes?: SignalExternalWorkflowExecutionFailedEventAttributes; + externalWorkflowExecutionCancelRequestedEventAttributes?: ExternalWorkflowExecutionCancelRequestedEventAttributes; + requestCancelExternalWorkflowExecutionInitiatedEventAttributes?: RequestCancelExternalWorkflowExecutionInitiatedEventAttributes; + requestCancelExternalWorkflowExecutionFailedEventAttributes?: RequestCancelExternalWorkflowExecutionFailedEventAttributes; + scheduleActivityTaskFailedEventAttributes?: ScheduleActivityTaskFailedEventAttributes; + requestCancelActivityTaskFailedEventAttributes?: RequestCancelActivityTaskFailedEventAttributes; + startTimerFailedEventAttributes?: StartTimerFailedEventAttributes; + cancelTimerFailedEventAttributes?: CancelTimerFailedEventAttributes; + startChildWorkflowExecutionFailedEventAttributes?: StartChildWorkflowExecutionFailedEventAttributes; + } + + export interface WorkflowExecutionStartedEventAttributes { + input?: string; + executionStartToCloseTimeout?: string; + taskStartToCloseTimeout?: string; + childPolicy?: string; + taskList?: TaskList; + workflowType?: WorkflowType; + tagList?: string[]; + continuedExecutionRunId?: string; + parentWorkflowExecution?: WorkflowExecution; + parentInitiatedEventId?: number; + } + + export interface WorkflowExecutionCompletedEventAttributes { + result?: string; + decisionTaskCompletedEventId?: number; + } + + export interface CompleteWorkflowExecutionFailedEventAttributes { + cause?: string; + decisionTaskCompletedEventId?: number; + } + + export interface WorkflowExecutionFailedEventAttributes { + reason?: string; + details?: string; + decisionTaskCompletedEventId?: number; + } + + export interface FailWorkflowExecutionFailedEventAttributes { + cause?: string; + decisionTaskCompletedEventId?: number; + } + + export interface WorkflowExecutionTimedOutEventAttributes { + timeoutType?: string; + childPolicy?: string; + } + + export interface WorkflowExecutionCanceledEventAttributes { + details?: string; + decisionTaskCompletedEventId?: number; + } + + export interface CancelWorkflowExecutionFailedEventAttributes { + cause?: string; + decisionTaskCompletedEventId?: number; + } + + export interface WorkflowExecutionContinuedAsNewEventAttributes { + input?: string; + decisionTaskCompletedEventId?: number; + newExecutionRunId?: string; + executionStartToCloseTimeout?: string; + taskList?: TaskList; + taskStartToCloseTimeout?: string; + childPolicy?: string; + tagList?: string[]; + workflowType?: WorkflowType; + } + + export interface ContinueAsNewWorkflowExecutionFailedEventAttributes { + cause?: string; + decisionTaskCompletedEventId?: number; + } + + export interface WorkflowExecutionTerminatedEventAttributes { + reason?: string; + details?: string; + childPolicy?: string; + cause?: string; + } + + export interface WorkflowExecutionCancelRequestedEventAttributes { + externalWorkflowExecution?: WorkflowExecution; + externalInitiatedEventId?: number; + cause?: string; + } + + export interface DecisionTaskScheduledEventAttributes { + taskList?: TaskList; + startToCloseTimeout?: string; + } + + export interface DecisionTaskStartedEventAttributes { + identity?: string; + scheduledEventId?: number; + } + + export interface DecisionTaskCompletedEventAttributes { + executionContext?: string; + scheduledEventId?: number; + startedEventId?: number; + } + + export interface DecisionTaskTimedOutEventAttributes { + timeoutType?: string; + scheduledEventId?: number; + startedEventId?: number; + } + + export interface ActivityTaskScheduledEventAttributes { + activityType?: ActivityType; + activityId?: string; + input?: string; + control?: string; + scheduleToStartTimeout?: string; + scheduleToCloseTimeout?: string; + startToCloseTimeout?: string; + taskList?: TaskList; + decisionTaskCompletedEventId?: number; + heartbeatTimeout?: string; + } + + export interface ActivityTaskStartedEventAttributes { + identity?: string; + scheduledEventId?: number; + } + + export interface ActivityTaskCompletedEventAttributes { + result?: string; + scheduledEventId?: number; + startedEventId?: number; + } + + export interface ActivityTaskFailedEventAttributes { + reason?: string; + details?: string; + scheduledEventId?: number; + startedEventId?: number; + } + + export interface ActivityTaskTimedOutEventAttributes { + timeoutType?: string; + scheduledEventId?: number; + startedEventId?: number; + details?: string; + } + + export interface ActivityTaskCanceledEventAttributes { + details?: string; + scheduledEventId?: number; + startedEventId?: number; + latestCancelRequestedEventId?: number; + } + + export interface ActivityTaskCancelRequestedEventAttributes { + decisionTaskCompletedEventId?: number; + activityId?: string; + } + + export interface WorkflowExecutionSignaledEventAttributes { + signalName?: string; + input?: string; + externalWorkflowExecution?: WorkflowExecution; + externalInitiatedEventId?: number; + } + + export interface MarkerRecordedEventAttributes { + markerName?: string; + details?: string; + decisionTaskCompletedEventId?: number; + } + + export interface TimerStartedEventAttributes { + timerId?: string; + control?: string; + startToFireTimeout?: string; + decisionTaskCompletedEventId?: number; + } + + export interface TimerFiredEventAttributes { + timerId?: string; + startedEventId?: number; + } + + export interface TimerCanceledEventAttributes { + timerId?: string; + startedEventId?: number; + decisionTaskCompletedEventId?: number; + } + + export interface StartChildWorkflowExecutionInitiatedEventAttributes { + workflowId?: string; + workflowType?: WorkflowType; + control?: string; + input?: string; + executionStartToCloseTimeout?: string; + taskList?: TaskList; + decisionTaskCompletedEventId?: number; + childPolicy?: string; + taskStartToCloseTimeout?: string; + tagList?: string[]; + } + + export interface ChildWorkflowExecutionStartedEventAttributes { + workflowExecution?: WorkflowExecution; + workflowType?: WorkflowType; + initiatedEventId?: number; + } + + export interface ChildWorkflowExecutionCompletedEventAttributes { + workflowExecution?: WorkflowExecution; + workflowType?: WorkflowType; + result?: string; + initiatedEventId?: number; + startedEventId?: number; + } + + export interface ChildWorkflowExecutionFailedEventAttributes { + workflowExecution?: WorkflowExecution; + workflowType?: WorkflowType; + reason?: string; + details?: string; + initiatedEventId?: number; + startedEventId?: number; + } + + export interface ChildWorkflowExecutionTimedOutEventAttributes { + workflowExecution?: WorkflowExecution; + workflowType?: WorkflowType; + timeoutType?: string; + initiatedEventId?: number; + startedEventId?: number; + } + + export interface ChildWorkflowExecutionCanceledEventAttributes { + workflowExecution?: WorkflowExecution; + workflowType?: WorkflowType; + details?: string; + initiatedEventId?: number; + startedEventId?: number; + } + + export interface ChildWorkflowExecutionTerminatedEventAttributes { + workflowExecution?: WorkflowExecution; + workflowType?: WorkflowType; + initiatedEventId?: number; + startedEventId?: number; + } + + export interface SignalExternalWorkflowExecutionInitiatedEventAttributes { + workflowId?: string; + runId?: string; + signalName?: string; + input?: string; + decisionTaskCompletedEventId?: number; + control?: string; + } + + export interface ExternalWorkflowExecutionSignaledEventAttributes { + workflowExecution?: WorkflowExecution; + initiatedEventId?: number; + } + + export interface SignalExternalWorkflowExecutionFailedEventAttributes { + workflowId?: string; + runId?: string; + cause?: string; + initiatedEventId?: number; + decisionTaskCompletedEventId?: number; + control?: string; + } + + export interface ExternalWorkflowExecutionCancelRequestedEventAttributes { + workflowExecution?: WorkflowExecution; + initiatedEventId?: number; + } + + export interface RequestCancelExternalWorkflowExecutionInitiatedEventAttributes { + workflowId?: string; + runId?: string; + decisionTaskCompletedEventId?: number; + control?: string; + } + + export interface RequestCancelExternalWorkflowExecutionFailedEventAttributes { + workflowId?: string; + runId?: string; + cause?: string; + initiatedEventId?: number; + decisionTaskCompletedEventId?: number; + control?: string; + } + + export interface ScheduleActivityTaskFailedEventAttributes { + activityType?: ActivityType; + activityId?: string; + cause?: string; + decisionTaskCompletedEventId?: number; + } + + export interface RequestCancelActivityTaskFailedEventAttributes { + activityId?: string; + cause?: string; + decisionTaskCompletedEventId?: number; + } + + export interface StartTimerFailedEventAttributes { + timerId?: string; + cause?: string; + decisionTaskCompletedEventId?: number; + } + + export interface CancelTimerFailedEventAttributes { + timerId?: string; + cause?: string; + decisionTaskCompletedEventId?: number; + } + + export interface StartChildWorkflowExecutionFailedEventAttributes { + workflowType?: WorkflowType; + cause?: string; + workflowId?: string; + initiatedEventId?: number; + decisionTaskCompletedEventId?: number; + control?: string; + } + + export interface ActivityTask { + taskToken?: string; + activityId?: string; + startedEventId?: number; + workflowExecution?: WorkflowExecution; + activityType?: ActivityType; + input?: string; + } + + export interface PollForActivityTaskResult { + activityTask?: ActivityTask; + } + + export interface PollForDecisionTaskResult { + decisionTask?: DecisionTask; + } + + export interface StartWorkflowExecutionResult { + run?: Run; + } + + export interface Run { + runId?: string; + } + + } + + export module Sns { + + export interface Client { + config: ClientConfig; + + publicTopic(params: PublishRequest, callback: (err: any, data: PublishResult) => void): void; + createTopic(params: CreateTopicRequest, callback: (err: any, data: CreateTopicResult) => void): void; + deleteTopic(params: DeleteTopicRequest, callback: (err: any, data: any) => void): void; + } + + export interface PublishRequest { + TopicArn?: string; + Message?: string; + MessageStructure?: string; + Subject?: string; + } + + export interface PublishResult { + MessageId?: string; + } + + export interface CreateTopicRequest { + Name?: string; + } + + export interface CreateTopicResult { + TopicArn?: string; + } + + export interface DeleteTopicRequest { + TopicArn?: string; + } + + } + + export module s3 { + + export interface Client { + config: ClientConfig; + + putObject(params: PutObjectRequest, callback: (err: any, data: any) => void): void; + getObject(params: GetObjectRequest, callback: (err: any, data: any) => void): void; + } + + export interface PutObjectRequest { + ACL?: string; + Body?: any; + Bucket: string; + CacheControl?: string; + ContentDisposition?: string; + ContentEncoding?: string; + ContentLanguage?: string; + ContentLength?: string; + ContentMD5?: string; + ContentType?: string; + Expires?: any; + GrantFullControl?: string; + GrantRead?: string; + GrantReadACP?: string; + GrantWriteACP?: string; + Key: string; + Metadata?: string[]; + ServerSideEncryption?: string; + StorageClass?: string; + WebsiteRedirectLocation?: string; + } + + export interface GetObjectRequest { + Bucket: string; + IfMatch?: string; + IfModifiedSince?: any; + IfNoneMatch?: string; + IfUnmodifiedSince?: any; + Key: string; + Range?: string; + ResponseCacheControl?: string; + ResponseContentDisposition?: string; + ResponseContentEncoding?: string; + ResponseContentLanguage?: string; + ResponseContentType?: string; + ResponseExpires?: any; + VersionId?: string; + } + + } +} diff --git a/consolidate/consolidate-tests.ts b/consolidate/consolidate-tests.ts new file mode 100644 index 000000000..bf4fea449 --- /dev/null +++ b/consolidate/consolidate-tests.ts @@ -0,0 +1,27 @@ +/// + +import consolidate = require('consolidate'); + +var path: string = null; +var options: any = null; +var fn: any = null; + +consolidate.clearCache(); +consolidate.jade(path, options, fn); +consolidate.dust(path, options, fn); +consolidate.swig(path, options, fn); +consolidate.liquor(path, options, fn); +consolidate.ejs(path, options, fn); +consolidate.eco(path, options, fn); +consolidate.jazz(path, options, fn); +consolidate.jqtpl(path, options, fn); +consolidate.haml(path, options, fn); +consolidate.whiskers(path, options, fn); +//consolidate.'haml-coffee':Function; +consolidate.hogan(path, options, fn); +consolidate.handlebars(path, options, fn); +consolidate.underscore(path, options, fn); +consolidate.qejs(path, options, fn); +consolidate.walrus(path, options, fn); +consolidate.mustache(path, options, fn); +consolidate.dot(path, options, fn); diff --git a/consolidate/consolidate.d.ts b/consolidate/consolidate.d.ts new file mode 100644 index 000000000..3bfe35bf0 --- /dev/null +++ b/consolidate/consolidate.d.ts @@ -0,0 +1,30 @@ +// Type definitions for consolidate +// Project: https://github.com/visionmedia/consolidate.js +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/consolidate.d.ts + +/// + +declare module "consolidate" { + export function clearCache(): void; + export var jade: (path: String, options: any, fn: any) => void; + export var dust: (path: String, options: any, fn: any) => void; + export var swig: (path: String, options: any, fn: any) => void; + export var liquor: (path: String, options: any, fn: any) => void; + export var ejs: (path: String, options: any, fn: any) => void; + export var eco: (path: String, options: any, fn: any) => void; + export var jazz: (path: String, options: any, fn: any) => void; + export var jqtpl: (path: String, options: any, fn: any) => void; + export var haml: (path: String, options: any, fn: any) => void; + export var whiskers: (path: String, options: any, fn: any) => void; + //export var 'haml-coffee':Function; + export var hogan: (path: String, options: any, fn: any) => void; + export var handlebars: (path: String, options: any, fn: any) => void; + export var underscore: (path: String, options: any, fn: any) => void; + export var qejs: (path: String, options: any, fn: any) => void; + export var walrus: (path: String, options: any, fn: any) => void; + export var mustache: (path: String, options: any, fn: any) => void; + export var dot: (path: String, options: any, fn: any) => void; +} diff --git a/fibers/fibers-tests.ts b/fibers/fibers-tests.ts new file mode 100644 index 000000000..62645defb --- /dev/null +++ b/fibers/fibers-tests.ts @@ -0,0 +1,13 @@ +/// + +import fibers = require('fibers'); + +var fib: fibers.Fiber; +var x:any = null; +var func: () => void = null; + +fib = fibers(func); +fib = fibers.current; +x = fibers.yield(x); +x = fib.run(); +x = fib.run(x); diff --git a/fibers/fibers.d.ts b/fibers/fibers.d.ts new file mode 100644 index 000000000..0faea1593 --- /dev/null +++ b/fibers/fibers.d.ts @@ -0,0 +1,24 @@ +// Type definitions for fibers +// Project: https://github.com/laverdet/node-fibers +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/fibers.d.ts + +declare module "fibers" { + + function fibers(callback: () => void): fibers.Fiber; + + module fibers { + export var poolSize: number; + export var fibersCreated: number; + export var current: fibers.Fiber; + export function yield(value: any): any; + + export interface Fiber { + run(step?: number): any; + } + } + + export = fibers; +} diff --git a/form-data/form-data-tests.ts b/form-data/form-data-tests.ts new file mode 100644 index 000000000..641a36874 --- /dev/null +++ b/form-data/form-data-tests.ts @@ -0,0 +1,8 @@ +/// + +import formData = require('form-data'); + +var value: any; +var fd = new formData.FormData(); +var obj: Object = fd.getHeaders(); +value = fd.pipe(value); diff --git a/form-data/form-data.d.ts b/form-data/form-data.d.ts new file mode 100644 index 000000000..af0f2d799 --- /dev/null +++ b/form-data/form-data.d.ts @@ -0,0 +1,15 @@ +// Type definitions for fibers +// Project: https://github.com/felixge/node-form-data +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/form-data.d.ts + +declare module "form-data" { + export class FormData { + append(key: string, value: any): FormData; + getHeaders(): Object; + // TODO expand pipe + pipe(to: any): any; + } +} diff --git a/fs-extra/fs-extra-tests.ts b/fs-extra/fs-extra-tests.ts new file mode 100644 index 000000000..ea3432e1c --- /dev/null +++ b/fs-extra/fs-extra-tests.ts @@ -0,0 +1,229 @@ +/// +/// + +import fs = require('fs-extra'); +import stream = require('stream'); + +var stats: fs.Stats; +var str: string; +var strArr: string[]; +var bool: boolean; +var num: number; +var src: string; +var dest: string; +var file: string; +var filename: string; +var dir: string; +var path: string; +var data: any; +var object: Object; +var buffer: NodeBuffer; +var modeNum: number; +var modeStr: string; +var encoding: string; +var type: string; +var flags: string; +var srcpath: string; +var dstpath: string; +var oldPath: string; +var newPath: string; +var cache: string; +var offset: number; +var length: number; +var position: number; +var cacheBool: boolean; +var cacheStr: string; +var fd: number; +var len: number; +var uid: number; +var gid: number; +var atime: number; +var mtime: number; +var statsCallback: (err: Error, stats: fs.Stats) => void; +var errorCallback: (err: Error) => void; +var openOpts: fs.OpenOptions; +var watcher: fs.FSWatcher; +var readStreeam: stream.Readable; +var writeStream: stream.Writable; + +fs.copy(src, dest, errorCallback); +fs.copy(src, dest, (src: string) => { + return false; +}, errorCallback); +fs.copySync(src, dest); +fs.copySync(src, dest, (src: string) => { + return false; +}); +fs.createFile(file, errorCallback); +fs.createFileSync(file); + +fs.mkdirs(dir, errorCallback); +fs.mkdirsSync(dir); +fs.mkdirp(dir, errorCallback); +fs.mkdirpSync(dir); + +fs.outputFile(file, data, errorCallback); +fs.outputFileSync(file, data); +fs.outputJson(file, data, errorCallback); +fs.outputJSON(file, data, errorCallback); + +fs.outputJsonSync(file, data); +fs.outputJSONSync(file, data); + +fs.readJson(file, errorCallback); +fs.readJson(file, openOpts, errorCallback); +fs.readJSON(file, errorCallback); +fs.readJSON(file, openOpts, errorCallback); + +fs.readJsonSync(file, openOpts); +fs.readJSONSync(file, openOpts); + +fs.remove(dir, errorCallback); +fs.removeSync(dir); + +fs.writeJson(file, object, errorCallback); +fs.writeJson(file, object, openOpts, errorCallback); +fs.writeJSON(file, object, errorCallback); +fs.writeJSON(file, object, openOpts, errorCallback); + +fs.writeJsonSync(file, object, openOpts); +fs.writeJSONSync(file, object, openOpts); + +fs.rename(oldPath, newPath, errorCallback); +fs.renameSync(oldPath, newPath); +fs.truncate(fd, len, errorCallback); +fs.truncateSync(fd, len); +fs.chown(path, uid, gid, errorCallback); +fs.chownSync(path, uid, gid); +fs.fchown(fd, uid, gid, errorCallback); +fs.fchownSync(fd, uid, gid); +fs.lchown(path, uid, gid, errorCallback); +fs.lchownSync(path, uid, gid); +fs.chmod(path, modeNum, errorCallback); +fs.chmod(path, modeStr, errorCallback); +fs.chmodSync(path, modeNum); +fs.chmodSync(path, modeStr); +fs.fchmod(fd, modeNum, errorCallback); +fs.fchmod(fd, modeStr, errorCallback); +fs.fchmodSync(fd, modeNum); +fs.fchmodSync(fd, modeStr); +fs.lchmod(path, modeStr, errorCallback); +fs.lchmod(path, modeNum, errorCallback); +fs.lchmodSync(path, modeNum); +fs.lchmodSync(path, modeStr); +fs.stat(path, statsCallback); +fs.lstat(path, statsCallback); +fs.fstat(fd, statsCallback); +stats = fs.statSync(path); +stats = fs.lstatSync(path); +stats = fs.fstatSync(fd); +fs.link(srcpath, dstpath, errorCallback); +fs.linkSync(srcpath, dstpath); +fs.symlink(srcpath, dstpath, type, errorCallback); +fs.symlinkSync(srcpath, dstpath, type); +fs.readlink(path, (err: Error, linkString: string) => { + +}); +fs.realpath(path, (err: Error, resolvedPath: string) => { + +}); +fs.realpath(path, cache, (err: Error, resolvedPath: string) => { + +}); +str = fs.realpathSync(path, cacheBool); +fs.unlink(path, errorCallback); +fs.unlinkSync(path); +fs.rmdir(path, errorCallback); +fs.rmdirSync(path); +fs.mkdir(path, modeNum, errorCallback); +fs.mkdir(path, modeStr, errorCallback); +fs.mkdirSync(path, modeNum); +fs.mkdirSync(path, modeStr); +fs.readdir(path, (err: Error, files: string[]) => { + +}); +strArr = fs.readdirSync(path); +fs.close(fd, errorCallback); +fs.closeSync(fd); +fs.open(path, flags, modeStr, (err: Error, fd: number) => [ + +]); +num = fs.openSync(path, flags, modeStr); +fs.utimes(path, atime, mtime, errorCallback); +fs.utimesSync(path, atime, mtime); +fs.futimes(fd, atime, mtime, errorCallback); +fs.futimesSync(fd, atime, mtime); +fs.fsync(fd, errorCallback); +fs.fsyncSync(fd); +fs.write(fd, buffer, offset, length, position, (err: Error, written: number, buffer: NodeBuffer) => { + +}); +num = fs.writeSync(fd, buffer, offset, length, position); +fs.read(fd, buffer, offset, length, position, (err: Error, bytesRead: number, buffer: NodeBuffer) => { + +}); +num = fs.readSync(fd, buffer, offset, length, position); +fs.readFile(filename, (err: Error, data: NodeBuffer) => { + +}); +fs.readFile(filename, encoding, (err: Error, data: string) => { + +}); +fs.readFile(filename, openOpts, (err: Error, data: string) => { + +}); +fs.readFile(filename, (err: Error, data: NodeBuffer) => { + +}); +buffer = fs.readFileSync(filename); +str = fs.readFileSync(filename, encoding); +str = fs.readFileSync(filename, openOpts); + +fs.writeFile(filename, data, errorCallback); +fs.writeFile(filename, data, encoding, errorCallback); +fs.writeFile(filename, data, openOpts, errorCallback); +fs.writeFileSync(filename, data); +fs.writeFileSync(filename, data, encoding); +fs.writeFileSync(filename, data, openOpts); + +fs.appendFile(filename, data, errorCallback); +fs.appendFile(filename, data, encoding, errorCallback); +fs.appendFile(filename, data, openOpts, errorCallback); +fs.appendFileSync(filename, data); +fs.appendFileSync(filename, data, encoding); +fs.appendFileSync(filename, data, openOpts); + +fs.watchFile(filename, { + curr: stats, + prev: stats +}); +fs.watchFile(filename, { + persistent: bool, + interval: num +}, { + curr: stats, + prev: stats +}); +fs.unwatchFile(filename); +watcher = fs.watch(filename, { persistent: bool }, (event: string, filename: string) => { + +}); +fs.exists(path, (exists: boolean) => { + +}); +bool = fs.existsSync(path); + +readStreeam = fs.createReadStream(path); +readStreeam = fs.createReadStream(path, { + flags: str, + encoding: str, + fd: num, + mode: num, + bufferSize: num +}); +writeStream = fs.createWriteStream(path); +writeStream = fs.createWriteStream(path, { + flags: str, + encoding: str, + string: str +}); diff --git a/fs-extra/fs-extra.d.ts b/fs-extra/fs-extra.d.ts new file mode 100644 index 000000000..75f6c71a0 --- /dev/null +++ b/fs-extra/fs-extra.d.ts @@ -0,0 +1,187 @@ +// Type definitions for aws-sdk +// Project: https://github.com/jprichardson/node-fs-extra +// Definitions by: midknight41 +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/fs-extra.d.ts + +/// + +declare module "fs-extra" { + import stream = require("stream"); + + export interface Stats { + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + 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; + } + + export interface FSWatcher { + close(): void; + } + + export class ReadStream extends stream.Readable { } + export class WriteStream extends stream.Writable { } + + //extended methods + export function copy(src: string, dest: string, callback?: (err: Error) => void): void; + export function copy(src: string, dest: string, filter: (src: string) => boolean, callback?: (err: Error) => void): void; + + export function copySync(src: string, dest: string): void; + export function copySync(src: string, dest: string, filter: (src: string) => boolean): void; + + export function createFile(file: string, callback?: (err: Error) => void): void; + export function createFileSync(file: string): void; + + export function mkdirs(dir: string, callback?: (err: Error) => void): void; + export function mkdirp(dir: string, callback?: (err: Error) => void): void; + export function mkdirsSync(dir: string): void; + export function mkdirpSync(dir: string): void; + + export function outputFile(file: string, data: any, callback?: (err: Error) => void): void; + export function outputFileSync(file: string, data: any): void; + + export function outputJson(file: string, data: any, callback?: (err: Error) => void): void; + export function outputJSON(file: string, data: any, callback?: (err: Error) => void): void; + export function outputJsonSync(file: string, data: any): void; + export function outputJSONSync(file: string, data: any): void; + + export function readJson(file: string, callback?: (err: Error) => void): void; + export function readJson(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; + export function readJSON(file: string, callback?: (err: Error) => void): void; + export function readJSON(file: string, options?: OpenOptions, callback?: (err: Error) => void): void; + + export function readJsonSync(file: string, options?: OpenOptions): void; + export function readJSONSync(file: string, options?: OpenOptions): void; + + export function remove(dir: string, callback?: (err: Error) => void): void; + export function removeSync(dir: string): void; + // export function delete(dir: string, callback?: (err: Error) => void): void; + // export function deleteSync(dir: string): void; + + export function writeJson(file: string, object: any, callback?: (err: Error) => void): void; + export function writeJson(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; + export function writeJSON(file: string, object: any, callback?: (err: Error) => void): void; + export function writeJSON(file: string, object: any, options?: OpenOptions, callback?: (err: Error) => void): void; + + export function writeJsonSync(file: string, object: any, options?: OpenOptions): void; + export function writeJSONSync(file: string, object: any, options?: OpenOptions): void; + + export function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void; + export function renameSync(oldPath: string, newPath: string): void; + export function truncate(fd: number, len: number, callback?: (err: Error) => void): void; + export function truncateSync(fd: number, len: number): void; + export function chown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; + export function chownSync(path: string, uid: number, gid: number): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err: Error) => void): void; + export function fchownSync(fd: number, uid: number, gid: number): void; + export function lchown(path: string, uid: number, gid: number, callback?: (err: Error) => void): void; + export function lchownSync(path: string, uid: number, gid: number): void; + export function chmod(path: string, mode: number, callback?: (err: Error) => void): void; + export function chmod(path: string, mode: string, callback?: (err: Error) => void): void; + export function chmodSync(path: string, mode: number): void; + export function chmodSync(path: string, mode: string): void; + export function fchmod(fd: number, mode: number, callback?: (err: Error) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err: Error) => void): void; + export function fchmodSync(fd: number, mode: number): void; + export function fchmodSync(fd: number, mode: string): void; + export function lchmod(path: string, mode: string, callback?: (err: Error) => void): void; + export function lchmod(path: string, mode: number, callback?: (err: Error) => void): void; + export function lchmodSync(path: string, mode: number): void; + export function lchmodSync(path: string, mode: string): void; + export function stat(path: string, callback?: (err: Error, stats: Stats) => void): void; + export function lstat(path: string, callback?: (err: Error, stats: Stats) => void): void; + export function fstat(fd: number, callback?: (err: Error, stats: Stats) => void): void; + export function statSync(path: string): Stats; + export function lstatSync(path: string): Stats; + export function fstatSync(fd: number): Stats; + export function link(srcpath: string, dstpath: string, callback?: (err: Error) => void): void; + export function linkSync(srcpath: string, dstpath: string): void; + export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err: Error) => void): void; + export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; + export function readlink(path: string, callback?: (err: Error, linkString: string) => void): void; + export function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void; + export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void; + export function realpathSync(path: string, cache?: boolean): string; + export function unlink(path: string, callback?: (err: Error) => void): void; + export function unlinkSync(path: string): void; + export function rmdir(path: string, callback?: (err: Error) => void): void; + export function rmdirSync(path: string): void; + export function mkdir(path: string, mode?: number, callback?: (err: Error) => void): void; + export function mkdir(path: string, mode?: string, callback?: (err: Error) => void): void; + export function mkdirSync(path: string, mode?: number): void; + export function mkdirSync(path: string, mode?: string): void; + export function readdir(path: string, callback?: (err: Error, files: string[]) => void ): void; + export function readdirSync(path: string): string[]; + export function close(fd: number, callback?: (err: Error) => void): void; + export function closeSync(fd: number): void; + export function open(path: string, flags: string, mode?: string, callback?: (err: Error, fs: number) => void): void; + export function openSync(path: string, flags: string, mode?: string): number; + export function utimes(path: string, atime: number, mtime: number, callback?: (err: Error) => void): void; + export function utimesSync(path: string, atime: number, mtime: number): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err: Error) => void): void; + export function futimesSync(fd: number, atime: number, mtime: number): void; + export function fsync(fd: number, callback?: (err: Error) => void): void; + export function fsyncSync(fd: number): void; + export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) => void): void; + export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; + export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void ): void; + export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; + export function readFile(filename: string, encoding: string, callback: (err: Error, data: string) => void ): void; + export function readFile(filename: string, options: OpenOptions, callback: (err: Error, data: string) => void ): void; + export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void ): void; + export function readFileSync(filename: string): NodeBuffer; + export function readFileSync(filename: string, encoding: string): string; + export function readFileSync(filename: string, options: OpenOptions): string; + export function writeFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; + export function writeFile(filename: string, data: any, options?: OpenOptions, callback?: (err: Error) => void): void; + export function writeFileSync(filename: string, data: any, encoding?: string): void; + export function writeFileSync(filename: string, data: any, option?: OpenOptions): void; + export function appendFile(filename: string, data: any, encoding?: string, callback?: (err: Error) => void): void; + export function appendFile(filename: string, data: any,option?: OpenOptions, callback?: (err: Error) => void): void; + export function appendFileSync(filename: string, data: any, encoding?: string): void; + export function appendFileSync(filename: string, data: any, option?: OpenOptions): void; + export function watchFile(filename: string, listener: { curr: Stats; prev: Stats; }): void; + export function watchFile(filename: string, options: { persistent?: boolean; interval?: number; }, listener: { curr: Stats; prev: Stats; }): void; + export function unwatchFile(filename: string, listener?: Stats): void; + export function watch(filename: string, options?: { persistent?: boolean; }, listener?: (event: string, filename: string) => any): FSWatcher; + export function exists(path: string, callback?: (exists: boolean) => void ): void; + export function existsSync(path: string): boolean; + + export interface OpenOptions { + encoding?: string; + flag?: string; + } + + export interface ReadStreamOptions { + flags?: string; + encoding?: string; + fd?: number; + mode?: number; + bufferSize?: number; + } + export interface WriteStreamOptions { + flags?: string; + encoding?: string; + string?: string; + } + export function createReadStream(path: string, options?: ReadStreamOptions): ReadStream; + export function createWriteStream(path: string, options?: WriteStreamOptions): WriteStream; +} diff --git a/gently/gently-tests.ts b/gently/gently-tests.ts new file mode 100644 index 000000000..a1ce56352 --- /dev/null +++ b/gently/gently-tests.ts @@ -0,0 +1,14 @@ +/// + +import Gently = require('gently'); + +var g = new Gently(); + +g.expect(null, '', () => { + // .. +})(); +g.expect(null, '', 0, () => { + // .. +})(); + +g.restore(null, ''); diff --git a/gently/gently.d.ts b/gently/gently.d.ts new file mode 100644 index 000000000..de2ec72c8 --- /dev/null +++ b/gently/gently.d.ts @@ -0,0 +1,26 @@ +// Type definitions for gently +// Project: https://www.npmjs.org/package/gently +// Definitions by: bonnici +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/gently.d.ts + +declare module "gently" { + export = Gently; + + class Gently { + constructor(); + hijacked: any[]; + + expect(obj: any, method: string, stubFn?: (...args: any[]) => any): (...args: any[]) => any; + expect(obj: any, method: string, count: number, stubFn: (...args: any[]) => any): (...args: any[]) => any; + + restore(obj: any, method: string): void; + + hijack(realRequire: (id: string) => any): (id: string) => any; + + stub(location: string, exportsName?: string): any; + + verify(msg?: string): void; + } +} diff --git a/imagemagick/imagemagick-tests.ts b/imagemagick/imagemagick-tests.ts new file mode 100644 index 000000000..dbf03db04 --- /dev/null +++ b/imagemagick/imagemagick-tests.ts @@ -0,0 +1,27 @@ +/// +/// + +import imagemagick = require('imagemagick'); +import child_process = require('child_process'); + +var str: string = null; +var num: number = 0; +var cp: child_process.ChildProcess; + +cp = imagemagick.identify(str, (err: Error, res: imagemagick.Features) => { + str = res.format; + num = res.width; + num = res.height; + num = res.depth; +}); + +cp = imagemagick.convert(str, num, (err: Error, res: any) => { + +}); + +cp = imagemagick.resize({ + width: num, + height: num +}, (err: Error, res: any) => { + +}); diff --git a/imagemagick/imagemagick.d.ts b/imagemagick/imagemagick.d.ts new file mode 100644 index 000000000..0d551a5d4 --- /dev/null +++ b/imagemagick/imagemagick.d.ts @@ -0,0 +1,59 @@ +// Type definitions for imagemagick +// Project: http://github.com/rsms/node-imagemagick +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/imagemagick.d.ts + +/// + +declare module "imagemagick" { + import child_process = require("child_process"); + + export function identify(path: string, callback: (err: Error, features: Features) => void): child_process.ChildProcess; + export function identify(path: any[], callback: (err: Error, result: string) => void): child_process.ChildProcess; + export module identify { + export var path: string; + } + export function readMetadata(path: string, callback: (err: Error, result: any) => void): child_process.ChildProcess; + + export function convert(args: any, callback: (err: Error, result: any) => void): child_process.ChildProcess; + export function convert(args: any, timeout: number, callback: (err: Error, result: any) => void): child_process.ChildProcess; + export module convert { + export var path: string; + } + + export function resize(options: Options, callback: (err: Error, result: any) => void): child_process.ChildProcess; + export function crop(options: Options, callback: (err: Error, result: any) => void): child_process.ChildProcess; + export function resizeArgs(options: Options): ResizeArgs; + + export interface Features { + format?: string; + width?: number; + height?: number; + depth?: number; + } + + export interface Options { + srcPath?: string; //: null, + srcData?: string; //: null, + srcFormat?: string; //: null, + dstPath?: string; //: null, + quality?: number; //: 0.8, + format?: string; //: 'jpg', + progressive?: boolean; //: false, + colorspace?: any; //: null, + width?: number; //: 0, + height?: number; //: 0, + strip?: boolean; //: true, + filter?: string; //: 'Lagrange', + sharpening?: number; //: 0.2, + customArgs?: any[]; //: [], + timeout?: number; //: 0 + } + + export interface ResizeArgs { + opt: Options; + args: string[]; + } +} diff --git a/memory-cache/memory-cache-tests.ts b/memory-cache/memory-cache-tests.ts new file mode 100644 index 000000000..14ee55c20 --- /dev/null +++ b/memory-cache/memory-cache-tests.ts @@ -0,0 +1,24 @@ +/// + +import memoryCache = require('memory-cache'); + +var key: any; +var value: any; +var bool: boolean; +var num: number; + +memoryCache.put(key, value); +memoryCache.put(key, value, num); +memoryCache.put(key, value, num, (key) => { + +}); +value = memoryCache.get(key); +memoryCache.del(key); +memoryCache.clear(); + +num = memoryCache.size(); +num = memoryCache.memsize(); + +memoryCache.debug(bool); +num = memoryCache.hits(); +num = memoryCache.misses(); diff --git a/memory-cache/memory-cache.d.ts b/memory-cache/memory-cache.d.ts new file mode 100644 index 000000000..1eb9c61cf --- /dev/null +++ b/memory-cache/memory-cache.d.ts @@ -0,0 +1,20 @@ +// Type definitions for memory-cache +// Project: http://github.com/ptarjan/node-cache +// Definitions by: Jeff Goddard +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/memory-cache.d.ts + +declare module "memory-cache" { + export function put(key: any, value: any, time?: number, timeoutCallback?: (key: any) => void): void; + export function get(key: any): any; + export function del(key: any): void; + export function clear(): void; + + export function size(): number; + export function memsize(): number; + + export function debug(bool: boolean): void; + export function hits(): number; + export function misses(): number; +} diff --git a/mime/mime-tests.ts b/mime/mime-tests.ts new file mode 100644 index 000000000..36f0e5c15 --- /dev/null +++ b/mime/mime-tests.ts @@ -0,0 +1,13 @@ +/// + +import mime = require('mime'); + +var str: string; +var obj: Object; + +str = mime.lookup(str); +str = mime.extension(str); +mime.load(str); +mime.define(obj); + +str = mime.charsets.lookup(str); diff --git a/mime/mime.d.ts b/mime/mime.d.ts new file mode 100644 index 000000000..bfaa7a51f --- /dev/null +++ b/mime/mime.d.ts @@ -0,0 +1,19 @@ +// Type definitions for mime +// Project: https://github.com/broofa/node-mime +// Definitions by: Jeff Goddard +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/mime.d.ts + +declare module "mime" { + export function lookup(path: string): string; + export function extension(mime: string): string; + export function load(filepath: string): void; + export function define(mimes: Object): void; + + interface Charsets { + lookup(mime: string): string; + } + + export var charsets: Charsets; +} diff --git a/mu2/mu2-tests.ts b/mu2/mu2-tests.ts new file mode 100644 index 000000000..e8172b800 --- /dev/null +++ b/mu2/mu2-tests.ts @@ -0,0 +1,32 @@ +/// +/// + +import mu2 = require('mu2'); +import stream = require('stream'); + +var str: string; +var value: any; +var read: ReadableStream; +var parsed: mu2.IParsed; + +str = mu2.root; + +read = mu2.compileAndRender(str, value); + +mu2.compile(str, (err: Error, parsed: mu2.IParsed) => { + +}); +mu2.compileText(str, str, (err: Error, parsed: mu2.IParsed) => { + +}); +parsed = mu2.compileText(str, str); +parsed = mu2.compileText(str); + +read = mu2.render(str, value); +read = mu2.render(parsed, value); + +read = mu2.renderText(str, value); +read = mu2.renderText(str, value, value); + +mu2.clearCache(); +mu2.clearCache(str); diff --git a/mu2/mu2.d.ts b/mu2/mu2.d.ts new file mode 100644 index 000000000..cbc46d6fb --- /dev/null +++ b/mu2/mu2.d.ts @@ -0,0 +1,29 @@ +// Type definitions for mu2 +// Project: http://github.com/raycmorgan/mu +// Definitions by: Jeff Goddard +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/mu2.d.ts + +/// + +declare module "mu2" { + export var root: string; + + export function compileAndRender(templateName: string, view: any): ReadableStream; + + export function compile(filename: string, callback: (err: Error, parsed: IParsed) => void): void; + + export function compileText(name: string, template: string, callback: (err: Error, parsed: IParsed) => void): void; + export function compileText(name: string, template: string): IParsed; + export function compileText(template: string): IParsed; + + export function render(filenameOrParsed: string, view: any): ReadableStream; + export function render(filenameOrParsed: IParsed, view: any): ReadableStream; + + export function renderText(template: string, view: any, partials?: any): ReadableStream; + + export function clearCache(templateName?: string): void; + + export interface IParsed { } +} diff --git a/nconf/nconf-tests.ts b/nconf/nconf-tests.ts new file mode 100644 index 000000000..13b314af8 --- /dev/null +++ b/nconf/nconf-tests.ts @@ -0,0 +1,101 @@ +/// + +import nconf = require('nconf'); + +var value: any; +var num: number; +var bool: boolean; +var valueArr: any[]; +var str: string; +var strArr: string[]; +var p: nconf.Provider; +var opts: nconf.IOptions; +var fopts: nconf.IFileOptions; +var store: nconf.IStore; +var callback: (err: Error) => void; + +value = nconf.clear(str, callback); +value = nconf.get (str, callback); +value = nconf.merge(str, value, callback); +value = nconf.set (str, value, callback); +value = nconf.reset(callback); + +value = nconf.load(callback); +nconf.mergeSources(value); +value = nconf.loadSources(); +value = nconf.save(value, callback); + +p = nconf.add(str); +p = nconf.add(str, opts);; + +p = nconf.argv(); +p = nconf.argv(opts); + +p = nconf.env(); +p = nconf.env(opts); + +p = nconf.file(str); +p = nconf.file(str, fopts); +p = nconf.file(fopts); + +p = nconf.use(str); +p = nconf.use(str, opts); + +p = nconf.defaults(); +p = nconf.defaults(opts); + +nconf.init(); +nconf.init(opts); + +p = nconf.overrides(); +p = nconf.overrides(opts); +nconf.remove(str); +store = nconf.create(str, opts); + +str = nconf.key(value, value); +valueArr = nconf.path(value); +nconf.loadFiles(value, callback); +nconf.loadFilesSync(value, callback); + +// - - - - - - - - - - - - - - - - - - - - - - - - - + +str = store.type; +value = store.get(str); +bool = store.set(str, value); +bool = store.clear(str); +bool = store.merge(str, value); +bool = store.reset(callback); + +// - - - - - - - - - - - - - - - - - - - - - - - - - + +p = new nconf.Provider(opts); +value = p.stores; +valueArr = p.sources; + +value = p.clear(str, callback); +value = p.get(str, callback); +value = p.merge(str,value,callback); +value = p.set(str,value,callback); +value = p.reset(callback); + +value = p.load(callback); +p.mergeSources(value); +value = p.loadSources(); +value = p.save(value, callback); + +p = p.add(str); +p = p.add(str, opts); +p = p.argv(); +p = p.argv(opts); +p = p.env(); +p = p.env(opts); +p = p.file(str); +p = p.file(str, fopts); +p = p.file(fopts); +p = p.use(str, opts); + +p = p.defaults(opts); +p.init(opts); +p = p.overrides(opts); +p.remove(str); +store = p.create(str, opts); diff --git a/nconf/nconf.d.ts b/nconf/nconf.d.ts new file mode 100644 index 000000000..2ebd18a15 --- /dev/null +++ b/nconf/nconf.d.ts @@ -0,0 +1,100 @@ +// Type definitions for nconf +// Project: https://github.com/flatiron/nconf +// Definitions by: Jeff Goddard +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/nconf.d.ts + +declare module "nconf" { + export var version: number; + export var stores: any; + export var sources: any[]; + + export function clear(key: string, callback?: ICallbackFunction): any; + export function get (key: string, callback?: ICallbackFunction): any; + export function merge(key: string, value: any, callback?: ICallbackFunction): any; + export function set (key: string, value: any, callback?: ICallbackFunction): any; + export function reset(callback?: ICallbackFunction): any; + + export function load(callback?: ICallbackFunction): any; + export function mergeSources(data: any): void; + export function loadSources(): any; + export function save(value: any, callback?: ICallbackFunction): any; + + export function add(name: string, options?: IOptions): Provider; + export function argv(options?: IOptions): Provider; + export function env(options?: IOptions): Provider; + export function file(name: string, options?: IFileOptions): Provider; + export function file(options: IFileOptions): Provider; + export function use(name: string, options?: IOptions): Provider; + export function defaults(options?: IOptions): Provider; + export function init(options?: IOptions): void; + export function overrides(options?: IOptions): Provider; + export function remove(name: string): void; + export function create(name: string, options: IOptions): IStore; + + export function key(...values: any[]): string; + export function path(key: any): any[]; + export function loadFiles(files: any, callback?: ICallbackFunction): void; + export function loadFilesSync(files: any, callback?: ICallbackFunction): void; + + export enum formats { + json, + ini + } + + export interface IOptions { + type?: string; + } + + export interface IFileOptions extends IOptions { + file?: string; + dir?: string; + search?: boolean; + json_spacing?: number; + } + + export interface ICallbackFunction { + (err: Error): void; + } + + export class Provider { + constructor(options: IOptions); + + stores: any; + sources: any[]; + + clear(key: string, callback?: ICallbackFunction): any; + get (key: string, callback?: ICallbackFunction): any; + merge(key: string, value: any, callback?: ICallbackFunction): any; + set (key: string, value: any, callback?: ICallbackFunction): any; + reset(callback?: ICallbackFunction): any; + + load(callback?: ICallbackFunction): any; + mergeSources(data: any): void; + loadSources(): any; + save(value: any, callback?: ICallbackFunction): any; + + add(name: string, options?: IOptions): Provider; + argv(options?: IOptions): Provider; + env(options?: IOptions): Provider; + file(name: string, options?: IFileOptions): Provider; + file(options: IFileOptions): Provider; + use(name: string, options?: IOptions): Provider; + + defaults(options?: IOptions): Provider; + init(options?: IOptions): void; + overrides(options?: IOptions): Provider; + remove(name: string): void; + create(name: string, options: IOptions): IStore; + } + + export interface IStore { + type: string; + get (key: string): any; + set (key: string, value: any): boolean; + clear(key: string): boolean; + merge(key: string, value: any): boolean; + reset(callback?: ICallbackFunction): boolean; + } +} diff --git a/nock/nock-tests.ts b/nock/nock-tests.ts new file mode 100644 index 000000000..b3b68dd20 --- /dev/null +++ b/nock/nock-tests.ts @@ -0,0 +1,60 @@ +/// + +import nock = require('nock'); + +var inst: nock.Scope; +var str: string; +var bool: boolean; +var data: string; +var num: number; +var value: any; +var regex: RegExp; +var options: nock.Options; +var headers: Object; + +inst = inst.head(str); +inst = inst.get(str); +inst = inst.get(str, data); +inst = inst.post(str); +inst = inst.post(str, data); +inst = inst.put(str); +inst = inst.put(str, data); + +inst = inst.delete(str); +inst = inst.delete(str, data); + +inst = inst.intercept(str, str); +inst = inst.intercept(str, str, str); +inst = inst.intercept(str, str, str, value); + +inst = inst.reply(num); +inst = inst.reply(num, str); +inst = inst.reply(num, str, headers); +inst = inst.reply(num, (uri: string, body: string) => { + return str; +}); +inst = inst.reply(num, (uri: string, body: string) => { + return str; +}, headers); +inst = inst.replyWithFile(num, str); + +inst = inst.defaultReplyHeaders(value); +inst = inst.matchHeader(str, str); + +inst = inst.filteringPath(regex, str); +inst = inst.filteringPath((path: string) => { + return str; +}); +inst = inst.filteringRequestBody(regex, str); +inst = inst.filteringRequestBody((path: string) => { + return str; +}); + +inst = inst.persist(); +inst = inst.log(() => { + +}); + +inst.done(); +bool = inst.isDone(); +inst.restore(); diff --git a/nock/nock.d.ts b/nock/nock.d.ts new file mode 100644 index 000000000..9c8aaac2e --- /dev/null +++ b/nock/nock.d.ts @@ -0,0 +1,54 @@ +// Type definitions for nock +// Project: https://github.com/pgte/nock +// Definitions by: bonnici +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/nock.d.ts + +declare module "nock" { + export = nock; + + function nock (host: string, options?: nock.Options): nock.Scope; + + module nock { + export function cleanAll(): void; + export var recorder: Recorder; + + export interface Scope { + get(path: string, data?: string): Scope; + post(path: string, data?: string): Scope; + put(path: string, data?: string): Scope; + head(path: string): Scope; + delete(path: string, data?: string): Scope; + intercept(path: string, verb: string, body?: string, options?: any): Scope; + + reply(responseCode: number, body?: string, headers?: Object): Scope; + reply(responseCode: number, callback: (uri: string, body: string) => string, headers?: Object): Scope; + replyWithFile(responseCode: number, fileName: string): Scope; + + defaultReplyHeaders(headers: Object): Scope; + matchHeader(name: string, value: string): Scope; + + filteringPath(regex: RegExp, replace: string): Scope; + filteringPath(fn: (path: string) => string): Scope; + filteringRequestBody(regex: RegExp, replace: string): Scope; + filteringRequestBody(fn: (path: string) => string): Scope; + + persist(): Scope; + log(out: () => void): Scope; + + done(): void; + isDone(): boolean; + restore(): void; + } + + export interface Recorder { + rec(capture?: boolean): void; + play(): string[]; + } + + export interface Options { + allowUnmocked?: boolean; + } + } +} diff --git a/nodeunit/nodeunit-tests.ts b/nodeunit/nodeunit-tests.ts new file mode 100644 index 000000000..bdd705b0e --- /dev/null +++ b/nodeunit/nodeunit-tests.ts @@ -0,0 +1,59 @@ +/// + +import nodeunit = require('nodeunit'); + +var num: number; +var value: any; +var actual: any; +var expected: any; +var message: string; +var operator: string; +var error: any; +var block: () =>{ + +}; + +export var testGroup: nodeunit.ITestGroup = { + setUp: function (callback: nodeunit.ICallbackFunction) { + callback(); + }, + tearDown: function (callback: nodeunit.ICallbackFunction) { + callback(); + }, + test1: function (test: nodeunit.Test) { + test.expect(num); + + test.fail(actual, expected, message, operator); + test.assert(value, message); + test.ok(value); + test.ok(value, message); + test.equal(actual, expected); + test.equal(actual, expected, message); + test.notEqual(actual, expected); + test.notEqual(actual, expected, message); + test.deepEqual(actual, expected); + test.deepEqual(actual, expected, message); + test.notDeepEqual(actual, expected); + test.notDeepEqual(actual, expected, message); + test.strictEqual(actual, expected); + test.strictEqual(actual, expected, message); + test.notStrictEqual(actual, expected); + test.notStrictEqual(actual, expected, message); + test.throws(block); + test.throws(block, error); + test.throws(block, error, message); + test.doesNotThrow(block); + test.doesNotThrow(block, error); + test.doesNotThrow(block, error, message); + test.ifError(value); + + //assertion wrappers + test.equals(actual, expected); + test.equals(actual, expected, message); + test.same(actual, expected); + test.same(actual, expected, message); + + test.done(error); + test.done(); + } +}; diff --git a/nodeunit/nodeunit.d.ts b/nodeunit/nodeunit.d.ts new file mode 100644 index 000000000..c427dbf17 --- /dev/null +++ b/nodeunit/nodeunit.d.ts @@ -0,0 +1,59 @@ +// Type definitions for nodeunit +// Project: https://github.com/caolan/nodeunit +// Definitions by: Jeff Goddard +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/nodeunit.d.ts + +declare module 'nodeunit' { + export interface Test { + done: ICallbackFunction; + expect(num: number): void; + + //assersions from node assert module + fail(actual: any, expected: any, message: string, operator: string): void; + assert(value: any, message: string): void; + ok(value: any, message?: string): void; + equal(actual: any, expected: any, message?: string): void; + notEqual(actual: any, expected: any, message?: string): void; + deepEqual(actual: any, expected: any, message?: string): void; + notDeepEqual(actual: any, expected: any, message?: string): void; + strictEqual(actual: any, expected: any, message?: string): void; + notStrictEqual(actual: any, expected: any, message?: string): void; + throws(block: any, error?: any, message?: string): void; + doesNotThrow(block: any, error?: any, message?: string): void; + ifError(value: any): void; + + //assertion wrappers + equals(actual: any, expected: any, message?: string): void; + same(actual: any, expected: any, message?: string): void; + } + + // Test Group Usage: + // var testGroup: nodeunit.ITestGroup = { + // setUp: function (callback: nodeunit.ICallbackFunction): void { + // callback(); + // }, + // tearDown: function (callback: nodeunit.ICallbackFunction): void { + // callback(); + // }, + // test1: function (test: nodeunit.Test): void { + // test.done(); + // } + // } + // exports.testgroup = testGroup; + + export interface ITestBody { + (callback: Test): void; + } + + export interface ITestGroup { + setUp?: (callback: ICallbackFunction) => void; + tearDown?: (callback: ICallbackFunction) => void; + } + + export interface ICallbackFunction { + (err?: any): void; + } +} + diff --git a/optimist/optimist-tests.ts b/optimist/optimist-tests.ts new file mode 100644 index 000000000..aa7f0341f --- /dev/null +++ b/optimist/optimist-tests.ts @@ -0,0 +1,46 @@ +/// + +import optimist = require('optimist'); + +var fn: Function; +var str: string; +var value: any; +var num: number; +var bool: boolean; +var strArr: string[]; + +var argv: optimist.Argv; +var opt: optimist.Optimist; + +argv = opt.argv; +argv = opt.argv; +argv = optimist(strArr).argv; + +opt = optimist(strArr).default(str, value); +opt = optimist(strArr).default({}); + +opt = optimist(strArr).boolean(str); +opt = optimist(strArr).boolean(strArr); + +opt = optimist(strArr).string(str); +opt = optimist(strArr).string(strArr); + +opt = opt.wrap(num); + +opt.help(); +opt.showHelp(fn); + +opt = opt.usage(str); + +opt = opt.demand(str); +opt = opt.demand(num); +opt = opt.demand(strArr); + +opt = opt.alias(str, str); + +opt = opt.describe(str, str); + +opt = opt.options(str, Object); + +opt.check(fn); +opt = opt.parse(strArr); diff --git a/optimist/optimist.d.ts b/optimist/optimist.d.ts new file mode 100644 index 000000000..01d44ab63 --- /dev/null +++ b/optimist/optimist.d.ts @@ -0,0 +1,53 @@ +// Type definitions for optimist +// Project: https://github.com/substack/node-optimist +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/optimist.d.ts + +declare module "optimist" { + + function optimist(args: string[]): optimist.Optimist; + + module optimist { + export interface Optimist { + default(name: string, value: any): Optimist; + default(args: Object): Optimist; + + boolean(name: string): Optimist; + boolean(names: string[]): Optimist; + + string(name: string): Optimist; + string(names: string[]): Optimist; + + wrap(columns: number): Optimist; + + help(): void; + showHelp(fn: Function): void; + + usage(message: string): Optimist; + + demand(key: string): Optimist; + demand(key: number): Optimist; + demand(key: string[]): Optimist; + + alias(key: string, alias: string): Optimist; + + describe(key: string, desc: string): Optimist; + + options(key: string, opt: Object): Optimist; + + check(fn: Function): void; + + parse(args: string[]): Optimist; + + argv: Argv; + } + + export interface Argv extends Object { + _: string[]; + } + } + + export = optimist; +} diff --git a/redis/redis-tests.ts b/redis/redis-tests.ts new file mode 100644 index 000000000..98ed2371b --- /dev/null +++ b/redis/redis-tests.ts @@ -0,0 +1,62 @@ +/// + +import redis = require('redis'); + +var value: any; +var valueArr: any[]; +var num: number; +var str: string; +var bool: boolean; +var err: Error; +var args: any[]; +var options: redis.ClientOpts; +var client: redis.RedisClient; +var info: redis.ServerInfo; +var resCallback: (err: Error, res: any) => void; +var numCallback: (err: Error, res: number) => void; +var strCallback: (err: Error, res: string) => void; +var messageHandler: (channel: string, message: any) => void; + +// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + +bool = redis.debug_mode; +redis.print(err, value); + +// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + +client = redis.createClient(num, str, options); + +bool = client.connected; +num = client.retry_delay; +num = client.retry_backoff; +valueArr = client.command_queue; +valueArr = client.offline_queue; +info = client.server_info; + +// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + +client.end(); + +// Connection (http://redis.io/commands#connection) +client.auth(str, resCallback); +client.ping(numCallback); + +// Strings (http://redis.io/commands#strings) +client.append(str, str, numCallback); +client.bitcount(str, numCallback); +client.bitcount(str, num, num, numCallback); +client.set(str, str, strCallback); +client.get(str, strCallback); +client.exists(str, str, numCallback); + +client.publish(str, value); +client.subscribe(str); +client.on(str, messageHandler); + +// ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- + +// some of the bulk methods +client.get(args); +client.get(args, resCallback); +client.set(args); +client.set(args, resCallback); diff --git a/redis/redis.d.ts b/redis/redis.d.ts new file mode 100644 index 000000000..e31b130ac --- /dev/null +++ b/redis/redis.d.ts @@ -0,0 +1,224 @@ +// Type definitions for redis +// Project: https://github.com/mranney/node_redis +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/redis.d.ts + +declare module "redis" { + export function createClient(port_arg: number, host_arg: string, options: ClientOpts): RedisClient; + export function print(err: Error, reply: any): void; + export var debug_mode: boolean; + + interface MessageHandler { + (channel: string, message: any): void; + } + + interface ResCallback { + (err: Error, res: any): void; + } + + interface NumCallback { + (err: Error, reply: number): void; + } + + interface StringCallback { + (err: Error, reply: string): void; + } + + interface ServerInfo { + redis_version: string; + versions: number[]; + } + + interface ClientOpts { + parser: string; + return_buffers?: boolean; + detect_buffers?: boolean; + socket_nodelay?: boolean; + no_ready_check?: boolean; + enable_offline_queue?: boolean; + retry_max_delay?: number; + connect_timeout?: number; + max_attempts?: number; + auth_pass?: boolean; + } + + interface RedisClient { + // event: connect + // event: error + // event: message + // event: pmessage + // event: subscribe + // event: psubscribe + // event: unsubscribe + // event: punsubscribe + + connected: boolean; + retry_delay: number; + retry_backoff: number; + command_queue: any[]; + offline_queue: any[]; + server_info: ServerInfo; + + end(): void; + + // Connection (http://redis.io/commands#connection) + auth(password: string, callback?: ResCallback): void; + ping(callback?: NumCallback): void; + + // Strings (http://redis.io/commands#strings) + append(key: string, value: string, callback?: NumCallback): void; + bitcount(key: string, callback?: NumCallback): void; + bitcount(key: string, start: number, end: number, callback?: NumCallback): void; + set(key: string, value: string, callback?: StringCallback): void; + get(key: string, callback?: StringCallback): void; + exists(key: string, value: string, callback?: NumCallback): void; + + publish(channel: string, value: any): void; + subscribe(channel: string): void; + on(channel: string, handler: MessageHandler): void; + + /* + commands = set_union([ + "get", "set", "setnx", "setex", "append", "strlen", "del", "exists", "setbit", "getbit", "setrange", "getrange", "substr", + "incr", "decr", "mget", "rpush", "lpush", "rpushx", "lpushx", "linsert", "rpop", "lpop", "brpop", "brpoplpush", "blpop", "llen", "lindex", + "lset", "lrange", "ltrim", "lrem", "rpoplpush", "sadd", "srem", "smove", "sismember", "scard", "spop", "srandmember", "sinter", "sinterstore", + "sunion", "sunionstore", "sdiff", "sdiffstore", "smembers", "zadd", "zincrby", "zrem", "zremrangebyscore", "zremrangebyrank", "zunionstore", + "zinterstore", "zrange", "zrangebyscore", "zrevrangebyscore", "zcount", "zrevrange", "zcard", "zscore", "zrank", "zrevrank", "hset", "hsetnx", + "hget", "hmset", "hmget", "hincrby", "hdel", "hlen", "hkeys", "hvals", "hgetall", "hexists", "incrby", "decrby", "getset", "mset", "msetnx", + "randomkey", "select", "move", "rename", "renamenx", "expire", "expireat", "keys", "dbsize", "auth", "ping", "echo", "save", "bgsave", + "bgrewriteaof", "shutdown", "lastsave", "type", "multi", "exec", "discard", "sync", "flushdb", "flushall", "sort", "info", "monitor", "ttl", + "persist", "slaveof", "debug", "config", "subscribe", "unsubscribe", "psubscribe", "punsubscribe", "publish", "watch", "unwatch", "cluster", + "restore", "migrate", "dump", "object", "client", "eval", "evalsha"], require("./lib/commands")); + */ + + get(args: any[], callback?: ResCallback): void; + set(args: any[], callback?: ResCallback): void; + setnx(args: any[], callback?: ResCallback): void; + setex(args: any[], callback?: ResCallback): void; + append(args: any[], callback?: ResCallback): void; + strlen(args: any[], callback?: ResCallback): void; + del(args: any[], callback?: ResCallback): void; + exists(args: any[], callback?: ResCallback): void; + setbit(args: any[], callback?: ResCallback): void; + getbit(args: any[], callback?: ResCallback): void; + setrange(args: any[], callback?: ResCallback): void; + getrange(args: any[], callback?: ResCallback): void; + substr(args: any[], callback?: ResCallback): void; + incr(args: any[], callback?: ResCallback): void; + decr(args: any[], callback?: ResCallback): void; + mget(args: any[], callback?: ResCallback): void; + rpush(args: any[], callback?: ResCallback): void; + lpush(args: any[], callback?: ResCallback): void; + rpushx(args: any[], callback?: ResCallback): void; + lpushx(args: any[], callback?: ResCallback): void; + linsert(args: any[], callback?: ResCallback): void; + rpop(args: any[], callback?: ResCallback): void; + lpop(args: any[], callback?: ResCallback): void; + brpop(args: any[], callback?: ResCallback): void; + brpoplpush(args: any[], callback?: ResCallback): void; + blpop(args: any[], callback?: ResCallback): void; + llen(args: any[], callback?: ResCallback): void; + lindex(args: any[], callback?: ResCallback): void; + lset(args: any[], callback?: ResCallback): void; + lrange(args: any[], callback?: ResCallback): void; + ltrim(args: any[], callback?: ResCallback): void; + lrem(args: any[], callback?: ResCallback): void; + rpoplpush(args: any[], callback?: ResCallback): void; + sadd(args: any[], callback?: ResCallback): void; + srem(args: any[], callback?: ResCallback): void; + smove(args: any[], callback?: ResCallback): void; + sismember(args: any[], callback?: ResCallback): void; + scard(args: any[], callback?: ResCallback): void; + spop(args: any[], callback?: ResCallback): void; + srandmember(args: any[], callback?: ResCallback): void; + sinter(args: any[], callback?: ResCallback): void; + sinterstore(args: any[], callback?: ResCallback): void; + sunion(args: any[], callback?: ResCallback): void; + sunionstore(args: any[], callback?: ResCallback): void; + sdiff(args: any[], callback?: ResCallback): void; + sdiffstore(args: any[], callback?: ResCallback): void; + smembers(args: any[], callback?: ResCallback): void; + zadd(args: any[], callback?: ResCallback): void; + zincrby(args: any[], callback?: ResCallback): void; + zrem(args: any[], callback?: ResCallback): void; + zremrangebyscore(args: any[], callback?: ResCallback): void; + zremrangebyrank(args: any[], callback?: ResCallback): void; + zunionstore(args: any[], callback?: ResCallback): void; + zinterstore(args: any[], callback?: ResCallback): void; + zrange(args: any[], callback?: ResCallback): void; + zrangebyscore(args: any[], callback?: ResCallback): void; + zrevrangebyscore(args: any[], callback?: ResCallback): void; + zcount(args: any[], callback?: ResCallback): void; + zrevrange(args: any[], callback?: ResCallback): void; + zcard(args: any[], callback?: ResCallback): void; + zscore(args: any[], callback?: ResCallback): void; + zrank(args: any[], callback?: ResCallback): void; + zrevrank(args: any[], callback?: ResCallback): void; + hset(args: any[], callback?: ResCallback): void; + hsetnx(args: any[], callback?: ResCallback): void; + hget(args: any[], callback?: ResCallback): void; + hmset(args: any[], callback?: ResCallback): void; + hmget(args: any[], callback?: ResCallback): void; + hincrby(args: any[], callback?: ResCallback): void; + hdel(args: any[], callback?: ResCallback): void; + hlen(args: any[], callback?: ResCallback): void; + hkeys(args: any[], callback?: ResCallback): void; + hvals(args: any[], callback?: ResCallback): void; + hgetall(args: any[], callback?: ResCallback): void; + hexists(args: any[], callback?: ResCallback): void; + incrby(args: any[], callback?: ResCallback): void; + decrby(args: any[], callback?: ResCallback): void; + getset(args: any[], callback?: ResCallback): void; + mset(args: any[], callback?: ResCallback): void; + msetnx(args: any[], callback?: ResCallback): void; + randomkey(args: any[], callback?: ResCallback): void; + select(args: any[], callback?: ResCallback): void; + move(args: any[], callback?: ResCallback): void; + rename(args: any[], callback?: ResCallback): void; + renamenx(args: any[], callback?: ResCallback): void; + expire(args: any[], callback?: ResCallback): void; + expireat(args: any[], callback?: ResCallback): void; + keys(args: any[], callback?: ResCallback): void; + dbsize(args: any[], callback?: ResCallback): void; + auth(args: any[], callback?: ResCallback): void; + ping(args: any[], callback?: ResCallback): void; + echo(args: any[], callback?: ResCallback): void; + save(args: any[], callback?: ResCallback): void; + bgsave(args: any[], callback?: ResCallback): void; + bgrewriteaof(args: any[], callback?: ResCallback): void; + shutdown(args: any[], callback?: ResCallback): void; + lastsave(args: any[], callback?: ResCallback): void; + type(args: any[], callback?: ResCallback): void; + multi(args: any[], callback?: ResCallback): void; + exec(args: any[], callback?: ResCallback): void; + discard(args: any[], callback?: ResCallback): void; + sync(args: any[], callback?: ResCallback): void; + flushdb(args: any[], callback?: ResCallback): void; + flushall(args: any[], callback?: ResCallback): void; + sort(args: any[], callback?: ResCallback): void; + info(args: any[], callback?: ResCallback): void; + monitor(args: any[], callback?: ResCallback): void; + ttl(args: any[], callback?: ResCallback): void; + persist(args: any[], callback?: ResCallback): void; + slaveof(args: any[], callback?: ResCallback): void; + debug(args: any[], callback?: ResCallback): void; + config(args: any[], callback?: ResCallback): void; + subscribe(args: any[], callback?: ResCallback): void; + unsubscribe(args: any[], callback?: ResCallback): void; + psubscribe(args: any[], callback?: ResCallback): void; + punsubscribe(args: any[], callback?: ResCallback): void; + publish(args: any[], callback?: ResCallback): void; + watch(args: any[], callback?: ResCallback): void; + unwatch(args: any[], callback?: ResCallback): void; + cluster(args: any[], callback?: ResCallback): void; + restore(args: any[], callback?: ResCallback): void; + migrate(args: any[], callback?: ResCallback): void; + dump(args: any[], callback?: ResCallback): void; + object(args: any[], callback?: ResCallback): void; + client(args: any[], callback?: ResCallback): void; + eval(args: any[], callback?: ResCallback): void; + evalsha(args: any[], callback?: ResCallback): void; + } +} diff --git a/rimraf/rimraf-tests.ts b/rimraf/rimraf-tests.ts new file mode 100644 index 000000000..74e33ce67 --- /dev/null +++ b/rimraf/rimraf-tests.ts @@ -0,0 +1,11 @@ +/// + +import rimraf = require('rimraf'); + +rimraf('./xyz', (err: Error) => { + +}); +rimraf.sync('./xyz'); + +rimraf.EMFILE_MAX = 0; +rimraf.BUSYTRIES_MAX = 0; diff --git a/rimraf/rimraf.d.ts b/rimraf/rimraf.d.ts new file mode 100644 index 000000000..b02581aef --- /dev/null +++ b/rimraf/rimraf.d.ts @@ -0,0 +1,16 @@ +// Type definitions for rimraf +// Project: https://github.com/isaacs/rimraf +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/rimraf.d.ts + +declare module "rimraf" { + function rimraf(path: string, callback: (error: Error) => void): void; + module rimraf { + export function sync(path: string): void; + export var EMFILE_MAX: number; + export var BUSYTRIES_MAX: number; + } + export = rimraf; +} diff --git a/sprintf/sprintf-tests.ts b/sprintf/sprintf-tests.ts new file mode 100644 index 000000000..563fbebdd --- /dev/null +++ b/sprintf/sprintf-tests.ts @@ -0,0 +1,14 @@ +/// + +import sprintf = require('sprintf'); + +var str: string; +var num: number; + +sprintf.sprintf(str, str); +sprintf.sprintf(str, str, num); +sprintf.sprintf(str, num, str); + +sprintf.vsprintf(str, [str]); +sprintf.vsprintf(str, [str, num]); +sprintf.vsprintf(str, [num, str]); diff --git a/sprintf/sprintf.d.ts b/sprintf/sprintf.d.ts new file mode 100644 index 000000000..547d93532 --- /dev/null +++ b/sprintf/sprintf.d.ts @@ -0,0 +1,11 @@ +// Type definitions for sprintff +// Project: https://github.com/maritz/node-sprintff +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/sprintff.d.ts + +declare module "sprintf" { + export function sprintf(fmt: string, ...args: any[]): string; + export function vsprintf(fmt: string, args: any[]): string; +} diff --git a/swig/swig-tests.ts b/swig/swig-tests.ts new file mode 100644 index 000000000..1f68aa44c --- /dev/null +++ b/swig/swig-tests.ts @@ -0,0 +1,25 @@ +/// + +import swig = require('swig'); + +var value: any; +var str: string; +var num: number; +var bool: boolean; + +var opts: swig.Options = { + allowErrors: bool, + autoescape: bool, + cache: bool, + encoding: str, + filters: value, + root: str, + tags: value, + extensions: value, + tzOffset: num +}; + +swig.init(opts); +value = swig.compileFile(str); +value = swig.compile(str); +value = swig.compile(str, opts); diff --git a/swig/swig.d.ts b/swig/swig.d.ts new file mode 100644 index 000000000..c8317ac5c --- /dev/null +++ b/swig/swig.d.ts @@ -0,0 +1,24 @@ +// Type definitions for swig +// Project: http://github.com/paularmstrong/swig +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/swig.d.ts + +declare module "swig" { + export function init(options: Options): void; + export function compileFile(filepath: string): any; + export function compile(source: string, options?: Options): any; + + export interface Options { + allowErrors?: boolean; + autoescape?: boolean; + cache?: boolean; + encoding?: string; + filters?: any; + root?: string; + tags?: any; + extensions?: any; + tzOffset?: number; + } +} diff --git a/swiz/swiz-tests.ts b/swiz/swiz-tests.ts new file mode 100644 index 000000000..b156ff140 --- /dev/null +++ b/swiz/swiz-tests.ts @@ -0,0 +1,172 @@ +/// + +import swiz = require('swiz'); + +var chain: swiz.IChain; +var sw: swiz.Swiz; +var value: any; +var valueArr: any[]; +var str: string; +var strArr: string[]; +var exp: RegExp; +var num: number; +var bool: boolean; +var callback: Function; + +var defs: swiz.struct.IObj[]; +var opts: swiz.ISwizOptions; +var field: swiz.struct.IField; +var ser: swiz.ISerializable; +var fieldArr: swiz.struct.IField[]; + +var opts: swiz.ISwizOptions = { + stripNulls: bool, + stripSerializerType: bool, + for: str +}; + +var obj: swiz.struct.IObj = { + name: str, + options: objOpts, + singular: str, + plural: str, + fields: fieldArr +}; + +var field: swiz.struct.IField = { + name: str, + options: fieldOpts, + src: str, + singular: str, + plural: str, + desc: str, + val: chain, + attribute: bool, + enumerated: bool, + ignorePublic: bool, + filterFrom: strArr, + coerceTo: value +}; + +var objOpts: swiz.struct.IObjOptions = { + singular: str, + plural: str, + fields: fieldArr +}; + +var fieldOpts: swiz.struct.IFieldOptions = { + src: str, + singular: str, + plural: str, + desc: str, + val: chain, + attribute: bool, + enumerated: value, + ignorePublic: bool, + filterFrom: strArr, + coerceTo: str +}; + +var valid: swiz.IValidator; +str = valid.name; +valid.func(value, value, callback); +str = valid.help; + +sw = new swiz.Swiz(defs, opts); +sw.buildObject(value, (err: any, result: any) => { + +}); +value = sw.buildObjectSync(value); +str = sw.serializeJson(value); +str = sw.serializeXml(value); +value = sw.deserializeXml(str); +sw.serialize(swiz.SERIALIZATION.SERIALIZATION_JSON, num, ser, (err: any, str: string) => { + +}); +sw.serializeForPagination(swiz.SERIALIZATION.SERIALIZATION_JSON, valueArr, value, (err: any, str: string) => { + +}); +sw.deserialize(swiz.SERIALIZATION.SERIALIZATION_JSON, num, str, (err: any, result: any) => { + +}); +field = sw.getFieldDefinition(str, str); + +// some of the chain API +chain = swiz.chain(); + +num = chain.getValidatorPos(str); +num = chain.hasValidator(str); + +valid = chain.getValidatorAtPos(num); +chain = chain.isUnique(); +chain = chain.toUnique(); +chain = chain.notIPBlacklisted(); +chain = chain.isCIDR(); +chain = chain.isEmail(); +chain = chain.isUrl(); +chain = chain.isAddressPair(); +chain = chain.isIP(); +chain = chain.isIPv4(); +chain = chain.isIPv6(); +chain = chain.isHostnameOrIp(); +chain = chain.isAllowedFQDNOrIP(); +chain = chain.isAllowedFQDNOrIP(strArr); +chain = chain.isHostname(); +chain = chain.isAlpha(); +chain = chain.isAlphanumeric(); +chain = chain.isNumeric(); +chain = chain.isInt(); +chain = chain.isLowercase(); +chain = chain.isUppercase(); +chain = chain.isDecimal(); +chain = chain.isFloat(); +chain = chain.notNull(); +chain = chain.isNull(); +chain = chain.notEmpty(); +chain = chain.equals(value); +chain = chain.contains(value); +chain = chain.notContains(value); +chain = chain.notIn(valueArr); +chain = chain.notIn(valueArr, bool); +chain = chain.regex(exp); +chain = chain.regex(str); +chain = chain.regex(str, str); +chain = chain.is(str); +chain = chain.is(str, str); +chain = chain.notRegex(exp); +chain = chain.notRegex(str); +chain = chain.notRegex(str, str); +chain = chain.not(str, str); +chain = chain.len(num); +chain = chain.len(num, num); +chain = chain.numItems(num, num); +chain = chain.toFloat(); +chain = chain.toInt(); +chain = chain.toBoolean(); +chain = chain.toBooleanStrict(); +chain = chain.entityDecode(); +chain = chain.entityEncode(); +chain = chain.trim(); +chain = chain.trim(str); +chain = chain.trim(); +chain = chain.trim(str); +chain = chain.ltrim(); +chain = chain.ltrim(str); +chain = chain.rtrim(str); +chain = chain.ifNull(str); +chain = chain.xss(); +chain = chain.xss(bool); +chain = chain.enumerated(value); +chain = chain.inArray(valueArr); +chain = chain.isString(); +chain = chain.isBoolean(); +chain = chain.range(value, value); +chain = chain.optional(); +chain = chain.isPort(); +chain = chain.isV1UUID(); +chain = chain.immutable(); +chain = chain.updateRequired(); +chain = chain.isArray(chain); +chain = chain.isHash(chain, chain); +chain = chain.rename(str); +chain = chain.custom(str); diff --git a/swiz/swiz.d.ts b/swiz/swiz.d.ts new file mode 100644 index 000000000..4e76fab7d --- /dev/null +++ b/swiz/swiz.d.ts @@ -0,0 +1,195 @@ +// Type definitions for swiz +// Project: https://github.com/racker/node-swiz +// Definitions by: Jeff Goddard +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/swiz.d.ts + +declare module "swiz" { + export class Cidr { + constructor(x: string, y?: string); + isInCIDR(x: any): boolean; + } + + export class Valve { + constructor(schema: IValveSchema, baton?: any); + setSchema(schema: IValveSchema): Valve; + addFinalValidator(func: (obj: any, callback: (err: Error, cleaned: any) => void) => void): Valve; + addChainValidator(name: string, description: string, func: (value: any, callback: (err: Error, cleaned: any) => void) => void): void; + check(obj: any, options: ICheckOptions, callback: (err: any, cleaned: any) => void): void; + check(obj: any, callback: (err: any, cleaned: any) => void): void; + checkUpdate(existing: any, obj: any, callback: (err: any, cleaned: any) => void): void; + help(schema: IValveSchema): any; + } + + export interface ICheckOptions { + strict?: boolean; + } + + export interface IValveSchema { + [index: string]: IValveSchemaMember; + } + + export interface IValveSchemaMember {} + + export interface IValveSchemaMemberArray extends IValveSchemaMember { + [index: string]: IValveSchemaMember; + } + + export function Chain(): IChain; + + export function chain(): IChain; + + export interface IChain extends IValveSchemaMember { + getValidatorPos(name: string): number; + hasValidator(name: string): number; + getValidatorAtPos(pos: number): IValidator; + isUnique(): IChain; + toUnique(): IChain; + notIPBlacklisted(): IChain; + isCIDR(): IChain; + isEmail(): IChain; + isUrl(): IChain; + isAddressPair(): IChain; + isIP(): IChain; + isIPv4(): IChain; + isIPv6(): IChain; + isHostnameOrIp(): IChain; + isAllowedFQDNOrIP(blacklist?: string[]): IChain; + isHostname(): IChain; + isAlpha(): IChain; + isAlphanumeric(): IChain; + isNumeric(): IChain; + isInt(): IChain; + isLowercase(): IChain; + isUppercase(): IChain; + isDecimal(): IChain; + isFloat(): IChain; + notNull(): IChain; + isNull(): IChain; + notEmpty(): IChain; + equals(arg: any): IChain; + contains(arg: any): IChain; + notContains(arg: any): IChain; + notIn(values: any[], caseSensitive?: boolean): IChain; + regex(pattern: RegExp): IChain; + regex(pattern: string, modifiers?: string): IChain; + is(pattern: string, modifiers?: string): IChain; + notRegex(pattern: RegExp): IChain; + notRegex(pattern: string, modifiers?: string): IChain; + not(pattern: string, modifiers: string): IChain; + len(min: number, max?: number): IChain; + numItems(min: number, max: number): IChain; + toFloat(): IChain; + toInt(): IChain; + toBoolean(): IChain; + toBooleanStrict(): IChain; + entityDecode(): IChain; + entityEncode(): IChain; + trim(chars?: string): IChain; + ltrim(chars?: string): IChain; + rtrim(chars: string): IChain; + ifNull(replace: string): IChain; + xss(is_image?: boolean): IChain; + enumerated(map: any): IChain; + inArray(array: any[]): IChain; + isString(): IChain; + isBoolean(): IChain; + range(min: any, max: any): IChain; + optional(): IChain; + isPort(): IChain; + isV1UUID(): IChain; + immutable(): IChain; + updateRequired(): IChain; + isArray(chain: IChain): IChain; + isHash(keyChain: IChain, valueChain: IChain): IChain; + rename(target: string): IChain; + custom(name: string): IChain; + } + + export function defToValve(def: struct.IObj[]): IValveSchema[]; + + export class Swiz { + constructor(defs: struct.IObj[], options?: ISwizOptions); + buildObject(obj: any, callback: (err: any, result: any) => void): void; + buildObjectSync(obj: any): any; + serializeJson(obj: any): string; + serializeXml(obj: any): string; + deserializeXml(xml: string): any; + serialize(mode: SERIALIZATION, version: number, obj: ISerializable, callback: (err: any, result: string) => void): void; + serializeForPagination(mode: SERIALIZATION, array: any[], metadata: any, callback: (err: any, result: string) => void): void; + deserialize(mode: SERIALIZATION, version: number, raw: string, callback: (err: any, result: any) => void): void; + getFieldDefinition(stype: string, name: string): struct.IField; + } + + export interface ISerializable { + getSerializerType(): string; + } + + export interface ISwizOptions { + stripNulls?: boolean; + stripSerializerType?: boolean; + for?: string; + } + + interface IValidator { + name: string; + func(value: any, baton: any, callback: Function): void; + help: string; + } + + export function stripSerializerTypes(obj: any): any; + + export module struct { + export function Obj(name: string, options?: IObjOptions): IObj; + export function Field(name: string, options?: IFieldOptions): IField; + export function coerce(value: any, coerceTo: string): any; + + export interface IObj { + name: string; + options: IObjOptions; + singular: string; + plural: string; + fields: IField[]; + } + + export interface IField { + name: string; + options: IFieldOptions; + src: string; + singular: string; + plural: string; + desc?: string; + val?: IChain; + attribute: boolean; + enumerated: boolean; + ignorePublic: boolean; + filterFrom: string[]; + coerceTo: any; + } + + export interface IObjOptions { + singular?: string; + plural?: string; + fields?: IField[]; + } + + export interface IFieldOptions { + src?: string; + singular?: string; + plural?: string; + desc?: string; + val?: IChain; + attribute?: boolean; + enumerated?: any; + ignorePublic?: boolean; + filterFrom?: string[]; + coerceTo?: string; + } + } + + export enum SERIALIZATION { + SERIALIZATION_JSON, + SERIALIZATION_XML + } +} diff --git a/timezone-js/timezone-js-tests.ts b/timezone-js/timezone-js-tests.ts new file mode 100644 index 000000000..9484d1640 --- /dev/null +++ b/timezone-js/timezone-js-tests.ts @@ -0,0 +1,26 @@ +/// + +import timezone = require('timezone-js'); +var tz = timezone.timezone; + +var value: any; +var str: string; +var bool: boolean; + +var opts: timezone.TimezoneJsOptions = { + async: bool, + success: (data: string) => { + + }, + error: (err: Error) => { + + }, + url: str +}; + +str = tz.zoneFileBasePath; +tz.loadingScheme; +tz.loadingSchemes; + +value = tz.transport(opts); +value = tz.init(opts); diff --git a/timezone-js/timezone-js.d.ts b/timezone-js/timezone-js.d.ts new file mode 100644 index 000000000..50b9c3f36 --- /dev/null +++ b/timezone-js/timezone-js.d.ts @@ -0,0 +1,45 @@ +// Type definitions for timezone-js +// Project: https://github.com/mde/timezone-js +// Definitions by: bonnici +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/timezone-js.d.ts + +declare module "timezone-js" { + export var timezone: TimezoneJs; + + export var Date: { + new (timezone?: string): TimezoneJsDate; + new (time: string, timezone?: string): TimezoneJsDate; + new (year?: number, month?: number, day?: number, hour?: number, minute?: number, second?: string, timezone?: string): TimezoneJsDate; + }; + + export interface TimezoneJsDate extends Date { + setTimezone: (timezone: string) => void; + } + + export interface TimezoneJs { + zoneFileBasePath: string; + loadingScheme: TimezoneJsLoadingScheme; + loadingSchemes: TimezoneJsLoadingSchemes; + + transport(opts: TimezoneJsOptions): any; + init(opts?: TimezoneJsOptions): any; + } + + export interface TimezoneJsOptions { + async?: boolean; + success?: (data: string) => void; + error?: (err: Error) => void; + url?: string; + } + + export interface TimezoneJsLoadingScheme { + } + + export enum TimezoneJsLoadingSchemes { + PRELOAD_ALL, + LAZY_LOAD, + MANUAL_LOAD + } + } diff --git a/twig/twig-tests.ts b/twig/twig-tests.ts new file mode 100644 index 000000000..bf41affd1 --- /dev/null +++ b/twig/twig-tests.ts @@ -0,0 +1,45 @@ +/// + +import twig = require('twig'); + +var value: any; +var str: string; +var num: number; +var bool: boolean; + +var params: twig.Parameters = { + id: value, + ref: value, + href: value, + path: value, + debug: bool, + trace: bool, + strict_variables: bool, + data: value +}; + +var temp: twig.Template; +var compOpts: twig.CompileOptions = { + filename: str, + settings: value +}; + +var compiled:(context: any) => any; + +temp = twig.twig(params); +twig.extendFilter(str, (left: any, ...params: any[]) => { + return str; +}); +twig.extendFunction(str, (...params: any[]) => { + return str; +}); +twig.extendTest(str, (value: any) => bool); +twig.extendTag(value); +compiled = twig.compile(str, compOpts); +twig.renderFile(str, compOpts, (err, result) => { + +}); +twig.__express(str, compOpts, (err, result) => { + +}); +twig.cache(bool); diff --git a/twig/twig.d.ts b/twig/twig.d.ts new file mode 100644 index 000000000..0ce655272 --- /dev/null +++ b/twig/twig.d.ts @@ -0,0 +1,37 @@ +// Type definitions for twig +// Project: https://github.com/justjohn/twig.js +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/twig.d.ts + +declare module "twig" { + export interface Parameters { + id?: any; + ref?: any; + href?: any; + path?: any; + debug?: boolean; + trace?: boolean; + strict_variables?: boolean; + data: any; + } + + export interface Template { + } + + export interface CompileOptions { + filename: string; + settings: any; + } + + export function twig(params: Parameters): Template; + export function extendFilter(name: string, definition: (left: any, ...params: any[]) => string): void; + export function extendFunction(name: string, definition: (...params: any[]) => string): void; + export function extendTest(name: string, definition: (value: any) => boolean): void; + export function extendTag(definition: any): void; + export function compile(markup: string, options: CompileOptions): (context: any) => any; + export function renderFile(path: string, options: CompileOptions, fn: (err: Error, result: any) => void): void; + export function __express(path: string, options: CompileOptions, fn: (err: Error, result: any) => void): void; + export function cache(value: boolean): void; +} diff --git a/watch/watch-tests.ts b/watch/watch-tests.ts new file mode 100644 index 000000000..4888d41e2 --- /dev/null +++ b/watch/watch-tests.ts @@ -0,0 +1,32 @@ +/// + +import watch = require('watch'); +import fs = require('fs'); + +var value: any; +var str: string; +var num: number; +var bool: boolean; + +var mon: watch.Monitor; +var opts: watch.Options = { + ignoreDotFiles: bool, + filter: value +}; + +mon.on('foo', () => { + +}); + +watch.watchTree(str, (f: any, curr: fs.Stats, prev: fs.Stats) => { + +}); +watch.watchTree(str, opts, (f: any, curr: fs.Stats, prev: fs.Stats) => { + +}); +watch.createMonitor(str, (monitor: watch.Monitor) => { + +}); +watch.createMonitor(str, opts, (monitor: watch.Monitor) => { + +}); diff --git a/watch/watch.d.ts b/watch/watch.d.ts new file mode 100644 index 000000000..d011b11f7 --- /dev/null +++ b/watch/watch.d.ts @@ -0,0 +1,35 @@ +// Type definitions for watch +// Project: https://github.com/mikeal/watch +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/watch.d.ts + +/// + +declare module "watch" { + import fs = require("fs"); + import events = require("events"); + + export interface Monitor extends events.EventEmitter { + // event: created + // event: removed + // event: changed + + // export function onCreated(callback, function(f, stat: fs.Stats) { }); + // export function onChanged(callback, function(f, curr: fs.Stats, prev: fs.Stats) { }); + // export function onRemoved(callback, function(f, stat: fs.Stats) { }); + } + + export interface Options { + persistent?: boolean; + ignoreDotFiles?: boolean; + filter?: any; + interval?: number; + } + + export function watchTree(root: string, callback: (f: any, curr: fs.Stats, prev: fs.Stats) => void): void; + export function watchTree(root: string, options: Options, callback: (f: any, curr: fs.Stats, prev: fs.Stats) => void): void; + export function createMonitor(root: string, callback: (monitor: Monitor) => void): void; + export function createMonitor(root: string, options: Options, callback: (monitor: Monitor) => void): void; +} diff --git a/winston/winston-tests.ts b/winston/winston-tests.ts new file mode 100644 index 000000000..499b427a6 --- /dev/null +++ b/winston/winston-tests.ts @@ -0,0 +1,40 @@ +/// + +import winston = require('winston'); + +var str: string; +var bool: boolean; +var metadata: any; +var options: any; +var value: any; +var transport: winston.Transport; + +transport = winston.transports.File; +transport = winston.transports.Console; +transport = winston.transports.Loggly; + +winston.log(str, str); +winston.log(str, str, metadata); +winston.debug(str); +winston.debug(str, metadata); +winston.info(str); +winston.info(str, metadata); +winston.warn(str); +winston.warn(str, metadata); +winston.error(str); +winston.error(str, metadata); + +winston.add(transport, options); +winston.remove(transport); + +winston.profile(str); + +winston.query(options, (err: any, results: any) => { + +}); + +value = winston.stream(options); + +winston.handleExceptions(transport); +winston.exitOnError = bool; + diff --git a/winston/winston.d.ts b/winston/winston.d.ts new file mode 100644 index 000000000..8ebd618ff --- /dev/null +++ b/winston/winston.d.ts @@ -0,0 +1,39 @@ +// Type definitions for winston +// Project: https://github.com/flatiron/winston +// Definitions by: bonnici +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/winston.d.ts + +declare module "winston" { + export function log(level: string, message: string, metadata?: any): void; + export function debug(message: string, metadata?: any): void; + export function info(message: string, metadata?: any): void; + export function warn(message: string, metadata?: any): void; + export function error(message: string, metadata?: any): void; + + export function add(transport: Transport, options: any): void; + export function remove(transport: Transport): void; + + export function profile(name: string): void; + + export function query(options: any, done: (err: any, results: any) => void): void; + + export function stream(options: any): any; + + export function handleExceptions(transport: Transport): void; + + export class Logger { + + } + + export interface Transport { + } + export interface Transports { + File: Transport; + Console: Transport; + Loggly: Transport; + } + export var transports: Transports; + export var exitOnError: boolean; +} diff --git a/wrench/wrench-tests.ts b/wrench/wrench-tests.ts new file mode 100644 index 000000000..c75a4ddb0 --- /dev/null +++ b/wrench/wrench-tests.ts @@ -0,0 +1,36 @@ +/// + +import wrench = require('wrench'); + +var str: string; +var num: number; +var bool: boolean; +var strArr: string[]; +var line: wrench.LineReader; + +strArr = wrench.readdirSyncRecursive(str); +wrench.rmdirSyncRecursive(str); +wrench.rmdirSyncRecursive(str, bool); +wrench.copyDirSyncRecursive(str, str); +wrench.copyDirSyncRecursive(str, str, { + preserve: bool +}); +wrench.chmodSyncRecursive(str, num); +wrench.chownSyncRecursive(str, num, num); +wrench.mkdirSyncRecursivefunction(str, num); +wrench.readdirRecursive(str, (err: Error, files: string[]) => { + +}); +wrench.rmdirRecursive(str, (err: Error) => { + +}); +wrench.copyDirRecursive(str, str, (err: Error) => { + +}); + +line = new wrench.LineReader(str); +line = new wrench.LineReader(str, num); + +str = line.getNextLine(); +bool = line.hasNextLine(); +num = line.getBufferAndSetCurrentPosition(num); diff --git a/wrench/wrench.d.ts b/wrench/wrench.d.ts new file mode 100644 index 000000000..d3c03fc77 --- /dev/null +++ b/wrench/wrench.d.ts @@ -0,0 +1,27 @@ +// Type definitions for wrench +// Project: https://github.com/ryanmcgrath/wrench-js +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/wrench.d.ts + +declare module "wrench" { + export function readdirSyncRecursive(baseDir: string): string[]; + export function rmdirSyncRecursive(path: string, failSilent?: boolean): void; + export function copyDirSyncRecursive(sourceDir: string, newDirLocation: string, opts?: { preserve?: boolean; }): void; + export function chmodSyncRecursive(sourceDir: string, filemode: number): void; + export function chownSyncRecursive(sourceDir: string, uid: number, gid: number): void; + export function mkdirSyncRecursivefunction(path: string, mode: number): void; + + export function readdirRecursive(baseDir: string, fn: (err: Error, files: string[]) => void): void; + export function rmdirRecursive(path: string, fn: (err: Error) => void): void; + export function copyDirRecursive(srcDir: string, newDir: string, fn: (err: Error) => void): void; + + export class LineReader { + constructor (filename: string, bufferSize?: number); + + getBufferAndSetCurrentPosition(position: number): number; + hasNextLine(): boolean; + getNextLine(): string; + } +} From ec18e20c241f2bd6920d2c5dd8b92cf33f2d4b42 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Wed, 23 Apr 2014 00:58:42 +0200 Subject: [PATCH 04/24] imported Request definitions from typescript-node-definitions - as per https://github.com/borisyankov/DefinitelyTyped/issues/115 - added DT header (scraped creators from git history) - added tests - updated some fields - restructured to be more accurate --- CONTRIBUTORS.md | 1 + request/request-tests.ts | 198 +++++++++++++++++++++++++++++++++++++++ request/request.d.ts | 171 +++++++++++++++++++++++++++++++++ 3 files changed, 370 insertions(+) create mode 100644 request/request-tests.ts create mode 100644 request/request.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 9f4f84f19..4e7cb6074 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -238,6 +238,7 @@ All definitions files include a header with the author and editors, so at some p * [Riot.js](https://github.com/moot/riotjs) (by [vvakame](https://github.com/vvakame)) * [Restify](https://github.com/mcavage/node-restify) (by [Bret Little](https://github.com/blittle)) * [Redis](https://github.com/mranney/node_redis) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) +* [Request](https://github.com/mikeal/request) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) * [Royalslider](http://dimsemenov.com/plugins/royal-slider/) (by [Christiaan Rakowski](https://github.com/csrakowski)) * [Rx.js](http://rx.codeplex.com/) (by [gsino](http://www.codeplex.com/site/users/view/gsino), [Igor Oleinikov](https://github.com/Igorbek), [Carl de Billy](http://carl.debilly.net/), [zoetrope](https://github.com/zoetrope)) * [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall)) diff --git a/request/request-tests.ts b/request/request-tests.ts new file mode 100644 index 000000000..d422c3abc --- /dev/null +++ b/request/request-tests.ts @@ -0,0 +1,198 @@ +/// + +import request = require('request'); +import http = require('http'); +import stream = require('stream'); +import formData = require('form-data'); + +var value: any; +var str: string; +var buffer: NodeBuffer; +var num: number; +var bool: boolean; +var date: Date; +var obj: Object; +var dest: string; + +var uri: string; +var headers: {[key: string]: string}; + +var agent: http.Agent; +var write: stream.Writable; +var req: request.Request; +var form: formData.FormData; + +var bodyArr: request.RequestPart[] = [{ + body: value +}, { + body: value +}, { + body: value +}]; + +// --- --- --- --- --- --- --- --- --- --- --- --- + +str = req.toJSON(); + +var cookieValue: request.CookieValue; +str = cookieValue.name; +value = cookieValue.value; +bool = cookieValue.httpOnly; + +var cookie: request.Cookie; +str = cookie.str; +date = cookie.expires; +str = cookie.path; +str = cookie.toString(); + +var jar: request.CookieJar; +jar.add(cookie); +cookie = jar.get(req); +str = jar.cookieString(req); + +var aws: request.AWSOptions; +str = aws.secret; +str = aws.bucket; + +var oauth: request.OAuthOptions; +str = oauth.callback; +str = oauth.consumer_key; +str = oauth.consumer_secret; +str = oauth.token; +str = oauth.token_secret; +str = oauth.verifier; + +var options: request.Options = { + url: str, + uri: str, + callback: (error: any, response: any, body: any) => { + + }, + jar: value, + form: value, + oauth: value, + aws: aws, + qs: obj, + json: value, + multipart: value, + agentOptions: value, + agentClass: value, + forever: value, + host: str, + port: num, + method: str, + headers: value, + body: value, + followRedirect: bool, + followAllRedirects: bool, + maxRedirects: num, + encoding: str, + pool: value, + timeout: num, + proxy: value, + strictSSL: bool +}; + +// --- --- --- --- --- --- --- --- --- --- --- --- + +agent = req.getAgent(); +//req.start(); +//req.abort(); +req.pipeDest(dest); +req = req.setHeader(str, str); +req = req.setHeader(str, str, bool); +req = req.setHeaders(headers); +req = req.qs(obj); +req = req.qs(obj, bool); +req = req.form(obj); +form = req.form(); +req = req.multipart(bodyArr); +req = req.json(value); +req = req.aws(aws); +req = req.aws(aws, bool); +req = req.oauth(oauth); +req = req.jar(jar); +write = req.pipe(write); +write = req.pipe(write, value); +req.write(); +req.end(str); +req.end(buffer); +req.pause(); +req.resume(); +req.abort(); +req.destroy(); + +// --- --- --- --- --- --- --- --- --- --- --- --- + +var callback: (error: any, response: any, body: any) => void; + +value = request.initParams; + +req = request(uri); +req = request(uri, options); +req = request(uri, options, callback); +req = request(uri, callback); +req = request(options); +req = request(options, callback); + +req = request.request(uri); +req = request.request(uri, options); +req = request.request(uri, options, callback); +req = request.request(uri, callback); +req = request.request(options); +req = request.request(options, callback); + +req = request.get(uri); +req = request.get(uri, options); +req = request.get(uri, options, callback); +req = request.get(uri, callback); +req = request.get(options); +req = request.get(options, callback); + +req = request.post(uri); +req = request.post(uri, options); +req = request.post(uri, options, callback); +req = request.post(uri, callback); +req = request.post(options); +req = request.post(options, callback); + +req = request.put(uri); +req = request.put(uri, options); +req = request.put(uri, options, callback); +req = request.put(uri, callback); +req = request.put(options); +req = request.put(options, callback); + +req = request.head(uri); +req = request.head(uri, options); +req = request.head(uri, options, callback); +req = request.head(uri, callback); +req = request.head(options); +req = request.head(options, callback); + +req = request.patch(uri); +req = request.patch(uri, options); +req = request.patch(uri, options, callback); +req = request.patch(uri, callback); +req = request.patch(options); +req = request.patch(options, callback); + +req = request.del(uri); +req = request.del(uri, options); +req = request.del(uri, options, callback); +req = request.del(uri, callback); +req = request.del(options); +req = request.del(options, callback); + +req = request.forever(value, value); +jar = request.jar(); +cookie = request.cookie(str); + +var r = request.defaults(options); +r(str); +r.get(str); +r.post(str); + +r(options); +r.get(options); +r.post(options); diff --git a/request/request.d.ts b/request/request.d.ts new file mode 100644 index 000000000..e6a1d100e --- /dev/null +++ b/request/request.d.ts @@ -0,0 +1,171 @@ +// Type definitions for request +// Project: https://github.com/mikeal/request +// Definitions by: Carlos Ballesteros Velasco , bonnici , Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +// Imported from: https://github.com/soywiz/typescript-node-definitions/d.ts + +/// +/// + +declare module 'request' { + import stream = require('stream'); + import http = require('http'); + import FormData = require('form-data'); + + export = RequestAPI; + + function RequestAPI(uri: string, options?: RequestAPI.Options, callback?: (error: any, response: any, body: any) => void): RequestAPI.Request; + function RequestAPI(uri: string, callback?: (error: any, response: any, body: any) => void): RequestAPI.Request; + function RequestAPI(options: RequestAPI.Options, callback?: (error: any, response: any, body: any) => void): RequestAPI.Request; + + module RequestAPI { + export function defaults(options: Options): typeof RequestAPI; + + export function request(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function request(uri: string, callback?: (error: any, response: any, body: any) => void): Request; + export function request(options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + + export function get(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function get(uri: string, callback?: (error: any, response: any, body: any) => void): Request; + export function get(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + + export function post(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function post(uri: string, callback?: (error: any, response: any, body: any) => void): Request; + export function post(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + + export function put(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function put(uri: string, callback?: (error: any, response: any, body: any) => void): Request; + export function put(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + + export function head(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function head(uri: string, callback?: (error: any, response: any, body: any) => void): Request; + export function head(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + + export function patch(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function patch(uri: string, callback?: (error: any, response: any, body: any) => void): Request; + export function patch(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + + export function del(uri: string, options?: Options, callback?: (error: any, response: any, body: any) => void): Request; + export function del(uri: string, callback?: (error: any, response: any, body: any) => void): Request; + export function del(options: Options, callback?: (error: any, response: any, body: any) => void): Request; + + export function forever(agentOptions: any, optionsArg: any): Request; + export function jar(): CookieJar; + export function cookie(str: string): Cookie; + + export var initParams: any; + + export interface Options { + url?: string; + uri?: string; + callback?: (error: any, response: any, body: any) => void; + jar?: any; // CookieJar + form?: FormData; + oauth?: OAuthOptions; + aws?: AWSOptions; + hawk ?: HawkOptions; + qs?: Object; + json?: any; + multipart?: RequestPart[]; + agentOptions?: any; + agentClass?: any; + forever?: any; + host?: string; + port?: number; + method?: string; + headers?: Headers; + body?: any; + followRedirect?: boolean; + followAllRedirects?: boolean; + maxRedirects?: number; + encoding?: string; + pool?: any; + timeout?: number; + proxy?: any; + strictSSL?: boolean; + } + + export interface RequestPart { + headers?: Headers; + body: any; + } + + export interface Request { + getAgent(): http.Agent; + //start(): void; + //abort(): void; + pipeDest(dest: any): void; + setHeader(name: string, value: string, clobber?: boolean): Request; + setHeaders(headers: Headers): Request; + qs(q: Object, clobber?: boolean): Request; + form(): FormData.FormData; + form(form: any): Request; + multipart(multipart: RequestPart[]): Request; + json(val: any): Request; + aws(opts: AWSOptions, now?: boolean): Request; + oauth(oauth: OAuthOptions): Request; + jar(jar: CookieJar): Request; + + pipe(dest: stream.Writable, opts?: any): stream.Writable; + write(): void; + end(chunk: string): void; + end(chunk: NodeBuffer): void; + pause(): void; + resume(): void; + abort(): void; + destroy(): void; + toJSON(): string; + } + + export interface Headers { + [key: string]: any; + } + + export interface AuthOptions { + user?: string; + username?: string; + pass?: string; + password?: string; + sendImmediately?: boolean; + } + + export interface OAuthOptions { + callback?: string; + consumer_key?: string; + consumer_secret?: string; + token?: string; + token_secret?: string; + verifier?: string; + } + + export interface HawkOptions { + credentials: any; + } + + export interface AWSOptions { + secret: string; + bucket?: string; + } + + export interface CookieJar { + add(cookie: Cookie): void; + get(req: Request): Cookie; + cookieString(req: Request): string; + } + + export interface CookieValue { + name: string; + value: any; + httpOnly: boolean; + } + + export interface Cookie extends Array { + constructor(name: string, req: Request): void; + str: string; + expires: Date; + path: string; + toString(): string; + } + } +} From 6dc732cd0e251379bf5533bb78869b4ece75508a Mon Sep 17 00:00:00 2001 From: Jeff May Date: Sun, 20 Apr 2014 00:12:00 -0400 Subject: [PATCH 05/24] Added node-uuid and tests --- node-uuid/node-uuid.d.ts | 49 ++++++++++++++++++++++++++++++++++++ node-uuid/node-uuid.tests.ts | 22 ++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 node-uuid/node-uuid.d.ts create mode 100644 node-uuid/node-uuid.tests.ts diff --git a/node-uuid/node-uuid.d.ts b/node-uuid/node-uuid.d.ts new file mode 100644 index 000000000..8c287bb2e --- /dev/null +++ b/node-uuid/node-uuid.d.ts @@ -0,0 +1,49 @@ +// Type definitions for node-uuid.js +// Project: https://github.com/broofa/node-uuid +// Definitions by: Jeff May +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +interface UUIDOptions { + + /** + * Node id as Array of 6 bytes (per 4.1.6). + * Default: Randomly generated ID. See note 1. + */ + node: any[] + + /** + * (Number between 0 - 0x3fff) RFC clock sequence. + * Default: An internally maintained clockseq is used. + */ + clockseq: number + + /** + * (Number | Date) Time in milliseconds since unix Epoch. + * Default: The current time is used. + */ + msecs: any + + /** + * (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if msecs is unspecified. + * Default: internal uuid counter is used, as per 4.2.1.2. + */ + nsecs: number +} + +interface UUID { + v1(options?: UUIDOptions, buffer?: number[], offset?: number): string + v1(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + + v2(options?: UUIDOptions, buffer?: number[], offset?: number): string + v2(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + + v3(options?: UUIDOptions, buffer?: number[], offset?: number): string + v3(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + + v4(options?: UUIDOptions, buffer?: number[], offset?: number): string + v4(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string +} + +declare var uuid: UUID; diff --git a/node-uuid/node-uuid.tests.ts b/node-uuid/node-uuid.tests.ts new file mode 100644 index 000000000..6e1d7bd8c --- /dev/null +++ b/node-uuid/node-uuid.tests.ts @@ -0,0 +1,22 @@ +/// + +var uid1: string = uuid.v1() +var uid2: string = uuid.v2() +var uid3: string = uuid.v3() +var uid4: string = uuid.v4() + +var options: UUIDOptions = { + node: [], + clockseq: 2, + nsecs: 3, + msecs: new Date() +} + +var padding: number[] = [0, 1, 2] + +var offset: number = 15 + +uuid.v1(options, padding, offset) +uuid.v2(options, padding, offset) +uuid.v3(options, padding, offset) +uuid.v4(options, padding, offset) From f4d822a03e20f93022648be6cc1e3bc9dcc39354 Mon Sep 17 00:00:00 2001 From: Jeff May Date: Tue, 22 Apr 2014 11:47:50 -0400 Subject: [PATCH 06/24] Added node-uuid to README.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d68e3061c..88263116e 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -207,6 +207,7 @@ All definitions files include a header with the author and editors, so at some p * [node-git](https://github.com/christkv/node-git) (by [vvakame](https://github.com/vvakame)) * [node_zeromq](https://github.com/JustinTulloss/zeromq.node) (by [Dave McKeown](https://github.com/davemckeown)) * [node-sqlserver](https://github.com/WindowsAzure/node-sqlserver) (by [Boris Yankov](https://github.com/borisyankov)) +* [node-uuid](https://github.com/broofa/node-uuid) (by [Jeff May](https://github.com/jeffmay)) * [notify.js](https://github.com/alexgibson/notify.js) (by [soundTricker](https://github.com/soundTricker)) * [NProgress](https://github.com/rstacruz/nprogress) (by [Judah Gabriel Himango](https://github.com/judahgabriel)) * [Numeral.js](https://github.com/adamwdraper/Numeral-js) (by [Vincent Bortone](https://github.com/vbortone/)) From 89c5eaf231206eb2b7c851e46c31766433abad48 Mon Sep 17 00:00:00 2001 From: Max Ackley Date: Wed, 23 Apr 2014 10:49:21 -0700 Subject: [PATCH 07/24] Added type definitions and tests for jQuery Finger plugin. --- CONTRIBUTORS.md | 1 + jquery.finger/jquery.finger-tests.ts | 37 +++++++++ jquery.finger/jquery.finger.d.ts | 109 +++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 jquery.finger/jquery.finger-tests.ts create mode 100644 jquery.finger/jquery.finger.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d68e3061c..96e221802 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -131,6 +131,7 @@ All definitions files include a header with the author and editors, so at some p * [jQuery.dataTables](http://www.datatables.net) (by [Armin Sander](https://github.com/pragmatrix)) * [jQuery.datetimepicker](http://trentrichardson.com/examples/timepicker/) (by [Doug McDonald](https://github.com/dougajmcdonald)) * [jQuery.dynatree](http://code.google.com/p/dynatree/) (by [François de Campredon](https://github.com/fdecampredon)) +* [jQuery.Finger](http://ngryman.sh/jquery.finger/) (by [Max Ackley](https://github.com/maxackley)) * [jQuery.Flot](http://www.flotcharts.org/) (by [Matt Burland](https://github.com/burlandm)) * [jQuery.form](http://malsup.com/jquery/form/) (by [François Guillot](http://fguillot.developpez.com/)) * [jQuery.Globalize](https://github.com/jquery/globalize) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/jquery.finger/jquery.finger-tests.ts b/jquery.finger/jquery.finger-tests.ts new file mode 100644 index 000000000..e50fe1d5f --- /dev/null +++ b/jquery.finger/jquery.finger-tests.ts @@ -0,0 +1,37 @@ +/// +/// + +$.Finger.doubleTapInterval = 400; +$.Finger.flickDuration = 250; +$.Finger.pressDuration = 100; +$.Finger.motionThreshhold = 10; +$.Finger.preventDefault = true; +var fingerEventObject: JQueryFingerEventObject; +fingerEventObject.x = 1; +fingerEventObject.y = 2; +fingerEventObject.dx = 3; +fingerEventObject.dy = 4; +fingerEventObject.adx = 3; +fingerEventObject.ady = 4; +fingerEventObject.orientation = 'horizontal'; +fingerEventObject.direction = 1; +$('body').on('drag', e => { + if ('vertical' == e.orientation) return; + e.preventDefault(); +}); + +$('body').on('drag', '.drag', e => { + if ('vertical' == e.orientation) return; + e.preventDefault(); +}); + +$('#menu').on('flick', function (e) { + if ('horizontal' == e.orientation) { + if (1 == e.direction) { + $(this).addClass('is-opened'); + } + else { + $(this).removeClass('is-opened'); + } + } +}); diff --git a/jquery.finger/jquery.finger.d.ts b/jquery.finger/jquery.finger.d.ts new file mode 100644 index 000000000..0b0cb7ebf --- /dev/null +++ b/jquery.finger/jquery.finger.d.ts @@ -0,0 +1,109 @@ +// Type definitions for jquery.finger.js +// Project: http://ngryman.sh/jquery.finger/ +// Definitions by: Max Ackley +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module JQueryFinger { + export interface JQueryFingerOptions { + /** + * The time the user must hold in order to fire a press event. If this + * time is not reached, a tap event will be fired instead. + * Default: 300(ms). + */ + pressDuration: number; + + /** + * The maximum time between two tap events to fire a doubletap event. + * If this time is reached, two distinct tap events will be fired instead. + * Default: 300(ms). + */ + doubleTapInterval: number; + + /** + * The maximum time the user will have to swipe in order to fire a flick + * event. If this time is reached, only drag events will continue to be + * fired. + * Default: 150(ms). + */ + flickDuration: number; + + /** + * The number of pixels the user will have to move in order to fire motion + * events (drag or flick). If this time is not reached, no motion will + * be handled and tap, doubletap or press event will be fired. + * Default: 5(px). + */ + motionThreshhold: number; + + /** + * Globally prevents every native default behavior. + * Default: undefined. + */ + preventDefault: boolean; + } +} + +interface JQueryFingerEventObject extends JQueryEventObject { + /** + * The x page coordinate. + */ + x: number; + + /** + * The y page coordinate. + */ + y: number; + + /** + * The x delta since the last event. + */ + dx: number; + + /** + * The y delta since the last event. + */ + dy: number; + + /** + * The absolute x delta since the last event. + */ + adx: number; + + /** + * The absolute y delta since the last event. + */ + ady: number; + + /** + * The orientation of the motion. Adjusted by $.Finger.motionThreshhold. + * Value is 'horizontal' or 'vertical'. + */ + orientation: string; + + /** + * The direction of the motion. Value is 1 if the motion is 'positive' + * (left-to-right or top-to-bottom) or -1 if 'negative'(right-to-left or + * bottom-to-top). + */ + direction: number; +} + +interface JQuery { + on(events: 'tap', handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + on(events: 'doubletap', handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + on(events: 'press', handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + on(events: 'drag', handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + on(events: 'flick', handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + + on(events: 'tap', data: any, handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + on(events: 'doubletap', data: any, handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + on(events: 'press', data: any, handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + on(events: 'drag', data: any, handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; + on(events: 'flick', data: any, handler: (eventObject: JQueryFingerEventObject, ...args: any[]) => any): JQuery; +} + +interface JQueryStatic { + Finger: JQueryFinger.JQueryFingerOptions; +} From e3c20e7aca12cb54e5b66d7bd03218805dfc0a00 Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Thu, 24 Apr 2014 11:35:12 +0100 Subject: [PATCH 08/24] (restangular) Fix argument order in custom methods The arguments were in the wrong order for custom methods --- restangular/restangular.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index a5b7de20d..0cc4321af 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -60,8 +60,8 @@ interface RestangularCustom { customGET(path: string, params?: any, headers?: any): ng.IPromise; customGETLIST(path: string, params?: any, headers?: any): ng.IPromise; customDELETE(path: string, params?: any, headers?: any): ng.IPromise; - customPOST(path: string, params?: any, headers?: any, elem?: any): ng.IPromise; - customPUT(path: string, params?: any, headers?: any, elem?: any): ng.IPromise; + customPOST(elem?: any, path?: string, params?: any, headers?: any): ng.IPromise; + customPUT(elem?: any, path?: string, params?: any, headers?: any): ng.IPromise; customOperation(operation: string, path: string, params?: any, headers?: any, elem?: any): ng.IPromise; addRestangularMethod(name: string, operation: string, path?: string, params?: any, headers?: any, elem?: any): ng.IPromise; } From e3d8e5fe91cfe0111686da53bf50ba8303d6102f Mon Sep 17 00:00:00 2001 From: Santi Albo Date: Thu, 24 Apr 2014 11:42:09 +0100 Subject: [PATCH 09/24] fix restangular test --- restangular/restangular-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/restangular/restangular-tests.ts b/restangular/restangular-tests.ts index 22473e13e..9643c9e6b 100644 --- a/restangular/restangular-tests.ts +++ b/restangular/restangular-tests.ts @@ -75,7 +75,7 @@ function test_basic() { $scope.account = account.get({ single: true }); - account.customPOST("messages", { param: "myParam" }, {}, { name: "My Message" }) + account.customPOST({ name: "My Message" }, "messages", { param: "myParam" }, {}) } function test_config() { From 4d233b71518a91c4e65bf03dbe4a8d8709412040 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 25 Apr 2014 09:57:57 +0100 Subject: [PATCH 10/24] jQueryUI: Tidy up and up to gotoCurrent --- jqueryui/jqueryui-tests.ts | 27 ++++++++++++ jqueryui/jqueryui.d.ts | 88 +++++++++++++++++++++++++++++--------- 2 files changed, 95 insertions(+), 20 deletions(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index b83006c3a..79263027f 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1362,6 +1362,33 @@ function test_datepicker() { $set = $(".selector").datepicker("option", "defaultDate", new Date()); $set = $(".selector").datepicker("option", "defaultDate", "+1m +7d"); } + + function duration() { + $(".selector").datepicker({ duration: "slow" }); + + var duration: string = $(".selector").datepicker("option", "duration"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "duration", "slow"); + } + + function firstDay() { + $(".selector").datepicker({ firstDay: 1 }); + + var firstDay: number = $(".selector").datepicker("option", "firstDay"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "firstDay", 1); + } + + function gotoCurrent() { + $(".selector").datepicker({ gotoCurrent: true }); + + var gotoCurrent: boolean = $(".selector").datepicker("option", "gotoCurrent"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "gotoCurrent", true); + } } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 5019a9950..26492bf20 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -1278,14 +1278,14 @@ interface JQuery { * Get the calculateWeek option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'calculateWeek' */ datepicker(methodName: 'option', optionName: 'calculateWeek'): (date: Date) => string; /** * Set the calculateWeek option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'calculateWeek' * @param calculateWeekValue A function to calculate the week of the year for a given date. The default implementation uses the ISO 8601 definition: weeks start on a Monday; the first week of the year contains the first Thursday of the year. */ datepicker(methodName: 'option', optionName: 'calculateWeek', calculateWeekValue: (date: Date) => string): JQuery; @@ -1294,14 +1294,14 @@ interface JQuery { * Get the changeMonth option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'changeMonth' */ datepicker(methodName: 'option', optionName: 'changeMonth'): boolean; /** * Set the changeMonth option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'changeMonth' * @param changeMonthValue Whether the month should be rendered as a dropdown instead of text. */ datepicker(methodName: 'option', optionName: 'changeMonth', changeMonthValue: boolean): JQuery; @@ -1310,14 +1310,14 @@ interface JQuery { * Get the changeYear option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'changeYear' */ datepicker(methodName: 'option', optionName: 'changeYear'): boolean; /** * Set the changeYear option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'changeYear' * @param changeYearValue Whether the year should be rendered as a dropdown instead of text. Use the yearRange option to control which years are made available for selection. */ datepicker(methodName: 'option', optionName: 'changeYear', changeYearValue: boolean): JQuery; @@ -1326,14 +1326,14 @@ interface JQuery { * Get the closeText option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'closeText' */ datepicker(methodName: 'option', optionName: 'closeText'): string; /** * Set the closeText option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'closeText' * @param closeTextValue The text to display for the close link. Use the showButtonPanel option to display this button. */ datepicker(methodName: 'option', optionName: 'closeText', closeTextValue: string): JQuery; @@ -1342,14 +1342,14 @@ interface JQuery { * Get the constrainInput option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'constrainInput' */ datepicker(methodName: 'option', optionName: 'constrainInput'): boolean; /** * Set the constrainInput option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'constrainInput' * @param constrainInputValue When true, entry in the input field is constrained to those characters allowed by the current dateFormat option. */ datepicker(methodName: 'option', optionName: 'constrainInput', constrainInputValue: boolean): JQuery; @@ -1358,14 +1358,14 @@ interface JQuery { * Get the currentText option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'currentText' */ datepicker(methodName: 'option', optionName: 'currentText'): string; /** * Set the currentText option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'currentText' * @param currentTextValue The text to display for the current day link. Use the showButtonPanel option to display this button. */ datepicker(methodName: 'option', optionName: 'currentText', currentTextValue: string): JQuery; @@ -1374,14 +1374,14 @@ interface JQuery { * Get the dateFormat option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'dateFormat' */ datepicker(methodName: 'option', optionName: 'dateFormat'): string; /** * Set the dateFormat option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'dateFormat' * @param dateFormatValue The format for parsed and displayed dates. For a full list of the possible formats see the formatDate function. */ datepicker(methodName: 'option', optionName: 'dateFormat', dateFormatValue: string): JQuery; @@ -1390,14 +1390,14 @@ interface JQuery { * Get the dayNames option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'dayNames' */ datepicker(methodName: 'option', optionName: 'dayNames'): string[]; /** * Set the dayNames option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'dayNames' * @param dayNamesValue The list of long day names, starting from Sunday, for use as requested via the dateFormat option. */ datepicker(methodName: 'option', optionName: 'dayNames', dayNamesValue: string[]): JQuery; @@ -1406,14 +1406,14 @@ interface JQuery { * Get the dayNamesMin option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'dayNamesMin' */ datepicker(methodName: 'option', optionName: 'dayNamesMin'): string[]; /** * Set the dayNamesMin option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'dayNamesMin' * @param dayNamesMinValue The list of minimised day names, starting from Sunday, for use as column headers within the datepicker. */ datepicker(methodName: 'option', optionName: 'dayNamesMin', dayNamesMinValue: string[]): JQuery; @@ -1422,14 +1422,14 @@ interface JQuery { * Get the dayNamesShort option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'dayNamesShort' */ datepicker(methodName: 'option', optionName: 'dayNamesShort'): string[]; /** * Set the dayNamesShort option, after initialization * * @param methodName 'option' - * @param optionName 'buttonText' + * @param optionName 'dayNamesShort' * @param dayNamesShortValue The list of abbreviated day names, starting from Sunday, for use as requested via the dateFormat option. */ datepicker(methodName: 'option', optionName: 'dayNamesShort', dayNamesShortValue: string[]): JQuery; @@ -1466,6 +1466,54 @@ interface JQuery { */ datepicker(methodName: 'option', optionName: 'defaultDate', defaultDateValue: string): JQuery; + /** + * Get the duration option, after initialization + * + * @param methodName 'option' + * @param optionName 'duration' + */ + datepicker(methodName: 'option', optionName: 'duration'): string; + /** + * Set the duration option, after initialization + * + * @param methodName 'option' + * @param optionName 'duration' + * @param durationValue Control the speed at which the datepicker appears, it may be a time in milliseconds or a string representing one of the three predefined speeds ("slow", "normal", "fast"). + */ + datepicker(methodName: 'option', optionName: 'duration', durationValue: string): JQuery; + + /** + * Get the firstDay option, after initialization + * + * @param methodName 'option' + * @param optionName 'firstDay' + */ + datepicker(methodName: 'option', optionName: 'firstDay'): number; + /** + * Set the firstDay option, after initialization + * + * @param methodName 'option' + * @param optionName 'firstDay' + * @param firstDayValue Set the first day of the week: Sunday is 0, Monday is 1, etc. + */ + datepicker(methodName: 'option', optionName: 'firstDay', firstDayValue: number): JQuery; + + /** + * Get the gotoCurrent option, after initialization + * + * @param methodName 'option' + * @param optionName 'gotoCurrent' + */ + datepicker(methodName: 'option', optionName: 'gotoCurrent'): boolean; + /** + * Set the gotoCurrent option, after initialization + * + * @param methodName 'option' + * @param optionName 'gotoCurrent' + * @param gotoCurrentValue When true, the current day link moves to the currently selected date instead of today. + */ + datepicker(methodName: 'option', optionName: 'gotoCurrent', gotoCurrentValue: boolean): JQuery; + /** * Gets the value currently associated with the specified optionName. * From 4fa6f7c29bec19e0d6420d91e2131d17c2a4570e Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sat, 26 Apr 2014 08:59:37 +1000 Subject: [PATCH 11/24] gruntjs: added node.js support --- gruntjs/gruntjs.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index f646bcbf2..fb971a099 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -1293,3 +1293,8 @@ interface IGrunt extends grunt.IConfigComponents, grunt.fail.FailModule, grunt.I */ version: string } + +// NodeJS Support +declare module 'grunt' { + export = IGrunt; +} From 87e0cf355331f726ee0169aabdaaef8754d3d83f Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sat, 26 Apr 2014 09:07:07 +1000 Subject: [PATCH 12/24] Update gruntjs.d.ts --- gruntjs/gruntjs.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index fb971a099..2bf0d91b4 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -1296,5 +1296,6 @@ interface IGrunt extends grunt.IConfigComponents, grunt.fail.FailModule, grunt.I // NodeJS Support declare module 'grunt' { - export = IGrunt; + var grunt: IGrunt; + export = grunt; } From 2b05c7787265ed95c79d6d8400bcc46d141e82af Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sat, 26 Apr 2014 09:08:53 +1000 Subject: [PATCH 13/24] fix underscore string module declaration --- underscore.string/underscore.string.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/underscore.string/underscore.string.d.ts b/underscore.string/underscore.string.d.ts index db9ec042d..9c828fdf7 100644 --- a/underscore.string/underscore.string.d.ts +++ b/underscore.string/underscore.string.d.ts @@ -562,7 +562,8 @@ interface UnderscoreStringStaticExports { toBoolean(str: string, trueValues?: any[], falseValues?: any[]): boolean; } -declare module "underscore.string" { -export = UnderscoreStringStatic; +declare module 'underscore.string' { + var underscoreString: UnderscoreStringStatic; + export = underscoreString; } // TODO interface UnderscoreString extends Underscore From 3963c4498b7208e0591af6a7873e1aab0afee488 Mon Sep 17 00:00:00 2001 From: MIZUNE Pine Date: Sat, 26 Apr 2014 10:37:50 +0900 Subject: [PATCH 14/24] Add url --- CONTRIBUTORS.md | 1 + js-url/js-url-test.ts | 9 +++++++++ js-url/js-url.d.ts | 14 ++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 js-url/js-url-test.ts create mode 100644 js-url/js-url.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d68e3061c..7806a004a 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -156,6 +156,7 @@ All definitions files include a header with the author and editors, so at some p * [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved)) * [jQuery.base64](https://github.com/yatt/jquery.base64) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) * [js-git](https://github.com/creationix/js-git) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [js-url](https://github.com/websanova/js-url) (by [MIZUNE Pine](https://github.com/pine613)) * [js-yaml](https://github.com/nodeca/js-yaml) (by [Bart van der Schoor](https://github.com/Bartvds/)) * [jScrollPane](http://jscrollpane.kelvinluck.com) (by [Dániel Tar](https://github.com/qcz)) * [JSDeferred](http://cho45.stfuawsc.com/jsdeferred/) (by [Daisuke Mino](https://github.com/minodisk)) diff --git a/js-url/js-url-test.ts b/js-url/js-url-test.ts new file mode 100644 index 000000000..0b26f6175 --- /dev/null +++ b/js-url/js-url-test.ts @@ -0,0 +1,9 @@ +/// + +url(); + +url('domain'); +url(1); + +url('domain', 'test.www.example.com/path/here'); +url(-1, 'test.www.example.com/path/here'); diff --git a/js-url/js-url.d.ts b/js-url/js-url.d.ts new file mode 100644 index 000000000..ff974f15e --- /dev/null +++ b/js-url/js-url.d.ts @@ -0,0 +1,14 @@ +// Type definitions for url() v1.8.6 +// Project: https://github.com/websanova/js-url +// Definitions by: MIZUNE Pine +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface UrlStatic { + (): string; + (pattern: string): string; + (pattern: number): string; + (pattern: string, url: string): string; + (pattern: number, url: string): string; +} + +declare var url: UrlStatic; From dd54ecd6b48b766d05264301117b35a9ff93ce22 Mon Sep 17 00:00:00 2001 From: satoru kimura Date: Sat, 26 Apr 2014 16:33:05 +0900 Subject: [PATCH 15/24] update to three.js r67. --- threejs/three-tests.ts | 6 +- threejs/three.d.ts | 544 +++++++++++++++++++++++------------------ 2 files changed, 311 insertions(+), 239 deletions(-) diff --git a/threejs/three-tests.ts b/threejs/three-tests.ts index 8207933bc..b5d9ed549 100644 --- a/threejs/three-tests.ts +++ b/threejs/three-tests.ts @@ -10550,7 +10550,6 @@ var container, stats; } geometry.computeFaceNormals(); - geometry.computeCentroids(); group = new THREE.Object3D(); group.scale.x = group.scale.y = group.scale.z = 2; @@ -16481,13 +16480,13 @@ function render() { var normalLength = 15; var fl: number; - var face: THREE.Face; + var face: THREE.Face3; for( f = 0, fl = geometry.faces.length; f < fl; f ++ ) { face = geometry.faces[ f ]; var arrow = new THREE.ArrowHelper( face.normal, - face.centroid, + face.normal, normalLength, 0x3333FF ); mesh.add( arrow ); @@ -17321,7 +17320,6 @@ function render() { // mergeVertices(); is run in case of duplicated vertices smooth.mergeVertices(); - smooth.computeCentroids(); smooth.computeFaceNormals(); smooth.computeVertexNormals(); diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 27938939a..1c5a4e8ca 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -1,4 +1,4 @@ -// Type definitions for three.js -- r66 +// Type definitions for three.js -- r67 // Project: http://mrdoob.github.com/three.js/ // Definitions by: Kon , Satoru Kimura // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -15,7 +15,7 @@ declare module THREE { export var AddEquation: BlendingEquation; export var SubtractEquation: BlendingEquation; export var ReverseSubtractEquation: BlendingEquation; - + // custom blending destination factors export enum BlendingDstFactor { } export var ZeroFactor: BlendingDstFactor; @@ -177,8 +177,8 @@ declare module THREE { /** * Camera with orthographic projection * - * @example - * var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); + * @example + * var camera = new THREE.OrthographicCamera( width / - 2, width / 2, height / 2, height / - 2, 1, 1000 ); * scene.add( camera ); * * @see src/cameras/OrthographicCamera.js @@ -281,20 +281,20 @@ declare module THREE { /** * Sets an offset in a larger frustum. This is useful for multi-window or multi-monitor/multi-machine setups. * For example, if you have 3x2 monitors and each monitor is 1920x1080 and the monitors are in grid like this: - * + * * +---+---+---+ * | A | B | C | * +---+---+---+ * | D | E | F | * +---+---+---+ - * + * * then for each monitor you would call it like this: - * + * * var w = 1920; * var h = 1080; * var fullWidth = w * 3; * var fullHeight = h * 2; - * + * * // A * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h ); * // B @@ -307,13 +307,13 @@ declare module THREE { * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h ); * // F * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h ); Note there is no reason monitors have to be the same size or in a grid. - * + * * @param fullWidth full width of multiview setup * @param fullHeight full height of multiview setup * @param x horizontal offset of subcamera * @param y vertical offset of subcamera * @param width width of subcamera - * @param height height of subcamera + * @param height height of subcamera */ setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): void; @@ -328,7 +328,7 @@ declare module THREE { interface BufferGeometryAttributeArray extends ArrayBufferView{ length: number; - } + } interface BufferGeometryAttribute{ itemSize: number; @@ -336,8 +336,8 @@ declare module THREE { numItems: number; } - interface BufferGeometryAttributes{ - [name: string]: BufferGeometryAttribute; + interface BufferGeometryAttributes{ + [name: string]: BufferGeometryAttribute; index?: BufferGeometryAttribute; position?: BufferGeometryAttribute; normal?: BufferGeometryAttribute; @@ -345,7 +345,7 @@ declare module THREE { } /** - * This is a superefficent class for geometries because it saves all data in buffers. + * This is a superefficent class for geometries because it saves all data in buffers. * It reduces memory costs and cpu cycles. But it is not as easy to work with because of all the nessecary buffer calculations. * It is mainly interesting when working with static objects. * @@ -419,7 +419,7 @@ declare module THREE { computeBoundingSphere(): void; /** - * Disposes the object from memory. + * Disposes the object from memory. * You need to call this when you want the bufferGeometry removed while the application is running. */ dispose(): void; @@ -446,7 +446,7 @@ declare module THREE { autoStart: boolean; /** - * When the clock is running, It holds the starttime of the clock. + * When the clock is running, It holds the starttime of the clock. * This counted from the number of milliseconds elapsed since 1 January 1970 00:00:00 UTC. */ startTime: number; @@ -503,7 +503,7 @@ declare module THREE { * }; * * }; - * + * * var car = new Car(); * car.addEventListener( 'start', function ( event ) { * @@ -547,57 +547,18 @@ declare module THREE { */ dispatchEvent(event: { type: string; target: any; }): void; } - - export interface Face { - /** - * Face normal. - */ - normal: Vector3; - - /** - * Face color. - */ - color: Color; - - /** - * Array of 4 vertex normals. - */ - vertexNormals: Vector3[]; - - /** - * Array of 4 vertex normals. - */ - vertexColors: Color[]; - - /** - * Array of 4 vertex tangets. - */ - vertexTangents: number[]; - - /** - * Material index (points to {@link Geometry.materials}). - */ - materialIndex: number; - - /** - * Face centroid. - */ - centroid: Vector3; - - clone(): Face; - } /** * Triangle face. * * # Example - * var normal = new THREE.Vector3( 0, 1, 0 ); - * var color = new THREE.Color( 0xffaa00 ); + * var normal = new THREE.Vector3( 0, 1, 0 ); + * var color = new THREE.Color( 0xffaa00 ); * var face = new THREE.Face3( 0, 1, 2, normal, color, 0 ); * * @source https://github.com/mrdoob/three.js/blob/master/src/core/Face3.js */ - export class Face3 implements Face { + export class Face3 { /** * @param a Vertex A index. * @param b Vertex B index. @@ -658,10 +619,6 @@ declare module THREE { */ materialIndex: number; - /** - * Face centroid. - */ - centroid: Vector3; clone(): Face3; } @@ -692,13 +649,13 @@ declare module THREE { /** * Base class for geometries - * + * * # Example * var geometry = new THREE.Geometry(); - * geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) ); - * geometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) ); - * geometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) ); - * geometry.faces.push( new THREE.Face3( 0, 1, 2 ) ); + * geometry.vertices.push( new THREE.Vector3( -10, 10, 0 ) ); + * geometry.vertices.push( new THREE.Vector3( -10, -10, 0 ) ); + * geometry.vertices.push( new THREE.Vector3( 10, -10, 0 ) ); + * geometry.faces.push( new THREE.Face3( 0, 1, 2 ) ); * geometry.computeBoundingSphere(); * * @see https://github.com/mrdoob/three.js/blob/master/src/core/Geometry.js @@ -732,7 +689,7 @@ declare module THREE { /** * Array of vertex normals, matching number and order of vertices. - * Normal vectors are nessecary for lighting + * Normal vectors are nessecary for lighting * To signal an update in this array, Geometry.normalsNeedUpdate needs to be set to true. */ // normals: Vector3[]; @@ -742,7 +699,7 @@ declare module THREE { * The array of faces describe how each vertex in the model is connected with each other. * To signal an update in this array, Geometry.elementsNeedUpdate needs to be set to true. */ - faces: Face[]; + faces: Face3[]; /** * Array of face UV layers. @@ -863,11 +820,6 @@ declare module THREE { */ applyMatrix(matrix: Matrix4): void; - /** - * Computes centroids for all faces. - */ - computeCentroids(): void; - /** * Computes face normals. */ @@ -890,7 +842,7 @@ declare module THREE { * Geometry must have vertex UVs (layer 0 will be used). */ computeTangents(): void; - + /** * Computes bounding box of the geometry, updating {@link Geometry.boundingBox} attribute. */ @@ -902,6 +854,8 @@ declare module THREE { */ computeBoundingSphere(): void; + merge( geometry: Geometry, matrix: Matrix, materialIndexOffset: number): void; + /** * Checks for duplicate vertices using hashmap. * Duplicated vertices are removed and faces' vertices are updated. @@ -914,19 +868,14 @@ declare module THREE { clone(): Geometry; /** - * Removes The object from memory. + * Removes The object from memory. * Don't forget to call this method when you remove an geometry because it can cuase meomory leaks. */ dispose(): void; computeLineDistances(): void; - } - - export class Geometry2 extends BufferGeometry { - vertices: Float32Array; - normals: Float32Array; - uvs: Float32Array; + makeGroups(usesFaceMaterial: boolean, maxVerticesInGroup: number): void; } /** @@ -1145,7 +1094,7 @@ declare module THREE { /** * Rotate an object along an axis in object space. The axis is assumed to be normalized. - * @param axis A normalized vector in object space. + * @param axis A normalized vector in object space. * @param angle The angle in radians. */ rotateOnAxis(axis: Vector3, angle: number): Object3D; @@ -1168,7 +1117,7 @@ declare module THREE { /** * Transforms a 3D scene object into 2D render data that can be rendered in a screen with your renderer of choice, projecting and clipping things out according to the used camera. - * If the scene were a real scene, this method would be the equivalent of taking a picture with the camera (and developing the film would be the next step, using a Renderer). + * If the scene were a real scene, this method would be the equivalent of taking a picture with the camera (and developing the film would be the next step, using a Renderer). * * @param scene scene to project. * @param camera camera to use in the projection. @@ -1178,14 +1127,14 @@ declare module THREE { objects: Object3D[]; // Mesh, Line or other object sprites: Object3D[]; // Sprite or Particle lights: Light[]; - elements: Face[]; // Line, Particle, Face3 or Face4 + elements: Face3[]; // Line, Particle, Face3 or Face4 }; } export interface Intersection { distance: number; point: Vector3; - face: Face; + face: Face3; object: Object3D; } @@ -1214,9 +1163,9 @@ declare module THREE { /** * This light's color gets applied to all the objects in the scene globally. - * + * * # example - * var light = new THREE.AmbientLight( 0x404040 ); // soft white light + * var light = new THREE.AmbientLight( 0x404040 ); // soft white light * scene.add( light ); * * @source https://github.com/mrdoob/three.js/blob/master/src/lights/AmbientLight.js @@ -1249,9 +1198,9 @@ declare module THREE { * Affects objects using MeshLambertMaterial or MeshPhongMaterial. * * @example - * // White directional light at half intensity shining from the top. - * var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); - * directionalLight.position.set( 0, 1, 0 ); + * // White directional light at half intensity shining from the top. + * var directionalLight = new THREE.DirectionalLight( 0xffffff, 0.5 ); + * directionalLight.position.set( 0, 1, 0 ); * scene.add( directionalLight ); * * @see src/lights/DirectionalLight.js @@ -1351,7 +1300,7 @@ declare module THREE { /** * Shadow map texture height in pixels. - * Default — 512. + * Default — 512. */ shadowMapHeight: number; @@ -1425,7 +1374,7 @@ declare module THREE { export class HemisphereLight extends Light { constructor(skyColorHex?: number, groundColorHex?: number, intensity?: number); - + position: Vector3; groundColor: Color; intensity: number; @@ -1438,7 +1387,7 @@ declare module THREE { * * @example * var light = new THREE.PointLight( 0xff0000, 1, 100 ); - * light.position.set( 50, 50, 50 ); + * light.position.set( 50, 50, 50 ); * scene.add( light ); */ export class PointLight extends Light { @@ -1469,15 +1418,15 @@ declare module THREE { * A point light that can cast shadow in one direction. * * @example - * // white spotlight shining from the side, casting shadow + * // white spotlight shining from the side, casting shadow * var spotLight = new THREE.SpotLight( 0xffffff ); * spotLight.position.set( 100, 1000, 100 ); - * spotLight.castShadow = true; + * spotLight.castShadow = true; * spotLight.shadowMapWidth = 1024; - * spotLight.shadowMapHeight = 1024; + * spotLight.shadowMapHeight = 1024; * spotLight.shadowCameraNear = 500; - * spotLight.shadowCameraFar = 4000; - * spotLight.shadowCameraFov = 30; + * spotLight.shadowCameraFar = 4000; + * spotLight.shadowCameraFov = 30; * scene.add( spotLight ); */ export class SpotLight extends Light { @@ -1601,7 +1550,7 @@ declare module THREE { * load * Dispatched when the image has completed loading * content — loaded image - * + * * error * * Dispatched when the image can't be loaded @@ -1658,17 +1607,19 @@ declare module THREE { load(url: string, onLoad: (bufferGeometry: BufferGeometry) => void): void; setCrossOrigin(crossOrigin: string): void; parse(json: any): BufferGeometry; - + } - export class Geometry2Loader { - constructor(manager?: LoadingManager); + export class Cache{ + constructor(); - load(url: string, onLoad: (geometry2: Geometry2) => void): void; - setCrossOrigin(crossOrigin: string): void; - parse(json: any): Geometry2; + files: any[]; + + add(key: string, file: any): void; + get(key: string): any; + remove(key: string): void; + clear(): void; } - /** * A loader for loading an image. * Unlike other loaders, this one emits events instead of using predefined callbacks. So if you're interested in getting notified when things happen, you need to add listeners to the object. @@ -1740,7 +1691,7 @@ declare module THREE { setCrossOrigin(crossOrigin: string): void; parse(json: any): Material; } - + export class ObjectLoader extends EventDispatcher { constructor(manager?: LoadingManager); @@ -1840,14 +1791,11 @@ declare module THREE { export class XHRLoader extends EventDispatcher { constructor(manager?: LoadingManager); + + cache: Cache; crossOrigin: string; - /** - * Begin loading from url - * - * @param url - */ - constructor(onLoad?: (responseText: string) => void, onProgress?: (event: any) => void, onError?: (event: any) => void); - load(onLoad?: (responseText: string) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; + + load(url: string, onLoad?: (responseText: string) => void, onProgress?: (event: any) => void, onError?: (event: any) => void): void; setCrossOrigin(crossOrigin: string): void; } @@ -1921,12 +1869,12 @@ declare module THREE { */ polygonOffsetFactor: number; - /** + /** * Sets the polygon offset units. Default is 0. */ polygonOffsetUnits: number; - /** + /** * Sets the alpha value to be used when running an alpha test. Default is 0. */ alphaTest: number; @@ -2207,7 +2155,7 @@ declare module THREE { normalMap: Texture; bumpMap: Texture; wrapRGB: Vector3; - + clone(): MeshPhongMaterial; } @@ -2238,6 +2186,11 @@ declare module THREE { color?: { type: string; value: THREE.Color; }; } + export class RawShaderMaterial extends ShaderMaterial { + constructor(parameters?: ShaderMaterialParameters); + + } + export interface ShaderMaterialParameters { uniforms?: Uniforms; fragmentShader?: string; @@ -2274,7 +2227,7 @@ declare module THREE { linewidth: number; wireframeLinewidth: number; defines: any; - + clone(): ShaderMaterial; } @@ -2355,7 +2308,7 @@ declare module THREE { constructor(min?: Vector3, max?: Vector3); max: Vector3; min: Vector3; - + set(min: Vector3, max: Vector3): Box3; applyMatrix4(matrix: Matrix4): Box3; expandByPoint(point: Vector3): Box3; @@ -2391,7 +2344,7 @@ declare module THREE { /** * Represents a color. See also {@link ColorUtils}. * - * @example + * @example * var color = new THREE.Color( 0xff0000 ); * * @see src/math/Color.js @@ -2475,7 +2428,7 @@ declare module THREE { */ setStyle(style: string): Color; - /** + /** * Returns the value of this color in CSS context style. * Example: rgb(r, g, b) */ @@ -2579,7 +2532,7 @@ declare module THREE { /** * Clamps the x to be larger than a. - * + * * @param x — Value to be clamped. * @param a — Minimum value */ @@ -2587,7 +2540,7 @@ declare module THREE { /** * Linear mapping of x from range [a1, a2] to range [b1, b2]. - * + * * @param x Value to be mapped. * @param a1 Minimum value for range A. * @param a2 Maximum value for range A. @@ -2713,7 +2666,10 @@ declare module THREE { determinant(): number; set(n11: number, n12: number, n13: number, n21: number, n22: number, n23: number, n31: number, n32: number, n33: number): Matrix3; multiplyScalar(s: number): Matrix3; + // DEPRECATED multiplyVector3Array(a: number[]): number[]; + applyToVector3Array(array: number[], offset?: number, length?: number): number[]; + flattenToArrayOffset(array: number[], offset: number): number[]; getNormalMatrix(m: Matrix4): Matrix3; getInverse(matrix: Matrix3, throwOnInvertible?: boolean): Matrix3; getInverse(matrix: Matrix4, throwOnInvertible?: boolean): Matrix3; @@ -2726,19 +2682,19 @@ declare module THREE { * A 4x4 Matrix. * * @example - * // Simple rig for rotating around 3 axes - * var m = new THREE.Matrix4(); - * var m1 = new THREE.Matrix4(); - * var m2 = new THREE.Matrix4(); - * var m3 = new THREE.Matrix4(); - * var alpha = 0; - * var beta = Math.PI; - * var gamma = Math.PI/2; - * m1.makeRotationX( alpha ); - * m2.makeRotationY( beta ); - * m3.makeRotationZ( gamma ); - * m.multiplyMatrices( m1, m2 ); - * m.multiply( m3 ); + * // Simple rig for rotating around 3 axes + * var m = new THREE.Matrix4(); + * var m1 = new THREE.Matrix4(); + * var m2 = new THREE.Matrix4(); + * var m3 = new THREE.Matrix4(); + * var alpha = 0; + * var beta = Math.PI; + * var gamma = Math.PI/2; + * m1.makeRotationX( alpha ); + * m2.makeRotationY( beta ); + * m3.makeRotationZ( gamma ); + * m.multiplyMatrices( m1, m2 ); + * m.multiply( m3 ); */ export class Matrix4 implements Matrix { @@ -2758,7 +2714,7 @@ declare module THREE { */ elements: Float32Array; - /** + /** * Sets all fields of this matrix. */ set(n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number): Matrix4; @@ -2816,15 +2772,10 @@ declare module THREE { */ transpose(): Matrix4; - /** - * Flattens this matrix into supplied flat array. - */ - flattenToArray(flat: number[]): number[]; - /** * Flattens this matrix into supplied flat array starting from offset position in the array. */ - flattenToArrayOffset(flat: number[], offset: number): number[]; + flattenToArrayOffset(array: number[], offset: number): number[]; /** * Sets the position component for this matrix from vector v. @@ -2870,7 +2821,7 @@ declare module THREE { /** * Sets this matrix as rotation transform around y axis by theta radians. - * + * * @param theta Rotation angle in radians. */ makeRotationY(theta: number): Matrix4; @@ -2886,7 +2837,7 @@ declare module THREE { * Sets this matrix as rotation transform around axis by angle radians. * Based on http://www.gamedev.net/reference/articles/article1199.asp. * - * @param axis Rotation axis. + * @param axis Rotation axis. * @param theta Rotation angle in radians. */ makeRotationAxis(axis: Vector3, angle: number): Matrix4; @@ -2896,7 +2847,7 @@ declare module THREE { */ makeScale(x: number, y: number, z: number): Matrix4; - /** + /** * Creates a frustum matrix. */ makeFrustum(left: number, right: number, bottom: number, top: number, near: number, far: number): Matrix4; @@ -2916,7 +2867,10 @@ declare module THREE { */ clone(): Matrix4; + // DEPRECATED multiplyVector3Array(a: number[]): number[]; + applyToVector3Array(array: number[], offset?: number, length?: number): number[]; + getMaxScaleOnAxis(): number; } @@ -2950,9 +2904,9 @@ declare module THREE { * Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages. * * @example - * var quaternion = new THREE.Quaternion(); - * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 ); - * var vector = new THREE.Vector3( 1, 0, 0 ); + * var quaternion = new THREE.Quaternion(); + * quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 ); + * var vector = new THREE.Vector3( 1, 0, 0 ); * vector.applyQuaternion( quaternion ); */ export class Quaternion { @@ -3100,7 +3054,7 @@ declare module THREE { /** * Represents a spline. - * + * * @see src/math/Spline.js */ export class Spline { @@ -3163,7 +3117,7 @@ declare module THREE { plane(optionalTarget?: Vector3): Plane; containsPoint(point: Vector3): boolean; copy(triangle: Triangle): Triangle; - + static normal(a: Vector3, b: Vector3, c: Vector3, optionalTarget?: Vector3): Vector3; static barycoordFromPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3, optionalTarget: Vector3): Vector3; static containsPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3): boolean; @@ -3248,7 +3202,7 @@ declare module THREE { /** * NOTE: Vector4 doesn't have the property. - * + * * distanceTo(v:T):number; */ distanceTo(v: Vector): number; @@ -3283,7 +3237,7 @@ declare module THREE { /** * 2D vector. - * + * * ( class Vector2 implements Vector ) */ export class Vector2 implements Vector { @@ -3333,7 +3287,7 @@ declare module THREE { */ divideScalar(s: number): Vector2; - /** + /** * Inverts this vector. */ negate(): Vector2; @@ -3400,7 +3354,7 @@ declare module THREE { /** * Gets a component of this vector. - */ + */ getComponent(index: number): number; fromArray(xy: number[]): Vector2; @@ -3426,9 +3380,9 @@ declare module THREE { * 3D vector. * * @example - * var a = new THREE.Vector3( 1, 0, 0 ); - * var b = new THREE.Vector3( 0, 1, 0 ); - * var c = new THREE.Vector3(); + * var a = new THREE.Vector3( 1, 0, 0 ); + * var b = new THREE.Vector3( 0, 1, 0 ); + * var c = new THREE.Vector3(); * c.crossVectors( a, b ); * * @see src/math/Vector3.js @@ -3478,7 +3432,7 @@ declare module THREE { */ addVectors(a: Vector3, b: Vector3): Vector3; - /** + /** * Subtracts v from this vector. */ sub(a: Vector3): Vector3; @@ -3488,7 +3442,7 @@ declare module THREE { */ subVectors(a: Vector3, b: Vector3): Vector3; - /** + /** * Multiplies this vector by scalar s. */ multiplyScalar(s: number): Vector3; @@ -3657,7 +3611,7 @@ declare module THREE { */ dot(v: Vector4): number; - /** + /** * Computes squared length of this vector. */ lengthSq(): number; @@ -3737,7 +3691,7 @@ declare module THREE { */ setW(w: number): Vector2; - /** + /** * NOTE: Vector4 doesn't have the property. * * distanceToSquared(v:T):number; @@ -3759,6 +3713,11 @@ declare module THREE { skinMatrix: Matrix4; skin: SkinnedMesh; + + accumulatedRotWeight: number; + accumulatedPosWeight: number; + accumulatedSclWeight: number; + update(parentSkinMatrix?: Matrix4, forceUpdate?: boolean): void; } @@ -3795,7 +3754,7 @@ declare module THREE { geometry: Geometry; material: Material; - + getMorphTargetIndexByName(name: string): number; updateMorphTargets(): void; clone(object?: Mesh): Mesh; @@ -3828,13 +3787,13 @@ declare module THREE { parseAnimations(): void; updateAnimation(delta: number): void; setAnimationLabel(label: string, start: number, end: number): void; - + clone(object?: MorphAnimMesh): MorphAnimMesh; } /** * A class for displaying particles in the form of variable size points. For example, if using the WebGLRenderer, the particles are displayed using GL_POINTS. - * + * * @see src/objects/ParticleSystem.js */ export class ParticleSystem extends Object3D { @@ -3846,7 +3805,7 @@ declare module THREE { constructor(geometry: Geometry, material?: ParticleSystemMaterial); constructor(geometry: Geometry, material?: ShaderMaterial); constructor(geometry: BufferGeometry, material?: ParticleSystemMaterial); - constructor(geometry: BufferGeometry, material?: ShaderMaterial); + constructor(geometry: BufferGeometry, material?: ShaderMaterial); /** * An instance of Geometry, where each vertex designates the position of a particle in the system. @@ -3868,6 +3827,16 @@ declare module THREE { clone(object?: ParticleSystem): ParticleSystem; } + export class Skeleton extends Mesh { + constructor(boneList: Bone[], useVertexTexture: boolean); + bones: Bone[]; + useVertexTexture: boolean; + boneMatrices: Float32Array; + + addBone(bone: Bone): Bone; + calculateInverses(bone: Bone): void; + } + export class SkinnedMesh extends Mesh { constructor(geometry?: Geometry, material?: MeshBasicMaterial, useVertexTexture?: boolean); constructor(geometry?: Geometry, material?: MeshDepthMaterial, useVertexTexture?: boolean); @@ -3877,13 +3846,10 @@ declare module THREE { constructor(geometry?: Geometry, material?: MeshPhongMaterial, useVertexTexture?: boolean); constructor(geometry?: Geometry, material?: ShaderMaterial, useVertexTexture?: boolean); - bones: Bone[]; identityMatrix: Matrix4; - useVertexTexture: boolean; - boneMatrices: Float32Array; - + pose(): void; - addBone(bone?: Bone): Bone; + normalizeSkinWeights(): void; clone(object?: SkinnedMesh): SkinnedMesh; } @@ -3917,7 +3883,7 @@ declare module THREE { autoClear: boolean; sortObjects: boolean; sortElements: boolean; - + getMaxAnisotropy(): number; render(scene: Scene, camera: Camera): void; clear(): void; @@ -3928,6 +3894,7 @@ declare module THREE { supportsVertexTextures(): void; setSize(width: number, height: number, updateStyle?: boolean): void; setClearColorHex(hex: number, alpha?: number): void; + setViewport(x: number, y: number, width: number, height: number): void; } export interface RendererPlugin { @@ -3936,7 +3903,7 @@ declare module THREE { } export interface WebGLRendererParameters { - /** + /** * A Canvas where the renderer draws its output. */ canvas?: HTMLCanvasElement; @@ -4045,7 +4012,7 @@ declare module THREE { */ gammaInput: boolean; - /** + /** * Default is false. */ gammaOutput: boolean; @@ -4077,7 +4044,7 @@ declare module THREE { shadowMapDebug: boolean; /** - * Default is false. + * Default is false. */ shadowMapCascade: boolean; @@ -4137,6 +4104,9 @@ declare module THREE { * Return a Boolean true if the context supports vertex textures. */ supportsVertexTextures(): boolean; + supportsFloatTextures(): boolean; + supportsStandardDerivatives(): boolean; + supportsCompressedTextureS3TC(): boolean; /** * Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0). @@ -4153,7 +4123,7 @@ declare module THREE { */ setScissor(x: number, y: number, width: number, height: number): void; - /** + /** * Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions. */ enableScissorTest(enable: boolean): void; @@ -4181,6 +4151,10 @@ declare module THREE { */ clear(color?: boolean, depth?: boolean, stencil?: boolean): void; + clearColor(): void; + clearDepth(): void; + clearStencil(): void; + /** * Initialises the postprocessing plugin, and adds it to the renderPluginsPost array. */ @@ -4193,7 +4167,7 @@ declare module THREE { /** * Tells the shadow map plugin to update using the passed scene and camera parameters. - * + * * @param scene an instance of Scene * @param camera — an instance of Camera */ @@ -4218,30 +4192,27 @@ declare module THREE { /** * Used for setting the gl frontFace, cullFace states in the GPU, thus enabling/disabling face culling when rendering. * If cullFace is false, culling will be disabled. - * @param cullFace "back", "front", "front_and_back", or false. + * @param cullFace "back", "front", "front_and_back", or false. * @param frontFace "ccw" or "cw */ - setFaceCulling(cullFace?: string, frontFace?: FrontFaceDirection): void; + setFaceCulling(cullFace?: CullFace, frontFace?: FrontFaceDirection): void; setDepthTest(depthTest: boolean): void; setDepthWrite(depthWrite: boolean): void; setBlending(blending: Blending, blendEquation: BlendingEquation, blendSrc: BlendingSrcFactor, blendDst: BlendingDstFactor): void; setTexture(texture: Texture, slot: number): void; setRenderTarget(renderTarget: RenderTarget): void; - supportsCompressedTextureS3TC(): any; getMaxAnisotropy(): number; getPrecision(): string; setMaterialFaces(material: Material): void; - supportsStandardDerivatives(): any; - supportsFloatTextures(): any; clearTarget(renderTarget:WebGLRenderTarget, color: boolean, depth: boolean, stencil: boolean): void; /** * Sets the clear color, using hex for the color and alpha for the opacity. - * + * * @example - * // Creates a renderer with black background - * var renderer = new THREE.WebGLRenderer(); - * renderer.setSize(200, 100); + * // Creates a renderer with black background + * var renderer = new THREE.WebGLRenderer(); + * renderer.setSize(200, 100); * renderer.setClearColorHex(0x000000, 1); */ setClearColorHex(hex: number, alpha: number): void; @@ -4292,16 +4263,13 @@ declare module THREE { export class RenderableFace { constructor(); - vertexNormalsModelView: Vector3[]; - normalWorld: Vector3; color: number; material: Material; uvs: Vector2[][]; v1: RenderableVertex; v2: RenderableVertex; v3: RenderableVertex; - normalModelView: Vector3; - centroidModel: Vector3; + normalModel: Vector3; vertexNormalsLength: number; z: number; vertexNormalsModel: Vector3[]; @@ -4342,11 +4310,11 @@ declare module THREE { visible: boolean; positionScreen: Vector4; positionWorld: Vector3; - + copy(vertex: RenderableVertex): void; } - // Shaders ///////////////////////////////////////////////////////////////////// + // Renderers / Shaders ///////////////////////////////////////////////////////////////////// export interface ShaderChunk { [name: string]: string; fog_pars_fragment: string; @@ -4436,11 +4404,20 @@ declare module THREE { depthRGBA: Shader; }; + // Renderers / WebGL ///////////////////////////////////////////////////////////////////// + export class WebGLProgram{ + constructor(renderer: WebGLRenderer, code: string, material: ShaderMaterial, parameters: WebGLRendererParameters); + } + + export class WebGLShader{ + constructor(gl: any, type: string, string: string); + } + // Scenes ///////////////////////////////////////////////////////////////////// export interface IFog { name:string; - color: Color; + color: Color; clone():IFog; } @@ -4450,7 +4427,7 @@ declare module THREE { */ export class Fog implements IFog { constructor(hex: number, near?: number, far?: number); - + name:string; /** @@ -4527,8 +4504,8 @@ declare module THREE { magFilter?: TextureFilter, minFilter?: TextureFilter, anisotropy?: number - ); - + ); + clone(): CompressedTexture; } @@ -4545,14 +4522,14 @@ declare module THREE { magFilter: TextureFilter, minFilter: TextureFilter, anisotropy?: number - ); + ); clone(): DataTexture; } export class Texture { constructor( - image: HTMLImageElement, + image: any, // HTMLImageElement or HTMLCanvasElement mapping?: Mapping, wrapS?: Wrapping, wrapT?: Wrapping, @@ -4561,7 +4538,7 @@ declare module THREE { format?: PixelFormat, type?: TextureDataType, anisotropy?: number - ); + ); constructor( image: HTMLCanvasElement, mapping?: Mapping, @@ -4572,7 +4549,7 @@ declare module THREE { format?: PixelFormat, type?: TextureDataType, anisotropy?: number - ); + ); constructor( image: HTMLImageElement, mapping?: MappingConstructor, @@ -4594,7 +4571,7 @@ declare module THREE { format?: PixelFormat, type?: TextureDataType, anisotropy?: number - ); + ); image: Object; // HTMLImageElement or ImageData ; mapping: Mapping; @@ -4635,29 +4612,30 @@ declare module THREE { style: string; weight: string; face: string; - faces: { [weight: string]: { [style: string]: Face; }; }; + faces: { [weight: string]: { [style: string]: Face3; }; }; size: number; - + drawText(text: string): { paths: Path[]; offset: number; }; Triangulate: { (contour: Vector2[], indices: boolean): Vector2[]; area(contour: Vector2[]): number; }; - extractGlyphPoints(c: string, face: Face, scale: number, offset: number, path: Path): { offset: number; path: Path; }; + extractGlyphPoints(c: string, face: Face3, scale: number, offset: number, path: Path): { offset: number; path: Path; }; generateShapes(text: string, parameters?: { size?: number; curveSegments?: number; font?: string; weight?: string; style?: string; }): Shape[]; loadFace(data: TypefaceData): TypefaceData; - getFace(): Face; + getFace(): Face3; }; export var GeometryUtils: { + // DEPRECATED merge(geometry1: Geometry, object2: Mesh, materialIndexOffset?: number): void; + // DEPRECATED merge(geometry1: Geometry, object2: Geometry, materialIndexOffset?: number): void; randomPointInTriangle(vectorA: Vector3, vectorB: Vector3, vectorC: Vector3): Vector3; - randomPointInFace(face: Face, geometry: Geometry, useCachedAreas: boolean): Vector3; + randomPointInFace(face: Face3, geometry: Geometry, useCachedAreas: boolean): Vector3; randomPointsInGeometry(geometry: Geometry, points: number): Vector3; triangleArea(vectorA: Vector3, vectorB: Vector3, vectorC: Vector3): number; center(geometry: Geometry): Vector3; - triangulateQuads(geometry: Geometry): void; }; export var ImageUtils: { @@ -4702,7 +4680,7 @@ declare module THREE { export class Animation { constructor(root: Mesh, name: string); - + root: Mesh; data: AnimationData; hierarchy: Bone[]; @@ -4711,9 +4689,11 @@ declare module THREE { isPlaying: boolean; isPaused: boolean; loop: boolean; + weight: number; interpolationType: AnimationInterpolation; + keyTypes: string[]; - play(loop?: boolean, startTimeMS?: number): void; + play(startTime?: number, weight?: number): void; pause(): void; stop(): void; reset(): void; @@ -4730,10 +4710,12 @@ declare module THREE { CATMULLROM: AnimationInterpolation; CATMULLROM_FORWARD: AnimationInterpolation; LINEAR: AnimationInterpolation; + + remove(name: string): void; removeFromUpdate(animation: Animation): void; get(name: string): AnimationData; update(deltaTimeMS: number): void; - parse(root: SkinnedMesh): Object3D[]; + parse(root: Mesh): Object3D[]; add(data: AnimationData): void; addToUpdate(animation: Animation): void; }; @@ -4779,7 +4761,7 @@ declare module THREE { export class CombinedCamera extends Camera { constructor(width: number, height: number, fov: number, near: number, far: number, orthoNear: number, orthoFar: number); - + fov: number; right: number; bottom: number; @@ -4815,6 +4797,103 @@ declare module THREE { updateCubeMap(renderer: Renderer, scene: Scene): void; } + // Extras / Curves ///////////////////////////////////////////////////////////////////// + export class ArcCurve extends EllipseCurve { + constructor(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean ); + } + export class ClosedSplineCurve3 extends Curve { + constructor( points:Vector3[] ); + + points:Vector3[]; + + getPoint(t: number): Vector3; + } + export class CubicBezierCurve extends Curve { + constructor( v0: Vector2, v1: Vector2, v2: Vector2, v3: Vector2 ); + + v0: Vector2; + v1: Vector2; + v2: Vector2; + v3: Vector2; + + getPoint(t: number): Vector2; + } + export class CubicBezierCurve3 extends Curve { + constructor( v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3 ); + + v0: Vector2; + v1: Vector2; + v2: Vector2; + v3: Vector2; + + getPoint(t: number): Vector3; + } + export class EllipseCurve extends Curve { + constructor( aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean ); + + ax: number; + ay: number; + xRadius: number; + yRadius: number; + aStartAngle: number; + aEndAngle: number; + aClockwise: boolean; + + getPoint(t: number): Vector2; + } + export class LineCurve extends Curve { + constructor( v1: Vector2, v2: Vector2 ); + + v1: Vector2; + v2: Vector2; + + getPoint(t: number): Vector2; + getPointAt(u: number): Vector2; + getTangent(t: number): Vector2; + } + export class LineCurve3 extends Curve { + constructor( v1: Vector3, v2: Vector3 ); + + v1: Vector2; + v2: Vector2; + + getPoint(t: number): Vector3; + } + export class QuadraticBezierCurve extends Curve { + constructor( v0: Vector2, v1: Vector2, v2: Vector2 ); + + v0: Vector2; + v1: Vector2; + v2: Vector2; + + getPoint(t: number): Vector2; + getTangent(t: number): Vector2; + } + export class QuadraticBezierCurve3 extends Curve { + constructor( v0: Vector3, v1: Vector3, v2: Vector3 ); + + v0: Vector2; + v1: Vector2; + v2: Vector2; + + getPoint(t: number): Vector3; + } + export class SplineCurve extends Curve { + constructor( points: Vector2[] ); + + points:Vector2[]; + + getPoint(t: number): Vector2; + } + export class SplineCurve3 extends Curve { + constructor( points: Vector3[] ); + + points:Vector3[]; + + getPoint(t: number): Vector3; + } + + // Extras / Core ///////////////////////////////////////////////////////////////////// /** @@ -5006,18 +5085,6 @@ declare module THREE { constructor(width: number, height: number, depth: number, widthSegments?: number, heightSegments?: number, depthSegments?: number); } - export class BoxGeometry2 extends Geometry2 { - /** - * @param width — Width of the sides on the X axis. - * @param height — Height of the sides on the Y axis. - * @param depth — Depth of the sides on the Z axis. - * @param widthSegments — Number of segmented faces along the width of the sides. - * @param heightSegments — Number of segmented faces along the height of the sides. - * @param depthSegments — Number of segmented faces along the depth of the sides. - */ - constructor(width: number, height: number, depth: number, widthSegments?: number, heightSegments?: number, depthSegments?: number); - } - export class CircleGeometry extends Geometry { constructor(radius?: number, segments?: number, thetaStart?: number, thetaLength?: number); } @@ -5033,7 +5100,7 @@ declare module THREE { * @param radiusSegments — Number of segmented faces around the circumference of the cylinder. * @param heightSegments — Number of rows of faces along the height of the cylinder. * @param openEnded - A Boolean indicating whether or not to cap the ends of the cylinder. - */ + */ constructor(radiusTop?: number, radiusBottom?: number, height?: number, radiusSegments?: number, heightSegments?: number, openEnded?: boolean); } @@ -5065,12 +5132,8 @@ declare module THREE { constructor(width: number, height: number, widthSegments?: number, heightSegments?: number); } - export class PlaneGeometry2 extends Geometry2 { - constructor(width: number, height: number, widthSegments?: number, heightSegments?: number); - } - export class PolyhedronGeometry extends Geometry { - constructor(vertices: Vector3[], faces: Face[], radius?: number, detail?: number); + constructor(vertices: Vector3[], faces: Face3[], radius?: number, detail?: number); } export class RingGeometry extends Geometry { @@ -5191,13 +5254,14 @@ declare module THREE { } export class DirectionalLightHelper extends Object3D { - constructor(light: Light, sphereSize: number, arrowLength: number); + constructor(light: Light, size: number); - lightSphere: Mesh; + lightPlane: Line; light: Light; targetLine: Line; update(): void; + dispose(): void; } export class EdgesHelper extends Line { @@ -5236,7 +5300,16 @@ declare module THREE { lightSphere: Mesh; light: Light; - + + update(): void; + } + + export class SkeletonHelper extends Line { + constructor(bone: Bone); + + skeleton: Skeleton; + matrixAutoUpdate: boolean; + update(): void; } @@ -5305,8 +5378,9 @@ declare module THREE { positionScreen: Vector3; customUpdateCallback: (object: LensFlare) => void; - add(obj: Object3D): void; add(texture: Texture, size?: number, distance?: number, blending?: Blending, color?: Color): void; + add(obj: Object3D): void; + updateLensFlares(): void; } From 7dc04342a1c6a3aa7309c2285852909c5ffdb05c Mon Sep 17 00:00:00 2001 From: Seon-Wook Park Date: Sun, 27 Apr 2014 01:39:00 +0200 Subject: [PATCH 16/24] noble: Make classes be extends of events.EventEmitter --- noble/noble.d.ts | 58 +++++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/noble/noble.d.ts b/noble/noble.d.ts index 12ffb08bb..20259f0a7 100644 --- a/noble/noble.d.ts +++ b/noble/noble.d.ts @@ -6,18 +6,20 @@ /// declare module "noble" { + import events = require("events"); + export function startScanning(): void; export function startScanning(serviceUUIDs: string[]): void; export function startScanning(serviceUUIDs: string[], allowDuplicates: boolean): void; export function stopScanning(): void; - export function on(event: string, callback: Function): void; - export function on(event: "stateChange", callback: (state: string) => void): void; - export function on(event: "scanStart", callback: () => void): void; - export function on(event: "scanStop", callback: () => void): void; - export function on(event: "discover", callback: (peripheral: Peripheral) => void): void; + export function on(event: string, listener: Function): events.EventEmitter; + export function on(event: "stateChange", listener: (state: string) => void): events.EventEmitter; + export function on(event: "scanStart", listener: () => void): events.EventEmitter; + export function on(event: "scanStop", listener: () => void): events.EventEmitter; + export function on(event: "discover", listener: (peripheral: Peripheral) => void): events.EventEmitter; - export class Peripheral { + export class Peripheral extends events.EventEmitter { uuid: string; advertisement: Advertisement; rssi: number; @@ -25,7 +27,7 @@ declare module "noble" { connect(callback: (error: string) => void): void; disconnect(callback: () => void): void; - discoverServices(serviceUUIDs: string[], callback: (error: string, services: Service[]) => void): void; + discoverServices(serviceUUIDs: string[], listener: (error: string, services: Service[]) => void): void; discoverAllServicesAndCharacteristics(callback: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; discoverSomeServicesAndCharacteristics(serviceUUIDs: string[], characteristicUUIDs: string[], callback: (error: string, services: Service[], characteristics: Characteristic[]) => void): void; @@ -33,11 +35,11 @@ declare module "noble" { writeHandle(handle: NodeBuffer, data: NodeBuffer, withoutResponse: boolean, callback: (error: string) => void): void; toString(): string; - on(event: string, callback: Function): void; - on(event: "connect", callback: (error: string) => void): void; - on(event: "disconnect", callback: (error: string) => void): void; - on(event: "rssiUpdate", callback: (rssi: number) => void): void; - on(event: "servicesDiscover", callback: (services: Service[]) => void): void; + on(event: string, listener: Function): events.EventEmitter; + on(event: "connect", listener: (error: string) => void): events.EventEmitter; + on(event: "disconnect", listener: (error: string) => void): events.EventEmitter; + on(event: "rssiUpdate", listener: (rssi: number) => void): events.EventEmitter; + on(event: "servicesDiscover", listener: (services: Service[]) => void): events.EventEmitter; } export interface Advertisement { @@ -48,7 +50,7 @@ declare module "noble" { serviceUuids: string[]; } - export class Service { + export class Service extends events.EventEmitter { uuid: string; name: string; type: string; @@ -59,12 +61,12 @@ declare module "noble" { discoverCharacteristics(characteristicUUIDs: string[], callback: (error: string, characteristics: Characteristic[]) => void): void; toString(): string; - on(event: string, callback: Function): void; - on(event: "includedServicesDiscover", callback: (includedServiceUuids: string[]) => void): void; - on(event: "characteristicsDiscover", callback: (characteristics: Characteristic[]) => void): void; + on(event: string, listener: Function): events.EventEmitter; + on(event: "includedServicesDiscover", listener: (includedServiceUuids: string[]) => void): events.EventEmitter; + on(event: "characteristicsDiscover", listener: (characteristics: Characteristic[]) => void): events.EventEmitter; } - export class Characteristic { + export class Characteristic extends events.EventEmitter { uuid: string; name: string; type: string; @@ -78,16 +80,16 @@ declare module "noble" { discoverDescriptors(callback: (error: string, descriptors: Descriptor[]) => void): void; toString(): string; - on(event: string, callback: Function): void; - on(event: string, option: boolean, callback: Function): void; - on(event: "read", callback: (data: NodeBuffer, isNotification: boolean) => void): void; - on(event: "write", withoutResponse: boolean, callback: (error: string) => void): void; - on(event: "broadcast", callback: (state: string) => void): void; - on(event: "notify", callback: (state: string) => void): void; - on(event: "descriptorsDiscover", callback: (descriptors: Descriptor[]) => void): void; + on(event: string, listener: Function): events.EventEmitter; + on(event: string, option: boolean, listener: Function): events.EventEmitter; + on(event: "read", listener: (data: NodeBuffer, isNotification: boolean) => void): events.EventEmitter; + on(event: "write", withoutResponse: boolean, listener: (error: string) => void): events.EventEmitter; + on(event: "broadcast", listener: (state: string) => void): events.EventEmitter; + on(event: "notify", listener: (state: string) => void): events.EventEmitter; + on(event: "descriptorsDiscover", listener: (descriptors: Descriptor[]) => void): events.EventEmitter; } - export class Descriptor { + export class Descriptor extends events.EventEmitter { uuid: string; name: string; type: string; @@ -96,9 +98,9 @@ declare module "noble" { writeValue(data: NodeBuffer, callback: (error: string) => void): void; toString(): string; - on(event: string, callback: Function): void; - on(event: "valueRead", callback: (error: string, data: NodeBuffer) => void): void; - on(event: "valueWrite", callback: (error: string) => void): void; + on(event: string, listener: Function): events.EventEmitter; + on(event: "valueRead", listener: (error: string, data: NodeBuffer) => void): events.EventEmitter; + on(event: "valueWrite", listener: (error: string) => void): events.EventEmitter; } } From 5b115418e10781bb8027913418dbc37129b5f15e Mon Sep 17 00:00:00 2001 From: Vladimir Kotikov Date: Mon, 28 Apr 2014 17:05:34 +0400 Subject: [PATCH 17/24] Cordova: multiple fixes * Rewrite ambiguous JSDoc comments if FileSystem.d.ts * Fixed typos & arguments order for ContactField constructor * Remove nonsense constructors in FileSystem.d.ts and Media.d.ts * Fixed typo in WebSQL.d.ts * Fixed repo hyperlink in WebSQL.d.ts --- cordova/plugins/Contacts.d.ts | 16 ++++++++-------- cordova/plugins/FileSystem.d.ts | 22 +++++----------------- cordova/plugins/Media.d.ts | 13 ------------- cordova/plugins/WebSQL.d.ts | 4 ++-- 4 files changed, 15 insertions(+), 40 deletions(-) diff --git a/cordova/plugins/Contacts.d.ts b/cordova/plugins/Contacts.d.ts index a6f7bc086..f054c12d0 100644 --- a/cordova/plugins/Contacts.d.ts +++ b/cordova/plugins/Contacts.d.ts @@ -143,9 +143,9 @@ interface ContactName { /** The contact's middle name. */ middleName?: string; /** The contact's prefix (example Mr. or Dr.) */ - honorifixPrefix?: string; + honorificPrefix?: string; /** The contact's suffix (example Esq.). */ - honorifixSuffix?: string; + honorificSuffix?: string; } declare var ContactName: { @@ -154,8 +154,8 @@ declare var ContactName: { familyName?: string, givenName?: string, middleName?: string, - honorifixPrefix?: string, - honorifixSuffix?: string): ContactName + honorificPrefix?: string, + honorificSuffix?: string): ContactName }; /** @@ -171,19 +171,19 @@ declare var ContactName: { * contains a base64-encoded image string. */ interface ContactField { - /** Set to true if this ContactField contains the user's preferred value. */ - pref: boolean; /** A string that indicates what type of field this is, home for example. */ type: string; /** The value of the field, such as a phone number or email address. */ value: string; + /** Set to true if this ContactField contains the user's preferred value. */ + pref: boolean; } declare var ContactField: { /** Constructor for ContactField object */ new(type?: string, - pref?: boolean, - value?: string): ContactField + value?: string, + pref?: boolean): ContactField }; /** diff --git a/cordova/plugins/FileSystem.d.ts b/cordova/plugins/FileSystem.d.ts index 4aefa5ecf..569f9a209 100644 --- a/cordova/plugins/FileSystem.d.ts +++ b/cordova/plugins/FileSystem.d.ts @@ -25,17 +25,7 @@ interface Window { /** This interface represents a file system. */ interface FileSystem { - /** - * Constructor for FileSystem object - * @param name This is the name of the file system. The specifics of naming filesystems - * is unspecified, but a name must be unique across the list of exposed file systems. - * @param root The root directory of the file system. - */ - new (name: string, root: DirectoryEntry) - /** - * This is the name of the file system. The specifics of naming filesystems - * is unspecified, but a name must be unique across the list of exposed file systems. - */ + /* The name of the file system, unique across the list of exposed file systems. */ name: string; /** The root directory of the file system. */ root: DirectoryEntry; @@ -46,8 +36,6 @@ interface FileSystem { * each of which may be a File or DirectoryEntry. */ interface Entry { - /** Constructor for Entry object */ - new ( isFile: boolean, isDirectory: boolean, name: string, fullPath: string, fileSystem: FileSystem, nativeURL: string) ; /** Entry is a file. */ isFile: boolean; /** Entry is a directory. */ @@ -265,13 +253,13 @@ interface FileSaver extends EventTarget { */ interface FileWriter extends FileSaver { /** - * The byte offset at which the next write to the file will occur. This must be no greater than length. - * A newly-created FileWriter must have position set to 0. + * The byte offset at which the next write to the file will occur. This always less or equal than length. + * A newly-created FileWriter will have position set to 0. */ position: number; /** * The length of the file. If the user does not have read access to the file, - * this must be the highest byte offset at which the user has written. + * this will be the highest byte offset at which the user has written. */ length: number; /** @@ -287,7 +275,7 @@ interface FileWriter extends FileSaver { seek(offset: number): void; /** * Changes the length of the file to that specified. If shortening the file, data beyond the new length - * must be discarded. If extending the file, the existing data must be zero-padded up to the new length. + * will be discarded. If extending the file, the existing data will be zero-padded up to the new length. * @param size The size to which the length of the file is to be adjusted, measured in bytes. */ truncate(size: number): void; diff --git a/cordova/plugins/Media.d.ts b/cordova/plugins/Media.d.ts index 3751152be..21d1a17e3 100644 --- a/cordova/plugins/Media.d.ts +++ b/cordova/plugins/Media.d.ts @@ -27,19 +27,6 @@ declare var Media: { * W3C specification and may deprecate the current APIs. */ interface Media { - /** - * Constructor for Media object. - * @param src A URI containing the audio content. - * @param mediaSuccess The callback that executes after a Media object has completed - * the current play, record, or stop action. - * @param mediaError The callback that executes if an error occurs. - * @param mediaStatus The callback that executes to indicate status changes. - */ - new ( - src: string, - mediaSuccess: () => void, - mediaError?: (error: MediaError) => any, - mediaStatus?: (status: number) => void): Media; /** * Returns the current position within an audio file. Also updates the Media object's position parameter. * @param mediaSuccess The callback that is passed the current position in seconds. diff --git a/cordova/plugins/WebSQL.d.ts b/cordova/plugins/WebSQL.d.ts index 807dab42a..8d28a69c8 100644 --- a/cordova/plugins/WebSQL.d.ts +++ b/cordova/plugins/WebSQL.d.ts @@ -1,5 +1,5 @@ // Type definitions for Apache Cordova WebSQL plugin. -// Project: https://github.com/sgrebnov/cordova-plugin-websql +// Project: https://github.com/MSOpenTech/cordova-plugin-websql // Definitions by: Microsoft Open Technologies, Inc. // Definitions: https://github.com/borisyankov/DefinitelyTyped // @@ -43,7 +43,7 @@ interface Database { successCallback?: () => void): void; name: string; version: string; - displayname: string; + displayName: string; size: number; } From 5bf0b7f456cb80c2f9dd3436e1b5c8c89e954652 Mon Sep 17 00:00:00 2001 From: Seon-Wook Park Date: Mon, 28 Apr 2014 17:08:47 +0200 Subject: [PATCH 18/24] noble: Remove vim comments --- noble/noble-tests.ts | 1 - noble/noble.d.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/noble/noble-tests.ts b/noble/noble-tests.ts index 3e7b4afaf..46851ab52 100644 --- a/noble/noble-tests.ts +++ b/noble/noble-tests.ts @@ -80,4 +80,3 @@ descriptor.writeValue(new Buffer(1), (error: string): void => {}); descriptor.on("valueRead", (error: string, data: NodeBuffer): void => {}); descriptor.on("valueWrite", (error: string): void => {}); -// vim expandtab shiftwidth=4 diff --git a/noble/noble.d.ts b/noble/noble.d.ts index 20259f0a7..f9c833bd1 100644 --- a/noble/noble.d.ts +++ b/noble/noble.d.ts @@ -104,4 +104,3 @@ declare module "noble" { } } -// vim expandtab shiftwidth=4 From 1d451a05e18067cfc61414685f70115cdab0dd97 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Sun, 6 Apr 2014 18:23:39 +0400 Subject: [PATCH 19/24] node: NodeBuffer -> Buffer. Mark NodeBuffer as deprecated --- buffer-equal/buffer-equal-tests.ts | 2 +- buffer-equal/buffer-equal.d.ts | 2 +- couchbase/couchbase.d.ts | 8 +- graceful-fs/graceful-fs-tests.ts | 2 +- gruntjs/gruntjs.d.ts | 10 +- node-ffi/node-ffi.d.ts | 180 ++++++++++++++--------------- node/node-0.8.8.d.ts | 80 ++++++------- node/node-tests.ts | 2 +- node/node.d.ts | 131 +++++++++++---------- q-io/Q-io-tests.ts | 8 +- q-io/Q-io.d.ts | 28 ++--- superagent/superagent.d.ts | 2 +- websocket/websocket.d.ts | 40 +++---- ws/ws.d.ts | 2 +- 14 files changed, 251 insertions(+), 246 deletions(-) diff --git a/buffer-equal/buffer-equal-tests.ts b/buffer-equal/buffer-equal-tests.ts index 743ed187e..192051ab4 100644 --- a/buffer-equal/buffer-equal-tests.ts +++ b/buffer-equal/buffer-equal-tests.ts @@ -3,6 +3,6 @@ import bufferEqual = require('buffer-equal'); var bool: boolean; -var buf: NodeBuffer; +var buf: Buffer; bool = bufferEqual(buf, buf); diff --git a/buffer-equal/buffer-equal.d.ts b/buffer-equal/buffer-equal.d.ts index bc8b1ce28..5f671662d 100644 --- a/buffer-equal/buffer-equal.d.ts +++ b/buffer-equal/buffer-equal.d.ts @@ -6,6 +6,6 @@ /// declare module 'buffer-equal' { - function bufferEqual(actual:NodeBuffer, expected:NodeBuffer): boolean; + function bufferEqual(actual:Buffer, expected:Buffer): boolean; export = bufferEqual; } diff --git a/couchbase/couchbase.d.ts b/couchbase/couchbase.d.ts index 2b0a720a9..3a8605b73 100644 --- a/couchbase/couchbase.d.ts +++ b/couchbase/couchbase.d.ts @@ -648,8 +648,8 @@ declare module 'couchbase' { append(key: string, fragment: string, callback: KeyCallback): void; append(key: string, fragment: string, options: AppendOptions, callback: KeyCallback): void; - append(key: string, fragment: NodeBuffer, callback: KeyCallback): void; - append(key: string, fragment: NodeBuffer, options: AppendOptions, callback: KeyCallback): void; + append(key: string, fragment: Buffer, callback: KeyCallback): void; + append(key: string, fragment: Buffer, options: AppendOptions, callback: KeyCallback): void; appendMulti(kv: { [key: string]: AppendMultiOptionsForValue }, options: AppendMultiOptions, callback: MultiCallback): void; decr(key: string, callback: KeyCallback): void; @@ -683,8 +683,8 @@ declare module 'couchbase' { prepend(key: string, fragment: string, callback: KeyCallback): void; prepend(key: string, fragment: string, options: PrependOptions, callback: KeyCallback): void; - prepend(key: string, fragment: NodeBuffer, callback: KeyCallback): void; - prepend(key: string, fragment: NodeBuffer, options: PrependOptions, callback: KeyCallback): void; + prepend(key: string, fragment: Buffer, callback: KeyCallback): void; + prepend(key: string, fragment: Buffer, options: PrependOptions, callback: KeyCallback): void; prependMulti(kv: { [key: string]: PrependMultiOptionsFoValue }, options: { [key: string]: PrependMultiOptions }, callback: MultiCallback): void; remove(key: string, callback: KeyCallback): void; diff --git a/graceful-fs/graceful-fs-tests.ts b/graceful-fs/graceful-fs-tests.ts index ca0a5e7b8..5c9bb19ae 100644 --- a/graceful-fs/graceful-fs-tests.ts +++ b/graceful-fs/graceful-fs-tests.ts @@ -3,6 +3,6 @@ import fs = require('graceful-fs'); var str: string; -var buf: NodeBuffer; +var buf: Buffer; fs.renameSync(str, str); \ No newline at end of file diff --git a/gruntjs/gruntjs.d.ts b/gruntjs/gruntjs.d.ts index 2bf0d91b4..86923c56e 100644 --- a/gruntjs/gruntjs.d.ts +++ b/gruntjs/gruntjs.d.ts @@ -336,7 +336,7 @@ declare module grunt { * whose return value will be used as the destination file's contents. If * this function returns `false`, the file copy will be aborted. */ - process?: (buffer: NodeBuffer) => boolean + process?: (buffer: Buffer) => boolean } /** @@ -370,21 +370,21 @@ declare module grunt { * Returns a string, unless options.encoding is null in which case it returns a Buffer. */ read(filepath: string): string - read(filepath: string, options: IFileEncodedOption): NodeBuffer + read(filepath: string, options: IFileEncodedOption): Buffer /** * Read a file's contents, parsing the data as JSON and returning the result. * @see FileModule.read for a list of supported options. */ readJSON(filepath: string): any - readJSON(filepath: string, options: IFileEncodedOption): NodeBuffer + readJSON(filepath: string, options: IFileEncodedOption): Buffer /** * Read a file's contents, parsing the data as YAML and returning the result. * @see FileModule.read for a list of supported options. */ readYAML(filepath: string): any - readYAML(filepath: string, options: IFileEncodedOption): NodeBuffer + readYAML(filepath: string, options: IFileEncodedOption): Buffer /** * Write the specified contents to a file, creating intermediate directories if necessary. @@ -394,7 +394,7 @@ declare module grunt { * @param options If an encoding is not specified, default to grunt.file.defaultEncoding. */ write(filepath: string, contents: string, options?: IFileEncodedOption): void - write(filepath: string, contents: NodeBuffer): void + write(filepath: string, contents: Buffer): void /** * Copy a source file to a destination path, creating intermediate directories if necessary. diff --git a/node-ffi/node-ffi.d.ts b/node-ffi/node-ffi.d.ts index 957cf5793..e5ee74621 100644 --- a/node-ffi/node-ffi.d.ts +++ b/node-ffi/node-ffi.d.ts @@ -38,13 +38,13 @@ declare module "ffi" { /** The type of arguments. */ argTypes: ref.Type[]; /** Is set for node-ffi functions. */ - ffi_type: NodeBuffer; + ffi_type: Buffer; abi: number; /** Get a `Callback` pointer of this function type. */ - toPointer(fn: (...args: any[]) => any): NodeBuffer; + toPointer(fn: (...args: any[]) => any): Buffer; /** Get a `ForeignFunction` of this function type. */ - toFunction(buf: NodeBuffer): ForeignFunction; + toFunction(buf: Buffer): ForeignFunction; } /** Creates and returns a type for a C function pointer. */ @@ -67,10 +67,10 @@ declare module "ffi" { * execution. */ export var ForeignFunction: { - new (ptr: NodeBuffer, retType: ref.Type, argTypes: any[], abi?: number): ForeignFunction; - new (ptr: NodeBuffer, retType: string, argTypes: any[], abi?: number): ForeignFunction; - (ptr: NodeBuffer, retType: ref.Type, argTypes: any[], abi?: number): ForeignFunction; - (ptr: NodeBuffer, retType: string, argTypes: any[], abi?: number): ForeignFunction; + new (ptr: Buffer, retType: ref.Type, argTypes: any[], abi?: number): ForeignFunction; + new (ptr: Buffer, retType: string, argTypes: any[], abi?: number): ForeignFunction; + (ptr: Buffer, retType: ref.Type, argTypes: any[], abi?: number): ForeignFunction; + (ptr: Buffer, retType: string, argTypes: any[], abi?: number): ForeignFunction; } export interface VariadicForeignFunction { @@ -96,17 +96,17 @@ declare module "ffi" { * contain the same ffi_type argument signature. */ export var VariadicForeignFunction: { - new (ptr: NodeBuffer, ret: ref.Type, fixedArgs: any[], abi?: number): VariadicForeignFunction; - new (ptr: NodeBuffer, ret: string, fixedArgs: any[], abi?: number): VariadicForeignFunction; - (ptr: NodeBuffer, ret: ref.Type, fixedArgs: any[], abi?: number): VariadicForeignFunction; - (ptr: NodeBuffer, ret: string, fixedArgs: any[], abi?: number): VariadicForeignFunction; + new (ptr: Buffer, ret: ref.Type, fixedArgs: any[], abi?: number): VariadicForeignFunction; + new (ptr: Buffer, ret: string, fixedArgs: any[], abi?: number): VariadicForeignFunction; + (ptr: Buffer, ret: ref.Type, fixedArgs: any[], abi?: number): VariadicForeignFunction; + (ptr: Buffer, ret: string, fixedArgs: any[], abi?: number): VariadicForeignFunction; }; export interface DynamicLibrary { /** Close library, returns the result of the `dlclose` system function. */ close(): number; /** Get a symbol from this library. */ - get(symbol: string): NodeBuffer; + get(symbol: string): Buffer; /** Get the result of the `dlerror` system function. */ error(): string; } @@ -126,8 +126,8 @@ declare module "ffi" { RTLD_GLOBAL: number; RTLD_NOLOAD: number; RTLD_NODELETE: number; - RTLD_NEXT: NodeBuffer; - RTLD_DEFAUL: NodeBuffer; + RTLD_NEXT: Buffer; + RTLD_DEFAUL: Buffer; } new (path?: string, mode?: number): DynamicLibrary; @@ -140,24 +140,24 @@ declare module "ffi" { * accept C callback functions. */ export var Callback: { - new (retType: any, argTypes: any[], abi: number, fn: any): NodeBuffer; - new (retType: any, argTypes: any[], fn: any): NodeBuffer; - (retType: any, argTypes: any[], abi: number, fn: any): NodeBuffer; - (retType: any, argTypes: any[], fn: any): NodeBuffer; + new (retType: any, argTypes: any[], abi: number, fn: any): Buffer; + new (retType: any, argTypes: any[], fn: any): Buffer; + (retType: any, argTypes: any[], abi: number, fn: any): Buffer; + (retType: any, argTypes: any[], fn: any): Buffer; } export var ffiType: { /** Get a `ffi_type *` Buffer appropriate for the given type. */ - (type: ref.Type): NodeBuffer + (type: ref.Type): Buffer /** Get a `ffi_type *` Buffer appropriate for the given type. */ - (type: string): NodeBuffer + (type: string): Buffer FFI_TYPE: StructType; } - export var CIF: (retType: any, types: any[], abi?: any) => NodeBuffer - export var CIF_var: (retType: any, types: any[], numFixedArgs: number, abi?: any) => NodeBuffer; + export var CIF: (retType: any, types: any[], abi?: any) => Buffer + export var CIF_var: (retType: any, types: any[], numFixedArgs: number, abi?: any) => Buffer; export var HAS_OBJC: boolean; - export var FFI_TYPES: {[key: string]: NodeBuffer}; + export var FFI_TYPES: {[key: string]: Buffer}; export var FFI_OK: number; export var FFI_BAD_TYPEDEF: number; export var FFI_BAD_ABI: number; @@ -172,8 +172,8 @@ declare module "ffi" { export var RTLD_GLOBAL: number; export var RTLD_NOLOAD: number; export var RTLD_NODELETE: number; - export var RTLD_NEXT: NodeBuffer; - export var RTLD_DEFAULT: NodeBuffer; + export var RTLD_NEXT: Buffer; + export var RTLD_DEFAULT: Buffer; export var LIB_EXT: string; export var FFI_TYPE: StructType; @@ -198,9 +198,9 @@ declare module "ref" { /** The current level of indirection of the buffer. */ indirection: number; /** To invoke when `ref.get` is invoked on a buffer of this type. */ - get(buffer: NodeBuffer, offset: number): any; + get(buffer: Buffer, offset: number): any; /** To invoke when `ref.set` is invoked on a buffer of this type. */ - set(buffer: NodeBuffer, offset: number, value: any): void; + set(buffer: Buffer, offset: number, value: any): void; /** The name to use during debugging for this datatype. */ name?: string; /** The alignment of this datatype when placed inside a struct. */ @@ -208,22 +208,22 @@ declare module "ref" { } /** A Buffer that references the C NULL pointer. */ - export var NULL: NodeBuffer; + export var NULL: Buffer; /** A pointer-sized buffer pointing to NULL. */ - export var NULL_POINTER: NodeBuffer; + export var NULL_POINTER: Buffer; /** Get the memory address of buffer. */ - export function address(buffer: NodeBuffer): number; + export function address(buffer: Buffer): number; /** Allocate the memory with the given value written to it. */ - export function alloc(type: Type, value?: any): NodeBuffer; + export function alloc(type: Type, value?: any): Buffer; /** Allocate the memory with the given value written to it. */ - export function alloc(type: string, value?: any): NodeBuffer; + export function alloc(type: string, value?: any): Buffer; /** * Allocate the memory with the given string written to it with the given * encoding (defaults to utf8). The buffer is 1 byte longer than the * string itself, and is NULL terminated. */ - export function allocCString(string: string, encoding?: string): NodeBuffer; + export function allocCString(string: string, encoding?: string): Buffer; /** Coerce a type.*/ export function coerceType(type: Type): Type; @@ -236,7 +236,7 @@ declare module "ref" { * if it's greater than 1 then it merely returns another Buffer, but with * one level less indirection. */ - export function deref(buffer: NodeBuffer): any; + export function deref(buffer: Buffer): any; /** Create clone of the type, with decremented indirection level by 1. */ export function derefType(type: Type): Type; @@ -245,51 +245,51 @@ declare module "ref" { /** Represents the native endianness of the processor ("LE" or "BE"). */ export var endianness: string; /** Check the indirection level and return a dereferenced when necessary. */ - export function get(buffer: NodeBuffer, offset?: number, type?: Type): any; + export function get(buffer: Buffer, offset?: number, type?: Type): any; /** Check the indirection level and return a dereferenced when necessary. */ - export function get(buffer: NodeBuffer, offset?: number, type?: string): any; + export function get(buffer: Buffer, offset?: number, type?: string): any; /** Get type of the buffer. Create a default type when none exists. */ - export function getType(buffer: NodeBuffer): Type; + export function getType(buffer: Buffer): Type; /** Check the NULL. */ - export function isNull(buffer: NodeBuffer): boolean; + export function isNull(buffer: Buffer): boolean; /** Read C string until the first NULL. */ - export function readCString(buffer: NodeBuffer, offset?: number): string; + export function readCString(buffer: Buffer, offset?: number): string; /** * Read a big-endian signed 64-bit int. * If there is losing precision, then return a string, otherwise a number. * @return {number|string} */ - export function readInt64BE(buffer: NodeBuffer, offset?: number): any; + export function readInt64BE(buffer: Buffer, offset?: number): any; /** * Read a little-endian signed 64-bit int. * If there is losing precision, then return a string, otherwise a number. * @return {number|string} */ - export function readInt64LE(buffer: NodeBuffer, offset?: number): any; + export function readInt64LE(buffer: Buffer, offset?: number): any; /** Read a JS Object that has previously been written. */ - export function readObject(buffer: NodeBuffer, offset?: number): Object; + export function readObject(buffer: Buffer, offset?: number): Object; /** Read data from the pointer. */ - export function readPointer(buffer: NodeBuffer, offset?: number, - length?: number): NodeBuffer; + export function readPointer(buffer: Buffer, offset?: number, + length?: number): Buffer; /** * Read a big-endian unsigned 64-bit int. * If there is losing precision, then return a string, otherwise a number. * @return {number|string} */ - export function readUInt64BE(buffer: NodeBuffer, offset?: number): any; + export function readUInt64BE(buffer: Buffer, offset?: number): any; /** * Read a little-endian unsigned 64-bit int. * If there is losing precision, then return a string, otherwise a number. * @return {number|string} */ - export function readUInt64LE(buffer: NodeBuffer, offset?: number): any; + export function readUInt64LE(buffer: Buffer, offset?: number): any; /** Create pointer to buffer. */ - export function ref(buffer: NodeBuffer): NodeBuffer; + export function ref(buffer: Buffer): Buffer; /** Create clone of the type, with incremented indirection level by 1. */ export function refType(type: Type): Type; /** Create clone of the type, with incremented indirection level by 1. */ @@ -300,66 +300,66 @@ declare module "ref" { * This function "attaches" source to the returned buffer to prevent it from * being garbage collected. */ - export function reinterpret(buffer: NodeBuffer, size: number, - offset?: number): NodeBuffer; + export function reinterpret(buffer: Buffer, size: number, + offset?: number): Buffer; /** * Scan past the boundary of the buffer's length until it finds size number * of aligned NULL bytes. */ - export function reinterpretUntilZeros(buffer: NodeBuffer, size: number, - offset?: number): NodeBuffer; + export function reinterpretUntilZeros(buffer: Buffer, size: number, + offset?: number): Buffer; /** Write pointer if the indirection is 1, otherwise write value. */ - export function set(buffer: NodeBuffer, offset: number, value: any, type?: Type): void; + export function set(buffer: Buffer, offset: number, value: any, type?: Type): void; /** Write pointer if the indirection is 1, otherwise write value. */ - export function set(buffer: NodeBuffer, offset: number, value: any, type?: string): void; + export function set(buffer: Buffer, offset: number, value: any, type?: string): void; /** Write the string as a NULL terminated. Default encoding is utf8. */ - export function writeCString(buffer: NodeBuffer, offset: number, + export function writeCString(buffer: Buffer, offset: number, string: string, encoding?: string): void; /** Write a big-endian signed 64-bit int. */ - export function writeInt64BE(buffer: NodeBuffer, offset: number, input: number): void; + export function writeInt64BE(buffer: Buffer, offset: number, input: number): void; /** Write a big-endian signed 64-bit int. */ - export function writeInt64BE(buffer: NodeBuffer, offset: number, input: string): void; + export function writeInt64BE(buffer: Buffer, offset: number, input: string): void; /** Write a little-endian signed 64-bit int. */ - export function writeInt64LE(buffer: NodeBuffer, offset: number, input: number): void; + export function writeInt64LE(buffer: Buffer, offset: number, input: number): void; /** Write a little-endian signed 64-bit int. */ - export function writeInt64LE(buffer: NodeBuffer, offset: number, input: string): void; + export function writeInt64LE(buffer: Buffer, offset: number, input: string): void; /** * Write the JS Object. This function "attaches" object to buffer to prevent * it from being garbage collected. */ - export function writeObject(buffer: NodeBuffer, offset: number, object: Object): void; + export function writeObject(buffer: Buffer, offset: number, object: Object): void; /** * Write the memory address of pointer to buffer at the specified offset. This * function "attaches" object to buffer to prevent it from being garbage collected. */ - export function writePointer(buffer: NodeBuffer, offset: number, - pointer: NodeBuffer): void; + export function writePointer(buffer: Buffer, offset: number, + pointer: Buffer): void; /** Write a little-endian unsigned 64-bit int. */ - export function writeUInt64BE(buffer: NodeBuffer, offset: number, input: number): void; + export function writeUInt64BE(buffer: Buffer, offset: number, input: number): void; /** Write a little-endian unsigned 64-bit int. */ - export function writeUInt64BE(buffer: NodeBuffer, offset: number, input: string): void; + export function writeUInt64BE(buffer: Buffer, offset: number, input: string): void; /** * Attach object to buffer such. * It prevents object from being garbage collected until buffer does. */ - export function _attach(buffer: NodeBuffer, object: Object): void; + export function _attach(buffer: Buffer, object: Object): void; /** Same as ref.reinterpret, except that this version does not attach buffer. */ - export function _reinterpret(buffer: NodeBuffer, size: number, - offset?: number): NodeBuffer; + export function _reinterpret(buffer: Buffer, size: number, + offset?: number): Buffer; /** Same as ref.reinterpretUntilZeros, except that this version does not attach buffer. */ - export function _reinterpretUntilZeros(buffer: NodeBuffer, size: number, - offset?: number): NodeBuffer; + export function _reinterpretUntilZeros(buffer: Buffer, size: number, + offset?: number): Buffer; /** Same as ref.writePointer, except that this version does not attach pointer. */ - export function _writePointer(buffer: NodeBuffer, offset: number, - pointer: NodeBuffer): void; + export function _writePointer(buffer: Buffer, offset: number, + pointer: Buffer): void; /** Same as ref.writeObject, except that this version does not attach object. */ - export function _writeObject(buffer: NodeBuffer, offset: number, object: Object): void; + export function _writeObject(buffer: Buffer, offset: number, object: Object): void; /** Default types. */ export var types: { @@ -375,7 +375,7 @@ declare module "ref" { }; } -interface NodeBuffer { +interface Buffer { /** Shorthand for `ref.address`. */ address(): number; /** Shorthand for `ref.deref`. */ @@ -397,11 +397,11 @@ interface NodeBuffer { /** Shorthand for `ref.readUInt64LE`. */ readUInt64LE(offset?: number): string; /** Shorthand for `ref.ref`. */ - ref(): NodeBuffer; + ref(): Buffer; /** Shorthand for `ref.reinterpret`. */ - reinterpret(size: number, offset?: number): NodeBuffer; + reinterpret(size: number, offset?: number): Buffer; /** Shorthand for `ref.reinterpretUntilZeros`. */ - reinterpretUntilZeros(size: number, offset?: number): NodeBuffer; + reinterpretUntilZeros(size: number, offset?: number): Buffer; /** Shorthand for `ref.writeCString`. */ writeCString(offset: number, string: string, encoding?: string): void; /** Shorthand for `ref.writeInt64BE`. */ @@ -415,7 +415,7 @@ interface NodeBuffer { /** Shorthand for `ref.writeObject`. */ writeObject(offset: number, object: Object): void; /** Shorthand for `ref.writePointer`. */ - writePointer(offset: number, pointer: NodeBuffer): void; + writePointer(offset: number, pointer: Buffer): void; /** Shorthand for `ref.writeUInt64BE`. */ writeUInt64BE(offset: number, input: number): any; /** Shorthand for `ref.writeUInt64BE`. */ @@ -447,21 +447,21 @@ declare module "ref-array" { * for the ArrayType. The "length" of the Array is determined by searching * through the buffer's contents until an aligned NULL pointer is encountered. */ - untilZeros(buffer: NodeBuffer): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + untilZeros(buffer: Buffer): { [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; new (length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; new (data: number[], length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; - new (data: NodeBuffer, length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; + new (data: Buffer, length?: number): { [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; (length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; (data: number[], length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; - (data: NodeBuffer, length?: number): { [i: number]: T; length: number; toArray(): T[]; - toJSON(): T[]; inspect(): string; buffer: NodeBuffer; ref(): NodeBuffer; }; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; + (data: Buffer, length?: number): { [i: number]: T; length: number; toArray(): T[]; + toJSON(): T[]; inspect(): string; buffer: Buffer; ref(): Buffer; }; } /** @@ -494,10 +494,10 @@ declare module "ref-struct" { */ interface StructType extends ref.Type { /** Pass it an existing Buffer instance to use that as the backing buffer. */ - new (arg: NodeBuffer, data?: {}): any; + new (arg: Buffer, data?: {}): any; new (data?: {}): any; /** Pass it an existing Buffer instance to use that as the backing buffer. */ - (arg: NodeBuffer, data?: {}): any; + (arg: Buffer, data?: {}): any; (data?: {}): any; fields: {[key: string]: {type: ref.Type}}; @@ -551,10 +551,10 @@ declare module "ref-union" { */ interface UnionType extends ref.Type { /** Pass it an existing Buffer instance to use that as the backing buffer. */ - new (arg: NodeBuffer, data?: {}): any; + new (arg: Buffer, data?: {}): any; new (data?: {}): any; /** Pass it an existing Buffer instance to use that as the backing buffer. */ - (arg: NodeBuffer, data?: {}): any; + (arg: Buffer, data?: {}): any; (data?: {}): any; fields: {[key: string]: {type: ref.Type}}; diff --git a/node/node-0.8.8.d.ts b/node/node-0.8.8.d.ts index 39f02a53a..7a1abbae3 100644 --- a/node/node-0.8.8.d.ts +++ b/node/node-0.8.8.d.ts @@ -44,22 +44,22 @@ declare var module: { // Same as module.exports declare var exports: any; declare var SlowBuffer: { - new (str: string, encoding?: string): NodeBuffer; - new (size: number): NodeBuffer; - new (array: any[]): NodeBuffer; - prototype: NodeBuffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; - concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; + concat(list: Buffer[], totalLength?: number): Buffer; }; declare var Buffer: { - new (str: string, encoding?: string): NodeBuffer; - new (size: number): NodeBuffer; - new (array: any[]): NodeBuffer; - prototype: NodeBuffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; - concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; + concat(list: Buffer[], totalLength?: number): Buffer; } /************************************************ @@ -82,10 +82,10 @@ interface EventEmitter { interface WritableStream extends EventEmitter { writable: boolean; write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; end(): void; end(str: string, enconding: string): void; - end(buffer: NodeBuffer): void; + end(buffer: Buffer): void; destroy(): void; destroySoon(): void; } @@ -155,13 +155,13 @@ interface NodeProcess extends EventEmitter { } // Buffer class -interface NodeBuffer { +interface Buffer { [index: number]: number; write(string: string, offset?: number, length?: number, encoding?: string): number; toString(encoding?: string, start?: number, end?: number): string; length: number; - copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): NodeBuffer; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; readUInt8(offset: number, noAsset?: boolean): number; readUInt16LE(offset: number, noAssert?: boolean): number; readUInt16BE(offset: number, noAssert?: boolean): number; @@ -247,7 +247,7 @@ declare module "http" { export interface ServerResponse extends events.NodeEventEmitter, stream.WritableStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; writeContinue(): void; writeHead(statusCode: number, reasonPhrase?: string, headers?: any): void; @@ -264,7 +264,7 @@ declare module "http" { export interface ClientRequest extends events.NodeEventEmitter, stream.WritableStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; write(chunk: any, encoding?: string): void; end(data?: any, encoding?: string): void; @@ -349,13 +349,13 @@ declare module "zlib" { export function createInflateRaw(options: ZlibOptions): InflateRaw; export function createUnzip(options: ZlibOptions): Unzip; - export function deflate(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function deflateRaw(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function gzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function gunzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function inflate(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function inflateRaw(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; - export function unzip(buf: NodeBuffer, callback: (error: Error, result) =>void ): void; + export function deflate(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function deflateRaw(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function gzip(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function gunzip(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function inflate(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function inflateRaw(buf: Buffer, callback: (error: Error, result) =>void ): void; + export function unzip(buf: Buffer, callback: (error: Error, result) =>void ): void; // Constants export var Z_NO_FLUSH: number; @@ -556,8 +556,8 @@ declare module "child_process" { timeout?: number; maxBuffer?: number; killSignal?: string; - }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; - export function exec(command: string, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function exec(command: string, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function execFile(file: string, args: string[], options: { cwd?: string; stdio?: any; @@ -567,7 +567,7 @@ declare module "child_process" { timeout?: number; maxBuffer?: string; killSignal?: string; - }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function fork(modulePath: string, args?: string[], options?: { cwd?: string; env?: any; @@ -615,7 +615,7 @@ declare module "net" { export interface NodeSocket extends stream.ReadWriteStream { // Extended base methods write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; connect(port: number, host?: string, connectionListener?: Function): void; connect(path: string, connectionListener?: Function): void; @@ -668,7 +668,7 @@ declare module "dgram" { export function createSocket(type: string, callback?: Function): Socket; interface Socket extends events.NodeEventEmitter { - send(buf: NodeBuffer, offset: number, length: number, port: number, address: string, callback?: Function): void; + send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: Function): void; bind(port: number, address?: string): void; close(): void; address: { address: string; family: string; port: number; }; @@ -761,13 +761,13 @@ declare module "fs" { export function futimesSync(fd: string, atime: number, mtime: number): void; export function fsync(fd: string, callback?: Function): void; export function fsyncSync(fd: string): void; - export function write(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: NodeBuffer) =>any): void; - export function writeSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): void; - export function read(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: NodeBuffer) => void): void; - export function readSync(fd: string, buffer: NodeBuffer, offset: number, length: number, position: number): any[]; + export function write(fd: string, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: Error, written: number, buffer: Buffer) =>any): void; + export function writeSync(fd: string, buffer: Buffer, offset: number, length: number, position: number): void; + export function read(fd: string, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: Error, bytesRead: number, buffer: Buffer) => void): void; + export function readSync(fd: string, buffer: Buffer, offset: number, length: number, position: number): any[]; export function readFile(filename: string, encoding: string, callback: (err: Error, data: string) => void ): void; - export function readFile(filename: string, callback: (err: Error, data: NodeBuffer) => void ): void; - export function readFileSync(filename: string): NodeBuffer; + export function readFile(filename: string, callback: (err: Error, data: Buffer) => void ): void; + export function readFileSync(filename: string): Buffer; export function readFileSync(filename: string, encoding: string): string; export function writeFile(filename: string, data: any, callback?: (err) => void): void; export function writeFile(filename: string, data: any, encoding?: string, callback?: (err) => void): void; @@ -811,8 +811,8 @@ declare module "path" { declare module "string_decoder" { export interface NodeStringDecoder { - write(buffer: NodeBuffer): string; - detectIncompleteChar(buffer: NodeBuffer): number; + write(buffer: Buffer): string; + detectIncompleteChar(buffer: Buffer): number; } export var StringDecoder: { new (encoding: string): NodeStringDecoder; @@ -963,7 +963,7 @@ declare module "crypto" { } export function getDiffieHellman(group_name: string): DiffieHellman; export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; - export function randomBytes(size: number, callback?: (err: Error, buf: NodeBuffer) =>void ); + export function randomBytes(size: number, callback?: (err: Error, buf: Buffer) =>void ); } declare module "stream" { @@ -972,10 +972,10 @@ declare module "stream" { export interface WritableStream extends events.NodeEventEmitter { writable: boolean; write(str: string, encoding?: string, fd?: string): boolean; - write(buffer: NodeBuffer): boolean; + write(buffer: Buffer): boolean; end(): void; end(str: string, enconding: string): void; - end(buffer: NodeBuffer): void; + end(buffer: Buffer): void; destroy(): void; destroySoon(): void; } diff --git a/node/node-tests.ts b/node/node-tests.ts index a77a4b39b..5598bac17 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -39,7 +39,7 @@ fs.writeFile("Harry Potter", assert.ifError); var content: string, - buffer: NodeBuffer; + buffer: Buffer; content = fs.readFileSync('testfile', 'utf8'); content = fs.readFileSync('testfile', {encoding : 'utf8'}); diff --git a/node/node.d.ts b/node/node.d.ts index 34862f4b7..beeb3775a 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -47,22 +47,22 @@ declare var module: { // Same as module.exports declare var exports: any; declare var SlowBuffer: { - new (str: string, encoding?: string): NodeBuffer; - new (size: number): NodeBuffer; - new (array: any[]): NodeBuffer; - prototype: NodeBuffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; - concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; + concat(list: Buffer[], totalLength?: number): Buffer; }; declare var Buffer: { - new (str: string, encoding?: string): NodeBuffer; - new (size: number): NodeBuffer; - new (array: any[]): NodeBuffer; - prototype: NodeBuffer; + new (str: string, encoding?: string): Buffer; + new (size: number): Buffer; + new (array: any[]): Buffer; + prototype: Buffer; isBuffer(obj: any): boolean; byteLength(string: string, encoding?: string): number; - concat(list: NodeBuffer[], totalLength?: number): NodeBuffer; + concat(list: Buffer[], totalLength?: number): Buffer; } /************************************************ @@ -98,17 +98,17 @@ interface ReadableStream extends NodeEventEmitter { pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: string): void; - unshift(chunk: NodeBuffer): void; + unshift(chunk: Buffer): void; wrap(oldStream: ReadableStream): ReadableStream; } interface WritableStream extends NodeEventEmitter { writable: boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } @@ -175,14 +175,16 @@ interface NodeProcess extends NodeEventEmitter { send?(message: any, sendHandle?: any): void; } -// Buffer class +/** + * @deprecated + */ interface NodeBuffer { [index: number]: number; write(string: string, offset?: number, length?: number, encoding?: string): number; toString(encoding?: string, start?: number, end?: number): string; length: number; - copy(targetBuffer: NodeBuffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; - slice(start?: number, end?: number): NodeBuffer; + copy(targetBuffer: Buffer, targetStart?: number, sourceStart?: number, sourceEnd?: number): number; + slice(start?: number, end?: number): Buffer; readUInt8(offset: number, noAsset?: boolean): number; readUInt16LE(offset: number, noAssert?: boolean): number; readUInt16BE(offset: number, noAssert?: boolean): number; @@ -214,6 +216,9 @@ interface NodeBuffer { fill(value: any, offset?: number, end?: number): void; } +// Buffer class +interface Buffer extends NodeBuffer {} + interface NodeTimer { ref() : void; unref() : void; @@ -272,8 +277,8 @@ declare module "http" { } export interface ServerResponse extends NodeEventEmitter, WritableStream { // Extended base methods - write(buffer: NodeBuffer): boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; @@ -291,15 +296,15 @@ declare module "http" { // Extended base methods end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } export interface ClientRequest extends NodeEventEmitter, WritableStream { // Extended base methods - write(buffer: NodeBuffer): boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; @@ -312,7 +317,7 @@ declare module "http" { // Extended base methods end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; @@ -396,13 +401,13 @@ declare module "zlib" { export function createInflateRaw(options?: ZlibOptions): InflateRaw; export function createUnzip(options?: ZlibOptions): Unzip; - export function deflate(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function deflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function gzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function gunzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function inflate(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function inflateRaw(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; - export function unzip(buf: NodeBuffer, callback: (error: Error, result: any) =>void ): void; + export function deflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function deflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function gzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function gunzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function inflate(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function inflateRaw(buf: Buffer, callback: (error: Error, result: any) =>void ): void; + export function unzip(buf: Buffer, callback: (error: Error, result: any) =>void ): void; // Constants export var Z_NO_FLUSH: number; @@ -603,8 +608,8 @@ declare module "child_process" { timeout?: number; maxBuffer?: number; killSignal?: string; - }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; - export function exec(command: string, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; + export function exec(command: string, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function execFile(file: string, args: string[], options: { cwd?: string; stdio?: any; @@ -614,7 +619,7 @@ declare module "child_process" { timeout?: number; maxBuffer?: string; killSignal?: string; - }, callback: (error: Error, stdout: NodeBuffer, stderr: NodeBuffer) =>void ): ChildProcess; + }, callback: (error: Error, stdout: Buffer, stderr: Buffer) =>void ): ChildProcess; export function fork(modulePath: string, args?: string[], options?: { cwd?: string; env?: any; @@ -676,8 +681,8 @@ declare module "net" { export interface Socket extends ReadWriteStream { // Extended base methods - write(buffer: NodeBuffer): boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; write(str: string, encoding?: string, fd?: string): boolean; @@ -701,7 +706,7 @@ declare module "net" { // Extended base methods end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; @@ -739,7 +744,7 @@ declare module "dgram" { export function createSocket(type: string, callback?: Function): Socket; interface Socket extends NodeEventEmitter { - send(buf: NodeBuffer, offset: number, length: number, port: number, address: string, callback?: Function): void; + send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: Function): void; bind(port: number, address?: string): void; close(): void; address: { address: string; family: string; port: number; }; @@ -849,17 +854,17 @@ declare module "fs" { export function futimesSync(fd: number, atime: number, mtime: number): void; export function fsync(fd: number, callback?: (err?: ErrnoException) => void): void; export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, written: number, buffer: NodeBuffer) => void): void; - export function writeSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, bytesRead: number, buffer: NodeBuffer) => void): void; - export function readSync(fd: number, buffer: NodeBuffer, offset: number, length: number, position: number): number; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, written: number, buffer: Buffer) => void): void; + export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; export function readFile(filename: string, encoding: string, callback: (err: ErrnoException, data: string) => void): void; export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: ErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { flag?: string; }, callback: (err: ErrnoException, data: NodeBuffer) => void): void; - export function readFile(filename: string, callback: (err: ErrnoException, data: NodeBuffer) => void ): void; + export function readFile(filename: string, options: { flag?: string; }, callback: (err: ErrnoException, data: Buffer) => void): void; + export function readFile(filename: string, callback: (err: ErrnoException, data: Buffer) => void ): void; export function readFileSync(filename: string, encoding: string): string; export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; - export function readFileSync(filename: string, options?: { flag?: string; }): NodeBuffer; + export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; export function writeFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void; export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void; @@ -911,8 +916,8 @@ declare module "path" { declare module "string_decoder" { export interface NodeStringDecoder { - write(buffer: NodeBuffer): string; - detectIncompleteChar(buffer: NodeBuffer): number; + write(buffer: Buffer): string; + detectIncompleteChar(buffer: Buffer): number; } export var StringDecoder: { new (encoding: string): NodeStringDecoder; @@ -1031,9 +1036,9 @@ declare module "crypto" { update(data: any, input_encoding?: string, output_encoding?: string): string; final(output_encoding?: string): string; setAutoPadding(auto_padding: boolean): void; + createDecipher(algorithm: string, password: any): Decipher; + createDecipheriv(algorithm: string, key: any, iv: any): Decipher; } - export function createDecipher(algorithm: string, password: any): Decipher; - export function createDecipheriv(algorithm: string, key: any, iv: any): Decipher; interface Decipher { update(data: any, input_encoding?: string, output_encoding?: string): void; final(output_encoding?: string): string; @@ -1063,11 +1068,11 @@ declare module "crypto" { } export function getDiffieHellman(group_name: string): DiffieHellman; export function pbkdf2(password: string, salt: string, iterations: number, keylen: number, callback: (err: Error, derivedKey: string) => any): void; - export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : NodeBuffer; - export function randomBytes(size: number): NodeBuffer; - export function randomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void; - export function pseudoRandomBytes(size: number): NodeBuffer; - export function pseudoRandomBytes(size: number, callback: (err: Error, buf: NodeBuffer) =>void ): void; + export function pbkdf2Sync(password: string, salt: string, iterations: number, keylen: number) : Buffer; + export function randomBytes(size: number): Buffer; + export function randomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; + export function pseudoRandomBytes(size: number): Buffer; + export function pseudoRandomBytes(size: number, callback: (err: Error, buf: Buffer) =>void ): void; } declare module "stream" { @@ -1090,7 +1095,7 @@ declare module "stream" { pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: string): void; - unshift(chunk: NodeBuffer): void; + unshift(chunk: Buffer): void; wrap(oldStream: ReadableStream): ReadableStream; push(chunk: any, encoding?: string): boolean; } @@ -1103,13 +1108,13 @@ declare module "stream" { export class Writable extends events.EventEmitter implements WritableStream { writable: boolean; constructor(opts?: WritableOptions); - _write(data: NodeBuffer, encoding: string, callback: Function): void; + _write(data: Buffer, encoding: string, callback: Function): void; _write(data: string, encoding: string, callback: Function): void; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } @@ -1122,13 +1127,13 @@ declare module "stream" { export class Duplex extends Readable implements ReadWriteStream { writable: boolean; constructor(opts?: DuplexOptions); - _write(data: NodeBuffer, encoding: string, callback: Function): void; + _write(data: Buffer, encoding: string, callback: Function): void; _write(data: string, encoding: string, callback: Function): void; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } @@ -1140,7 +1145,7 @@ declare module "stream" { readable: boolean; writable: boolean; constructor(opts?: TransformOptions); - _transform(chunk: NodeBuffer, encoding: string, callback: Function): void; + _transform(chunk: Buffer, encoding: string, callback: Function): void; _transform(chunk: string, encoding: string, callback: Function): void; _flush(callback: Function): void; read(size?: number): any; @@ -1150,14 +1155,14 @@ declare module "stream" { pipe(destination: T, options?: { end?: boolean; }): T; unpipe(destination?: T): void; unshift(chunk: string): void; - unshift(chunk: NodeBuffer): void; + unshift(chunk: Buffer): void; wrap(oldStream: ReadableStream): ReadableStream; push(chunk: any, encoding?: string): boolean; - write(buffer: NodeBuffer, cb?: Function): boolean; + write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; write(str: string, encoding?: string, cb?: Function): boolean; end(): void; - end(buffer: NodeBuffer, cb?: Function): void; + end(buffer: Buffer, cb?: Function): void; end(str: string, cb?: Function): void; end(str: string, encoding?: string, cb?: Function): void; } diff --git a/q-io/Q-io-tests.ts b/q-io/Q-io-tests.ts index f4ac32e9e..21b896988 100644 --- a/q-io/Q-io-tests.ts +++ b/q-io/Q-io-tests.ts @@ -8,7 +8,7 @@ var bool:boolean; var num:number; var x:any; var path:string; -var buffer:NodeBuffer; +var buffer:Buffer; var str:string; var strArr:string[]; var source:string; @@ -22,7 +22,7 @@ var anyQ:Q.Promise; var strQ:Q.Promise; var boolQ:Q.Promise; var dateQ:Q.Promise; -var bufferQ:Q.Promise; +var bufferQ:Q.Promise; var statsQ:Q.Promise; var readQ:Q.Promise; @@ -39,12 +39,12 @@ fs.open(path, options).then((x) => { }); //fs.open(path, options):Q.Promise; //fs.open(path, options):Q.Promise; -//fs.open(path, options):Q.Promise; +//fs.open(path, options):Q.Promise; //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; +//fs.read(path, options):Q.Promise; voidQ = fs.write(path, buffer, options); voidQ = fs.write(path, str, options); diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts index cbe37214e..f9d1c10d1 100644 --- a/q-io/Q-io.d.ts +++ b/q-io/Q-io.d.ts @@ -18,17 +18,17 @@ declare module QioFS { export function open(path:string, options?:any):Q.Promise; //export function open(path:string, options?:any):Q.Promise; //export function open(path:string, options?:any):Q.Promise; - //export function open(path:string, options?:any):Q.Promise; + //export function open(path:string, options?:any):Q.Promise; //TODO how to define the multiple return types? use any for now? export function read(path:string, options?:any):Q.Promise; //export function read(path:string, options?:any):Q.Promise; - //export function read(path:string, options?:any):Q.Promise; + //export function read(path:string, options?:any):Q.Promise; - export function write(path:string, content:NodeBuffer, options?:any):Q.Promise; + export function write(path:string, content:Buffer, options?:any):Q.Promise; export function write(path:string, content:string, options?:any):Q.Promise; - export function append(path:string, content:NodeBuffer, options?:any):Q.Promise; + export function append(path:string, content:Buffer, options?:any):Q.Promise; export function append(path:string, content:string, options?:any):Q.Promise; export function copy(source:string, target:string):Q.Promise; @@ -102,7 +102,7 @@ declare module QioFS { //this should return a q-io/fs-mock MockFS export function reroot(path:string):typeof QioFS; - export function toObject(path:string):{[path:string]:NodeBuffer}; + export function toObject(path:string):{[path:string]:Buffer}; //listed but not implemented by Q-io //export function glob(pattern):Q.Promise; @@ -189,7 +189,7 @@ declare module QioHTTP { declare module Qio { interface ForEachCallback { - (chunk:NodeBuffer):Q.Promise; + (chunk:Buffer):Q.Promise; (chunk:string):Q.Promise; } interface ForEach { @@ -198,13 +198,13 @@ declare module Qio { interface Reader extends ForEach { read(charset:string):Q.Promise; - read():Q.Promise; + read():Q.Promise; close():void; node:ReadableStream; } interface Writer { write(content:string):void; - write(content:NodeBuffer):void; + write(content:Buffer):void; flush():Q.Promise; close():void; destroy():void; @@ -213,9 +213,9 @@ declare module Qio { interface Stream { read(charset:string):Q.Promise; - read():Q.Promise; + read():Q.Promise; write(content:string):void; - write(content:NodeBuffer):void; + write(content:Buffer):void; flush():Q.Promise; close():void; destroy():void; @@ -229,15 +229,15 @@ declare module Qio { interface QioBufferReader { new ():Qio.Reader; read(stream:Qio.Reader, charset:string):string; - read(stream:Qio.Reader):NodeBuffer; - join(buffers:NodeBuffer[]):NodeBuffer; + read(stream:Qio.Reader):Buffer; + join(buffers:Buffer[]):Buffer; } interface QioBufferWriter { - (writer:NodeBuffer):Qio.Writer; + (writer:Buffer):Qio.Writer; Writer:Qio.Writer; } interface QioBufferStream { - (buffer:NodeBuffer, encoding:string):Qio.Stream + (buffer:Buffer, encoding:string):Qio.Stream } declare module "q-io/http" { diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index 860f70ea3..f416dee81 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -43,7 +43,7 @@ declare module "superagent" { send(data: string): Request; send(data: Object): Request; write(data: string, encoding: string): boolean; - write(data: NodeBuffer, encoding: string): boolean; + write(data: Buffer, encoding: string): boolean; pipe(stream: WritableStream, options?: Object): WritableStream; buffer(val: boolean): Request; timeout(ms: number): Request; diff --git a/websocket/websocket.d.ts b/websocket/websocket.d.ts index cc22b89ea..d984e1bea 100644 --- a/websocket/websocket.d.ts +++ b/websocket/websocket.d.ts @@ -128,11 +128,11 @@ declare module "websocket" { constructor(serverConfig?: IServerConfig); /** Send binary message for each connection */ - broadcast(data: NodeBuffer): void; + broadcast(data: Buffer): void; /** Send UTF-8 message for each connection */ broadcast(data: IStringified): void; /** Send binary message for each connection */ - broadcastBytes(data: NodeBuffer): void; + broadcastBytes(data: Buffer): void; /** Send UTF-8 message for each connection */ broadcastUTF(data: IStringified): void; /** Attach the `server` instance to a Node http.Server instance */ @@ -251,26 +251,26 @@ declare module "websocket" { export interface IMessage { type: string; utf8Data?: string; - binaryData?: NodeBuffer; + binaryData?: Buffer; } export interface IBufferList extends events.EventEmitter { encoding: string; length: number; - write(buf: NodeBuffer): boolean; - end(buf: NodeBuffer): void; + write(buf: Buffer): boolean; + end(buf: Buffer): void; /** * For each buffer, perform some action. * If fn's result is a true value, cut out early. */ - forEach(fn: (buf: NodeBuffer) => boolean): void; + forEach(fn: (buf: Buffer) => boolean): void; /** Create a single buffer out of all the chunks */ - join(start: number, end: number): NodeBuffer; + join(start: number, end: number): Buffer; /** Join all the chunks to existing buffer */ - joinInto(buf: NodeBuffer, offset: number, start: number, end: number): NodeBuffer; + joinInto(buf: Buffer, offset: number, start: number, end: number): Buffer; /** * Advance the buffer stream by `n` bytes. @@ -290,10 +290,10 @@ declare module "websocket" { // Events on(event: string, listener: () => void): IBufferList; on(event: 'advance', cb: (n: number) => void): IBufferList; - on(event: 'write', cb: (buf: NodeBuffer) => void): IBufferList; + on(event: 'write', cb: (buf: Buffer) => void): IBufferList; addListener(event: string, listener: () => void): IBufferList; addListener(event: 'advance', cb: (n: number) => void): IBufferList; - addListener(event: 'write', cb: (buf: NodeBuffer) => void): IBufferList; + addListener(event: 'write', cb: (buf: Buffer) => void): IBufferList; } class connection extends events.EventEmitter { @@ -330,8 +330,8 @@ declare module "websocket" { config: IConfig; socket: net.Socket; maskOutgoingPackets: boolean; - maskBytes: NodeBuffer; - frameHeader: NodeBuffer; + maskBytes: Buffer; + frameHeader: Buffer; bufferList: IBufferList; currentFrame: frame; fragmentationSize: number; @@ -390,14 +390,14 @@ declare module "websocket" { * to the remote peer. If config.fragmentOutgoingMessages is true the message may be * sent as multiple fragments if it exceeds config.fragmentationThreshold bytes. */ - sendBytes(buffer: NodeBuffer): void; + sendBytes(buffer: Buffer): void; /** Auto-detect the data type and send UTF-8 or Binary message */ - send(data: NodeBuffer): void; + send(data: Buffer): void; send(data: IStringified): void; /** Sends a ping frame. Ping frames must not exceed 125 bytes in length. */ - ping(data: NodeBuffer): void; + ping(data: Buffer): void; ping(data: IStringified): void; /** @@ -408,7 +408,7 @@ declare module "websocket" { * be no need to use this method to respond to pings. * Pong frames must not exceed 125 bytes in length. */ - pong(buffer: NodeBuffer): void; + pong(buffer: Buffer): void; /** * Serializes a `frame` object into binary data and immediately sends it to @@ -494,10 +494,10 @@ declare module "websocket" { * The binary payload data. * Even text frames are sent with a Buffer providing the binary payload data. */ - binaryPayload: NodeBuffer; + binaryPayload: Buffer; - maskBytes: NodeBuffer; - frameHeader: NodeBuffer; + maskBytes: Buffer; + frameHeader: Buffer; config: IConfig; maxReceivedFrameSize: number; protocolError: boolean; @@ -507,7 +507,7 @@ declare module "websocket" { addData(bufferList: IBufferList): boolean; throwAwayPayload(bufferList: IBufferList): boolean; - toBuffer(nullMask: boolean): NodeBuffer; + toBuffer(nullMask: boolean): Buffer; } export interface IClientConfig extends IConfig { diff --git a/ws/ws.d.ts b/ws/ws.d.ts index 2a3dbae40..5e5393ea5 100644 --- a/ws/ws.d.ts +++ b/ws/ws.d.ts @@ -110,7 +110,7 @@ declare module "ws" { close(): void; handleUpgrade(request: http.ClientRequest, socket: net.Socket, - upgradeHead: NodeBuffer, callback: (client: WebSocket) => void): void; + upgradeHead: Buffer, callback: (client: WebSocket) => void): void; // Events on(event: string, listener: () => void): Server; From c40cc2df8905af0ede9acbeea46e7d580a2eb4ea Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Mon, 7 Apr 2014 18:35:06 +0400 Subject: [PATCH 20/24] node: rename ErrnoException to NodeErrnoException --- node/node.d.ts | 96 +++++++++++++++++++++++++------------------------- 1 file changed, 48 insertions(+), 48 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index beeb3775a..6be669a01 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -71,7 +71,7 @@ declare var Buffer: { * * ************************************************/ -interface ErrnoException extends Error { +interface NodeErrnoException extends Error { errno?: any; code?: string; path?: string; @@ -789,90 +789,90 @@ declare module "fs" { export interface ReadStream extends ReadableStream { } export interface WriteStream extends WritableStream { } - export function rename(oldPath: string, newPath: string, callback?: (err?: ErrnoException) => void): void; + export function rename(oldPath: string, newPath: string, callback?: (err?: NodeErrnoException) => void): void; export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string, callback?: (err?: ErrnoException) => void): void; - export function truncate(path: string, len: number, callback?: (err?: ErrnoException) => void): void; + export function truncate(path: string, callback?: (err?: NodeErrnoException) => void): void; + export function truncate(path: string, len: number, callback?: (err?: NodeErrnoException) => void): void; export function truncateSync(path: string, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: ErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: ErrnoException) => void): void; + export function ftruncate(fd: number, callback?: (err?: NodeErrnoException) => void): void; + export function ftruncate(fd: number, len: number, callback?: (err?: NodeErrnoException) => void): void; export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; export function chownSync(path: string, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string, uid: number, gid: number, callback?: (err?: ErrnoException) => void): void; + export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; export function lchownSync(path: string, uid: number, gid: number): void; - export function chmod(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; - export function chmod(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function chmod(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; + export function chmod(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; export function chmodSync(path: string, mode: number): void; export function chmodSync(path: string, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: ErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: ErrnoException) => void): void; + export function fchmod(fd: number, mode: number, callback?: (err?: NodeErrnoException) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err?: NodeErrnoException) => void): void; export function fchmodSync(fd: number, mode: number): void; export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; - export function lchmod(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function lchmod(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; + export function lchmod(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; export function lchmodSync(path: string, mode: number): void; export function lchmodSync(path: string, mode: string): void; - export function stat(path: string, callback?: (err: ErrnoException, stats: Stats) => any): void; - export function lstat(path: string, callback?: (err: ErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: ErrnoException, stats: Stats) => any): void; + export function stat(path: string, callback?: (err: NodeErrnoException, stats: Stats) => any): void; + export function lstat(path: string, callback?: (err: NodeErrnoException, stats: Stats) => any): void; + export function fstat(fd: number, callback?: (err: NodeErrnoException, stats: Stats) => any): void; export function statSync(path: string): Stats; export function lstatSync(path: string): Stats; export function fstatSync(fd: number): Stats; - export function link(srcpath: string, dstpath: string, callback?: (err?: ErrnoException) => void): void; + export function link(srcpath: string, dstpath: string, callback?: (err?: NodeErrnoException) => void): void; export function linkSync(srcpath: string, dstpath: string): void; - export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: ErrnoException) => void): void; + export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeErrnoException) => void): void; export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; - export function readlink(path: string, callback?: (err: ErrnoException, linkString: string) => any): void; + export function readlink(path: string, callback?: (err: NodeErrnoException, linkString: string) => any): void; export function readlinkSync(path: string): string; - export function realpath(path: string, callback?: (err: ErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string, cache: {[path: string]: string}, callback: (err: ErrnoException, resolvedPath: string) =>any): void; + export function realpath(path: string, callback?: (err: NodeErrnoException, resolvedPath: string) => any): void; + export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeErrnoException, resolvedPath: string) =>any): void; export function realpathSync(path: string, cache?: {[path: string]: string}): string; - export function unlink(path: string, callback?: (err?: ErrnoException) => void): void; + export function unlink(path: string, callback?: (err?: NodeErrnoException) => void): void; export function unlinkSync(path: string): void; - export function rmdir(path: string, callback?: (err?: ErrnoException) => void): void; + export function rmdir(path: string, callback?: (err?: NodeErrnoException) => void): void; export function rmdirSync(path: string): void; - export function mkdir(path: string, callback?: (err?: ErrnoException) => void): void; - export function mkdir(path: string, mode: number, callback?: (err?: ErrnoException) => void): void; - export function mkdir(path: string, mode: string, callback?: (err?: ErrnoException) => void): void; + export function mkdir(path: string, callback?: (err?: NodeErrnoException) => void): void; + export function mkdir(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; + export function mkdir(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; export function mkdirSync(path: string, mode?: number): void; export function mkdirSync(path: string, mode?: string): void; - export function readdir(path: string, callback?: (err: ErrnoException, files: string[]) => void): void; + export function readdir(path: string, callback?: (err: NodeErrnoException, files: string[]) => void): void; export function readdirSync(path: string): string[]; - export function close(fd: number, callback?: (err?: ErrnoException) => void): void; + export function close(fd: number, callback?: (err?: NodeErrnoException) => void): void; export function closeSync(fd: number): void; - export function open(path: string, flags: string, callback?: (err: ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: number, callback?: (err: ErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: string, callback?: (err: ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, callback?: (err: NodeErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: number, callback?: (err: NodeErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: string, callback?: (err: NodeErrnoException, fd: number) => any): void; export function openSync(path: string, flags: string, mode?: number): number; export function openSync(path: string, flags: string, mode?: string): number; - export function utimes(path: string, atime: number, mtime: number, callback?: (err?: ErrnoException) => void): void; + export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeErrnoException) => void): void; export function utimesSync(path: string, atime: number, mtime: number): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: ErrnoException) => void): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeErrnoException) => void): void; export function futimesSync(fd: number, atime: number, mtime: number): void; - export function fsync(fd: number, callback?: (err?: ErrnoException) => void): void; + export function fsync(fd: number, callback?: (err?: NodeErrnoException) => void): void; export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeErrnoException, written: number, buffer: Buffer) => void): void; export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: ErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeErrnoException, bytesRead: number, buffer: Buffer) => void): void; export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function readFile(filename: string, encoding: string, callback: (err: ErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: ErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { flag?: string; }, callback: (err: ErrnoException, data: Buffer) => void): void; - export function readFile(filename: string, callback: (err: ErrnoException, data: Buffer) => void ): void; + export function readFile(filename: string, encoding: string, callback: (err: NodeErrnoException, data: string) => void): void; + export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeErrnoException, data: string) => void): void; + export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeErrnoException, data: Buffer) => void): void; + export function readFile(filename: string, callback: (err: NodeErrnoException, data: Buffer) => void ): void; export function readFileSync(filename: string, encoding: string): string; export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void; + export function writeFile(filename: string, data: any, callback?: (err: NodeErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: ErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: ErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: ErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; + export function appendFile(filename: string, data: any, callback?: (err: NodeErrnoException) => void): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; From d100d104c6b01549027c2beac1d742571a13d654 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Mon, 7 Apr 2014 18:50:35 +0400 Subject: [PATCH 21/24] node: now modules depend on events.EventEmitter, not NodeEventEmitter --- browser-harness/browser-harness.d.ts | 33 ++++++++++++++-------------- msnodesql/msnodesql.d.ts | 4 +++- node/node.d.ts | 31 +++++++++++++------------- 3 files changed, 36 insertions(+), 32 deletions(-) diff --git a/browser-harness/browser-harness.d.ts b/browser-harness/browser-harness.d.ts index 68dbf8be5..a96074164 100644 --- a/browser-harness/browser-harness.d.ts +++ b/browser-harness/browser-harness.d.ts @@ -6,27 +6,28 @@ /// declare module "browser-harness" { + import _events = require('events'); - interface HarnessEvents extends NodeEventEmitter { - once(event: string, listener: (driver: Driver) => void): NodeEventEmitter; - once(event: 'ready', listener: (driver: Driver) => void): NodeEventEmitter; + interface HarnessEvents extends _events.EventEmitter { + once(event: string, listener: (driver: Driver) => void): _events.EventEmitter; + once(event: 'ready', listener: (driver: Driver) => void): _events.EventEmitter; - on(event: string, listener: (driver: Driver) => void): NodeEventEmitter; - on(event: 'ready', listener: (driver: Driver) => void): NodeEventEmitter; + on(event: string, listener: (driver: Driver) => void): _events.EventEmitter; + on(event: 'ready', listener: (driver: Driver) => void): _events.EventEmitter; } - interface DriverEvents extends NodeEventEmitter { - once(event: string, listener: (text: string) => void): NodeEventEmitter; - once(event: 'console.log', listener: (text: string) => void): NodeEventEmitter; - once(event: 'console.warn', listener: (text: string) => void): NodeEventEmitter; - once(event: 'console.error', listener: (text: string) => void): NodeEventEmitter; - once(event: 'window.onerror', listener: (text: string) => void): NodeEventEmitter; + interface DriverEvents extends _events.EventEmitter { + once(event: string, listener: (text: string) => void): _events.EventEmitter; + once(event: 'console.log', listener: (text: string) => void): _events.EventEmitter; + once(event: 'console.warn', listener: (text: string) => void): _events.EventEmitter; + once(event: 'console.error', listener: (text: string) => void): _events.EventEmitter; + once(event: 'window.onerror', listener: (text: string) => void): _events.EventEmitter; - on(event: string, listener: (text: string) => void): NodeEventEmitter; - on(event: 'console.log', listener: (text: string) => void): NodeEventEmitter; - on(event: 'console.warn', listener: (text: string) => void): NodeEventEmitter; - on(event: 'console.error', listener: (text: string) => void): NodeEventEmitter; - on(event: 'window.onerror', listener: (text: string) => void): NodeEventEmitter; + on(event: string, listener: (text: string) => void): _events.EventEmitter; + on(event: 'console.log', listener: (text: string) => void): _events.EventEmitter; + on(event: 'console.warn', listener: (text: string) => void): _events.EventEmitter; + on(event: 'console.error', listener: (text: string) => void): _events.EventEmitter; + on(event: 'window.onerror', listener: (text: string) => void): _events.EventEmitter; } export interface Driver { diff --git a/msnodesql/msnodesql.d.ts b/msnodesql/msnodesql.d.ts index cadb323db..39bf01fb8 100644 --- a/msnodesql/msnodesql.d.ts +++ b/msnodesql/msnodesql.d.ts @@ -7,6 +7,8 @@ /// declare module "msnodesql" { + import events = require('events'); + export function open(connectionString: string, callback?: OpenCallback): Connection; export function query(connectionString: string, query: string, callback?: QueryCallback): StreamEvents; @@ -55,5 +57,5 @@ declare module "msnodesql" { close(immediately: boolean, callback?: ErrorCallback); } - interface StreamEvents extends NodeEventEmitter { } + interface StreamEvents extends events.EventEmitter {} } \ No newline at end of file diff --git a/node/node.d.ts b/node/node.d.ts index 6be669a01..8966fa18b 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -4,7 +4,7 @@ /************************************************ * * -* Node.js v0.10.1 API * +* Node.js v0.10.1 API * * * ************************************************/ @@ -256,7 +256,7 @@ declare module "http" { import net = require("net"); import stream = require("stream"); - export interface Server extends NodeEventEmitter { + export interface Server extends events.EventEmitter { listen(port: number, hostname?: string, backlog?: number, callback?: Function): Server; listen(path: string, callback?: Function): Server; listen(handle: any, listeningListener?: Function): Server; @@ -264,7 +264,7 @@ declare module "http" { address(): { port: number; family: string; address: string; }; maxHeadersCount: number; } - export interface ServerRequest extends NodeEventEmitter, ReadableStream { + export interface ServerRequest extends events.EventEmitter, ReadableStream { method: string; url: string; headers: any; @@ -275,7 +275,7 @@ declare module "http" { resume(): void; connection: net.Socket; } - export interface ServerResponse extends NodeEventEmitter, WritableStream { + export interface ServerResponse extends events.EventEmitter, WritableStream { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -301,7 +301,7 @@ declare module "http" { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface ClientRequest extends NodeEventEmitter, WritableStream { + export interface ClientRequest extends events.EventEmitter, WritableStream { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -322,7 +322,7 @@ declare module "http" { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface ClientResponse extends NodeEventEmitter, ReadableStream { + export interface ClientResponse extends events.EventEmitter, ReadableStream { statusCode: number; httpVersion: string; headers: any; @@ -507,8 +507,8 @@ declare module "https" { }; export interface Server extends tls.Server { } export function createServer(options: ServerOptions, requestListener?: Function): Server; - export function request(options: RequestOptions, callback?: (res: NodeEventEmitter) =>void ): http.ClientRequest; - export function get(options: RequestOptions, callback?: (res: NodeEventEmitter) =>void ): http.ClientRequest; + export function request(options: RequestOptions, callback?: (res: events.EventEmitter) =>void ): http.ClientRequest; + export function get(options: RequestOptions, callback?: (res: events.EventEmitter) =>void ): http.ClientRequest; export var globalAgent: Agent; } @@ -540,14 +540,14 @@ declare module "repl" { ignoreUndefined?: boolean; writer?: Function; } - export function start(options: ReplOptions): NodeEventEmitter; + export function start(options: ReplOptions): events.EventEmitter; } declare module "readline" { import events = require("events"); import stream = require("stream"); - export interface ReadLine extends NodeEventEmitter { + export interface ReadLine extends events.EventEmitter { setPrompt(prompt: string, length: number): void; prompt(preserveCursor?: boolean): void; question(query: string, callback: Function): void; @@ -582,7 +582,7 @@ declare module "child_process" { import events = require("events"); import stream = require("stream"); - export interface ChildProcess extends NodeEventEmitter { + export interface ChildProcess extends events.EventEmitter { stdin: WritableStream; stdout: ReadableStream; stderr: ReadableStream; @@ -743,7 +743,7 @@ declare module "dgram" { export function createSocket(type: string, callback?: Function): Socket; - interface Socket extends NodeEventEmitter { + interface Socket extends events.EventEmitter { send(buf: Buffer, offset: number, length: number, port: number, address: string, callback?: Function): void; bind(port: number, address?: string): void; close(): void; @@ -758,6 +758,7 @@ declare module "dgram" { declare module "fs" { import stream = require("stream"); + import events = require("events"); interface Stats { isFile(): boolean; @@ -782,7 +783,7 @@ declare module "fs" { ctime: Date; } - interface FSWatcher extends NodeEventEmitter { + interface FSWatcher extends events.EventEmitter { close(): void; } @@ -1255,8 +1256,8 @@ declare module "domain" { export class Domain extends events.EventEmitter { run(fn: Function): void; - add(emitter: NodeEventEmitter): void; - remove(emitter: NodeEventEmitter): void; + add(emitter: events.EventEmitter): void; + remove(emitter: events.EventEmitter): void; bind(cb: (err: Error, data: any) => any): any; intercept(cb: (data: any) => any): any; dispose(): void; From c52e7bdf63b7d45f0d551d2534a19a3eea250ba9 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Mon, 7 Apr 2014 19:49:19 +0400 Subject: [PATCH 22/24] node: now modules depend on stream.* when possible --- browserify/browserify.d.ts | 2 +- highland/highland-tests.ts | 4 +- highland/highland.d.ts | 6 +-- node/node.d.ts | 83 +++++++++++++++++++------------------- promptly/promptly.d.ts | 5 ++- q-io/Q-io.d.ts | 4 +- superagent/superagent.d.ts | 3 +- through/through.d.ts | 4 +- 8 files changed, 57 insertions(+), 54 deletions(-) diff --git a/browserify/browserify.d.ts b/browserify/browserify.d.ts index e725de98c..ebed2a490 100644 --- a/browserify/browserify.d.ts +++ b/browserify/browserify.d.ts @@ -16,7 +16,7 @@ interface BrowserifyObject extends NodeEventEmitter { debug?: boolean; standalone?: string; insertGlobalVars?: any; - }, cb?: (err: any, src: any) => void): ReadableStream; + }, cb?: (err: any, src: any) => void): NodeReadableStream; external(file: string): BrowserifyObject; ignore(file: string): BrowserifyObject; diff --git a/highland/highland-tests.ts b/highland/highland-tests.ts index 3625b3f81..0a724a7fb 100644 --- a/highland/highland-tests.ts +++ b/highland/highland-tests.ts @@ -22,8 +22,8 @@ var strArr: string[]; var numArr: string[]; var funcArr: Function[]; -var readable: ReadableStream; -var writable: WritableStream; +var readable: NodeReadableStream; +var writable: NodeWritableStream; var emitter: NodeEventEmitter; // - - - - - - - - - - - - - - - - - diff --git a/highland/highland.d.ts b/highland/highland.d.ts index 8760a5c2d..3bec0c6eb 100644 --- a/highland/highland.d.ts +++ b/highland/highland.d.ts @@ -62,7 +62,7 @@ interface HighlandStatic { (xs: (push: (err: Error, x?: R) => void, next: () => void) => void): Highland.Stream; (xs: Highland.Stream): Highland.Stream; - (xs: ReadableStream): Highland.Stream; + (xs: NodeReadableStream): Highland.Stream; (xs: NodeEventEmitter): Highland.Stream; // moar (promise for everything?) @@ -419,8 +419,8 @@ declare module Highland { * @api public */ pipe(dest: Stream): Stream; - pipe(dest: ReadWriteStream): Stream; - pipe(dest: WritableStream): void; + pipe(dest: NodeReadWriteStream): Stream; + pipe(dest: NodeWritableStream): void; /** * Destroys a stream by unlinking it from any consumers and sources. This will diff --git a/node/node.d.ts b/node/node.d.ts index 8966fa18b..d0a67ffef 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -55,6 +55,7 @@ declare var SlowBuffer: { byteLength(string: string, encoding?: string): number; concat(list: Buffer[], totalLength?: number): Buffer; }; + declare var Buffer: { new (str: string, encoding?: string): Buffer; new (size: number): Buffer; @@ -89,20 +90,20 @@ interface NodeEventEmitter { emit(event: string, ...args: any[]): boolean; } -interface ReadableStream extends NodeEventEmitter { +interface NodeReadableStream extends NodeEventEmitter { readable: boolean; read(size?: number): any; setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; + wrap(oldStream: NodeReadableStream): NodeReadableStream; } -interface WritableStream extends NodeEventEmitter { +interface NodeWritableStream extends NodeEventEmitter { writable: boolean; write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; @@ -113,12 +114,12 @@ interface WritableStream extends NodeEventEmitter { end(str: string, encoding?: string, cb?: Function): void; } -interface ReadWriteStream extends ReadableStream, WritableStream { } +interface NodeReadWriteStream extends NodeReadableStream, NodeWritableStream {} interface NodeProcess extends NodeEventEmitter { - stdout: WritableStream; - stderr: WritableStream; - stdin: ReadableStream; + stdout: NodeWritableStream; + stderr: NodeWritableStream; + stdin: NodeReadableStream; argv: string[]; execPath: string; abort(): void; @@ -264,7 +265,7 @@ declare module "http" { address(): { port: number; family: string; address: string; }; maxHeadersCount: number; } - export interface ServerRequest extends events.EventEmitter, ReadableStream { + export interface ServerRequest extends events.EventEmitter, stream.Readable { method: string; url: string; headers: any; @@ -275,7 +276,7 @@ declare module "http" { resume(): void; connection: net.Socket; } - export interface ServerResponse extends events.EventEmitter, WritableStream { + export interface ServerResponse extends events.EventEmitter, stream.Writable { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -301,7 +302,7 @@ declare module "http" { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface ClientRequest extends events.EventEmitter, WritableStream { + export interface ClientRequest extends events.EventEmitter, stream.Writable { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -322,7 +323,7 @@ declare module "http" { end(str: string, encoding?: string, cb?: Function): void; end(data?: any, encoding?: string): void; } - export interface ClientResponse extends events.EventEmitter, ReadableStream { + export interface ClientResponse extends events.EventEmitter, stream.Readable { statusCode: number; httpVersion: string; headers: any; @@ -385,13 +386,13 @@ declare module "zlib" { import stream = require("stream"); export interface ZlibOptions { chunkSize?: number; windowBits?: number; level?: number; memLevel?: number; strategy?: number; dictionary?: any; } - export interface Gzip extends ReadWriteStream { } - export interface Gunzip extends ReadWriteStream { } - export interface Deflate extends ReadWriteStream { } - export interface Inflate extends ReadWriteStream { } - export interface DeflateRaw extends ReadWriteStream { } - export interface InflateRaw extends ReadWriteStream { } - export interface Unzip extends ReadWriteStream { } + export interface Gzip extends stream.Transform { } + export interface Gunzip extends stream.Transform { } + export interface Deflate extends stream.Transform { } + export interface Inflate extends stream.Transform { } + export interface DeflateRaw extends stream.Transform { } + export interface InflateRaw extends stream.Transform { } + export interface Unzip extends stream.Transform { } export function createGzip(options?: ZlibOptions): Gzip; export function createGunzip(options?: ZlibOptions): Gunzip; @@ -531,8 +532,8 @@ declare module "repl" { export interface ReplOptions { prompt?: string; - input?: ReadableStream; - output?: WritableStream; + input?: NodeReadableStream; + output?: NodeWritableStream; terminal?: boolean; eval?: Function; useColors?: boolean; @@ -557,8 +558,8 @@ declare module "readline" { write(data: any, key?: any): void; } export interface ReadLineOptions { - input: ReadableStream; - output: WritableStream; + input: NodeReadableStream; + output: NodeWritableStream; completer?: Function; terminal?: boolean; } @@ -583,9 +584,9 @@ declare module "child_process" { import stream = require("stream"); export interface ChildProcess extends events.EventEmitter { - stdin: WritableStream; - stdout: ReadableStream; - stderr: ReadableStream; + stdin: stream.Writable; + stdout: stream.Readable; + stderr: stream.Readable; pid: number; kill(signal?: string): void; send(message: any, sendHandle: any): void; @@ -679,7 +680,7 @@ declare module "dns" { declare module "net" { import stream = require("stream"); - export interface Socket extends ReadWriteStream { + export interface Socket extends stream.Duplex { // Extended base methods write(buffer: Buffer): boolean; write(buffer: Buffer, cb?: Function): boolean; @@ -787,8 +788,8 @@ declare module "fs" { close(): void; } - export interface ReadStream extends ReadableStream { } - export interface WriteStream extends WritableStream { } + export interface ReadStream extends stream.Readable {} + export interface WriteStream extends stream.Writable {} export function rename(oldPath: string, newPath: string, callback?: (err?: NodeErrnoException) => void): void; export function renameSync(oldPath: string, newPath: string): void; @@ -980,7 +981,7 @@ declare module "tls" { connections: number; } - export interface ClearTextStream extends ReadWriteStream { + export interface ClearTextStream extends stream.Duplex { authorized: boolean; authorizationError: Error; getPeerCertificate(): any; @@ -1085,7 +1086,7 @@ declare module "stream" { objectMode?: boolean; } - export class Readable extends events.EventEmitter implements ReadableStream { + export class Readable extends events.EventEmitter implements NodeReadableStream { readable: boolean; constructor(opts?: ReadableOptions); _read(size: number): void; @@ -1093,11 +1094,11 @@ declare module "stream" { setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; + wrap(oldStream: NodeReadableStream): NodeReadableStream; push(chunk: any, encoding?: string): boolean; } @@ -1106,7 +1107,7 @@ declare module "stream" { decodeStrings?: boolean; } - export class Writable extends events.EventEmitter implements WritableStream { + export class Writable extends events.EventEmitter implements NodeWritableStream { writable: boolean; constructor(opts?: WritableOptions); _write(data: Buffer, encoding: string, callback: Function): void; @@ -1125,7 +1126,7 @@ declare module "stream" { } // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements ReadWriteStream { + export class Duplex extends Readable implements NodeReadWriteStream { writable: boolean; constructor(opts?: DuplexOptions); _write(data: Buffer, encoding: string, callback: Function): void; @@ -1142,7 +1143,7 @@ declare module "stream" { export interface TransformOptions extends ReadableOptions, WritableOptions {} // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements ReadWriteStream { + export class Transform extends events.EventEmitter implements NodeReadWriteStream { readable: boolean; writable: boolean; constructor(opts?: TransformOptions); @@ -1153,11 +1154,11 @@ declare module "stream" { setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: ReadableStream): ReadableStream; + wrap(oldStream: NodeReadableStream): NodeReadableStream; push(chunk: any, encoding?: string): boolean; write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; diff --git a/promptly/promptly.d.ts b/promptly/promptly.d.ts index 3469ea04a..8999d1cc4 100644 --- a/promptly/promptly.d.ts +++ b/promptly/promptly.d.ts @@ -6,6 +6,7 @@ /// declare module "promptly" { + import stream = require('stream'); interface Callback { (err: Error, value: string): void; @@ -17,8 +18,8 @@ declare module "promptly" { validator?: any; retry?: boolean; silent?: boolean; - input?: ReadableStream; - output?: WritableStream; + input?: NodeReadableStream; + output?: NodeWritableStream; } export function prompt(message: string, fn?: Callback):any; diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts index f9d1c10d1..cc321e24b 100644 --- a/q-io/Q-io.d.ts +++ b/q-io/Q-io.d.ts @@ -200,7 +200,7 @@ declare module Qio { read(charset:string):Q.Promise; read():Q.Promise; close():void; - node:ReadableStream; + node: NodeReadableStream; } interface Writer { write(content:string):void; @@ -208,7 +208,7 @@ declare module Qio { flush():Q.Promise; close():void; destroy():void; - node:WritableStream; + node: NodeWritableStream; } interface Stream { diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index f416dee81..df0e288e9 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -6,6 +6,7 @@ /// declare module "superagent" { + import stream = require('stream'); export interface Response { text: string; body: any; @@ -44,7 +45,7 @@ declare module "superagent" { send(data: Object): Request; write(data: string, encoding: string): boolean; write(data: Buffer, encoding: string): boolean; - pipe(stream: WritableStream, options?: Object): WritableStream; + pipe(stream: NodeWritableStream, options?: Object): stream.Writable; buffer(val: boolean): Request; timeout(ms: number): Request; clearTimeout(): Request; diff --git a/through/through.d.ts b/through/through.d.ts index 8a617c424..1491085a2 100644 --- a/through/through.d.ts +++ b/through/through.d.ts @@ -6,7 +6,7 @@ /// declare module "through" { - import Stream = require("stream"); + import stream = require("stream"); function through(write?: (data) => void, end?: () => void, @@ -15,7 +15,7 @@ declare module "through" { }): through.ThroughStream; module through { - export interface ThroughStream extends ReadWriteStream { + export interface ThroughStream extends stream.Transform { autoDestroy: boolean; } } From 25a3c76b4474eb66abe42a84d19525b0237521f7 Mon Sep 17 00:00:00 2001 From: Paul Loyd Date: Thu, 10 Apr 2014 21:57:58 +0400 Subject: [PATCH 23/24] node: move Node* to NodeJS module --- browserify/browserify.d.ts | 4 +- highland/highland-tests.ts | 6 +- highland/highland.d.ts | 10 +- jake/jake.d.ts | 24 +-- node/node.d.ts | 359 +++++++++++++++++++------------------ promptly/promptly.d.ts | 4 +- q-io/Q-io.d.ts | 4 +- superagent/superagent.d.ts | 2 +- 8 files changed, 211 insertions(+), 202 deletions(-) diff --git a/browserify/browserify.d.ts b/browserify/browserify.d.ts index ebed2a490..5326abaeb 100644 --- a/browserify/browserify.d.ts +++ b/browserify/browserify.d.ts @@ -5,7 +5,7 @@ /// -interface BrowserifyObject extends NodeEventEmitter { +interface BrowserifyObject extends NodeJS.EventEmitter { add(file: string): BrowserifyObject; require(file: string, opts?: { expose: string; @@ -16,7 +16,7 @@ interface BrowserifyObject extends NodeEventEmitter { debug?: boolean; standalone?: string; insertGlobalVars?: any; - }, cb?: (err: any, src: any) => void): NodeReadableStream; + }, cb?: (err: any, src: any) => void): NodeJS.ReadableStream; external(file: string): BrowserifyObject; ignore(file: string): BrowserifyObject; diff --git a/highland/highland-tests.ts b/highland/highland-tests.ts index 0a724a7fb..c7e213aa1 100644 --- a/highland/highland-tests.ts +++ b/highland/highland-tests.ts @@ -22,9 +22,9 @@ var strArr: string[]; var numArr: string[]; var funcArr: Function[]; -var readable: NodeReadableStream; -var writable: NodeWritableStream; -var emitter: NodeEventEmitter; +var readable: NodeJS.ReadableStream; +var writable: NodeJS.WritableStream; +var emitter: NodeJS.EventEmitter; // - - - - - - - - - - - - - - - - - diff --git a/highland/highland.d.ts b/highland/highland.d.ts index 3bec0c6eb..3f98c948e 100644 --- a/highland/highland.d.ts +++ b/highland/highland.d.ts @@ -62,8 +62,8 @@ interface HighlandStatic { (xs: (push: (err: Error, x?: R) => void, next: () => void) => void): Highland.Stream; (xs: Highland.Stream): Highland.Stream; - (xs: NodeReadableStream): Highland.Stream; - (xs: NodeEventEmitter): Highland.Stream; + (xs: NodeJS.ReadableStream): Highland.Stream; + (xs: NodeJS.EventEmitter): Highland.Stream; // moar (promise for everything?) (xs: Highland.Thenable>): Highland.Stream; @@ -365,7 +365,7 @@ declare module Highland { /** * Actual Stream constructor wrapped the the main exported function */ - interface Stream extends NodeEventEmitter { + interface Stream extends NodeJS.EventEmitter { /** * Pauses the stream. All Highland Streams start in the paused state. @@ -419,8 +419,8 @@ declare module Highland { * @api public */ pipe(dest: Stream): Stream; - pipe(dest: NodeReadWriteStream): Stream; - pipe(dest: NodeWritableStream): void; + pipe(dest: NodeJS.ReadWriteStream): Stream; + pipe(dest: NodeJS.WritableStream): void; /** * Destroys a stream by unlinking it from any consumers and sources. This will diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 330aac324..904a8084b 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -133,7 +133,7 @@ declare module jake{ * @event stderr When the stderr for the child-process recieves data. This streams the stderr data. Passes one arg, the chunk of data. * @event error When a shell-command */ - export interface Exec extends NodeEventEmitter { + export interface Exec extends NodeJS.EventEmitter { append(cmd:string): void; run(): void; } @@ -187,7 +187,7 @@ declare module jake{ * * @event complete */ - export class Task implements NodeEventEmitter { + export class Task implements NodeJS.EventEmitter { /** * @name name The name of the Task * @param prereqs Prerequisites to be run before this task @@ -206,11 +206,11 @@ declare module jake{ */ reenable(): void; - addListener(event: string, listener: Function): NodeEventEmitter; - on(event: string, listener: Function): NodeEventEmitter; - once(event: string, listener: Function): NodeEventEmitter; - removeListener(event: string, listener: Function): NodeEventEmitter; - removeAllListeners(event?: string): NodeEventEmitter; + addListener(event: string, listener: Function): NodeJS.EventEmitter; + on(event: string, listener: Function): NodeJS.EventEmitter; + once(event: string, listener: Function): NodeJS.EventEmitter; + removeListener(event: string, listener: Function): NodeJS.EventEmitter; + removeAllListeners(event?: string): NodeJS.EventEmitter; setMaxListeners(n: number): void; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; @@ -381,11 +381,11 @@ declare module jake{ constructor(name:string, definition?:()=>void); } - export function addListener(event: string, listener: Function): NodeEventEmitter; - export function on(event: string, listener: Function): NodeEventEmitter; - export function once(event: string, listener: Function): NodeEventEmitter; - export function removeListener(event: string, listener: Function): NodeEventEmitter; - export function removeAllListener(event: string): NodeEventEmitter; + export function addListener(event: string, listener: Function): NodeJS.EventEmitter; + export function on(event: string, listener: Function): NodeJS.EventEmitter; + export function once(event: string, listener: Function): NodeJS.EventEmitter; + export function removeListener(event: string, listener: Function): NodeJS.EventEmitter; + export function removeAllListener(event: string): NodeJS.EventEmitter; export function setMaxListeners(n: number): void; export function listeners(event: string): Function[]; export function emit(event: string, ...args: any[]): boolean; diff --git a/node/node.d.ts b/node/node.d.ts index d0a67ffef..11af9e5b1 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -13,17 +13,17 @@ * GLOBAL * * * ************************************************/ -declare var process: NodeProcess; +declare var process: NodeJS.Process; declare var global: any; declare var __filename: string; declare var __dirname: string; -declare function setTimeout(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; -declare function clearTimeout(timeoutId: NodeTimer): void; -declare function setInterval(callback: (...args: any[]) => void , ms: number , ...args: any[]): NodeTimer; -declare function clearInterval(intervalId: NodeTimer): void; -declare function setImmediate(callback: (...args: any[]) => void , ...args: any[]): any; +declare function setTimeout(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearTimeout(timeoutId: NodeJS.Timer): void; +declare function setInterval(callback: (...args: any[]) => void, ms: number, ...args: any[]): NodeJS.Timer; +declare function clearInterval(intervalId: NodeJS.Timer): void; +declare function setImmediate(callback: (...args: any[]) => void, ...args: any[]): any; declare function clearImmediate(immediateId: any): void; declare var require: { @@ -32,7 +32,7 @@ declare var require: { cache: any; extensions: any; main: any; -} +}; declare var module: { exports: any; @@ -42,7 +42,7 @@ declare var module: { loaded: boolean; parent: any; children: any[]; -} +}; // Same as module.exports declare var exports: any; @@ -56,6 +56,9 @@ declare var SlowBuffer: { concat(list: Buffer[], totalLength?: number): Buffer; }; + +// Buffer class +interface Buffer extends NodeBuffer {} declare var Buffer: { new (str: string, encoding?: string): Buffer; new (size: number): Buffer; @@ -68,112 +71,126 @@ declare var Buffer: { /************************************************ * * -* INTERFACES * +* GLOBAL INTERFACES * * * ************************************************/ +declare module NodeJS { + export interface ErrnoException extends Error { + errno?: any; + code?: string; + path?: string; + syscall?: string; + } -interface NodeErrnoException extends Error { - errno?: any; - code?: string; - path?: string; - syscall?: string; -} + export interface EventEmitter { + addListener(event: string, listener: Function): EventEmitter; + on(event: string, listener: Function): EventEmitter; + once(event: string, listener: Function): EventEmitter; + removeListener(event: string, listener: Function): EventEmitter; + removeAllListeners(event?: string): EventEmitter; + setMaxListeners(n: number): void; + listeners(event: string): Function[]; + emit(event: string, ...args: any[]): boolean; + } -interface NodeEventEmitter { - addListener(event: string, listener: Function): NodeEventEmitter; - on(event: string, listener: Function): NodeEventEmitter; - once(event: string, listener: Function): NodeEventEmitter; - removeListener(event: string, listener: Function): NodeEventEmitter; - removeAllListeners(event?: string): NodeEventEmitter; - setMaxListeners(n: number): void; - listeners(event: string): Function[]; - emit(event: string, ...args: any[]): boolean; -} + export interface ReadableStream extends EventEmitter { + readable: boolean; + read(size?: number): any; + setEncoding(encoding: string): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; + unshift(chunk: string): void; + unshift(chunk: Buffer): void; + wrap(oldStream: ReadableStream): ReadableStream; + } -interface NodeReadableStream extends NodeEventEmitter { - readable: boolean; - read(size?: number): any; - setEncoding(encoding: string): void; - pause(): void; - resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; - unshift(chunk: string): void; - unshift(chunk: Buffer): void; - wrap(oldStream: NodeReadableStream): NodeReadableStream; -} + export interface WritableStream extends EventEmitter { + writable: boolean; + write(buffer: Buffer, cb?: Function): boolean; + write(str: string, cb?: Function): boolean; + write(str: string, encoding?: string, cb?: Function): boolean; + end(): void; + end(buffer: Buffer, cb?: Function): void; + end(str: string, cb?: Function): void; + end(str: string, encoding?: string, cb?: Function): void; + } -interface NodeWritableStream extends NodeEventEmitter { - writable: boolean; - write(buffer: Buffer, cb?: Function): boolean; - write(str: string, cb?: Function): boolean; - write(str: string, encoding?: string, cb?: Function): boolean; - end(): void; - end(buffer: Buffer, cb?: Function): void; - end(str: string, cb?: Function): void; - end(str: string, encoding?: string, cb?: Function): void; -} + export interface ReadWriteStream extends ReadableStream, WritableStream {} -interface NodeReadWriteStream extends NodeReadableStream, NodeWritableStream {} - -interface NodeProcess extends NodeEventEmitter { - stdout: NodeWritableStream; - stderr: NodeWritableStream; - stdin: NodeReadableStream; - argv: string[]; - execPath: string; - abort(): void; - chdir(directory: string): void; - cwd(): string; - env: any; - exit(code?: number): void; - getgid(): number; - setgid(id: number): void; - setgid(id: string): void; - getuid(): number; - setuid(id: number): void; - setuid(id: string): void; - version: string; - versions: { http_parser: string; node: string; v8: string; ares: string; uv: string; zlib: string; openssl: string; }; - config: { - target_defaults: { - cflags: any[]; - default_configuration: string; - defines: string[]; - include_dirs: string[]; - libraries: string[]; + export interface Process extends EventEmitter { + stdout: WritableStream; + stderr: WritableStream; + stdin: ReadableStream; + argv: string[]; + execPath: string; + abort(): void; + chdir(directory: string): void; + cwd(): string; + env: any; + exit(code?: number): void; + getgid(): number; + setgid(id: number): void; + setgid(id: string): void; + getuid(): number; + setuid(id: number): void; + setuid(id: string): void; + version: string; + versions: { + http_parser: string; + node: string; + v8: string; + ares: string; + uv: string; + zlib: string; + openssl: string; }; - variables: { - clang: number; - host_arch: string; - node_install_npm: boolean; - node_install_waf: boolean; - node_prefix: string; - node_shared_openssl: boolean; - node_shared_v8: boolean; - node_shared_zlib: boolean; - node_use_dtrace: boolean; - node_use_etw: boolean; - node_use_openssl: boolean; - target_arch: string; - v8_no_strict_aliasing: number; - v8_use_snapshot: boolean; - visibility: string; - }; - }; - kill(pid: number, signal?: string): void; - pid: number; - title: string; - arch: string; - platform: string; - memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; - nextTick(callback: Function): void; - umask(mask?: number): number; - uptime(): number; - hrtime(time?:number[]): number[]; + config: { + target_defaults: { + cflags: any[]; + default_configuration: string; + defines: string[]; + include_dirs: string[]; + libraries: string[]; + }; + variables: { + clang: number; + host_arch: string; + node_install_npm: boolean; + node_install_waf: boolean; + node_prefix: string; + node_shared_openssl: boolean; + node_shared_v8: boolean; + node_shared_zlib: boolean; + node_use_dtrace: boolean; + node_use_etw: boolean; + node_use_openssl: boolean; + target_arch: string; + v8_no_strict_aliasing: number; + v8_use_snapshot: boolean; + visibility: string; + }; + }; + kill(pid: number, signal?: string): void; + pid: number; + title: string; + arch: string; + platform: string; + memoryUsage(): { rss: number; heapTotal: number; heapUsed: number; }; + nextTick(callback: Function): void; + umask(mask?: number): number; + uptime(): number; + hrtime(time?:number[]): number[]; - // Worker - send?(message: any, sendHandle?: any): void; + // Worker + send?(message: any, sendHandle?: any): void; + } + + export interface Timer { + ref() : void; + unref() : void; + } } /** @@ -217,14 +234,6 @@ interface NodeBuffer { fill(value: any, offset?: number, end?: number): void; } -// Buffer class -interface Buffer extends NodeBuffer {} - -interface NodeTimer { - ref() : void; - unref() : void; -} - /************************************************ * * * MODULES * @@ -238,7 +247,7 @@ declare module "querystring" { } declare module "events" { - export class EventEmitter implements NodeEventEmitter { + export class EventEmitter implements NodeJS.EventEmitter { static listenerCount(emitter: EventEmitter, event: string): number; addListener(event: string, listener: Function): EventEmitter; @@ -532,8 +541,8 @@ declare module "repl" { export interface ReplOptions { prompt?: string; - input?: NodeReadableStream; - output?: NodeWritableStream; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; terminal?: boolean; eval?: Function; useColors?: boolean; @@ -558,8 +567,8 @@ declare module "readline" { write(data: any, key?: any): void; } export interface ReadLineOptions { - input: NodeReadableStream; - output: NodeWritableStream; + input: NodeJS.ReadableStream; + output: NodeJS.WritableStream; completer?: Function; terminal?: boolean; } @@ -791,90 +800,90 @@ declare module "fs" { export interface ReadStream extends stream.Readable {} export interface WriteStream extends stream.Writable {} - export function rename(oldPath: string, newPath: string, callback?: (err?: NodeErrnoException) => void): void; + export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function renameSync(oldPath: string, newPath: string): void; - export function truncate(path: string, callback?: (err?: NodeErrnoException) => void): void; - export function truncate(path: string, len: number, callback?: (err?: NodeErrnoException) => void): void; + export function truncate(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function truncate(path: string, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function truncateSync(path: string, len?: number): void; - export function ftruncate(fd: number, callback?: (err?: NodeErrnoException) => void): void; - export function ftruncate(fd: number, len: number, callback?: (err?: NodeErrnoException) => void): void; + export function ftruncate(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function ftruncate(fd: number, len: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function ftruncateSync(fd: number, len?: number): void; - export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; + export function chown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function chownSync(path: string, uid: number, gid: number): void; - export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; + export function fchown(fd: number, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function fchownSync(fd: number, uid: number, gid: number): void; - export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeErrnoException) => void): void; + export function lchown(path: string, uid: number, gid: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function lchownSync(path: string, uid: number, gid: number): void; - export function chmod(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; - export function chmod(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; + export function chmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function chmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function chmodSync(path: string, mode: number): void; export function chmodSync(path: string, mode: string): void; - export function fchmod(fd: number, mode: number, callback?: (err?: NodeErrnoException) => void): void; - export function fchmod(fd: number, mode: string, callback?: (err?: NodeErrnoException) => void): void; + export function fchmod(fd: number, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function fchmod(fd: number, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function fchmodSync(fd: number, mode: number): void; export function fchmodSync(fd: number, mode: string): void; - export function lchmod(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; - export function lchmod(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; + export function lchmod(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function lchmod(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function lchmodSync(path: string, mode: number): void; export function lchmodSync(path: string, mode: string): void; - export function stat(path: string, callback?: (err: NodeErrnoException, stats: Stats) => any): void; - export function lstat(path: string, callback?: (err: NodeErrnoException, stats: Stats) => any): void; - export function fstat(fd: number, callback?: (err: NodeErrnoException, stats: Stats) => any): void; + export function stat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function lstat(path: string, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; + export function fstat(fd: number, callback?: (err: NodeJS.ErrnoException, stats: Stats) => any): void; export function statSync(path: string): Stats; export function lstatSync(path: string): Stats; export function fstatSync(fd: number): Stats; - export function link(srcpath: string, dstpath: string, callback?: (err?: NodeErrnoException) => void): void; + export function link(srcpath: string, dstpath: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function linkSync(srcpath: string, dstpath: string): void; - export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeErrnoException) => void): void; + export function symlink(srcpath: string, dstpath: string, type?: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function symlinkSync(srcpath: string, dstpath: string, type?: string): void; - export function readlink(path: string, callback?: (err: NodeErrnoException, linkString: string) => any): void; + export function readlink(path: string, callback?: (err: NodeJS.ErrnoException, linkString: string) => any): void; export function readlinkSync(path: string): string; - export function realpath(path: string, callback?: (err: NodeErrnoException, resolvedPath: string) => any): void; - export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeErrnoException, resolvedPath: string) =>any): void; + export function realpath(path: string, callback?: (err: NodeJS.ErrnoException, resolvedPath: string) => any): void; + export function realpath(path: string, cache: {[path: string]: string}, callback: (err: NodeJS.ErrnoException, resolvedPath: string) =>any): void; export function realpathSync(path: string, cache?: {[path: string]: string}): string; - export function unlink(path: string, callback?: (err?: NodeErrnoException) => void): void; + export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function unlinkSync(path: string): void; - export function rmdir(path: string, callback?: (err?: NodeErrnoException) => void): void; + export function rmdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function rmdirSync(path: string): void; - export function mkdir(path: string, callback?: (err?: NodeErrnoException) => void): void; - export function mkdir(path: string, mode: number, callback?: (err?: NodeErrnoException) => void): void; - export function mkdir(path: string, mode: string, callback?: (err?: NodeErrnoException) => void): void; + export function mkdir(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function mkdir(path: string, mode: number, callback?: (err?: NodeJS.ErrnoException) => void): void; + export function mkdir(path: string, mode: string, callback?: (err?: NodeJS.ErrnoException) => void): void; export function mkdirSync(path: string, mode?: number): void; export function mkdirSync(path: string, mode?: string): void; - export function readdir(path: string, callback?: (err: NodeErrnoException, files: string[]) => void): void; + export function readdir(path: string, callback?: (err: NodeJS.ErrnoException, files: string[]) => void): void; export function readdirSync(path: string): string[]; - export function close(fd: number, callback?: (err?: NodeErrnoException) => void): void; + export function close(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function closeSync(fd: number): void; - export function open(path: string, flags: string, callback?: (err: NodeErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: number, callback?: (err: NodeErrnoException, fd: number) => any): void; - export function open(path: string, flags: string, mode: string, callback?: (err: NodeErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: number, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; + export function open(path: string, flags: string, mode: string, callback?: (err: NodeJS.ErrnoException, fd: number) => any): void; export function openSync(path: string, flags: string, mode?: number): number; export function openSync(path: string, flags: string, mode?: string): number; - export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeErrnoException) => void): void; + export function utimes(path: string, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function utimesSync(path: string, atime: number, mtime: number): void; - export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeErrnoException) => void): void; + export function futimes(fd: number, atime: number, mtime: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function futimesSync(fd: number, atime: number, mtime: number): void; - export function fsync(fd: number, callback?: (err?: NodeErrnoException) => void): void; + export function fsync(fd: number, callback?: (err?: NodeJS.ErrnoException) => void): void; export function fsyncSync(fd: number): void; - export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeErrnoException, written: number, buffer: Buffer) => void): void; + export function write(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, written: number, buffer: Buffer) => void): void; export function writeSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeErrnoException, bytesRead: number, buffer: Buffer) => void): void; + export function read(fd: number, buffer: Buffer, offset: number, length: number, position: number, callback?: (err: NodeJS.ErrnoException, bytesRead: number, buffer: Buffer) => void): void; export function readSync(fd: number, buffer: Buffer, offset: number, length: number, position: number): number; - export function readFile(filename: string, encoding: string, callback: (err: NodeErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeErrnoException, data: string) => void): void; - export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeErrnoException, data: Buffer) => void): void; - export function readFile(filename: string, callback: (err: NodeErrnoException, data: Buffer) => void ): void; + export function readFile(filename: string, encoding: string, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + export function readFile(filename: string, options: { encoding: string; flag?: string; }, callback: (err: NodeJS.ErrnoException, data: string) => void): void; + export function readFile(filename: string, options: { flag?: string; }, callback: (err: NodeJS.ErrnoException, data: Buffer) => void): void; + export function readFile(filename: string, callback: (err: NodeJS.ErrnoException, data: Buffer) => void ): void; export function readFileSync(filename: string, encoding: string): string; export function readFileSync(filename: string, options: { encoding: string; flag?: string; }): string; export function readFileSync(filename: string, options?: { flag?: string; }): Buffer; - export function writeFile(filename: string, data: any, callback?: (err: NodeErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; - export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; + export function writeFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function writeFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function writeFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; - export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeErrnoException) => void): void; - export function appendFile(filename: string, data: any, callback?: (err: NodeErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: number; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, options: { encoding?: string; mode?: string; flag?: string; }, callback?: (err: NodeJS.ErrnoException) => void): void; + export function appendFile(filename: string, data: any, callback?: (err: NodeJS.ErrnoException) => void): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: number; flag?: string; }): void; export function appendFileSync(filename: string, data: any, options?: { encoding?: string; mode?: string; flag?: string; }): void; export function watchFile(filename: string, listener: (curr: Stats, prev: Stats) => void): void; @@ -1086,7 +1095,7 @@ declare module "stream" { objectMode?: boolean; } - export class Readable extends events.EventEmitter implements NodeReadableStream { + export class Readable extends events.EventEmitter implements NodeJS.ReadableStream { readable: boolean; constructor(opts?: ReadableOptions); _read(size: number): void; @@ -1094,11 +1103,11 @@ declare module "stream" { setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: NodeReadableStream): NodeReadableStream; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; push(chunk: any, encoding?: string): boolean; } @@ -1107,7 +1116,7 @@ declare module "stream" { decodeStrings?: boolean; } - export class Writable extends events.EventEmitter implements NodeWritableStream { + export class Writable extends events.EventEmitter implements NodeJS.WritableStream { writable: boolean; constructor(opts?: WritableOptions); _write(data: Buffer, encoding: string, callback: Function): void; @@ -1126,7 +1135,7 @@ declare module "stream" { } // Note: Duplex extends both Readable and Writable. - export class Duplex extends Readable implements NodeReadWriteStream { + export class Duplex extends Readable implements NodeJS.ReadWriteStream { writable: boolean; constructor(opts?: DuplexOptions); _write(data: Buffer, encoding: string, callback: Function): void; @@ -1143,7 +1152,7 @@ declare module "stream" { export interface TransformOptions extends ReadableOptions, WritableOptions {} // Note: Transform lacks the _read and _write methods of Readable/Writable. - export class Transform extends events.EventEmitter implements NodeReadWriteStream { + export class Transform extends events.EventEmitter implements NodeJS.ReadWriteStream { readable: boolean; writable: boolean; constructor(opts?: TransformOptions); @@ -1154,11 +1163,11 @@ declare module "stream" { setEncoding(encoding: string): void; pause(): void; resume(): void; - pipe(destination: T, options?: { end?: boolean; }): T; - unpipe(destination?: T): void; + pipe(destination: T, options?: { end?: boolean; }): T; + unpipe(destination?: T): void; unshift(chunk: string): void; unshift(chunk: Buffer): void; - wrap(oldStream: NodeReadableStream): NodeReadableStream; + wrap(oldStream: NodeJS.ReadableStream): NodeJS.ReadableStream; push(chunk: any, encoding?: string): boolean; write(buffer: Buffer, cb?: Function): boolean; write(str: string, cb?: Function): boolean; diff --git a/promptly/promptly.d.ts b/promptly/promptly.d.ts index 8999d1cc4..beb831924 100644 --- a/promptly/promptly.d.ts +++ b/promptly/promptly.d.ts @@ -18,8 +18,8 @@ declare module "promptly" { validator?: any; retry?: boolean; silent?: boolean; - input?: NodeReadableStream; - output?: NodeWritableStream; + input?: NodeJS.ReadableStream; + output?: NodeJS.WritableStream; } export function prompt(message: string, fn?: Callback):any; diff --git a/q-io/Q-io.d.ts b/q-io/Q-io.d.ts index cc321e24b..9c3963376 100644 --- a/q-io/Q-io.d.ts +++ b/q-io/Q-io.d.ts @@ -200,7 +200,7 @@ declare module Qio { read(charset:string):Q.Promise; read():Q.Promise; close():void; - node: NodeReadableStream; + node: NodeJS.ReadableStream; } interface Writer { write(content:string):void; @@ -208,7 +208,7 @@ declare module Qio { flush():Q.Promise; close():void; destroy():void; - node: NodeWritableStream; + node: NodeJS.WritableStream; } interface Stream { diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index df0e288e9..9e6f9c4b5 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -45,7 +45,7 @@ declare module "superagent" { send(data: Object): Request; write(data: string, encoding: string): boolean; write(data: Buffer, encoding: string): boolean; - pipe(stream: NodeWritableStream, options?: Object): stream.Writable; + pipe(stream: NodeJS.WritableStream, options?: Object): stream.Writable; buffer(val: boolean): Request; timeout(ms: number): Request; clearTimeout(): Request; From e17cda940289318200654fc9ced181c85bfb25f1 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 22:00:50 +0200 Subject: [PATCH 24/24] node fix for mu2 --- mu2/mu2-tests.ts | 2 +- mu2/mu2.d.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mu2/mu2-tests.ts b/mu2/mu2-tests.ts index e8172b800..24b85ec4d 100644 --- a/mu2/mu2-tests.ts +++ b/mu2/mu2-tests.ts @@ -6,7 +6,7 @@ import stream = require('stream'); var str: string; var value: any; -var read: ReadableStream; +var read: NodeJS.ReadableStream; var parsed: mu2.IParsed; str = mu2.root; diff --git a/mu2/mu2.d.ts b/mu2/mu2.d.ts index cbc46d6fb..714703934 100644 --- a/mu2/mu2.d.ts +++ b/mu2/mu2.d.ts @@ -10,7 +10,7 @@ declare module "mu2" { export var root: string; - export function compileAndRender(templateName: string, view: any): ReadableStream; + export function compileAndRender(templateName: string, view: any): NodeJS.ReadableStream; export function compile(filename: string, callback: (err: Error, parsed: IParsed) => void): void; @@ -18,10 +18,10 @@ declare module "mu2" { export function compileText(name: string, template: string): IParsed; export function compileText(template: string): IParsed; - export function render(filenameOrParsed: string, view: any): ReadableStream; - export function render(filenameOrParsed: IParsed, view: any): ReadableStream; + export function render(filenameOrParsed: string, view: any): NodeJS.ReadableStream; + export function render(filenameOrParsed: IParsed, view: any): NodeJS.ReadableStream; - export function renderText(template: string, view: any, partials?: any): ReadableStream; + export function renderText(template: string, view: any, partials?: any): NodeJS.ReadableStream; export function clearCache(templateName?: string): void;