From 1f81d75c3ff24f14800a8e61349da668552c5873 Mon Sep 17 00:00:00 2001 From: Ragesh Krishna Date: Sun, 30 Mar 2014 17:30:29 +0530 Subject: [PATCH 001/225] Fixes #1636: Add get(setting) definition on express.Application --- express/express.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/express/express.d.ts b/express/express.d.ts index 243aa41d4d..0fea845144 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -967,6 +967,12 @@ declare module "express" { * @param val */ set (setting: string, val: string): Application; + + get(name: string): string; + + get(name: string, ...handlers: RequestFunction[]): Application; + + get(name: RegExp, ...handlers: RequestFunction[]): Application; /** * Return the app's absolute pathname From 0ec5f624f1c7772653a41c1937de40adecd45ce7 Mon Sep 17 00:00:00 2001 From: sgrebnov Date: Sat, 29 Mar 2014 18:24:39 +0400 Subject: [PATCH 002/225] Adds bindings for Apache Cordova --- README.md | 1 + cordova/cordova-tests.ts | 229 ++++++++++++++++++ cordova/cordova.d.ts | 60 +++++ cordova/plugins/BatteryStatus.d.ts | 125 ++++++++++ cordova/plugins/Camera.d.ts | 167 ++++++++++++++ cordova/plugins/Contacts.d.ts | 262 +++++++++++++++++++++ cordova/plugins/Device.d.ts | 31 +++ cordova/plugins/DeviceMotion.d.ts | 77 +++++++ cordova/plugins/DeviceOrientation.d.ts | 86 +++++++ cordova/plugins/Dialogs.d.ts | 66 ++++++ cordova/plugins/FileSystem.d.ts | 294 ++++++++++++++++++++++++ cordova/plugins/FileTransfer.d.ts | 129 +++++++++++ cordova/plugins/Globalization.d.ts | 255 ++++++++++++++++++++ cordova/plugins/InAppBrowser.d.ts | 219 ++++++++++++++++++ cordova/plugins/Media.d.ts | 86 +++++++ cordova/plugins/MediaCapture.d.ts | 167 ++++++++++++++ cordova/plugins/NetworkInformation.d.ts | 60 +++++ cordova/plugins/Push.d.ts | 68 ++++++ cordova/plugins/Splashscreen.d.ts | 17 ++ cordova/plugins/Vibration.d.ts | 15 ++ cordova/plugins/WebSQL.d.ts | 103 +++++++++ 21 files changed, 2517 insertions(+) create mode 100644 cordova/cordova-tests.ts create mode 100644 cordova/cordova.d.ts create mode 100644 cordova/plugins/BatteryStatus.d.ts create mode 100644 cordova/plugins/Camera.d.ts create mode 100644 cordova/plugins/Contacts.d.ts create mode 100644 cordova/plugins/Device.d.ts create mode 100644 cordova/plugins/DeviceMotion.d.ts create mode 100644 cordova/plugins/DeviceOrientation.d.ts create mode 100644 cordova/plugins/Dialogs.d.ts create mode 100644 cordova/plugins/FileSystem.d.ts create mode 100644 cordova/plugins/FileTransfer.d.ts create mode 100644 cordova/plugins/Globalization.d.ts create mode 100644 cordova/plugins/InAppBrowser.d.ts create mode 100644 cordova/plugins/Media.d.ts create mode 100644 cordova/plugins/MediaCapture.d.ts create mode 100644 cordova/plugins/NetworkInformation.d.ts create mode 100644 cordova/plugins/Push.d.ts create mode 100644 cordova/plugins/Splashscreen.d.ts create mode 100644 cordova/plugins/Vibration.d.ts create mode 100644 cordova/plugins/WebSQL.d.ts diff --git a/README.md b/README.md index 377dcdd56d..80d11aa6ed 100755 --- a/README.md +++ b/README.md @@ -58,6 +58,7 @@ List of Definitions * [CKEditor](https://github.com/ckeditor/ckeditor-dev) (by [Ondrej Sevcik](https://github.com/ondrejsevcik)) * [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon)) * [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem)) +* [Cordova](http://cordova.apache.org) (by [Microsoft Open Technologies, Inc.](http://msopentech.com/)) * [Couchbase / Couchnode](https://github.com/couchbase/couchnode) (by [Basarat Ali Syed](https://github.com/basarat)) * [Crossfilter](https://github.com/square/crossfilter) (by [Schmulik Raskin](https://github.com/schmuli)) * [crypto-js](https://code.google.com/p/crypto-js/) (by [Gia Bảo @ Sân Đình](https://github.com/giabao)). @see [cryptojs.d.ts repo](https://github.com/giabao/cryptojs.d.ts) diff --git a/cordova/cordova-tests.ts b/cordova/cordova-tests.ts new file mode 100644 index 0000000000..4cd95e694c --- /dev/null +++ b/cordova/cordova-tests.ts @@ -0,0 +1,229 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +/// + +// Apache Cordova core +//---------------------------------------------------------------------- + +console.log('cordova.version: ' + cordova.version + ', cordova.platformId: ' + cordova.platformId); + +cordova.exec(null, null, "NativeClassName", "MethodName"); + +cordova.define('mymodule', (require, exports, module) => { }); +var myModule = cordova.require('mymodule'); + +var argsCheck: ArgsCheck = cordova.require('cordova/argcheck'); +argsCheck.checkArgs('ssA', 'cordova.exec', [() => { }, () => { }, 'window', 'openDatabase']); + +// Battery status plugin +//---------------------------------------------------------------------- +window.addEventListener('batterystatus', + (ev: BatteryStatusEvent) => { console.log('Battery level is ' + ev.level); }); + +window.addEventListener('batterycritical', + ()=> { alert('Battery is critical low!'); }); + +// Camera plugin +//---------------------------------------------------------------------- + +navigator.camera.getPicture( + (data: string) => { alert('Got photo!'); }, + (message: string)=> { alert('Failed!: ' + message); }, + { + allowEdit: true, + cameraDirection: Camera.Direction.BACK, + destinationType: Camera.DestinationType.FILE_URI, + encodingType: Camera.EncodingType.JPEG, + sourceType: Camera.PictureSourceType.PHOTOLIBRARY, + quality: 80 + }); + +// Contacts plugin +//---------------------------------------------------------------------- + +var contact: Contact = navigator.contacts.create({ + nickname: 'John Smith', + displayName: 'John Smith', + phoneNumbers: [{ pref: true, type: "work", value: "+185642556856" }] +}); + +navigator.contacts.find(["phoneNumbers"], + (contacts: Contact[])=> { alert('Find ' + contacts.length + ' contacts'); }, + (error: ContactError) => { alert('Error: ' + error.message); }, + { + filter: "+1", + multiple: true + } +); + +// Device API +//---------------------------------------------------------------------- + +console.log(JSON.stringify(device)); + +// DeviceMotion plugin +//---------------------------------------------------------------------- + +navigator.accelerometer.getCurrentAcceleration( + (acc: Acceleration) => { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); }, + () => { alert('Error!'); }); + +var acchandle: WatchHandle = navigator.accelerometer.watchAcceleration( + (acc: Acceleration)=> { console.log('X: ' + acc.x + 'Y: ' + acc.y + 'Z: ' + acc.z); }, + () => { alert('Error!'); }, + { frequency: 10 }); + +navigator.accelerometer.clearWatch(acchandle); + +// DeviceOrientation plugin +//---------------------------------------------------------------------- + +navigator.compass.getCurrentHeading( + (heading: CompassHeading)=> { console.log('Got heading to ' + heading.magneticHeading); }, + (error: CompassError)=> { alert('Error! ' + error.code); }, + { frequency: 10 }); + +var accelhandle = navigator.compass.watchHeading( + (heading: CompassHeading) => { console.log('Got heading to ' + heading.magneticHeading); }, + (error: CompassError) => { alert('Error! ' + error.code); }, + { frequency: 10 }); + +navigator.compass.clearWatch(accelhandle); + +// Dialogs plugin +//---------------------------------------------------------------------- + +navigator.notification.alert('Alert!', () => { alert('You\'re alerted'); }, 'Alert', 'Ok'); +navigator.notification.confirm('Are you ok?', (choice: number) => { alert('Your choice is ' + choice); }); + +// FileSystem plugin +//---------------------------------------------------------------------- + +function fsaccessor(fs: FileSystem) { + console.log('FS root is: ' + fs.root.name); + var fsreader: DirectoryReader = fs.root.createReader(); + fsreader.readEntries( + (entries: Entry[]) => { console.log(fs.root.name + ' has ' + entries.length + ' child elements'); }, + (err: Error)=> { alert('Error: ' + err.message); }); +} + +window.requestFileSystem( + window.TEMPORARY, + 1024 * 1024 * 5, + fsaccessor, + (err: Error) => { alert('Error: ' + err.message); }); + +// FileTransfer plugin +//---------------------------------------------------------------------- + +var file = new FileTransfer(); +file.download('http://some.server.com/download.php', + 'cdvfile://localhost/persistent/path/to/downloads/', + (file: FileEntry)=> { console.log('File Downloaded to ' + file.fullPath); }, + (err: FileTransferError)=> { alert('Error ' + err.code); }, + { headers: null }, + true); + + +// InAppBrowser plugin +//---------------------------------------------------------------------- + +// signature of window.open() added by InAppBrowser plugin +// is similar to native window.open signature, so the compiler can's +// select proper overload, but we cast result to InAppBrowser manually. +var iab = window.open('google.com', '_self'); +iab.addEventListener('loadstart', (ev: InAppBrowserEvent) => { console.log('Start opening ' + ev.url); }); +iab.show(); + +// Globalization plugin +//---------------------------------------------------------------------- + +navigator.globalization.dateToString(new Date(), + (date) => { console.log(JSON.stringify(date)); }, + (error) => { alert(error.message); }, + { formatLength: "short", selector: "date" }); + +navigator.globalization.getDateNames( + (names) => { + names.value.forEach((name) => { console.log(name); }); + }, + (error) => { alert(error.message); }, + { item: "months", type: "wide" }); + +// Media and Media Capture +//---------------------------------------------------------------------- + +var media = new Media('', + () => { console.log('Media opened'); }, + (err: MediaError) => { alert('Error: ' + err.code); }); +media.play(); +media.setVolume(10); + +console.log('Supported audio modes are: ' + JSON.stringify(navigator.device.capture.supportedAudioModes)); + +navigator.device.capture.captureAudio( + (captures: MediaFile[])=> { console.log(captures.length + ' captured'); }, + (err: CaptureError)=> { alert('Error ' + err.message); }, + { + limit: 3, + duration: 10 + }); + +// Push Notifications +//---------------------------------------------------------------------- + +var pushNotification = window.plugins.pushNotification; +pushNotification.register( + (regId: string) => { console.log('Successfully registered'); }, + (err: any) => { alert('Error!'); }, + { + channelName: "your_channel_name", + ecb: "onNotification" + }); + +function onNotification(e: any) { + navigator.notification.alert(e.text2, () => { }, e.text1); +} + +window.plugins.pushNotification.unregister(() => { }, () => { }); + +// Network Plugin +//---------------------------------------------------------------------- + +console.log('Connection type is: ' + navigator.connectionSpeed); + +var connType = navigator.connection.type; +if (connType == Connection.WIFI) { + console.log('Congratulations, you\'re with fast Internet!'); +} + +document.addEventListener('offline', () => { alert('You\'re offline!'); }); + +// SplashScreen plugin +//---------------------------------------------------------------------- + +navigator.splashscreen.show(); +navigator.splashscreen.hide(); + + +// WebSQL plugin +//---------------------------------------------------------------------- + +var db = window.openDatabase('Test', '0.1', 'test', 1024 * 1024 * 5); +db.transaction( + (tx: SqlTransaction) => { + tx.executeSql('CREATE TABLE Sample IF NOT EXIST...'); + tx.executeSql('INSERT INTO Sample VALUES...'); + }, + (err: SqlError) => { + if (err.code = SqlError.SYNTAX_ERR) { + alert('Error ' + err.message); + } + }, + () => { console.log('Transaction completed successfully'); } +); + +// Vibration plugin +//---------------------------------------------------------------------- +navigator.notification.vibrate(100); \ No newline at end of file diff --git a/cordova/cordova.d.ts b/cordova/cordova.d.ts new file mode 100644 index 0000000000..95be388824 --- /dev/null +++ b/cordova/cordova.d.ts @@ -0,0 +1,60 @@ +// Type definitions for Apache Cordova. +// Project: http://cordova.apache.org +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// +/// + +interface Cordova { + /** Invokes native functionality by specifying corresponding service name, action and optional parameters. + * @param success A success callback function. + * @param fail An error callback function. + * @param service The service name to call on the native side (corresponds to a native class). + * @param action The action name to call on the native side (generally corresponds to the native class method). + * @param args An array of arguments to pass into the native environment. + */ + exec(success: () => any, fail: () => any, service: string, action: string, args?: string[]): void; + /** Gets the operating system name. */ + platformId: string; + /** Gets Cordova framework version */ + version: string; + /** Defines custom logic as a Cordova module. Other modules can later access it using module name provided. */ + define(moduleName: string, factory: (require: any, exports: any, module: any) => any): void; + /** Access a Cordova module by name. */ + require(moduleName: string): any; +} + +// cordova/argscheck module +interface ArgsCheck { + checkArgs(argsSpec: string, functionName: string, args: any[], callee?: any): void; + getValue(value?: any, defaultValue?: any): any; + enableChecks: boolean; +} + +// cordova/urlutil module +interface UrlUtil { + makeAbsolute(url: string): string +} + +/** Apache Cordova instance */ +declare var cordova: Cordova; \ No newline at end of file diff --git a/cordova/plugins/BatteryStatus.d.ts b/cordova/plugins/BatteryStatus.d.ts new file mode 100644 index 0000000000..7343fab494 --- /dev/null +++ b/cordova/plugins/BatteryStatus.d.ts @@ -0,0 +1,125 @@ +// Type definitions for Apache Cordova BatteryStatus plugin. +// Project: https://github.com/apache/cordova-plugin-battery-status +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Window { + onbatterystatus: (type: BatteryStatusEvent) => void; + onbatterycritical: (type: BatteryStatusEvent) => void; + onbatterylow: (type: BatteryStatusEvent) => void; + /** + * Adds a listener for an event from the BatteryStatus plugin. + * @param type the event to listen for + * batterystatus: event fires when the percentage of battery charge + * changes by at least 1 percent, or if the device is plugged in or unplugged. + * batterycritical: event fires when the percentage of battery charge has reached + * the critical battery threshold. The value is device-specific. + * batterylow: event fires when the percentage of battery charge has + * reached the low battery threshold, device-specific value. + * @param listener the function that executes when the event fires. The function is + * passed an BatteryStatusEvent object as a parameter. + */ + addEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; + /** + * Adds a listener for an event from the BatteryStatus plugin. + * @param type the event to listen for + * batterystatus: event fires when the percentage of battery charge + * changes by at least 1 percent, or if the device is plugged in or unplugged. + * batterycritical: event fires when the percentage of battery charge has reached + * the critical battery threshold. The value is device-specific. + * batterylow: event fires when the percentage of battery charge has + * reached the low battery threshold, device-specific value. + * @param listener the function that executes when the event fires. The function is + * passed an BatteryStatusEvent object as a parameter. + */ + addEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; + /** + * Adds a listener for an event from the BatteryStatus plugin. + * @param type the event to listen for + * batterystatus: event fires when the percentage of battery charge + * changes by at least 1 percent, or if the device is plugged in or unplugged. + * batterycritical: event fires when the percentage of battery charge has reached + * the critical battery threshold. The value is device-specific. + * batterylow: event fires when the percentage of battery charge has + * reached the low battery threshold, device-specific value. + * @param listener the function that executes when the event fires. The function is + * passed an BatteryStatusEvent object as a parameter. + */ + addEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; + /** + * Adds a listener for an event from the BatteryStatus plugin. + * @param type the event to listen for + * batterystatus: event fires when the percentage of battery charge + * changes by at least 1 percent, or if the device is plugged in or unplugged. + * batterycritical: event fires when the percentage of battery charge has reached + * the critical battery threshold. The value is device-specific. + * batterylow: event fires when the percentage of battery charge has + * reached the low battery threshold, device-specific value. + * @param listener the function that executes when the event fires. The function is + * passed an BatteryStatusEvent object as a parameter. + */ + addEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void; + /** + * Removes a listener for an event from the BatteryStatus plugin. + * @param type The event to stop listening for. + * batterystatus: event fires when the percentage of battery charge + * changes by at least 1 percent, or if the device is plugged in or unplugged. + * batterycritical: event fires when the percentage of battery charge has reached + * the critical battery threshold. The value is device-specific. + * batterylow: event fires when the percentage of battery charge has + * reached the low battery threshold, device-specific value. + * @param callback the function that executes when the event fires. The function is + * passed an BatteryStatusEvent object as a parameter. + */ + removeEventListener(type: "batterystatus", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; + /** + * Removes a listener for an event from the BatteryStatus plugin. + * @param type The event to stop listening for. + * batterystatus: event fires when the percentage of battery charge + * changes by at least 1 percent, or if the device is plugged in or unplugged. + * batterycritical: event fires when the percentage of battery charge has reached + * the critical battery threshold. The value is device-specific. + * batterylow: event fires when the percentage of battery charge has + * reached the low battery threshold, device-specific value. + * @param callback the function that executes when the event fires. The function is + * passed an BatteryStatusEvent object as a parameter. + */ + removeEventListener(type: "batterycritical", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; + /** + * Removes a listener for an event from the BatteryStatus plugin. + * @param type The event to stop listening for. + * batterystatus: event fires when the percentage of battery charge + * changes by at least 1 percent, or if the device is plugged in or unplugged. + * batterycritical: event fires when the percentage of battery charge has reached + * the critical battery threshold. The value is device-specific. + * batterylow: event fires when the percentage of battery charge has + * reached the low battery threshold, device-specific value. + * @param callback the function that executes when the event fires. The function is + * passed an BatteryStatusEvent object as a parameter. + */ + removeEventListener(type: "batterylow", listener: (ev: BatteryStatusEvent) => any, useCapture?: boolean): void; + /** + * Removes a listener for an event from the BatteryStatus plugin. + * @param type The event to stop listening for. + * batterystatus: event fires when the percentage of battery charge + * changes by at least 1 percent, or if the device is plugged in or unplugged. + * batterycritical: event fires when the percentage of battery charge has reached + * the critical battery threshold. The value is device-specific. + * batterylow: event fires when the percentage of battery charge has + * reached the low battery threshold, device-specific value. + * @param callback the function that executes when the event fires. The function is + * passed an BatteryStatusEvent object as a parameter. + */ + removeEventListener(type: string, listener: (ev: Event) => any, useCapture?: boolean): void; +} + +/** Object, that passed into battery event listener */ +interface BatteryStatusEvent extends Event { + /* The percentage of battery charge (0-100). */ + level: number; + /* A boolean that indicates whether the device is plugged in. */ + isPlugged: boolean; +} \ No newline at end of file diff --git a/cordova/plugins/Camera.d.ts b/cordova/plugins/Camera.d.ts new file mode 100644 index 0000000000..eb0c971475 --- /dev/null +++ b/cordova/plugins/Camera.d.ts @@ -0,0 +1,167 @@ +// Type definitions for Apache Cordova Camera plugin. +// Project: https://github.com/apache/cordova-plugin-camera +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + /** + * This plugin provides an API for taking pictures and for choosing images from the system's image library. + */ + camera: Camera; +} + +/** + * This plugin provides an API for taking pictures and for choosing images from the system's image library. + */ +interface Camera { + /** + * Removes intermediate photos taken by the camera from temporary storage. + * @param onSuccess Success callback, that called when cleanup succeeds. + * @param onError Error callback, that get an error message. + */ + cleanup( + onSuccess: () => void, + onError: (message: string) => void): void; + /** + * Takes a photo using the camera, or retrieves a photo from the device's image gallery. + * @param cameraSuccess Success callback, that get the image + * as a base64-encoded String, or as the URI for the image file. + * @param cameraError Error callback, that get an error message. + * @param cameraOptions Optional parameters to customize the camera settings. + */ + getPicture( + cameraSuccess: (data: string) => void, + cameraError: (message: string) => void, + cameraOptions?: CameraOptions): void; + // Next will work only on iOS + //getPicture( + // cameraSuccess: (data: string) => void, + // cameraError: (message: string) => void, + // cameraOptions?: CameraOptions): CameraPopoverHandle; +} + +interface CameraOptions { + /** Picture quality in range o-100 */ + quality?: number; + /** + * Choose the format of the return value. + * Defined in navigator.camera.DestinationType + * DATA_URL : 0, Return image as base64-encoded string + * FILE_URI : 1, Return image file URI + * NATIVE_URI : 2 Return image native URI + * (e.g., assets-library:// on iOS or content:// on Android) + */ + destinationType?: number; + /** + * Set the source of the picture. Defined in navigator.camera.PictureSourceType + * PHOTOLIBRARY : 0, + * CAMERA : 1, + * SAVEDPHOTOALBUM : 2 + */ + sourceType?: number; + /** Allow simple editing of image before selection. */ + allowEdit?: boolean; + /** + * Choose the returned image file's encoding. Defined in navigator.camera.EncodingType + * JPEG : 0 Return JPEG encoded image + * PNG : 1 Return PNG encoded image + */ + encodingType?: number; + /** + * Width in pixels to scale image. Must be used with targetHeight. + * Aspect ratio remains constant. + */ + targetWidth?: number; + /** + * Height in pixels to scale image. Must be used with targetWidth. + * Aspect ratio remains constant. + */ + targetHeight?: number; + /** + * Set the type of media to select from. Only works when PictureSourceType + * is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in nagivator.camera.MediaType + * PICTURE: 0 allow selection of still pictures only. DEFAULT. + * Will return format specified via DestinationType + * VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI + * ALLMEDIA : 2 allow selection from all media types + */ + mediaType?: number; + /** Rotate the image to correct for the orientation of the device during capture. */ + correctOrientation?: boolean; + /** Save the image to the photo album on the device after capture. */ + saveToPhotoAlbum?: boolean; + /** Choose the camera to use (front- or back-facing). Defined in navigator.camera.Direction */ + cameraDirection?: number; + /** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */ + popoverOptions?: CameraPopoverOptions; +} + +/** + * A handle to the popover dialog created by navigator.camera.getPicture. Used on iOS only. + */ +interface CameraPopoverHandle { + /** + * Set the position of the popover. + * @param popoverOptions the CameraPopoverOptions that specify the new position. + */ + setPosition(popoverOptions: CameraPopoverOptions): void; +} + +/** + * iOS-only parameters that specify the anchor element location and arrow direction + * of the popover when selecting images from an iPad's library or album. + */ +interface CameraPopoverOptions { + x: number; + y: number; + width: number; + height: number; + /** + * Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection + * Matches iOS UIPopoverArrowDirection constants. + * ARROW_UP : 1, + * ARROW_DOWN : 2, + * ARROW_LEFT : 4, + * ARROW_RIGHT : 8, + * ARROW_ANY : 15 + */ + arrowDir : number; +} + +declare var Camera: { + // Camera constants, defined in Camera plugin + DestinationType: { + DATA_URL: number; + FILE_URI: number; + NATIVE_URI: number + } + Direction: { + BACK: number; + FRONT: number; + } + EncodingType: { + JPEG: number; + PNG: number; + } + MediaType: { + PICTURE: number; + VIDEO: number; + ALLMEDIA: number; + } + PictureSourceType: { + PHOTOLIBRARY: number; + CAMERA: number; + SAVEDPHOTOALBUM: number; + } + // Used only on iOS + PopoverArrowDirection: { + ARROW_UP: number; + ARROW_DOWN: number; + ARROW_LEFT: number; + ARROW_RIGHT: number; + ARROW_ANY: number; + } +}; \ No newline at end of file diff --git a/cordova/plugins/Contacts.d.ts b/cordova/plugins/Contacts.d.ts new file mode 100644 index 0000000000..a6f7bc0868 --- /dev/null +++ b/cordova/plugins/Contacts.d.ts @@ -0,0 +1,262 @@ +// Type definitions for Apache Cordova Contacts plugin. +// Project: https://github.com/apache/cordova-plugin-contacts +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + /** Provides access to the device contacts database. */ + contacts: Contacts; +} + +interface Contacts { + /** + * The navigator.contacts.create method is synchronous, and returns a new Contact object. + * This method does not retain the Contact object in the device contacts database, + * for which you need to invoke the Contact.save method. + * @param properties Object with contact fields + */ + create(properties?: ContactProperties): Contact; + /** + * The navigator.contacts.find method executes asynchronously, querying the device contacts database + * and returning an array of Contact objects. The resulting objects are passed to the onSuccess + * callback function specified by the onSuccess parameter. + * @param fields The fields parameter specifies the fields to be used as a search qualifier, + * and only those results are passed to the onSuccess callback function. A zero-length fields parameter + * is invalid and results in ContactError.INVALID_ARGUMENT_ERROR. A contactFields value of "*" returns all contact fields. + * @param onSuccess Success callback function invoked with the array of Contact objects returned from the database + * @param onError Error callback function, invoked when an error occurs. + * @param options Search options to filter navigator.contacts. + */ + find(fields: string[], + onSuccess: (contacts: Contact[]) => void, + onError: (error: ContactError) => void, + options?: ContactFindOptions): void; +} + +interface ContactProperties { + /** A globally unique identifier. */ + id?: string; + /** The name of this Contact, suitable for display to end users. */ + displayName?: string; + /** An object containing all components of a persons name. */ + name?: ContactName; + /** A casual name by which to address the contact. */ + nickname?: string; + /** An array of all the contact's phone numbers. */ + phoneNumbers?: ContactField[]; + /** An array of all the contact's email addresses. */ + emails?: ContactField[]; + /** An array of all the contact's addresses. */ + addresses?: ContactAddress[]; + /** An array of all the contact's IM addresses. */ + ims?: ContactField[]; + /** An array of all the contact's organizations. */ + organizations?: ContactOrganization[]; + /** The birthday of the contact. */ + birthday?: Date; + /** A note about the contact. */ + note?: string; + /** An array of the contact's photos. */ + photos?: ContactField[]; + /** An array of all the user-defined categories associated with the contact. */ + categories?: ContactField[]; + /** An array of web pages associated with the contact. */ + urls?: ContactField[]; +} + +/** + * The Contact object represents a user's contact. Contacts can be created, stored, or removed + * from the device contacts database. Contacts can also be retrieved (individually or in bulk) + * from the database by invoking the navigator.contacts.find method. + */ +interface Contact extends ContactProperties { + /** + * Returns a new Contact object that is a deep copy of the calling object, with the id property set to null + */ + clone(): Contact; + /** + * Removes the contact from the device contacts database, otherwise executes an error callback with a ContactError object. + * @param onSuccess Success callback function invoked on success operation. + * @param onError Error callback function, invoked when an error occurs. + */ + remove( + onSuccess: () => void, + onError: (error: Error) => void): void; + /** + * Saves a new contact to the device contacts database, or updates an existing contact if a contact with the same id already exists. + * @param onSuccess Success callback function invoked on success operation with che Contact object. + * @param onError Error callback function, invoked when an error occurs. + */ + save( + onSuccess: (contact: Contact) => void, + onError: (error: Error) => void): void; +} + +declare var Contact: { + /** Constructor of Contact object */ + new(id?: string, + displayName?: string, + name?: ContactName, + nickname?: string, + phoneNumbers?: ContactField[], + emails?: ContactField[], + addresses?: ContactAddress[], + ims?: ContactField[], + organizations?: ContactOrganization[], + birthday?: Date, + note?: string, + photos?: ContactField[], + categories?: ContactField, + urls?: ContactField[]): Contact +}; + +/** The ContactError object is returned to the user through the contactError callback function when an error occurs. */ +interface ContactError { + /** Error code */ + code: number; + /** Error message */ + message: string; +} + +declare var ContactError: { + new(code: number): ContactError; + UNKNOWN_ERROR: number; + INVALID_ARGUMENT_ERROR: number; + TIMEOUT_ERROR: number; + PENDING_OPERATION_ERROR: number; + IO_ERROR: number; + NOT_SUPPORTED_ERROR: number; + PERMISSION_DENIED_ERROR: number +}; + +/** Contains different kinds of information about a Contact object's name. */ +interface ContactName { + /** The complete name of the contact. */ + formatted?: string; + /** The contact's family name. */ + familyName?: string; + /** The contact's given name. */ + givenName?: string; + /** The contact's middle name. */ + middleName?: string; + /** The contact's prefix (example Mr. or Dr.) */ + honorifixPrefix?: string; + /** The contact's suffix (example Esq.). */ + honorifixSuffix?: string; +} + +declare var ContactName: { + /** Constructor for ContactName object */ + new(formatted?: string, + familyName?: string, + givenName?: string, + middleName?: string, + honorifixPrefix?: string, + honorifixSuffix?: string): ContactName +}; + +/** + * The ContactField object is a reusable component that represents contact fields generically. + * Each ContactField object contains a value, type, and pref property. A Contact object stores + * several properties in ContactField[] arrays, such as phone numbers and email addresses. + * + * In most instances, there are no pre-determined values for a ContactField object's type attribute. + * For example, a phone number can specify type values of home, work, mobile, iPhone, + * or any other value that is supported by a particular device platform's contact database. + * However, for the Contact photos field, the type field indicates the format of the returned image: + * url when the value attribute contains a URL to the photo image, or base64 when the value + * 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; +} + +declare var ContactField: { + /** Constructor for ContactField object */ + new(type?: string, + pref?: boolean, + value?: string): ContactField +}; + +/** + * The ContactAddress object stores the properties of a single address of a contact. + * A Contact object may include more than one address in a ContactAddress[] array. + */ +interface ContactAddress { + /** Set to true if this ContactAddress contains the user's preferred value. */ + pref?: boolean; + /** A string indicating what type of field this is, home for example. */ + type?: string; + /** The full address formatted for display. */ + formatted?: string; + /** The full street address. */ + streetAddress?: string; + /** The city or locality. */ + locality?: string; + /** The state or region. */ + region?: string; + /** The zip code or postal code. */ + postalCode?: string; + /** The country name. */ + country?: string; +} + +declare var ContactAddress: { + /** Constructor of ContactAddress object */ + new(pref?: boolean, + type?: string, + formatted?: string, + streetAddress?: string, + locality?: string, + region?: string, + postalCode?: string, + country?: string): ContactAddress +}; + +/** + * The ContactOrganization object stores a contact's organization properties. A Contact object stores + * one or more ContactOrganization objects in an array. + */ +interface ContactOrganization { + /** Set to true if this ContactOrganization contains the user's preferred value. */ + pref?: boolean; + /** A string that indicates what type of field this is, home for example. */ + type?: string; + /** The name of the organization. */ + name?: string; + /** The department the contract works for. */ + department?: string; + /** The contact's title at the organization. */ + title?: string; +} + +declare var ContactOrganization: { + /** Constructor for ContactOrganization object */ + new(pref?: boolean, + type?: string, + name?: string, + department?: string, + title?: string): ContactOrganization +}; + +/** Search options to filter navigator.contacts. */ +interface ContactFindOptions { + /** The search string used to find navigator.contacts. */ + filter?: string; + /** Determines if the find operation returns multiple navigator.contacts. */ + multiple?: boolean; +} + +declare var ContactFindOptions: { + /** Constructor for ContactFindOptions object */ + new(filter?: string, + multiple?: boolean): ContactFindOptions +}; \ No newline at end of file diff --git a/cordova/plugins/Device.d.ts b/cordova/plugins/Device.d.ts new file mode 100644 index 0000000000..8365ee70f6 --- /dev/null +++ b/cordova/plugins/Device.d.ts @@ -0,0 +1,31 @@ +// Type definitions for Apache Cordova Device plugin. +// Project: https://github.com/apache/cordova-plugin-device +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +/** + * This plugin defines a global device object, which describes the device's hardware and software. + * Although the object is in the global scope, it is not available until after the deviceready event. + */ +interface Device { + /** Get the version of Cordova running on the device. */ + cordova: string; + /** + * The device.model returns the name of the device's model or product. The value is set + * by the device manufacturer and may be different across versions of the same product. + */ + model: string; + /** device.name is deprecated as of version 2.3.0. Use device.model instead. */ + name: string; + /** Get the device's operating system name. */ + platform: string; + /** Get the device's Universally Unique Identifier (UUID). */ + uuid: string; + /** Get the operating system version. */ + version: string; +} + +declare var device: Device; \ No newline at end of file diff --git a/cordova/plugins/DeviceMotion.d.ts b/cordova/plugins/DeviceMotion.d.ts new file mode 100644 index 0000000000..a0e8908494 --- /dev/null +++ b/cordova/plugins/DeviceMotion.d.ts @@ -0,0 +1,77 @@ +// Type definitions for Apache Cordova Device Motion plugin. +// Project: https://github.com/apache/cordova-plugin-device-motion +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + /** + * This plugin provides access to the device's accelerometer. The accelerometer is a motion sensor + * that detects the change (delta) in movement relative to the current device orientation, + * in three dimensions along the x, y, and z axis. + */ + accelerometer: Accelerometer; +} + +/** + * This plugin provides access to the device's accelerometer. The accelerometer is a motion sensor + * that detects the change (delta) in movement relative to the current device orientation, + * in three dimensions along the x, y, and z axis. + */ +interface Accelerometer { + /** + * Stop watching the Acceleration referenced by the watchID parameter. + * @param watchID The ID returned by navigator.accelerometer.watchAcceleration. + */ + clearWatch(watchID: WatchHandle): void; + /** + * Get the current acceleration along the x, y, and z axes. + * These acceleration values are returned to the accelerometerSuccess callback function. + * @param accelerometerSuccess Success callback that gets the Acceleration object. + * @param accelerometerError Success callback + */ + getCurrentAcceleration( + accelerometerSuccess: (acceleration: Acceleration) => void, + accelerometerError: () => void): void; + /** + * Retrieves the device's current Acceleration at a regular interval, executing the + * accelerometerSuccess callback function each time. Specify the interval in milliseconds + * via the acceleratorOptions object's frequency parameter. + * The returned watch ID references the accelerometer's watch interval, and can be used + * with navigator.accelerometer.clearWatch to stop watching the accelerometer. + * @param accelerometerSuccess Callback, that called at every time interval and passes an Acceleration object. + * @param accelerometerError Error callback. + * @param accelerometerOptions Object with options for watchAcceleration + */ + watchAcceleration( + accelerometerSuccess: (acceleration: Acceleration) => void, + accelerometerError: () => void, + accelerometerOptions?: AccelerometerOptions): WatchHandle; +} + +/** + * Contains Accelerometer data captured at a specific point in time. Acceleration values include + * the effect of gravity (9.81 m/s^2), so that when a device lies flat and facing up, x, y, and z + * values returned should be 0, 0, and 9.81. + */ +interface Acceleration { + /** Amount of acceleration on the x-axis. (in m/s^2) */ + x: number; + /** Amount of acceleration on the y-axis. (in m/s^2) */ + y: number; + /** Amount of acceleration on the z-axis. (in m/s^2) */ + z: number; + /** Creation timestamp in milliseconds. */ + timestamp: number; +} + +/** Object with options for watchAcceleration */ +interface AccelerometerOptions { + /** How often to retrieve the Acceleration in milliseconds. (Default: 10000) */ + frequency?: number; +} + +/** Abstract type for watch IDs used by Accelerometer. Values of these type are actually `number` at runtime.*/ +interface WatchHandle { } \ No newline at end of file diff --git a/cordova/plugins/DeviceOrientation.d.ts b/cordova/plugins/DeviceOrientation.d.ts new file mode 100644 index 0000000000..effbc06dae --- /dev/null +++ b/cordova/plugins/DeviceOrientation.d.ts @@ -0,0 +1,86 @@ +// Type definitions for Apache Cordova Device Orientation plugin. +// Project: https://github.com/apache/cordova-plugin-device-orientation +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + /** + * This plugin provides access to the device's compass. The compass is a sensor that detects + * the direction or heading that the device is pointed, typically from the top of the device. + * It measures the heading in degrees from 0 to 359.99, where 0 is north. + */ + compass: Compass; +} + +/** + * This plugin provides access to the device's compass. The compass is a sensor that detects + * the direction or heading that the device is pointed, typically from the top of the device. + * It measures the heading in degrees from 0 to 359.99, where 0 is north. + */ +interface Compass { + /** + * Get the current compass heading. The compass heading is returned via a CompassHeading + * object using the onSuccess callback function. + * @param onSuccess Success callback that passes CompassHeading object. + * @param onError Error callback that passes CompassError object. + */ + getCurrentHeading( + onSuccess: (heading: CompassHeading) => void, + onError: (error: CompassError) => void, + options?: CompassOptions): void; + /** + * Gets the device's current heading at a regular interval. Each time the heading is retrieved, + * the headingSuccess callback function is executed. The returned watch ID references the compass + * watch interval. The watch ID can be used with navigator.compass.clearWatch to stop watching + * the navigator.compass. + * @param onSuccess Success callback that passes CompassHeading object. + * @param onError Error callback that passes CompassError object. + * @param options CompassOptions object + */ + watchHeading( + onSuccess: (heading: CompassHeading) => void, + onError: (error: CompassError) => void, + options?: CompassOptions): number; + /** + * Stop watching the compass referenced by the watch ID parameter. + * @param id The ID returned by navigator.compass.watchHeading. + */ + clearWatch(id: number): void; +} + +/** A CompassHeading object is returned to the compassSuccess callback function. */ +interface CompassHeading { + /** The heading in degrees from 0-359.99 at a single moment in time. */ + magneticHeading: number; + /** The heading relative to the geographic North Pole in degrees 0-359.99 at a single moment in time. A negative value indicates that the true heading can't be determined. */ + trueHeading: number; + /** The deviation in degrees between the reported heading and the true heading. */ + headingAccuracy: number; + /** The time at which this heading was determined. */ + timestamp: number; +} + +interface CompassOptions { + filter?: number; + frequency?: number; +} + +/** A CompassError object is returned to the onError callback function when an error occurs. */ +interface CompassError { + /** + * One of the predefined error codes + * CompassError.COMPASS_INTERNAL_ERR + * CompassError.COMPASS_NOT_SUPPORTED + */ + code: number; +} + +declare var CompassError: { + /** Constructor for CompassError object */ + new(code: number): CompassError; + COMPASS_INTERNAL_ERR: number; + COMPASS_NOT_SUPPORTED: number +} \ No newline at end of file diff --git a/cordova/plugins/Dialogs.d.ts b/cordova/plugins/Dialogs.d.ts new file mode 100644 index 0000000000..5e2a7416dc --- /dev/null +++ b/cordova/plugins/Dialogs.d.ts @@ -0,0 +1,66 @@ +// Type definitions for Apache Cordova Dialogs plugin. +// Project: https://github.com/apache/cordova-plugin-dialogs +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + /** This plugin provides access to some native dialog UI elements. */ + notification: Notification +} + +/** This plugin provides access to some native dialog UI elements. */ +interface Notification { + /** + * Shows a custom alert or dialog box. Most Cordova implementations use a native dialog box for this feature, + * but some platforms use the browser's alert function, which is typically less customizable. + * @param message Dialog message. + * @param alertCallback Callback to invoke when alert dialog is dismissed. + * @param title Dialog title, defaults to 'Alert'. + * @param buttonName Button name, defaults to OK. + */ + alert(message: string, + alertCallback: () => void, + title?: string, + buttonName?: string): void; + /** + * The device plays a beep sound. + * @param times The number of times to repeat the beep. + */ + beep(times: number): void; + /** + * Displays a customizable confirmation dialog box. + * @param message Dialog message. + * @param confirmCallback Callback to invoke with index of button pressed (1, 2, or 3) + * or when the dialog is dismissed without a button press (0). + * @param title Dialog title, defaults to Confirm. + * @param buttonLabels Array of strings specifying button labels, defaults to [OK,Cancel]. + */ + confirm(message: string, + confirmCallback: (choice: number) => void, + title?: string, + buttonLabels?: string[]): void; + /** + * Displays a native dialog box that is more customizable than the browser's prompt function. + * @param message Dialog message. + * @param promptCallback Callback to invoke when a button is pressed. + * @param title Dialog title, defaults to "Prompt". + * @param buttonLabels Array of strings specifying button labels, defaults to ["OK","Cancel"]. + * @param defaultText Default textbox input value, default: "". + */ + prompt(message: string, + promptCallback: (result: NotificationPromptResult) => void, + title?: string, + buttonLabels?: string[], + defaultText?: string): void; +} + +/** Object, passed to promptCallback */ +interface NotificationPromptResult { + /** The index of the pressed button. Note that the index uses one-based indexing, so the value is 1, 2, 3, etc. */ + buttonIndex: number; + /** The text entered in the prompt dialog box. */ + input1: string; +} \ No newline at end of file diff --git a/cordova/plugins/FileSystem.d.ts b/cordova/plugins/FileSystem.d.ts new file mode 100644 index 0000000000..4aefa5ecfd --- /dev/null +++ b/cordova/plugins/FileSystem.d.ts @@ -0,0 +1,294 @@ +// Type definitions for Apache Cordova File System plugin. +// Project: https://github.com/apache/cordova-plugin-file +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Window { + /** + * Requests a filesystem in which to store application data. + * @param type Whether the filesystem requested should be persistent, as defined above. Use one of TEMPORARY or PERSISTENT. + * @param size This is an indicator of how much storage space, in bytes, the application expects to need. + * @param successCallback The callback that is called when the user agent provides a filesystem. + * @param errorCallback A callback that is called when errors happen, or when the request to obtain the filesystem is denied. + */ + requestFileSystem( + type: number, + size: number, + successCallback: (fileSystem: FileSystem) => void, + errorCallback?: (fileError: Error) => void): void; + TEMPORARY: number; + PERSISTENT: number; +} + +/** 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. + */ + name: string; + /** The root directory of the file system. */ + root: DirectoryEntry; +} + +/** + * An abstract interface representing entries in a file system, + * 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. */ + isDirectory: boolean; + /** The name of the entry, excluding the path leading to it. */ + name: string; + /** The full absolute path from the root to the entry. */ + fullPath: string; + /** The file system on which the entry resides. */ + fileSystem: FileSystem; + nativeURL: string; + /** + * Look up metadata about this entry. + * @param successCallback A callback that is called with the time of the last modification. + * @param errorCallback A callback that is called when errors happen. + */ + getMetadata( + successCallback: (metadata: Metadata) => void, + errorCallback?: (error: Error) => void): void; + /** + * Move an entry to a different location on the file system. It is an error to try to: + * move a directory inside itself or to any child at any depth;move an entry into its parent if a name different from its current one isn't provided; + * move a file to a path occupied by a directory; + * move a directory to a path occupied by a file; + * move any element to a path occupied by a directory which is not empty. + * A move of a file on top of an existing file must attempt to delete and replace that file. + * A move of a directory on top of an existing empty directory must attempt to delete and replace that directory. + * @param parent The directory to which to move the entry. + * @param newName The new name of the entry. Defaults to the Entry's current name if unspecified. + * @param successCallback A callback that is called with the Entry for the new location. + * @param errorCallback A callback that is called when errors happen. + */ + moveTo(parent: DirectoryEntry, + newName?: string, + successCallback?: (entry: Entry) => void , + errorCallback?: (error: Error) => void ): void; + /** + * Copy an entry to a different location on the file system. It is an error to try to: + * copy a directory inside itself or to any child at any depth; + * copy an entry into its parent if a name different from its current one isn't provided; + * copy a file to a path occupied by a directory; + * copy a directory to a path occupied by a file; + * copy any element to a path occupied by a directory which is not empty. + * A copy of a file on top of an existing file must attempt to delete and replace that file. + * A copy of a directory on top of an existing empty directory must attempt to delete and replace that directory. + * Directory copies are always recursive--that is, they copy all contents of the directory. + * @param parent The directory to which to move the entry. + * @param newName The new name of the entry. Defaults to the Entry's current name if unspecified. + * @param successCallback A callback that is called with the Entry for the new object. + * @param errorCallback A callback that is called when errors happen. + */ + copyTo(parent: DirectoryEntry, + newName?: string, + successCallback?: (entry: Entry) => void , + errorCallback?: (error: Error) => void ): void; + toURL(): string; + /** + * Deletes a file or directory. It is an error to attempt to delete a directory that is not empty. It is an error to attempt to delete the root directory of a filesystem. + * @param successCallback A callback that is called on success. + * @param errorCallback A callback that is called when errors happen. + */ + remove(successCallback: () => void , + errorCallback?: (error: Error) => void ): void; + /** + * Look up the parent DirectoryEntry containing this Entry. If this Entry is the root of its filesystem, its parent is itself. + * @param successCallback A callback that is called with the time of the last modification. + * @param errorCallback A callback that is called when errors happen. + */ + getParent(successCallback: (entry: Entry) => void , + errorCallback?: (error: Error) => void ): void; +} + +/** This interface supplies information about the state of a file or directory. */ +interface Metadata { + /** This is the time at which the file or directory was last modified. */ + modificationTime: Date; + /** The size of the file, in bytes. This must return 0 for directories. */ + size: number; +} + +/** This interface represents a directory on a file system. */ +interface DirectoryEntry extends Entry { + /** + * Creates a new DirectoryReader to read Entries from this Directory. + */ + createReader(): DirectoryReader; + /** + * Creates or looks up a file. + * @param path Either an absolute path or a relative path from this DirectoryEntry + * to the file to be looked up or created. + * It is an error to attempt to create a file whose immediate parent does not yet exist. + * @param options If create and exclusive are both true, and the path already exists, getFile must fail. + * If create is true, the path doesn't exist, and no other error occurs, getFile must create it as a zero-length file and return a corresponding FileEntry. + * If create is not true and the path doesn't exist, getFile must fail. + * If create is not true and the path exists, but is a directory, getFile must fail. + * Otherwise, if no other error occurs, getFile must return a FileEntry corresponding to path. + * @param successCallback A callback that is called to return the File selected or created. + * @param errorCallback A callback that is called when errors happen. + */ + getFile(path: string, options?: Flags, + successCallback?: (entry: FileEntry) => void, + errorCallback?: (error: Error) => void): void; + /** + * Creates or looks up a directory. + * @param path Either an absolute path or a relative path from this DirectoryEntry + * to the directory to be looked up or created. + * It is an error to attempt to create a directory whose immediate parent does not yet exist. + * @param options If create and exclusive are both true and the path already exists, getDirectory must fail. + * If create is true, the path doesn't exist, and no other error occurs, getDirectory must create and return a corresponding DirectoryEntry. + * If create is not true and the path doesn't exist, getDirectory must fail. + * If create is not true and the path exists, but is a file, getDirectory must fail. + * Otherwise, if no other error occurs, getDirectory must return a DirectoryEntry corresponding to path. + * @param successCallback A callback that is called to return the Directory selected or created. + * @param errorCallback A callback that is called when errors happen. + */ + getDirectory(path: string, options?: Flags, + successCallback?: (entry: DirectoryEntry) => void, + errorCallback?: (error: Error) => void): void; + /** + * Deletes a directory and all of its contents, if any. In the event of an error (e.g. trying + * to delete a directory that contains a file that cannot be removed), some of the contents + * of the directory may be deleted. It is an error to attempt to delete the root directory of a filesystem. + * @param successCallback A callback that is called on success. + * @param errorCallback A callback that is called when errors happen. + */ + removeRecursively(successCallback: () => void, + errorCallback?: (error: Error) => void): void; +} + +/** + * This dictionary is used to supply arguments to methods + * that look up or create files or directories. + */ +interface Flags { + /** Used to indicate that the user wants to create a file or directory if it was not previously there. */ + create?: boolean; + /** By itself, exclusive must have no effect. Used with create, it must cause getFile and getDirectory to fail if the target path already exists. */ + exclusive?: boolean; +} + +/** + * This interface lets a user list files and directories in a directory. If there are + * no additions to or deletions from a directory between the first and last call to + * readEntries, and no errors occur, then: + * A series of calls to readEntries must return each entry in the directory exactly once. + * Once all entries have been returned, the next call to readEntries must produce an empty array. + * If not all entries have been returned, the array produced by readEntries must not be empty. + * The entries produced by readEntries must not include the directory itself ["."] or its parent [".."]. + */ +interface DirectoryReader { + /** + * Read the next block of entries from this directory. + * @param successCallback Called once per successful call to readEntries to deliver the next + * previously-unreported set of Entries in the associated Directory. + * If all Entries have already been returned from previous invocations + * of readEntries, successCallback must be called with a zero-length array as an argument. + * @param errorCallback A callback indicating that there was an error reading from the Directory. + */ + readEntries(successCallback: (entries: Entry[]) => void, errorCallback?: (error: Error) => void): void; +} + +/** This interface represents a file on a file system. */ +interface FileEntry extends Entry { + /** + * Creates a new FileWriter associated with the file that this FileEntry represents. + * @param successCallback A callback that is called with the new FileWriter. + * @param errorCallback A callback that is called when errors happen. + */ + createWriter(successCallback: ( + writer: FileWriter) => void, + errorCallback?: (error: Error) => void): void; + /** + * Returns a File that represents the current state of the file that this FileEntry represents. + * @param successCallback A callback that is called with the File. + * @param errorCallback A callback that is called when errors happen. + */ + file(successCallback: (file: File) => void, + errorCallback?: (error: Error) => void): void; +} + +/** + * This interface provides methods to monitor the asynchronous writing of blobs + * to disk using progress events and event handler attributes. + */ +interface FileSaver extends EventTarget { + /** Terminate file operation */ + abort(): void; + /** + * The FileSaver object can be in one of 3 states. The readyState attribute, on getting, + * must return the current state, which must be one of the following values: + * INIT + * WRITING + * DONE + */ + readyState: number; + /** Handler for writestart events. */ + onwritestart: (event: ProgressEvent) => void; + /** Handler for progress events. */ + onprogress: (event: ProgressEvent) => void; + /** Handler for write events. */ + onwrite: (event: ProgressEvent) => void; + /** Handler for abort events. */ + onabort: (event: ProgressEvent) => void; + /** Handler for error events. */ + onerror: (event: ProgressEvent) => void; + /** Handler for writeend events. */ + onwriteend: (event: ProgressEvent) => void; + /** The last error that occurred on the FileSaver. */ + error: Error; +} + +/** + * This interface expands on the FileSaver interface to allow for multiple write + * actions, rather than just saving a single Blob. + */ +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. + */ + 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. + */ + length: number; + /** + * Write the supplied data to the file at position. + * @param {Blob} data The blob to write. + */ + write(data: Blob): void; + /** + * The file position at which the next write will occur. + * @param offset If nonnegative, an absolute byte offset into the file. + * If negative, an offset back from the end of the file. + */ + 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. + * @param size The size to which the length of the file is to be adjusted, measured in bytes. + */ + truncate(size: number): void; +} \ No newline at end of file diff --git a/cordova/plugins/FileTransfer.d.ts b/cordova/plugins/FileTransfer.d.ts new file mode 100644 index 0000000000..e8f1793d9b --- /dev/null +++ b/cordova/plugins/FileTransfer.d.ts @@ -0,0 +1,129 @@ +// Type definitions for Apache Cordova FileTransfer plugin. +// Project: https://github.com/apache/cordova-plugin-file-transfer +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +/// + +/** + * The FileTransfer object provides a way to upload files using an HTTP multi-part POST request, + * and to download files as well. + */ +interface FileTransfer { + /** Called with a ProgressEvent whenever a new chunk of data is transferred. */ + onprogress: Function; + /** + * Sends a file to a server. + * @param fileURL Filesystem URL representing the file on the device. For backwards compatibility, + * this can also be the full path of the file on the device. + * @param server URL of the server to receive the file, as encoded by encodeURI(). + * @param successCallback A callback that is passed a FileUploadResult object. + * @param errorCallback A callback that executes if an error occurs retrieving the FileUploadResult. + * Invoked with a FileTransferError object. + * @param options Optional parameters. + * @param trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates. + * This is useful since Android rejects self-signed security certificates. + * Not recommended for production use. Supported on Android and iOS. + */ + upload( + fileURL: string, + server: string, + successCallback: (result: FileUploadResult) => void, + errorCallback: (error: FileTransferError) => void, + options?: FileUploadOptions, + trustAllHosts?: boolean): void; + /** + * downloads a file from server. + * @param source URL of the server to download the file, as encoded by encodeURI(). + * @param target Filesystem url representing the file on the device. For backwards compatibility, + * this can also be the full path of the file on the device. + * @param successCallback A callback that is passed a FileEntry object. (Function) + * @param errorCallback A callback that executes if an error occurs when retrieving the fileEntry. + * Invoked with a FileTransferError object. + * @param options Optional parameters. + * @param trustAllHosts Optional parameter, defaults to false. If set to true, it accepts all security certificates. + * This is useful since Android rejects self-signed security certificates. + * Not recommended for production use. Supported on Android and iOS. + */ + download( + source: string, + target: string, + successCallback: (fileEntry: FileEntry) => void, + errorCallback: (error: FileTransferError) => void, + options?: FileDownloadOptions, + trustAllHosts?: boolean): void; + /** + * Aborts an in-progress transfer. The onerror callback is passed a FileTransferError object + * which has an error code of FileTransferError.ABORT_ERR. + */ + abort(): void; +} + +declare var FileTransfer: { + new (): FileTransfer; +}; + +/** A FileUploadResult object is passed to the success callback of the FileTransfer object's upload() method. */ +interface FileUploadResult { + /** The number of bytes sent to the server as part of the upload. */ + bytesSent: number; + /** The HTTP response code returned by the server. */ + responseCode: number; + /** The HTTP response returned by the server. */ + response: string; + /** The HTTP response headers by the server. Currently supported on iOS only.*/ + headers: any; +} + +/** Optional parameters for upload method. */ +interface FileUploadOptions { + /** The name of the form element. Defaults to file. */ + fileKey?: string; + /** The file name to use when saving the file on the server. Defaults to image.jpg. */ + fileName?: string; + /** The mime type of the data to upload. Defaults to image/jpeg. */ + mimeType?: string; + /** A set of optional key/value pairs to pass in the HTTP request. */ + params?: Object; + /** Whether to upload the data in chunked streaming mode. Defaults to true. */ + chunkedMode?: boolean; + /** A map of header name/header values. Use an array to specify more than one value. */ + headers?: Object[]; +} + +/** Optional parameters for download method. */ +interface FileDownloadOptions { + /** A map of header name/header values. Use an array to specify more than one value. */ + headers?: Object[]; +} + +/** A FileTransferError object is passed to an error callback when an error occurs. */ +interface FileTransferError { + /** + * One of the predefined error codes listed below. + * FileTransferError.FILE_NOT_FOUND_ERR + * FileTransferError.INVALID_URL_ERR + * FileTransferError.CONNECTION_ERR + * FileTransferError.ABORT_ERR + */ + code: number; + /** URL to the source. */ + source: string; + /** URL to the target. */ + target: string; + /** HTTP status code. This attribute is only available when a response code is received from the HTTP connection. */ + http_status: number; + body: any; +} + +declare var FileTransferError: { + /** Constructor for FileTransferError object */ + new (code?: number, source?: string, target?: string, status?: number, body?: any): FileTransferError; + FILE_NOT_FOUND_ERR: number; + INVALID_URL_ERR: number; + CONNECTION_ERR: number; + ABORT_ERR: number; +} \ No newline at end of file diff --git a/cordova/plugins/Globalization.d.ts b/cordova/plugins/Globalization.d.ts new file mode 100644 index 0000000000..bb9cd2f4ab --- /dev/null +++ b/cordova/plugins/Globalization.d.ts @@ -0,0 +1,255 @@ +// Type definitions for Apache Cordova Globalization plugin. +// Project: https://github.com/apache/cordova-plugin-globalization +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + /** This plugin obtains information and performs operations specific to the user's locale and timezone. */ + globalization: Globalization +} + +/** This plugin obtains information and performs operations specific to the user's locale and timezone. */ +interface Globalization { + /** + * Get the string identifier for the client's current language. + * @param onSuccess Called on success getting the language with a properties object, + * that should have a value property with a String value. + * @param onError Called on error getting the language with a GlobalizationError object. + * The error's expected code is GlobalizationError.UNKNOWN_ERROR. + */ + getPreferredLanguage( + onSuccess: (language: { value: string; }) => void, + onError: (error: GlobalizationError) => void): void; + /** + * Get the string identifier for the client's current locale setting. + * @param onSuccess Called on success getting the locale identifier with a properties object, + * that should have a value property with a String value. + * @param onError Called on error getting the locale identifier with a GlobalizationError object. + * The error's expected code is GlobalizationError.UNKNOWN\_ERROR. + */ + getLocaleName( + onSuccess: (locale: { value: string; }) => void, + onError: (error: GlobalizationError) => void): void; + /** + * Returns a date formatted as a string according to the client's locale and timezone. + * @param date Date to format. + * @param onSuccess Called on success with a properties object, + * that should have a value property with a String value. + * @param onError Called on error with a GlobalizationError object. + * The error's expected code is GlobalizationError.FORMATTING_ERROR. + * @param options Optional format parameters. Default {formatLength:'short', selector:'date and time'} + */ + dateToString( + date: Date, + onSuccess: (date: { value: string; }) => void, + onError: (error: GlobalizationError) => void, + options?: { type?: string; item?: string; }): void; + /** + * Parses a date formatted as a string, according to the client's user preferences + * and calendar using the time zone of the client, and returns the corresponding date object. + * @param dateString String to parse + * @param onSuccess Called on success with GlobalizationDate object + * @param onError Called on error getting the language with a GlobalizationError object. + * The error's expected code is GlobalizationError.PARSING_ERROR. + * @param options Optional parse parameters. Default {formatLength:'short', selector:'date and time'} + */ + stringToDate( + dateString: string, + onSuccess: (date: GlobalizationDate) => void, + onError: (error: GlobalizationError) => void, + options?: { type?: string; item?: string; }): void; + /** + * Returns a pattern string to format and parse dates according to the client's user preferences. + * @param onSuccess Called on success getting pattern with a GlobalizationDatePattern object + * @param onError Called on error getting pattern with a GlobalizationError object. + * The error's expected code is GlobalizationError.PATTERN_ERROR. + * @param options Optional format parameters. Default {formatLength:'short', selector:'date and time'} + */ + getDatePattern( + onSuccess: (datePattern: GlobalizationDatePattern) => void, + onError: (error: GlobalizationError) => void, + options?: { type?: string; item?: string; }): void; + /** + * Returns an array of the names of the months or days of the week, depending on the client's user preferences and calendar. + * @param onSuccess Called on success getting names with a properties object, + * that should have a value property with a String[] value. + * @param onError Called on error getting the language with a GlobalizationError object. + * The error's expected code is GlobalizationError.UNKNOWN_ERROR. + * @param options Optional parameters. Default: {type:'wide', item:'months'} + */ + getDateNames( + onSuccess: (names: { value: string[]; }) => void, + onError: (error: GlobalizationError) => void, + options?: { type?: string; item?: string; }): void; + /** + * Indicates whether daylight savings time is in effect for a given date using the client's time zone and calendar. + * @param {Date} date Date to check + * @param onSuccess Called on success with a properties object, + * that should have a dst property with a boolean value. + * @param onError Called on error with a GlobalizationError object. + * The error's expected code is GlobalizationError.UNKNOWN_ERROR. + */ + isDaylightSavingsTime( + date: Date, + onSuccess: (result: { dst: boolean; }) => void, + onError: (error: GlobalizationError) => void): void; + /** + * Returns the first day of the week according to the client's user preferences and calendar. + * @param onSuccess Called on success with a day object, + * that should have a value property with a number value. + * @param onError Called on error with a GlobalizationError object. + * The error's expected code is GlobalizationError.UNKNOWN_ERROR. + */ + getFirstDayOfWeek( + onSuccess: (day: { value: number; }) => void, + onError: (error: GlobalizationError) => void): void; + /** + * Returns a number formatted as a string according to the client's user preferences. + * @param value Number to format + * @param onSuccess Called on success with a result object, + * that should have a value property with a String value. + * @param onError Called on error with a GlobalizationError object. + * The error's expected code is GlobalizationError.FORMATTING_ERROR. + * @param format Optional format parameters. Default: {type:'decimal'} + */ + nubmerToString( + value: number, + onSuccess: (result: { value: string; }) => void, + onError: (error: GlobalizationError) => void, + format?: { type?: string; }): void; + /** + * Parses a number formatted as a string according to the client's user preferences and returns the corresponding number. + * @param value String to parse + * @param onSuccess Called on success with a result object, + * that should have a value property with a number value. + * @param onError Called on error with a GlobalizationError object. + * The error's expected code is GlobalizationError.FORMATTING_ERROR. + * @param format Optional format parameters. Default: {type:'decimal'} + */ + stringToNumber( + value: string, + onSuccess: (result: { value: number; }) => void, + onError: (error: GlobalizationError) => void, + format?: { type?: string; }): void; + /** + * Returns a pattern string to format and parse numbers according to the client's user preferences. + * @param onSuccess Called on success getting pattern with a GlobalizationNumberPattern object + * @param onError Called on error getting the language with a GlobalizationError object. + * The error's expected code is GlobalizationError.PATTERN_ERROR. + * @param options Optional format parameters. Default {type:'decimal'}. + */ + getNumberPattern( + onSuccess: (result: GlobalizationNumberPattern) => void, + onError: (error: GlobalizationError) => void, + format?: { type?: string; }): void; + /** + * Returns a pattern string to format and parse currency values according to the client's user preferences and ISO 4217 currency code. + * @param currencyCode Should be a String of one of the ISO 4217 currency codes, for example 'USD'. + * @param onSuccess Called on success getting pattern with a GlobalizatioCurrencyPattern object + * @param onError Called on error getting pattern with a GlobalizationError object. + * The error's expected code is GlobalizationError.FORMATTING_ERROR. + * @param options Optional format parameters. Default {type:'decimal'}. + */ + getCurrencyPattern( + currencyCode: string, + onSuccess: (result: GlobalizationCurrencyPattern) => void, + onError: (error: GlobalizationError) => void): void; +} + +/** Date returned by stringToDate */ +interface GlobalizationDate { + /* The four digit year. */ + year: number; + /* The month from (0-11). */ + month: number; + /* The day from (1-31). */ + day: number; + /* The hour from (0-23). */ + hour: number; + /* The minute from (0-59). */ + minute: number; + /* The second from (0-59). */ + second: number; + /* The milliseconds (from 0-999), not available on all platforms. */ + millisecond: number; +} + +/** Pattern to format and parse dates according to the client's user preferences.*/ +interface GlobalizationDatePattern { + /* The date and time pattern to format and parse dates. The patterns follow Unicode Technical Standard #35. */ + pattern: string; + /* The abbreviated name of the time zone on the client. */ + timezone: string; + /* The current difference in seconds between the client's time zone and coordinated universal time. */ + utc_offset: number; + /* The current daylight saving time offset in seconds between the client's non-daylight saving's time zone and the client's daylight saving's time zone. */ + dst_offset: number; +} + +interface GlobalizationDateNameOptions { + type?: string; + item?: string; +} + +/** Pattern to format and parse numbers according to the client's user preferences. */ +interface GlobalizationNumberPattern { + /* The number pattern to format and parse numbers. The patterns follow Unicode Technical Standard #35. */ + pattern: string; + /* The symbol to use when formatting and parsing, such as a percent or currency symbol. */ + symbol: string; + /* The number of fractional digits to use when parsing and formatting numbers. */ + fraction: number; + /* The rounding increment to use when parsing and formatting. */ + rounding: number; + /* The symbol to use for positive numbers when parsing and formatting. */ + positive: string; + /* The symbol to use for negative numbers when parsing and formatting. */ + negative: string; + /* The decimal symbol to use for parsing and formatting. */ + decimal: string; + /* The grouping symbol to use for parsing and formatting. */ + grouping: string; +} + +/** + * Pattern to format and parse currency values according + * to the client's user preferences and ISO 4217 currency code. + */ +interface GlobalizationCurrencyPattern { + /** The currency pattern to format and parse currency values. The patterns follow Unicode Technical Standard #35. */ + pattern: string; + /** The ISO 4217 currency code for the pattern. */ + code: string; + /** The number of fractional digits to use when parsing and formatting currency. */ + fraction: number; + /** The rounding increment to use when parsing and formatting. */ + rounding: number; + /** The decimal symbol to use for parsing and formatting. */ + decimal: string; + /** The grouping symbol to use for parsing and formatting. */ + grouping: string; +} + +/** An object representing a error from the Globalization API. */ +interface GlobalizationError { + /** One of the following codes representing the error type: + * GlobalizationError.UNKNOWN_ERROR: 0 + * GlobalizationError.FORMATTING_ERROR: 1 + * GlobalizationError.PARSING_ERROR: 2 + * GlobalizationError.PATTERN_ERROR: 3 + */ + code: number; + /** A text message that includes the error's explanation and/or details */ + message: string; +} + +/** An object representing a error from the Globalization API. */ +declare var GlobalizationError: { + UNKNOWN_ERROR: number; + FORMATTING_ERROR: number; + PARSING_ERROR: number; + PATTERN_ERROR: number; +} \ No newline at end of file diff --git a/cordova/plugins/InAppBrowser.d.ts b/cordova/plugins/InAppBrowser.d.ts new file mode 100644 index 0000000000..882a7cfb3b --- /dev/null +++ b/cordova/plugins/InAppBrowser.d.ts @@ -0,0 +1,219 @@ +// Type definitions for Apache Cordova InAppBrowser plugin. +// Project: https://github.com/apache/cordova-plugin-inappbrowser +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Window { + /** + * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. + * @param url The URL to load. + * @param target The target in which to load the URL, an optional parameter that defaults to _self. + * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. + * The options string must not contain any blank space, and each feature's + * name/value pairs must be separated by a comma. Feature names are case insensitive. + */ + open(url: string, target?: "_self", options?: string): InAppBrowser; + /** + * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. + * @param url The URL to load. + * @param target The target in which to load the URL, an optional parameter that defaults to _self. + * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. + * The options string must not contain any blank space, and each feature's + * name/value pairs must be separated by a comma. Feature names are case insensitive. + */ + open(url: string, target?: "_blank", options?: string): InAppBrowser; + /** + * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. + * @param url The URL to load. + * @param target The target in which to load the URL, an optional parameter that defaults to _self. + * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. + * The options string must not contain any blank space, and each feature's + * name/value pairs must be separated by a comma. Feature names are case insensitive. + */ + open(url: string, target?: "_system", options?: string): InAppBrowser; + /** + * Opens a URL in a new InAppBrowser instance, the current browser instance, or the system browser. + * @param url The URL to load. + * @param target The target in which to load the URL, an optional parameter that defaults to _self. + * @param options Options for the InAppBrowser. Optional, defaulting to: location=yes. + * The options string must not contain any blank space, and each feature's + * name/value pairs must be separated by a comma. Feature names are case insensitive. + */ + open(url: string, target?: string, options?: string, replace?: boolean): InAppBrowser; +} + +/** + * The object returned from a call to window.open. + * NOTE: The InAppBrowser window behaves like a standard web browser, and can't access Cordova APIs. + */ +interface InAppBrowser extends Window { + onloadstart: (type: InAppBrowserEvent) => void; + onloadstop: (type: InAppBrowserEvent) => void; + onloaderror: (type: InAppBrowserEvent) => void; + onexit: (type: InAppBrowserEvent) => void; + // addEventListener overloads + /** + * Adds a listener for an event from the InAppBrowser. + * @param type the event to listen for + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + addEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void; + /** + * Adds a listener for an event from the InAppBrowser. + * @param type the event to listen for + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + addEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void; + /** + * Adds a listener for an event from the InAppBrowser. + * @param type the event to listen for + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + addEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void; + /** + * Adds a listener for an event from the InAppBrowser. + * @param type the event to listen for + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + addEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void; + /** + * Adds a listener for an event from the InAppBrowser. + * @param type the event to listen for + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + addEventListener(type: string, callback: (event: InAppBrowserEvent) => void): void; + // removeEventListener overloads + /** + * Removes a listener for an event from the InAppBrowser. + * @param type The event to stop listening for. + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + removeEventListener(type: "loadstart", callback: (event: InAppBrowserEvent) => void): void; + /** + * Removes a listener for an event from the InAppBrowser. + * @param type The event to stop listening for. + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + removeEventListener(type: "loadstop", callback: (event: InAppBrowserEvent) => void): void; + /** + * Removes a listener for an event from the InAppBrowser. + * @param type The event to stop listening for. + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + removeEventListener(type: "loaderror", callback: (event: InAppBrowserEvent) => void): void; + /** + * Removes a listener for an event from the InAppBrowser. + * @param type The event to stop listening for. + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + removeEventListener(type: "exit", callback: (event: InAppBrowserEvent) => void): void; + /** + * Removes a listener for an event from the InAppBrowser. + * @param type The event to stop listening for. + * loadstart: event fires when the InAppBrowser starts to load a URL. + * loadstop: event fires when the InAppBrowser finishes loading a URL. + * loaderror: event fires when the InAppBrowser encounters an error when loading a URL. + * exit: event fires when the InAppBrowser window is closed. + * @param callback the function that executes when the event fires. The function is + * passed an InAppBrowserEvent object as a parameter. + */ + removeEventListener(type: string, callback: (event: InAppBrowserEvent) => void): void; + /** Closes the InAppBrowser window. */ + close(): void; + /** + * Displays an InAppBrowser window that was opened hidden. Calling this has no effect + * if the InAppBrowser was already visible. + */ + show(): void; + /** + * Injects JavaScript code into the InAppBrowser window. + * @param script Details of the script to run, specifying either a file or code key. + * @param callback The function that executes after the JavaScript code is injected. + * If the injected script is of type code, the callback executes with + * a single parameter, which is the return value of the script, wrapped in an Array. + * For multi-line scripts, this is the return value of the last statement, + * or the last expression evaluated. + */ + executeScript(script: { code: string }, callback: (result: any) => void): void; + /** + * Injects JavaScript code into the InAppBrowser window. + * @param script Details of the script to run, specifying either a file or code key. + * @param callback The function that executes after the JavaScript code is injected. + * If the injected script is of type code, the callback executes with + * a single parameter, which is the return value of the script, wrapped in an Array. + * For multi-line scripts, this is the return value of the last statement, + * or the last expression evaluated. + */ + executeScript(script: { file: string }, callback: (result: any) => void): void; + /** + * Injects CSS into the InAppBrowser window. + * @param css Details of the script to run, specifying either a file or code key. + * @param callback The function that executes after the CSS is injected. + */ + insertCSS(css: { code: string }, callback: () => void): void; + /** + * Injects CSS into the InAppBrowser window. + * @param css Details of the script to run, specifying either a file or code key. + * @param callback The function that executes after the CSS is injected. + */ + insertCSS(css: { file: string }, callback: () => void): void; +} + +interface InAppBrowserEvent extends Event { + /** the eventname, either loadstart, loadstop, loaderror, or exit. */ + type: string; + /** the URL that was loaded. */ + url: string; + /** the error code, only in the case of loaderror. */ + code: number; + /** the error message, only in the case of loaderror. */ + message: string; +} \ No newline at end of file diff --git a/cordova/plugins/Media.d.ts b/cordova/plugins/Media.d.ts new file mode 100644 index 0000000000..3751152be1 --- /dev/null +++ b/cordova/plugins/Media.d.ts @@ -0,0 +1,86 @@ +// Type definitions for Apache Cordova Media plugin. +// Project: https://github.com/apache/cordova-plugin-media +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +declare var Media: { + new ( + src: string, + mediaSuccess: () => void, + mediaError?: (error: MediaError) => any, + mediaStatus?: (status: number) => void): Media; + //Media statuses + MEDIA_NONE: number; + MEDIA_STARTING: number; + MEDIA_RUNNING: number; + MEDIA_PAUSED: number; + MEDIA_STOPPED: number +}; + +/** + * This plugin provides the ability to record and play back audio files on a device. + * NOTE: The current implementation does not adhere to a W3C specification for media capture, + * and is provided for convenience only. A future implementation will adhere to the latest + * 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. + * @param mediaError The callback to execute if an error occurs. + */ + getCurrentPosition( + mediaSuccess: (position: number) => void, + mediaError?: (error: MediaError) => void): void; + /** Returns the duration of an audio file in seconds. If the duration is unknown, it returns a value of -1. */ + getDuration(): number; + /** Starts or resumes playing an audio file. */ + play(): void; + /** Pauses playing an audio file. */ + pause(): void; + /** + * Releases the underlying operating system's audio resources. This is particularly important + * for Android, since there are a finite amount of OpenCore instances for media playback. + * Applications should call the release function for any Media resource that is no longer needed. + */ + release(): void; + /** + * Sets the current position within an audio file. + * @param position Position in milliseconds. + */ + seekTo(position: number): void; + /** + * Set the volume for an audio file. + * @param volume The volume to set for playback. The value must be within the range of 0.0 to 1.0. + */ + setVolume(volume: number): void; + /** Starts recording an audio file. */ + startRecord(): void; + /** Stops recording an audio file. */ + stopRecord(): void; + /** Stops playing an audio file. */ + stop(): void; + /** + * The position within the audio playback, in seconds. + * Not automatically updated during play; call getCurrentPosition to update. + */ + position: number; + /** The duration of the media, in seconds. */ + duration: number; +} diff --git a/cordova/plugins/MediaCapture.d.ts b/cordova/plugins/MediaCapture.d.ts new file mode 100644 index 0000000000..f4818b2641 --- /dev/null +++ b/cordova/plugins/MediaCapture.d.ts @@ -0,0 +1,167 @@ +// Type definitions for Apache Cordova MediaCapture plugin. +// Project: https://github.com/apache/cordova-plugin-media-capture +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + device: Device; +} + +interface Device { + capture: Capture; +} + +/** This plugin provides access to the device's audio, image, and video capture capabilities. */ +interface Capture { + /** + * Start the audio recorder application and return information about captured audio clip files. + * @param onSuccess Executes when the capture operation finishes with an array + * of MediaFile objects describing each captured audio clip file. + * @param onError Executes, if the user terminates the operation before an audio clip is captured, + * with a CaptureError object, featuring the CaptureError.CAPTURE_NO_MEDIA_FILES error code. + * @param options Encapsulates audio capture configuration options. + */ + captureAudio( + onSuccess: (mediaFiles: MediaFile[]) => void, + onError: (error: CaptureError) => void, + options?: AudioOptions): void ; + /** + * Start the camera application and return information about captured image files. + * @param onSuccess Executes when the capture operation finishes with an array + * of MediaFile objects describing each captured image clip file. + * @param onError Executes, if the user terminates the operation before an audio clip is captured, + * with a CaptureError object, featuring the CaptureError.CAPTURE_NO_MEDIA_FILES error code. + * @param options Encapsulates audio capture configuration options. + */ + captureImage( + onSuccess: (mediaFiles: MediaFile[]) => void, + onError: (error: CaptureError) => void, + options?: ImageOptions): void ; + /** + * Start the video recorder application and return information about captured video clip files. + * @param onSuccess Executes when the capture operation finishes with an array + * of MediaFile objects describing each captured video clip file. + * @param onError Executes, if the user terminates the operation before an audio clip is captured, + * with a CaptureError object, featuring the CaptureError.CAPTURE_NO_MEDIA_FILES error code. + * @param options Encapsulates audio capture configuration options. + */ + captureVideo( + onSuccess: (mediaFiles: MediaFile[]) => void, + onError: (error: CaptureError) => void, + options?: VideoOptions): void ; + /** The audio recording formats supported by the device. */ + supportedAudioModes: ConfigurationData[]; + /** The recording image sizes and formats supported by the device. */ + supportedImageModes: ConfigurationData[]; + /** The recording video resolutions and formats supported by the device. */ + supportedVideoModes: ConfigurationData[]; +} + +/** Encapsulates properties of a media capture file. */ +interface MediaFile { + /** The name of the file, without path information. */ + name: string; + /** The full path of the file, including the name. */ + fullPath: string; + /** The file's mime type */ + type: string; + /** The date and time when the file was last modified. */ + lastModifiedDate: Date; + /** The size of the file, in bytes. */ + size: number; + /** + * Retrieves format information about the media capture file. + * @param successCallback Invoked with a MediaFileData object when successful. + * @param errorCallback Invoked if the attempt fails, this function. + */ + getFormatData( + successCallback: (data: MediaFileData) => void, + errorCallback?: () => void): void; +} + +/** Encapsulates format information about a media file. */ +interface MediaFileData { + /** The actual format of the audio and video content. */ + codecs: string; + /** The average bitrate of the content. The value is zero for images. */ + bitrate: number; + /** The height of the image or video in pixels. The value is zero for audio clips. */ + height: number; + /** The width of the image or video in pixels. The value is zero for audio clips. */ + width: number; + /** The length of the video or sound clip in seconds. The value is zero for images. */ + duration: number; +} + +/** Encapsulates the error code resulting from a failed media capture operation. */ +interface CaptureError { + /** + * One of the pre-defined error codes listed below. + * CaptureError.CAPTURE_INTERNAL_ERR + * The camera or microphone failed to capture image or sound. + * CaptureError.CAPTURE_APPLICATION_BUSY + * The camera or audio capture application is currently serving another capture request. + * CaptureError.CAPTURE_INVALID_ARGUMENT + * Invalid use of the API (e.g., the value of limit is less than one). + * CaptureError.CAPTURE_NO_MEDIA_FILES + * The user exits the camera or audio capture application before capturing anything. + * CaptureError.CAPTURE_NOT_SUPPORTED + * The requested capture operation is not supported. + */ + code: number; + message: string; +} + +declare var CaptureError: { + /** Constructor for CaptureError */ + new (code: number, message: string): CaptureError; + CAPTURE_INTERNAL_ERR: number; + CAPTURE_APPLICATION_BUSY: number; + CAPTURE_INVALID_ARGUMENT: number; + CAPTURE_NO_MEDIA_FILES: number; + CAPTURE_NOT_SUPPORTED: number; +} + +/** Encapsulates audio capture configuration options. */ +interface AudioOptions { + /** + * The maximum number of audio clips the device's user can capture in a single + * capture operation. The value must be greater than or equal to 1. + */ + limit?: number; + /** The maximum duration of a audio clip, in seconds. */ + duration?: number; +} + +/** Encapsulates image capture configuration options. */ +interface ImageOptions { + /** + * The maximum number of images the user can capture in a single capture operation. + * The value must be greater than or equal to 1 (defaults to 1). + */ + limit?: number; +} + +/** Encapsulates video capture configuration options. */ +interface VideoOptions { + /** + * The maximum number of video clips the device's user can capture in a single + * capture operation. The value must be greater than or equal to 1. + */ + limit?: number; + /** The maximum duration of a video clip, in seconds. */ + duration?: number; +} + +/** Encapsulates a set of media capture parameters that a device supports. */ +interface ConfigurationData { + /** The ASCII-encoded lowercase string representing the media type. */ + type: string; + /** The height of the image or video in pixels. The value is zero for sound clips. */ + height: number; + /** The width of the image or video in pixels. The value is zero for sound clips. */ + width: number; +} \ No newline at end of file diff --git a/cordova/plugins/NetworkInformation.d.ts b/cordova/plugins/NetworkInformation.d.ts new file mode 100644 index 0000000000..53093284f1 --- /dev/null +++ b/cordova/plugins/NetworkInformation.d.ts @@ -0,0 +1,60 @@ +// Type definitions for Apache Cordova Network Information plugin. +// Project: https://github.com/apache/cordova-plugin-network-information +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + /** + * This plugin provides an implementation of an old version of the Network Information API. + * It provides information about the device's cellular and wifi connection, and whether the device has an internet connection. + */ + connection: Connection; + // see https://github.com/apache/cordova-plugin-network-information/blob/dev/doc/index.md#api-change + // for + network: { + /** + * This plugin provides an implementation of an old version of the Network Information API. + * It provides information about the device's cellular and wifi connection, and whether the device has an internet connection. + */ + connection: Connection + } +} + +interface Document { + addEventListener(type: "online", connectionStateCallback: () => any, useCapture?: boolean): void; + addEventListener(type: "offline", connectionStateCallback: () => any, useCapture?: boolean): void; +} + +/** + * The connection object, exposed via navigator.connection, provides information + * about the device's cellular and wifi connection. + */ +interface Connection { + /** + * This property offers a fast way to determine the device's network connection state, and type of connection. + * One of: + * Connection.UNKNOWN + * Connection.ETHERNET + * Connection.WIFI + * Connection.CELL_2G + * Connection.CELL_3G + * Connection.CELL_4G + * Connection.CELL + * Connection.NONE + */ + type: number +} + +declare var Connection: { + UNKNOWN: number; + ETHERNET: number; + WIFI: number; + CELL_2G: number; + CELL_3G: number; + CELL_4G: number; + CELL: number; + NONE: number; +} \ No newline at end of file diff --git a/cordova/plugins/Push.d.ts b/cordova/plugins/Push.d.ts new file mode 100644 index 0000000000..9b66234867 --- /dev/null +++ b/cordova/plugins/Push.d.ts @@ -0,0 +1,68 @@ +// Type definitions for Apache Cordova Push plugin. +// Project: https://github.com/phonegap-build/PushPlugin +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Window { + plugins: { + /** + * This plugin allows to receive push notifications. The Android implementation uses + * Google's GCM (Google Cloud Messaging) service, + * whereas the iOS version is based on Apple APNS Notifications + */ + pushNotification: PushNotification + } +} + +/** + * This plugin allows to receive push notifications. The Android implementation uses + * Google's GCM (Google Cloud Messaging) service, + * whereas the iOS version is based on Apple APNS Notifications + */ +interface PushNotification { + /** + * Registers as push notification receiver. + * @param successCallback Called when a plugin method returns without error. + * @param errorCallback Called when the plugin returns an error. + * @param registrationOptions Options for registration process. + */ + register( + successCallback: (registrationId: string) => void, + errorCallback: (error: any) => void, + registrationOptions: RegistrationOptions): void; + /** + * Unregisters as push notification receiver. + * @param successCallback Called when a plugin method returns without error. + * @param errorCallback Called when the plugin returns an error. + */ + unregister( + successCallback: (result: any) => void, + errorCallback: (error: any) => void): void; + /** + * Sets the badge count visible when the app is not running. iOS only. + * @param successCallback Called when a plugin method returns without error. + * @param errorCallback Called when the plugin returns an error. + * @param badgeCount An integer indicating what number should show up in the badge. Passing 0 will clear the badge. + */ + setApplicationIconBadgeNumber( + successCallback: (result: any) => void, + errorCallback: (error: any) => void, + badgeCount: number): void; +} + +/** Options for registration process. */ +interface RegistrationOptions { + /** This is the Google project ID you need to obtain by registering your application for GCM. Android only */ + senderID?: string; + /** WP8 only */ + channelName?: string; + /** Callback, that is fired when notification arrived */ + ecb?: string; + badge?: boolean; + sound?: boolean; + alert?: boolean +} + diff --git a/cordova/plugins/Splashscreen.d.ts b/cordova/plugins/Splashscreen.d.ts new file mode 100644 index 0000000000..1d0d8697aa --- /dev/null +++ b/cordova/plugins/Splashscreen.d.ts @@ -0,0 +1,17 @@ +// Type definitions for Apache Cordova Splashscreen plugin. +// Project: https://github.com/apache/cordova-plugin-splashscreen +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Navigator { + /** This plugin displays and hides a splash screen during application launch. */ + splashscreen: { + /** Dismiss the splash screen. */ + hide(): void; + /** Displays the splash screen. */ + show(): void; + } +} \ No newline at end of file diff --git a/cordova/plugins/Vibration.d.ts b/cordova/plugins/Vibration.d.ts new file mode 100644 index 0000000000..240d6ec464 --- /dev/null +++ b/cordova/plugins/Vibration.d.ts @@ -0,0 +1,15 @@ +// Type definitions for Apache Cordova Vibration plugin. +// Project: https://github.com/apache/cordova-plugin-vibration +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Notification { + /** + * Vibrates the device for the specified amount of time. + * @param time Milliseconds to vibrate the device. Ignored on iOS. + */ + vibrate(time: number): void +} \ No newline at end of file diff --git a/cordova/plugins/WebSQL.d.ts b/cordova/plugins/WebSQL.d.ts new file mode 100644 index 0000000000..807dab42a7 --- /dev/null +++ b/cordova/plugins/WebSQL.d.ts @@ -0,0 +1,103 @@ +// Type definitions for Apache Cordova WebSQL plugin. +// Project: https://github.com/sgrebnov/cordova-plugin-websql +// Definitions by: Microsoft Open Technologies, Inc. +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// +// Copyright (c) Microsoft Open Technologies, Inc. +// Licensed under the MIT license. + +interface Window { + /** + * Creates (opens, if exist) database with supplied parameters. + * @param name Database name + * @param version Database version + * @param displayname Database display name + * @param size Size, in bytes + * @param creationCallback Callback, that executed on database creation. Accepts Database object. + */ + openDatabase(name: string, + version: string, + displayname: string, + size: number, + creationCallback?: (database: Database) => void): Database; +} + +interface Database { + /** + * Starts new transaction. + * @param callback Function, that will be called when transaction starts. + * @param errorCallback Called, when Transaction fails. + * @param successCallback Called, when transaction committed. + */ + transaction(callback: (transaction: SqlTransaction) => void, + errorCallback?: (error: SqlError) => void, + successCallback?: () => void): void; + /** + * Starts new transaction. + * @param callback Function, that will be called when transaction starts. + * @param errorCallback Called, when Transaction fails. + * @param successCallback Called, when transaction committed. + */ + readTransaction(callback: (transaction: SqlTransaction) => void, + errorCallback?: (error: SqlError) => void, + successCallback?: () => void): void; + name: string; + version: string; + displayname: string; + size: number; +} + +declare var Database: { + /** Constructor for Database object */ + new(name: string, + version: string, + displayname: string, + size: number, + creationCallback: (database: Database)=> void): Database; +}; + +interface SqlTransaction { + /** + * Executes SQL statement via current transaction. + * @param sql SQL statement to execute. + * @param arguments SQL stetement arguments. + * @param successCallback Called in case of query has been successfully done. + * @param errorCallback Called, when query fails. + */ + executeSql(sql: string, + arguments?: any[], + successCallback?: (transaction: SqlTransaction, resultSet: SqlResultSet) => void, + errorCallback?: (transaction: SqlTransaction, error: SqlError) => void): void; +} + +declare var SqlTransaction: { + new(): SqlTransaction; +}; + +interface SqlResultSet { + insertId: number; + rowsAffected: number; + rows: SqlResultSetRowList; +} + +interface SqlResultSetRowList { + length: number; + item(index: number): Object; +} + +interface SqlError { + code: number; + message: string; +} + +declare var SqlError: { + // Error code constants from http://www.w3.org/TR/webdatabase/#sqlerror + UNKNOWN_ERR: number; + DATABASE_ERR: number; + VERSION_ERR: number; + TOO_LARGE_ERR: number; + QUOTA_ERR: number; + SYNTAX_ERR: number; + CONSTRAINT_ERR: number; + TIMEOUT_ERR: number; +}; \ No newline at end of file From b5fb5ecf07dbe61d81bda07d4ecaaca537f813b1 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Tue, 1 Apr 2014 21:40:57 -0400 Subject: [PATCH 003/225] Fixed up lodash with support for Array, List, Dictionary. Some test cases are still failing, this seems to due to inference of result types, like for use in the accumulator methods (foldl for example). Most of these could be resolved by using the correct generic type. I was trying to avoid this type of fix for the tests. --- lodash/lodash-tests.disabled.ts | 633 +++--- lodash/lodash.d.ts | 3305 ++++++++++++++++++++++++------- 2 files changed, 2899 insertions(+), 1039 deletions(-) diff --git a/lodash/lodash-tests.disabled.ts b/lodash/lodash-tests.disabled.ts index aca0bbdf0b..97c2709405 100644 --- a/lodash/lodash-tests.disabled.ts +++ b/lodash/lodash-tests.disabled.ts @@ -41,16 +41,16 @@ interface IKey { var foodsOrganic: IFoodOrganic[] = [ { name: 'banana', organic: true }, - { name: 'beet', organic: false }, + { name: 'beet', organic: false }, ]; var foodsType: IFoodType[] = [ - { name: 'apple', type: 'fruit' }, + { name: 'apple', type: 'fruit' }, { name: 'banana', type: 'fruit' }, - { name: 'beet', type: 'vegetable' } + { name: 'beet', type: 'vegetable' } ]; var foodsCombined: IFoodCombined[] = [ - { 'name': 'apple', 'organic': false, 'type': 'fruit' }, - { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } + { 'name': 'apple', 'organic': false, 'type': 'fruit' }, + { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } ]; var stoogesQuotes: IStoogesQuote[] = [ @@ -63,24 +63,24 @@ var stoogesAges: IStoogesAge[] = [ ]; var stoogesCombined: IStoogesCombined[] = [ - { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } + { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, + { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } ]; var keys: IKey[] = [ - { 'dir': 'left', 'code': 97 }, - { 'dir': 'right', 'code': 100 } + { 'dir': 'left', 'code': 97 }, + { 'dir': 'right', 'code': 100 } ]; class Dog { - constructor(public name: string) {} + constructor(public name: string) { } public bark() { - console.log('Woof, woof!'); + console.log('Woof, woof!'); } } -var result : any; +var result: any; /************* * Chaining * @@ -89,7 +89,10 @@ result = <_.LoDashWrapper>_('test'); result = <_.LoDashWrapper>_(1); result = <_.LoDashWrapper>_(true); result = <_.LoDashArrayWrapper>_(['test1', 'test2']); -result = <_.LoDashObjectWrapper<_.Dictionary>>_({'key1': 'test1', 'key2': 'test2'}); +// Appears to be a change in the compiler, if the type explicity implements the object indexer. +// Looking at: https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9&referringTitle=Documentation +// "The ‘noimplicitany’ option now warns on the use of the hidden default indexer" +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }); result = <_.LoDashWrapper>_.chain('test'); result = <_.LoDashWrapper>_('test').chain(); @@ -99,8 +102,8 @@ result = <_.LoDashWrapper>_.chain(true); result = <_.LoDashWrapper>_(true).chain(); result = <_.LoDashArrayWrapper>_.chain(['test1', 'test2']); result = <_.LoDashArrayWrapper>_(['test1', 'test2']).chain(); -result = <_.LoDashObjectWrapper<_.Dictionary>>_.chain({'key1': 'test1', 'key2': 'test2'}); -result = <_.LoDashObjectWrapper<_.Dictionary>>_({'key1': 'test1', 'key2': 'test2'}).chain(); +result = <_.LoDashObjectWrapper<_.Dictionary>>_.chain(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).chain(); //Wrapped array shortcut methods result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).concat(5, 6); @@ -116,31 +119,31 @@ result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1, 2, 5, 6); result = <_.LoDashWrapper>_([1, 2, 3, 4]).unshift(5, 6); -result = _.tap([1, 2, 3, 4], function(array) { console.log(array); }); -result = <_.LoDashWrapper>_('test').tap(function(value) { console.log(value); }); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function(array) { console.log(array); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_({'key1': 'test1', 'key2': 'test2'}).tap(function(array) { console.log(array); }); +result = _.tap([1, 2, 3, 4], function (array) { console.log(array); }); +result = <_.LoDashWrapper>_('test').tap(function (value) { console.log(value); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function (array) { console.log(array); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).tap(function (array) { console.log(array); }); result = _('test').toString(); result = _([1, 2, 3]).toString(); -result = _({'key1': 'test1', 'key2': 'test2'}).toString(); +result = _({ 'key1': 'test1', 'key2': 'test2' }).toString(); result = _('test').valueOf(); result = _([1, 2, 3]).valueOf(); -result = <_.Dictionary>_({'key1': 'test1', 'key2': 'test2'}).valueOf(); +result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).valueOf(); result = _('test').value(); result = _([1, 2, 3]).value(); -result = <_.Dictionary>_({'key1': 'test1', 'key2': 'test2'}).value(); +result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).value(); // /************* // * Arrays * // *************/ result = _.compact([0, 1, false, 2, '', 3]); - result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); +result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); - result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); result = _.rest([1, 2, 3]); result = _.rest([1, 2, 3], 2); @@ -160,48 +163,48 @@ result = _.tail([1, 2, 3], (num) => num < 3) result = _.tail(foodsOrganic, 'test') result = _.tail(foodsType, { 'type': 'value' }) -result = _.findIndex(['apple', 'banana', 'beet'], function(f) { - return /^b/.test(f); +result = _.findIndex(['apple', 'banana', 'beet'], function (f) { + return /^b/.test(f); }); result = _.findIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); +result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); -result = _.findLastIndex(['apple', 'banana', 'beet'], function(f: string) { - return /^b/.test(f); +result = _.findLastIndex(['apple', 'banana', 'beet'], function (f: string) { + return /^b/.test(f); }); result = _.findLastIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); +result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); result = _.first([1, 2, 3]); result = _.first([1, 2, 3], 2); -result = _.first([1, 2, 3], function(num) { - return num < 3; +result = _.first([1, 2, 3], function (num) { + return num < 3; }); result = _.first(foodsOrganic, 'organic'); result = _.first(foodsType, { 'type': 'fruit' }); - result = _.head([1, 2, 3]); - result = _.head([1, 2, 3], 2); - result = _.head([1, 2, 3], function(num) { - return num < 3; - }); - result = _.head(foodsOrganic, 'organic'); - result = _.head(foodsType, { 'type': 'fruit' }); +result = _.head([1, 2, 3]); +result = _.head([1, 2, 3], 2); +result = _.head([1, 2, 3], function (num) { + return num < 3; +}); +result = _.head(foodsOrganic, 'organic'); +result = _.head(foodsType, { 'type': 'fruit' }); - result = _.take([1, 2, 3]); - result = _.take([1, 2, 3], 2); - result = _.take([1, 2, 3], (num) => num < 3); - result = _.take(foodsOrganic, 'organic'); - result = _.take(foodsType, { 'type': 'fruit' }); +result = _.take([1, 2, 3]); +result = _.take([1, 2, 3], 2); +result = _.take([1, 2, 3], (num) => num < 3); +result = _.take(foodsOrganic, 'organic'); +result = _.take(foodsType, { 'type': 'fruit' }); result = _.flatten([1, [2], [3, [[4]]]]); result = _.flatten([1, [2], [3, [[4]]]], true); var result: any result = _.flatten(stoogesQuotes, 'quotes'); - result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); - result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); - result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); +result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); +result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); +result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); result = _.indexOf([1, 2, 3, 1, 2, 3], 2); result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); @@ -209,8 +212,8 @@ result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); result = _.initial([1, 2, 3]); result = _.initial([1, 2, 3], 2); -result = _.initial([1, 2, 3], function(num) { - return num > 1; +result = _.initial([1, 2, 3], function (num) { + return num > 1; }); result = _.initial(foodsOrganic, 'organic'); result = _.initial(foodsType, { 'type': 'vegetable' }); @@ -219,8 +222,8 @@ result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.last([1, 2, 3]); result = _.last([1, 2, 3], 2); -result = _.last([1, 2, 3], function(num) { - return num > 1; +result = _.last([1, 2, 3], function (num) { + return num > 1; }); result = _.last(foodsOrganic, 'organic'); result = _.last(foodsType, { 'type': 'vegetable' }); @@ -228,8 +231,8 @@ result = _.last(foodsType, { 'type': 'vegetable' }); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); -result = <{[key: string]: any}>_.zipObject(['moe', 'larry'], [30, 40]); -result = <{[key: string]: any}>_.object(['moe', 'larry'], [30, 40]); +result = <{ [key: string]: any }>_.zipObject(['moe', 'larry'], [30, 40]); +result = <{ [key: string]: any }>_.object(['moe', 'larry'], [30, 40]); result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); @@ -240,39 +243,39 @@ result = _.range(0, -10, -1); result = _.range(1, 4, 0); result = _.range(0); -result = _.remove([1, 2, 3, 4, 5, 6], function(num: number) { return num % 2 == 0; }); +result = _.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; }); result = _.remove(foodsOrganic, 'organic'); -result = _.remove(foodsType, { 'type': 'vegetable'}); +result = _.remove(foodsType, { 'type': 'vegetable' }); result = _.sortedIndex([20, 30, 50], 40); result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); var sortedIndexDict = { - 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } + 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } }; -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return sortedIndexDict.wordToNumber[word]; +result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word) { + return sortedIndexDict.wordToNumber[word]; }); -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return this.wordToNumber[word]; +result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word) { + return this.wordToNumber[word]; }, sortedIndexDict); result = _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.uniq([1, 2, 1, 3, 1]); result = _.uniq([1, 1, 2, 2, 3], true); -result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { - return letter.toLowerCase(); +result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { + return letter.toLowerCase(); }); -result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); -result = <{x: number;}[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); +result = <{ x: number; }[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - result = _.unique([1, 2, 1, 3, 1]); - result = _.unique([1, 1, 2, 2, 3], true); - result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { - return letter.toLowerCase(); - }); - result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - result = <{x: number;}[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +result = _.unique([1, 2, 1, 3, 1]); +result = _.unique([1, 1, 2, 2, 3], true); +result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { + return letter.toLowerCase(); +}); +result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); +result = <{ x: number; }[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); @@ -291,165 +294,165 @@ result = _.contains([1, 2, 3], 1, 2); result = _.contains({ 'name': 'moe', 'age': 40 }, 'moe'); result = _.contains('curly', 'ur'); - result = _.include([1, 2, 3], 1); - result = _.include([1, 2, 3], 1, 2); - result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); - result = _.include('curly', 'ur'); +result = _.include([1, 2, 3], 1); +result = _.include([1, 2, 3], 1, 2); +result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); +result = _.include('curly', 'ur'); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return Math.floor(num); }); +result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return this.floor(num); }, Math); result = <_.Dictionary>_.countBy(['one', 'two', 'three'], 'length'); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function(num) { return Math.floor(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function(num) { return this.floor(num); }, Math); - result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return Math.floor(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return this.floor(num); }, Math); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); result = _.every([true, 1, null, 'yes'], Boolean); result = _.every(stoogesAges, 'age'); result = _.every(stoogesAges, { 'age': 50 }); - result = _.all([true, 1, null, 'yes'], Boolean); - result = _.all(stoogesAges, 'age'); - result = _.all(stoogesAges, { 'age': 50 }); +result = _.all([true, 1, null, 'yes'], Boolean); +result = _.all(stoogesAges, 'age'); +result = _.all(stoogesAges, { 'age': 50 }); -result = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +result = _.filter([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); result = _.filter(foodsCombined, 'organic'); result = _.filter(foodsCombined, { 'type': 'fruit' }); - result = _([1, 2, 3, 4, 5, 6]).filter(function(num) { return num % 2 == 0; }).value(); - result = _(foodsCombined).filter('organic').value(); - result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); +result = _([1, 2, 3, 4, 5, 6]).filter(function (num) { return num % 2 == 0; }).value(); +result = _(foodsCombined).filter('organic').value(); +result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); - result = _.select([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); - result = _.select(foodsCombined, 'organic'); - result = _.select(foodsCombined, { 'type': 'fruit' }); +result = _.select([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); +result = _.select(foodsCombined, 'organic'); +result = _.select(foodsCombined, { 'type': 'fruit' }); - result = _([1, 2, 3, 4, 5, 6]).select(function(num) { return num % 2 == 0; }).value(); - result = _(foodsCombined).select('organic').value(); - result = _(foodsCombined).select({ 'type': 'fruit' }).value(); +result = _([1, 2, 3, 4, 5, 6]).select(function (num) { return num % 2 == 0; }).value(); +result = _(foodsCombined).select('organic').value(); +result = _(foodsCombined).select({ 'type': 'fruit' }).value(); -result = _.find([1, 2, 3, 4], function(num) { - return num % 2 == 0; +result = _.find([1, 2, 3, 4], function (num) { + return num % 2 == 0; }); result = _.find(foodsCombined, { 'type': 'vegetable' }); result = _.find(foodsCombined, 'organic'); - result = _.detect([1, 2, 3, 4], function(num) { - return num % 2 == 0; - }); - result = _.detect(foodsCombined, { 'type': 'vegetable' }); - result = _.detect(foodsCombined, 'organic'); +result = _.detect([1, 2, 3, 4], function (num) { + return num % 2 == 0; +}); +result = _.detect(foodsCombined, { 'type': 'vegetable' }); +result = _.detect(foodsCombined, 'organic'); - result = _.findWhere([1, 2, 3, 4], function(num) { - return num % 2 == 0; - }); - result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); - result = _.findWhere(foodsCombined, 'organic'); +result = _.findWhere([1, 2, 3, 4], function (num) { + return num % 2 == 0; +}); +result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); +result = _.findWhere(foodsCombined, 'organic'); -result = _.findLast([1, 2, 3, 4], function(num) { - return num % 2 == 0; +result = _.findLast([1, 2, 3, 4], function (num) { + return num % 2 == 0; }); result = _.findLast(foodsCombined, { 'type': 'vegetable' }); result = _.findLast(foodsCombined, 'organic'); -result = _.forEach([1, 2, 3], function(num) { console.log(num); }); -result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.forEach([1, 2, 3], function (num) { console.log(num); }); +result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); - result = _.each([1, 2, 3], function(num) { console.log(num); }); - result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.each([1, 2, 3], function (num) { console.log(num); }); +result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); - result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function(num) { console.log(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEach(function(num) { console.log(num); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function (num) { console.log(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); }); - result = <_.LoDashArrayWrapper>_([1, 2, 3]).each(function(num) { console.log(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_({ 'one': 1, 'two': 2, 'three': 3 }).each(function(num) { console.log(num); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3]).each(function (num) { console.log(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).each(function (num) { console.log(num); }); -result = _.forEachRight([1, 2, 3], function(num) { console.log(num); }); -result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.forEachRight([1, 2, 3], function (num) { console.log(num); }); +result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); - result = _.eachRight([1, 2, 3], function(num) { console.log(num); }); - result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); +result = _.eachRight([1, 2, 3], function (num) { console.log(num); }); +result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); - result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEachRight(function(num) { console.log(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_({ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function(num) { console.log(num); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEachRight(function (num) { console.log(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); }); - result = <_.LoDashArrayWrapper>_([1, 2, 3]).eachRight(function(num) { console.log(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_({ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function(num) { console.log(num); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3]).eachRight(function (num) { console.log(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return Math.floor(num); }); +result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return this.floor(num); }, Math); result = <_.Dictionary>_.groupBy(['one', 'two', 'three'], 'length'); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return Math.floor(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return this.floor(num); }, Math); - result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); }); +result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math); +result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); result = <_.Dictionary>_.indexBy(keys, 'dir'); -result = <_.Dictionary>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); -result = <_.Dictionary>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); +result = <_.Dictionary>_.indexBy(keys, function (key) { return String.fromCharCode(key.code); }); +result = <_.Dictionary>_.indexBy(keys, function (key) { this.fromCharCode(key.code); }, String); result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); result = _.invoke([123, 456], String.prototype.split, ''); -result = _.map([1, 2, 3], function(num) { return num * 3; }); -result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); +result = _.map([1, 2, 3], function (num) { return num * 3; }); +result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { return num * 3; }); result = _.map(stoogesAges, 'name'); - result = _([1, 2, 3]).map(function(num) { return num * 3; }).value(); - result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function(num) { return num * 3; }).value(); - result = _(stoogesAges).map('name').value(); +result = _([1, 2, 3]).map(function (num) { return num * 3; }).value(); +result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function (num) { return num * 3; }).value(); +result = _(stoogesAges).map('name').value(); -result = _.collect([1, 2, 3], function(num) { return num * 3; }); -result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); +result = _.collect([1, 2, 3], function (num) { return num * 3; }); +result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { return num * 3; }); result = _.collect(stoogesAges, 'name'); - result = _([1, 2, 3]).collect(function(num) { return num * 3; }).value(); - result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function(num) { return num * 3; }).value(); - result = _(stoogesAges).collect('name').value(); +result = _([1, 2, 3]).collect(function (num) { return num * 3; }).value(); +result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function (num) { return num * 3; }).value(); +result = _(stoogesAges).collect('name').value(); result = _.max([4, 2, 8, 6]); -result = _.max(stoogesAges, function(stooge) { return stooge.age; }); +result = _.max(stoogesAges, function (stooge) { return stooge.age; }); result = _.max(stoogesAges, 'age'); result = _.min([4, 2, 8, 6]); -result = _.min(stoogesAges, function(stooge) { return stooge.age; }); +result = _.min(stoogesAges, function (stooge) { return stooge.age; }); result = _.min(stoogesAges, 'age'); result = _.pluck(stoogesAges, 'name'); -result = _.reduce([1, 2, 3], function(sum: number, num: number) { - return sum + num; +result = _.reduce([1, 2, 3], function (sum: number, num: number) { + return sum + num; }); interface ABC { - a: number; - b: number; - c: number; + a: number; + b: number; + c: number; } -result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.foldl([1, 2, 3], function(sum, num) { - return sum + num; +result = _.foldl([1, 2, 3], function (sum, num) { + return sum + num; }); -result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.inject([1, 2, 3], function(sum, num) { - return sum + num; +result = _.inject([1, 2, 3], function (sum, num) { + return sum + num; }); -result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); -result = _.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); +result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); +result = _.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); -result = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); +result = _.reject([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); result = _.reject(foodsCombined, 'organic'); result = _.reject(foodsCombined, { 'type': 'fruit' }); @@ -465,20 +468,20 @@ result = _.size('curly'); result = _.some([null, 0, 'yes', false], Boolean); result = _.some(foodsCombined, 'organic'); result = _.some(foodsCombined, { 'type': 'meat' }); - + result = _.any([null, 0, 'yes', false], Boolean); result = _.any(foodsCombined, 'organic'); result = _.any(foodsCombined, { 'type': 'meat' }); - -result = _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); -result = _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); + +result = _.sortBy([1, 2, 3], function (num) { return Math.sin(num); }); +result = _.sortBy([1, 2, 3], function (num) { return this.sin(num); }, Math); result = _.sortBy(['banana', 'strawberry', 'apple'], 'length'); -(function(a: number, b: number, c: number, d: number){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +(function (a: number, b: number, c: number, d: number) { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); - + /************* * Functions * *************/ @@ -486,20 +489,20 @@ var saves = ['profile', 'settings']; var asyncSave = (obj: any) => obj.done(); var done: Function; -done = _.after(saves.length, function() { - console.log('Done saving!'); +done = _.after(saves.length, function () { + console.log('Done saving!'); }); -_.forEach(saves, function(type) { - asyncSave({ 'type': type, 'complete': done }); +_.forEach(saves, function (type) { + asyncSave({ 'type': type, 'complete': done }); }); -done = _(saves.length).after(function() { - console.log('Done saving!'); +done = _(saves.length).after(function () { + console.log('Done saving!'); }).value(); -_.forEach(saves, function(type) { - asyncSave({ 'type': type, 'complete': done }); +_.forEach(saves, function (type) { + asyncSave({ 'type': type, 'complete': done }); }); var funcBind = function (greeting: string) { return greeting + ' ' + this.name }; @@ -510,8 +513,8 @@ var funcBind3: () => any = _(funcBind).bind({ 'name': 'moe' }, 'hi').value(); funcBind3(); var view = { - 'label': 'docs', - 'onClick': function() { console.log('clicked ' + this.label); } + 'label': 'docs', + 'onClick': function () { console.log('clicked ' + this.label); } }; view = _.bindAll(view); @@ -521,17 +524,17 @@ view = _(view).bindAll().value(); jQuery('#docs').on('click', view.onClick); var objectBindKey = { - 'name': 'moe', - 'greet': function(greeting: string) { - return greeting + ' ' + this.name; - } + 'name': 'moe', + 'greet': function (greeting: string) { + return greeting + ' ' + this.name; + } }; var funcBindKey: Function = _.bindKey(objectBindKey, 'greet', 'hi'); funcBindKey(); -objectBindKey.greet = function(greeting) { - return greeting + ', ' + this.name + '!'; +objectBindKey.greet = function (greeting) { + return greeting + ', ' + this.name + '!'; }; funcBindKey(); @@ -540,78 +543,78 @@ funcBindKey = _(objectBindKey).bindKey('greet', 'hi').value(); funcBindKey(); var realNameMap = { - 'curly': 'jerome' + 'curly': 'jerome' }; -var format = function(name: string) { - name = realNameMap[name.toLowerCase()] || name; - return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); +var format = function (name: string) { + name = realNameMap[name.toLowerCase()] || name; + return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); }; -var greet = function(formatted: string) { - return 'Hiya ' + formatted + '!'; +var greet = function (formatted: string) { + return 'Hiya ' + formatted + '!'; }; result = _.compose(greet, format); result = <_.LoDashObjectWrapper>_(greet).compose(format); -var createCallbackObj = { name: 'Joe' }; +var createCallbackObj: { [index: string]: string; } = { name: 'Joe' }; result = <() => any>_.createCallback('name'); result = <() => boolean>_.createCallback(createCallbackObj); result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback(); result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback(); -result = _.curry(function(a, b, c) { - console.log(a + b + c); +result = _.curry(function (a, b, c) { + console.log(a + b + c); }); -result = <_.LoDashObjectWrapper>_(function(a, b, c) { - console.log(a + b + c); +result = <_.LoDashObjectWrapper>_(function (a, b, c) { + console.log(a + b + c); }).curry(); declare var source: any; -result = _.debounce(function() {}, 150); +result = _.debounce(function () { }, 150); -jQuery('#postbox').on('click', _.debounce(function() {}, 300, { - 'leading': true, - 'trailing': false +jQuery('#postbox').on('click', _.debounce(function () { }, 300, { + 'leading': true, + 'trailing': false })); -source.addEventListener('message', _.debounce(function() {}, 250, { - 'maxWait': 1000 +source.addEventListener('message', _.debounce(function () { }, 250, { + 'maxWait': 1000 }), false); -result = <_.LoDashObjectWrapper>_(function() {}).debounce(150); +result = <_.LoDashObjectWrapper>_(function () { }).debounce(150); -jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function() {}).debounce(300, { - 'leading': true, - 'trailing': false +jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function () { }).debounce(300, { + 'leading': true, + 'trailing': false })); -source.addEventListener('message', <_.LoDashObjectWrapper>_(function() {}).debounce(250, { - 'maxWait': 1000 +source.addEventListener('message', <_.LoDashObjectWrapper>_(function () { }).debounce(250, { + 'maxWait': 1000 }), false); var returnedDebounce = _.throttle(function (a) { return a * 5; }, 5); returnedThrottled(4); -result = _.defer(function() { console.log('deferred'); }); -result = <_.LoDashWrapper>_(function() { console.log('deferred'); }).defer(); +result = _.defer(function () { console.log('deferred'); }); +result = <_.LoDashWrapper>_(function () { console.log('deferred'); }).defer(); var log = _.bind(console.log, console); result = _.delay(log, 1000, 'logged later'); result = <_.LoDashWrapper>_(log).delay(1000, 'logged later'); -var fibonacci = _.memoize(function(n) { - return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); +var fibonacci = _.memoize(function (n) { + return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); var data = { - 'moe': { 'name': 'moe', 'age': 40 }, - 'curly': { 'name': 'curly', 'age': 60 } + 'moe': { 'name': 'moe', 'age': 40 }, + 'curly': { 'name': 'curly', 'age': 60 } }; -var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity); +var stooge = _.memoize(function (name: string) { return data[name]; }, _.identity); stooge('curly'); stooge['cache']['curly'].name = 'jerome'; @@ -620,21 +623,21 @@ stooge('curly'); var returnedMemoize = _.throttle(function (a) { return a * 5; }, 5); returnedMemoize(4); -var initialize = _.once(function(){ }); +var initialize = _.once(function () { }); initialize(); initialize();'' var returnedOnce = _.throttle(function (a) { return a * 5; }, 5); returnedOnce(4); -var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; }; +var greetPartial = function (greeting: string, name: string) { return greeting + ' ' + name; }; var hi = _.partial(greetPartial, 'hi'); hi('moe'); var defaultsDeep = _.partialRight(_.merge, _.defaults); var optionsPartialRight = { - 'variable': 'data', - 'imports': { 'jq': $ } + 'variable': 'data', + 'imports': { 'jq': $ } }; defaultsDeep(optionsPartialRight, _.templateSettings); @@ -642,16 +645,16 @@ defaultsDeep(optionsPartialRight, _.templateSettings); var throttled = _.throttle(function () { }, 100); jQuery(window).on('scroll', throttled); -jQuery('.interactive').on('click', _.throttle(function() { }, 300000, { - 'trailing': false +jQuery('.interactive').on('click', _.throttle(function () { }, 300000, { + 'trailing': false })); -var returnedThrottled = _.throttle(function (a) { return a*5; }, 5); +var returnedThrottled = _.throttle(function (a) { return a * 5; }, 5); returnedThrottled(4); -var helloWrap = function(name: string) { return 'hello ' + name; }; -var helloWrap2 = _.wrap(helloWrap, function(func) { - return 'before, ' + func('moe') + ', after'; +var helloWrap = function (name: string) { return 'hello ' + name; }; +var helloWrap2 = _.wrap(helloWrap, function (func) { + return 'before, ' + func('moe') + ', after'; }); helloWrap2(); @@ -659,93 +662,93 @@ helloWrap2(); * Objects * ***********/ interface NameAge { - name: string; - age: number; + name: string; + age: number; } result = _.assign({ 'name': 'moe' }, { 'age': 40 }); -result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; +result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function (a, b) { + return typeof a == 'undefined' ? b : a; }); result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function (a, b) { + return typeof a == 'undefined' ? b : a; }); result = _.extend({ 'name': 'moe' }, { 'age': 40 }); -result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; +result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function (a, b) { + return typeof a == 'undefined' ? b : a; }); result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function (a, b) { + return typeof a == 'undefined' ? b : a; }); result = _.clone(stoogesAges); result = _.clone(stoogesAges, true); -result = _.clone(stoogesAges, true, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +result = _.clone(stoogesAges, true, function (value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; }); result = _.cloneDeep(stoogesAges); -result = _.cloneDeep(stoogesAges, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +result = _.cloneDeep(stoogesAges, function (value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; }); interface Food { - name: string; - type: string; + name: string; + type: string; } var foodDefaults = { 'name': 'apple' }; result = _.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' }); - result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); +result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); -result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { - return num % 2 == 0; +result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { + return num % 2 == 0; }); -result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { - return num % 2 == 1; +result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { + return num % 2 == 1; }); -result = _.forIn(new Dog('Dagny'), function(value, key) { - console.log(key); +result = _.forIn(new Dog('Dagny'), function (value, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function(value, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function (value, key) { + console.log(key); }); -result = _.forInRight(new Dog('Dagny'), function(value, key) { - console.log(key); +result = _.forInRight(new Dog('Dagny'), function (value, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function(value, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function (value, key) { + console.log(key); }); interface ZeroOne { - 0: string; - 1: string; - one: string; + 0: string; + 1: string; + one: string; } -result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - console.log(key); +result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function (num, key) { + console.log(key); }); - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function(num, key) { - console.log(key); - }); - -result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function (num, key) { + console.log(key); }); - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function(num, key) { - console.log(key); - }); +result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function (num, key) { + console.log(key); +}); + +result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function (num, key) { + console.log(key); +}); result = _.functions(_); result = _.methods(_); @@ -756,12 +759,12 @@ result = <_.LoDashArrayWrapper>_(_).methods(); result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); interface FirstSecond { - first: string; - second: string; + first: string; + second: string; } result = _.invert({ 'first': 'moe', 'second': 'larry' }); -(function(...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); +(function (...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); (function () { return _.isArray(arguments); })(); result = _.isArray([1, 2, 3]); @@ -784,12 +787,12 @@ result = _.isEqual(moe, copy); var words = ['hello', 'goodbye']; var otherWords = ['hi', 'goodbye']; -result = _.isEqual(words, otherWords, function(a, b) { - var reGreet = /^(?:hello|hi)$/i, - aGreet = _.isString(a) && reGreet.test(a), - bGreet = _.isString(b) && reGreet.test(b); +result = _.isEqual(words, otherWords, function (a, b) { + var reGreet = /^(?:hello|hi)$/i, + aGreet = _.isString(a) && reGreet.test(a), + bGreet = _.isString(b) && reGreet.test(b); - return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; + return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; }); result = _.isFinite(-101); @@ -817,7 +820,7 @@ class Stooge { constructor( public name: string, public age: number - ) {} + ) { } } result = _.isPlainObject(new Stooge('moe', 40)); @@ -833,67 +836,67 @@ result = _.isUndefined(void 0); result = _.keys({ 'one': 1, 'two': 2, 'three': 3 }); var mergeNames = { - 'stooges': [ - { 'name': 'moe' }, - { 'name': 'larry' } - ] + 'stooges': [ + { 'name': 'moe' }, + { 'name': 'larry' } + ] }; var mergeAges = { - 'stooges': [ - { 'age': 40 }, - { 'age': 50 } - ] + 'stooges': [ + { 'age': 40 }, + { 'age': 50 } + ] }; result = _.merge(mergeNames, mergeAges); var mergeFood = { - 'fruits': ['apple'], - 'vegetables': ['beet'] + 'fruits': ['apple'], + 'vegetables': ['beet'] }; var mergeOtherFood = { - 'fruits': ['banana'], - 'vegetables': ['carrot'] + 'fruits': ['banana'], + 'vegetables': ['carrot'] }; interface FruitVeg { - fruits: string[]; - vegetables: string[] + fruits: string[]; + vegetables: string[] }; -result = _.merge(mergeFood, mergeOtherFood, function(a, b) { - return _.isArray(a) ? a.concat(b) : undefined; +result = _.merge(mergeFood, mergeOtherFood, function (a, b) { + return _.isArray(a) ? a.concat(b) : undefined; }); interface HasName { - name: string; + name: string; } result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); -result = _.omit({ 'name': 'moe', 'age': 40 }, function(value) { - return typeof value == 'number'; +result = _.omit({ 'name': 'moe', 'age': 40 }, function (value) { + return typeof value == 'number'; }); result = _.pairs({ 'moe': 30, 'larry': 40 }); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { - return key.charAt(0) != '_'; +result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function (value, key) { + return key.charAt(0) != '_'; }); -result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r, num) { - num *= num; - if (num % 2) { - return r.push(num) < 3; - } +result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function (r, num) { + num *= num; + if (num % 2) { + return r.push(num) < 3; + } }); // → [1, 9, 25] -result = <{a:number;b:number;c:number;}>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r, num, key) { - r[key] = num * 3; +result = <{ a: number; b: number; c: number; }>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function (r, num, key) { + r[key] = num * 3; }); result = _.values({ 'one': 1, 'two': 2, 'three': 3 }); @@ -907,9 +910,9 @@ result = _.escape('Moe, Larry & Curly'); result = <{ name: string }>_.identity({ 'name': 'moe' }); _.mixin({ - 'capitalize': function(string) { - return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - } + 'capitalize': function (string) { + return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + } }); var lodash = _.noConflict(); @@ -923,10 +926,10 @@ result = _.random(1.2, 5.2); result = _.random(0, 5, true); var object = { - 'cheese': 'crumpets', - 'stuff': function() { - return 'nonsense'; - } + 'cheese': 'crumpets', + 'stuff': function () { + return 'nonsense'; + } }; result = _.result(object, 'cheese'); @@ -960,10 +963,10 @@ class Mage { } } -var mage = new Mage(); +var mage = new Mage(); result = _.times(3, <() => number>_.partial(_.random, 1, 6)); -result = _.times(3, function(n: number) { mage.castSpell(n); }); -result = _.times(3, function(n: number) { this.cast(n); }, mage); +result = _.times(3, function (n: number) { mage.castSpell(n); }); +result = _.times(3, function (n: number) { this.cast(n); }, mage); result = _.unescape('Moe, Larry & Curly'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index b48f7e6034..3c4b572c15 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -181,15 +181,15 @@ declare module _ { **/ valueOf(): T; - /** - * @see valueOf - **/ - value(): T; - } + /** + * @see valueOf + **/ + value(): T; + } - interface LoDashWrapper extends LoDashWrapperBase> {} + interface LoDashWrapper extends LoDashWrapperBase> { } - interface LoDashObjectWrapper extends LoDashWrapperBase> {} + interface LoDashObjectWrapper extends LoDashWrapperBase> { } interface LoDashArrayWrapper extends LoDashWrapperBase> { concat(...items: T[]): LoDashArrayWrapper; @@ -263,6 +263,11 @@ declare module _ { * @param array Array to compact. * @return (Array) Returns a new array of filtered values. **/ + compact(array: Array): T[]; + + /** + * @see _.compact + **/ compact(array: List): T[]; } @@ -270,8 +275,8 @@ declare module _ { /** * @see _.compact **/ - compact(): LoDashArrayWrapper; - } + compact(): LoDashArrayWrapper; + } //_.difference interface LoDashStatic { @@ -282,6 +287,12 @@ declare module _ { * @param others The arrays of values to exclude. * @return Returns a new array of filtered values. **/ + difference( + array: Array, + ...others: Array[]): T[]; + /** + * @see _.difference + **/ difference( array: List, ...others: List[]): T[]; @@ -291,6 +302,11 @@ declare module _ { /** * @see _.difference **/ + difference( + ...others: Array[]): LoDashArrayWrapper; + /** + * @see _.difference + **/ difference( ...others: List[]): LoDashArrayWrapper; } @@ -307,7 +323,7 @@ declare module _ { * @return Returns the index of the found element, else -1. **/ findIndex( - array: List, + array: Array, callback: ListIterator, thisArg?: any): number; @@ -316,8 +332,30 @@ declare module _ { **/ findIndex( array: List, + callback: ListIterator, + thisArg?: any): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: Array, pluckValue: string): number; - + + /** + * @see _.findIndex + **/ + findIndex( + array: List, + pluckValue: string): number; + + /** + * @see _.findIndex + **/ + findIndex( + array: Array, + whereDictionary: W): number; + /** * @see _.findIndex **/ @@ -336,18 +374,40 @@ declare module _ { * @param thisArg The this binding of callback. * @return Returns the index of the found element, else -1. **/ + findLastIndex( + array: Array, + callback: ListIterator, + thisArg?: any): number; + + /** + * @see _.findLastIndex + **/ findLastIndex( array: List, callback: ListIterator, thisArg?: any): number; - + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: Array, + pluckValue: string): number; + /** * @see _.findLastIndex **/ findLastIndex( array: List, pluckValue: string): number; - + + /** + * @see _.findLastIndex + **/ + findLastIndex( + array: Array, + whereDictionary: Dictionary): number; + /** * @see _.findLastIndex **/ @@ -372,8 +432,21 @@ declare module _ { * @param array Retrieves the first element of this array. * @return Returns the first element of `array`. **/ + first(array: Array): T; + + /** + * @see _.first + **/ first(array: List): T; + /** + * @see _.first + * @param n The number of elements to return. + **/ + first( + array: Array, + n: number): T[]; + /** * @see _.first * @param n The number of elements to return. @@ -382,6 +455,16 @@ declare module _ { array: List, n: number): T[]; + /** + * @see _.first + * @param callback The function called per element. + * @param [thisArg] The this binding of callback. + **/ + first( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + /** * @see _.first * @param callback The function called per element. @@ -392,6 +475,14 @@ declare module _ { callback: ListIterator, thisArg?: any): T[]; + /** + * @see _.first + * @param pluckValue "_.pluck" style callback value + **/ + first( + array: Array, + pluckValue: string): T[]; + /** * @see _.first * @param pluckValue "_.pluck" style callback value @@ -400,6 +491,14 @@ declare module _ { array: List, pluckValue: string): T[]; + /** + * @see _.first + * @param whereValue "_.where" style callback value + **/ + first( + array: Array, + whereValue: W): T[]; + /** * @see _.first * @param whereValue "_.where" style callback value @@ -408,73 +507,141 @@ declare module _ { array: List, whereValue: W): T[]; - /** - * @see _.first - **/ - head(array: List): T; + /** + * @see _.first + **/ + head(array: Array): T; - /** - * @see _.first - **/ - head( - array: List, - n: number): T[]; + /** + * @see _.first + **/ + head(array: List): T; - /** - * @see _.first - **/ - head( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.first + **/ + head( + array: Array, + n: number): T[]; - /** - * @see _.first - **/ - head( - array: List, - pluckValue: string): T[]; + /** + * @see _.first + **/ + head( + array: List, + n: number): T[]; - /** - * @see _.first - **/ - head( - array: List, - whereValue: W): T[]; + /** + * @see _.first + **/ + head( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.first - **/ - take(array: List): T; + /** + * @see _.first + **/ + head( + array: List, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.first - **/ - take( - array: List, - n: number): T[]; + /** + * @see _.first + **/ + head( + array: Array, + pluckValue: string): T[]; - /** - * @see _.first - **/ - take( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.first + **/ + head( + array: List, + pluckValue: string): T[]; - /** - * @see _.first - **/ - take( - array: List, - pluckValue: string): T[]; + /** + * @see _.first + **/ + head( + array: Array, + whereValue: W): T[]; - /** - * @see _.first - **/ - take( - array: List, - whereValue: W): T[]; + /** + * @see _.first + **/ + head( + array: List, + whereValue: W): T[]; + + /** + * @see _.first + **/ + take(array: Array): T; + + /** + * @see _.first + **/ + take(array: List): T; + + /** + * @see _.first + **/ + take( + array: Array, + n: number): T[]; + + /** + * @see _.first + **/ + take( + array: List, + n: number): T[]; + + /** + * @see _.first + **/ + take( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + **/ + take( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.first + **/ + take( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.first + **/ + take( + array: List, + pluckValue: string): T[]; + + /** + * @see _.first + **/ + take( + array: Array, + whereValue: W): T[]; + + /** + * @see _.first + **/ + take( + array: List, + whereValue: W): T[]; } //_.flatten @@ -494,65 +661,153 @@ declare module _ { * @param shallow If true then only flatten one level, optional, default = false. * @return `array` flattened. **/ + flatten(array: Array, isShallow?: boolean): T[]; + + /** + * @see _.flatten + **/ flatten(array: List, isShallow?: boolean): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + isShallow: boolean, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, isShallow: boolean, callback: ListIterator, - thisArg?: any): T[]; + thisArg?: any): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, callback: ListIterator, - thisArg?: any): T[]; + thisArg?: any): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + isShallow: boolean, + whereValue: W): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, isShallow: boolean, - whereValue: W): T[]; + whereValue: W): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + whereValue: W): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, - whereValue: W): T[]; + whereValue: W): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + isShallow: boolean, + pluckValue: string): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, isShallow: boolean, - pluckValue: string): T[]; + pluckValue: string): T[]; + /** + * @see _.flatten + **/ + flatten( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.flatten + **/ flatten( array: List, - pluckValue: string): T[]; + pluckValue: string): T[]; } interface LoDashArrayWrapper { /** * @see _.flatten **/ - flatten(isShallow?: boolean): LoDashArrayWrapper; + flatten(isShallow?: boolean): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( isShallow: boolean, callback: ListIterator, thisArg?: any): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( callback: ListIterator, thisArg?: any): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( isShallow: boolean, pluckValue: string): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( pluckValue: string): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( isShallow: boolean, whereValue: W): LoDashArrayWrapper; - flatten( + /** + * @see _.flatten + **/ + flatten( whereValue: W): LoDashArrayWrapper; } @@ -567,10 +822,26 @@ declare module _ { * @param fromIndex The index to search from. * @return The index of `value` within `array`. **/ + indexOf( + array: Array, + value: T): number; + + /** + * @see _.indexOf + **/ indexOf( array: List, value: T): number; + /** + * @see _.indexOf + * @param fromIndex The index to search from + **/ + indexOf( + array: Array, + value: T, + fromIndex: number): number; + /** * @see _.indexOf * @param fromIndex The index to search from @@ -580,6 +851,15 @@ declare module _ { value: T, fromIndex: number): number; + /** + * @see _.indexOf + * @param isSorted True to perform a binary search on a sorted array. + **/ + indexOf( + array: Array, + value: T, + isSorted: boolean): number; + /** * @see _.indexOf * @param isSorted True to perform a binary search on a sorted array. @@ -607,9 +887,23 @@ declare module _ { * @param n Leaves this many elements behind, optional. * @return Returns everything but the last `n` elements of `array`. **/ + initial( + array: Array): T[]; + + /** + * @see _.initial + **/ initial( array: List): T[]; + /** + * @see _.initial + * @param n The number of elements to exclude. + **/ + initial( + array: Array, + n: number): T[]; + /** * @see _.initial * @param n The number of elements to exclude. @@ -618,6 +912,14 @@ declare module _ { array: List, n: number): T[]; + /** + * @see _.initial + * @param callback The function called per element + **/ + initial( + array: Array, + callback: ListIterator): T[]; + /** * @see _.initial * @param callback The function called per element @@ -626,6 +928,14 @@ declare module _ { array: List, callback: ListIterator): T[]; + /** + * @see _.initial + * @param pluckValue _.pluck style callback + **/ + initial( + array: Array, + pluckValue: string): T[]; + /** * @see _.initial * @param pluckValue _.pluck style callback @@ -634,6 +944,14 @@ declare module _ { array: List, pluckValue: string): T[]; + /** + * @see _.initial + * @param whereValue _.where style callback + **/ + initial( + array: Array, + whereValue: W): T[]; + /** * @see _.initial * @param whereValue _.where style callback @@ -651,6 +969,11 @@ declare module _ { * @param arrays The arrays to inspect. * @return Returns an array of composite values. **/ + intersection(...arrays: Array[]): T[]; + + /** + * @see _.intersection + **/ intersection(...arrays: List[]): T[]; } @@ -669,8 +992,21 @@ declare module _ { * @param array The array to query. * @return Returns the last element(s) of array. **/ + last(array: Array): T; + + /** + * @see _.last + **/ last(array: List): T; + /** + * @see _.last + * @param n The number of elements to return + **/ + last( + array: Array, + n: number): T[]; + /** * @see _.last * @param n The number of elements to return @@ -679,6 +1015,15 @@ declare module _ { array: List, n: number): T[]; + /** + * @see _.last + * @param callback The function called per element + **/ + last( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + /** * @see _.last * @param callback The function called per element @@ -688,6 +1033,14 @@ declare module _ { callback: ListIterator, thisArg?: any): T[]; + /** + * @see _.last + * @param pluckValue _.pluck style callback + **/ + last( + array: Array, + pluckValue: string): T[]; + /** * @see _.last * @param pluckValue _.pluck style callback @@ -696,6 +1049,14 @@ declare module _ { array: List, pluckValue: string): T[]; + /** + * @see _.last + * @param whereValue _.where style callback + **/ + last( + array: Array, + whereValue: W): T[]; + /** * @see _.last * @param whereValue _.where style callback @@ -716,12 +1077,20 @@ declare module _ { * @param fromIndex The index to search from. * @return The index of the matched value or -1. **/ + lastIndexOf( + array: Array, + value: T, + fromIndex?: number): number; + + /** + * @see _.lastIndexOf + **/ lastIndexOf( array: List, value: T, fromIndex?: number): number; } - + //_.pull interface LoDashStatic { /** @@ -731,6 +1100,13 @@ declare module _ { * @param values The values to remove. * @return array. **/ + pull( + array: Array, + ...values: any[]): any[]; + + /** + * @see _.pull + **/ pull( array: List, ...values: any[]): any[]; @@ -747,12 +1123,11 @@ declare module _ { * @param step The value to increment or decrement by. * @return Returns a new range array. **/ - range( start: number, stop: number, step?: number): number[]; - + /** * @see _.range * @param end The end of the range. @@ -779,11 +1154,27 @@ declare module _ { * @param thisArg The this binding of callback. * @return A new array of removed elements. **/ + remove( + array: Array, + callback?: ListIterator, + thisArg?: any): any[]; + + /** + * @see _.remove + **/ remove( array: List, callback?: ListIterator, thisArg?: any): any[]; + /** + * @see _.remove + * @param pluckValue _.pluck style callback + **/ + remove( + array: Array, + pluckValue?: string): any[]; + /** * @see _.remove * @param pluckValue _.pluck style callback @@ -792,6 +1183,14 @@ declare module _ { array: List, pluckValue?: string): any[]; + /** + * @see _.remove + * @param whereValue _.where style callback + **/ + remove( + array: Array, + wherealue?: Dictionary): any[]; + /** * @see _.remove * @param whereValue _.where style callback @@ -821,14 +1220,19 @@ declare module _ { * @param {*} [thisArg] The this binding of callback. * @return Returns a slice of array. **/ + rest(array: Array): T[]; + + /** + * @see _.rest + **/ rest(array: List): T[]; /** * @see _.rest **/ rest( - array: List, - callback: ListIterator, + array: Array, + callback: ListIterator, thisArg?: any): T[]; /** @@ -836,89 +1240,186 @@ declare module _ { **/ rest( array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + rest( + array: Array, n: number): T[]; - + + /** + * @see _.rest + **/ + rest( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + rest( + array: Array, + pluckValue: string): T[]; + /** * @see _.rest **/ rest( array: List, pluckValue: string): T[]; - + /** * @see _.rest **/ - rest( + rest( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + rest( array: List, whereValue: W): T[]; - /** - * @see _.rest - **/ - drop(array: List): T[]; + /** + * @see _.rest + **/ + drop(array: Array): T[]; - /** - * @see _.rest - **/ - drop( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.rest + **/ + drop(array: List): T[]; - /** - * @see _.rest - **/ - drop( - array: List, - n: number): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - pluckValue: string): T[]; - - /** - * @see _.rest - **/ - drop( - array: List, - whereValue: W): T[]; + /** + * @see _.rest + **/ + drop( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.rest - **/ - tail(array: List): T[]; + /** + * @see _.rest + **/ + drop( + array: List, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.rest - **/ - tail( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.rest + **/ + drop( + array: Array, + n: number): T[]; - /** - * @see _.rest - **/ - tail( - array: List, - n: number): T[]; - - /** - * @see _.rest - **/ - tail( - array: List, - pluckValue: string): T[]; - - /** - * @see _.rest - **/ - tail( - array: List, - whereValue: W): T[]; + /** + * @see _.rest + **/ + drop( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + drop( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + drop( + array: List, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + drop( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + drop( + array: List, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + tail(array: Array): T[]; + + /** + * @see _.rest + **/ + tail(array: List): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + n: number): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + n: number): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + pluckValue: string): T[]; + + /** + * @see _.rest + **/ + tail( + array: Array, + whereValue: W): T[]; + + /** + * @see _.rest + **/ + tail( + array: List, + whereValue: W): T[]; } //_.sortedIndex @@ -939,12 +1440,30 @@ declare module _ { * @param callback Iterator to compute the sort ranking of each value, optional. * @return The index at which value should be inserted into array. **/ + sortedIndex( + array: Array, + value: T, + callback?: (x: T) => TSort, + thisArg?: any): number; + + /** + * @see _.sortedIndex + **/ sortedIndex( array: List, value: T, - callback?: (x: T) => TSort, + callback?: (x: T) => TSort, thisArg?: any): number; + /** + * @see _.sortedIndex + * @param pluckValue the _.pluck style callback + **/ + sortedIndex( + array: Array, + value: T, + pluckValue: string): number; + /** * @see _.sortedIndex * @param pluckValue the _.pluck style callback @@ -954,6 +1473,15 @@ declare module _ { value: T, pluckValue: string): number; + /** + * @see _.sortedIndex + * @param pluckValue the _.where style callback + **/ + sortedIndex( + array: Array, + value: T, + whereValue: W): number; + /** * @see _.sortedIndex * @param pluckValue the _.where style callback @@ -972,6 +1500,11 @@ declare module _ { * @param arrays The arrays to inspect. * @return Returns an array of composite values. **/ + union(...arrays: Array[]): T[]; + + /** + * @see _.union + **/ union(...arrays: List[]): T[]; } @@ -995,14 +1528,39 @@ declare module _ { * @param context 'this' object in `iterator`, optional. * @return Copy of `array` where all elements are unique. **/ + uniq(array: Array, isSorted?: boolean): T[]; + + /** + * @see _.uniq + **/ uniq(array: List, isSorted?: boolean): T[]; + /** + * @see _.uniq + **/ + uniq( + array: Array, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.uniq + **/ uniq( array: List, isSorted: boolean, callback: ListIterator, thisArg?: any): T[]; + /** + * @see _.uniq + **/ + uniq( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; + /** * @see _.uniq **/ @@ -1011,6 +1569,15 @@ declare module _ { callback: ListIterator, thisArg?: any): T[]; + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + array: Array, + isSorted: boolean, + pluckValue: string): T[]; + /** * @see _.uniq * @param pluckValue _.pluck style callback @@ -1020,10 +1587,31 @@ declare module _ { isSorted: boolean, pluckValue: string): T[]; + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + uniq( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ uniq( array: List, pluckValue: string): T[]; + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + array: Array, + isSorted: boolean, + whereValue: W): T[]; + /** * @see _.uniq * @param whereValue _.where style callback @@ -1033,54 +1621,133 @@ declare module _ { isSorted: boolean, whereValue: W): T[]; + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + uniq( + array: Array, + whereValue: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ uniq( array: List, whereValue: W): T[]; - /** - * @see _.uniq - **/ - unique(array: List, isSorted?: boolean): T[]; + /** + * @see _.uniq + **/ + unique(array: Array, isSorted?: boolean): T[]; - unique( - array: List, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.uniq + **/ + unique(array: List, isSorted?: boolean): T[]; - /** - * @see _.uniq - **/ - unique( - array: List, - isSorted: boolean, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.uniq + **/ + unique( + array: Array, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.uniq - * @param pluckValue _.pluck style callback - **/ - unique( - array: List, - isSorted: boolean, - pluckValue: string): T[]; + /** + * @see _.uniq + **/ + unique( + array: List, + callback: ListIterator, + thisArg?: any): T[]; - unique( - array: List, - pluckValue: string): T[]; + /** + * @see _.uniq + **/ + unique( + array: Array, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; - /** - * @see _.uniq - * @param whereValue _.where style callback - **/ - unique( - array: List, - whereValue?: W): T[]; + /** + * @see _.uniq + **/ + unique( + array: List, + isSorted: boolean, + callback: ListIterator, + thisArg?: any): T[]; - unique( - array: List, - isSorted: boolean, - whereValue?: W): T[]; + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: Array, + isSorted: boolean, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: List, + isSorted: boolean, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: Array, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param pluckValue _.pluck style callback + **/ + unique( + array: List, + pluckValue: string): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: Array, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: List, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: Array, + isSorted: boolean, + whereValue?: W): T[]; + + /** + * @see _.uniq + * @param whereValue _.where style callback + **/ + unique( + array: List, + isSorted: boolean, + whereValue?: W): T[]; } //_.without @@ -1091,6 +1758,13 @@ declare module _ { * @param values The value(s) to exclude. * @return A new array of filtered values. **/ + without( + array: Array, + ...values: T[]): T[]; + + /** + * @see _.without + **/ without( array: List, ...values: T[]): T[]; @@ -1112,15 +1786,15 @@ declare module _ { **/ zip(...arrays: any[]): any[]; - /** - * @see _.zip - **/ - unzip(...arrays: any[][]): any[][]; + /** + * @see _.zip + **/ + unzip(...arrays: any[][]): any[][]; - /** - * @see _.zip - **/ - unzip(...arrays: any[]): any[]; + /** + * @see _.zip + **/ + unzip(...arrays: any[]): any[]; } //_.zipObject @@ -1137,12 +1811,12 @@ declare module _ { keys: List, values: List): TResult; - /** - * @see _.object - **/ - object( - keys: List, - values: List): TResult; + /** + * @see _.object + **/ + object( + keys: List, + values: List): TResult; } /* ************* @@ -1160,14 +1834,42 @@ declare module _ { * @return A new array of elements corresponding to the provided indexes. **/ at( - collection: Collection, + collection: Array, indexes: number[]): T[]; /** * @see _.at **/ at( - collection: Collection, + collection: List, + indexes: number[]): T[]; + + /** + * @see _.at + **/ + at( + collection: Dictionary, + indexes: number[]): T[]; + + /** + * @see _.at + **/ + at( + collection: Array, + ...indexes: number[]): T[]; + + /** + * @see _.at + **/ + at( + collection: List, + ...indexes: number[]): T[]; + + /** + * @see _.at + **/ + at( + collection: Dictionary, ...indexes: number[]): T[]; } @@ -1182,7 +1884,15 @@ declare module _ { * @return True if the target element is found, else false. **/ contains( - collection: Collection, + collection: Array, + target: T, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + contains( + collection: List, target: T, fromIndex?: number): boolean; @@ -1206,29 +1916,37 @@ declare module _ { targetString: string, fromIndex?: number): boolean; - /** - * @see _.contains - **/ - include( - collection: Collection, - target: T, - fromIndex?: number): boolean; + /** + * @see _.contains + **/ + include( + collection: Array, + target: T, + fromIndex?: number): boolean; - /** - * @see _.contains - **/ - include( - dictionary: Dictionary, - key: string, - fromIndex?: number): boolean; + /** + * @see _.contains + **/ + include( + collection: List, + target: T, + fromIndex?: number): boolean; - /** - * @see _.contains - **/ - include( - searchString: string, - targetString: string, - fromIndex?: number): boolean; + /** + * @see _.contains + **/ + include( + dictionary: Dictionary, + key: string, + fromIndex?: number): boolean; + + /** + * @see _.contains + **/ + include( + searchString: string, + targetString: string, + fromIndex?: number): boolean; } //_.countBy @@ -1250,7 +1968,7 @@ declare module _ { * @return Returns the composed aggregate object. **/ countBy( - collection: Collection, + collection: Array, callback?: ListIterator, thisArg?: any): Dictionary; @@ -1259,16 +1977,52 @@ declare module _ { * @param callback Function name **/ countBy( - collection: Collection, + collection: List, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Array, callback: string, - thisArg?: any): Dictionary; + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: List, + callback: string, + thisArg?: any): Dictionary; + + /** + * @see _.countBy + * @param callback Function name + **/ + countBy( + collection: Dictionary, + callback: string, + thisArg?: any): Dictionary; } interface LoDashArrayWrapper { /** * @see _.countBy **/ - countBy( + countBy( callback?: ListIterator, thisArg?: any): LoDashObjectWrapper>; @@ -1276,7 +2030,7 @@ declare module _ { * @see _.countBy * @param callback Function name **/ - countBy( + countBy( callback: string, thisArg?: any): LoDashObjectWrapper>; } @@ -1299,7 +2053,7 @@ declare module _ { * @return True if all elements passed the callback check, else false. **/ every( - collection: Collection, + collection: Array, callback?: ListIterator, thisArg?: any): boolean; @@ -1308,7 +2062,41 @@ declare module _ { * @param pluckValue _.pluck style callback **/ every( - collection: Collection, + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + every( + collection: Dictionary, pluckValue: string): boolean; /** @@ -1316,32 +2104,96 @@ declare module _ { * @param whereValue _.where style callback **/ every( - collection: Collection, + collection: Array, whereValue: W): boolean; - /** - * @see _.every - **/ - all( - collection: Collection, - callback?: ListIterator, - thisArg?: any): boolean; + /** + * @see _.every + * @param whereValue _.where style callback + **/ + every( + collection: List, + whereValue: W): boolean; - /** - * @see _.every - * @param pluckValue _.pluck style callback - **/ - all( - collection: Collection, - pluckValue: string): boolean; + /** + * @see _.every + * @param whereValue _.where style callback + **/ + every( + collection: Dictionary, + whereValue: W): boolean; - /** - * @see _.every - * @param whereValue _.where style callback - **/ - all( - collection: Collection, - whereValue: W): boolean; + /** + * @see _.every + **/ + all( + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + **/ + all( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + **/ + all( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.every + * @param pluckValue _.pluck style callback + **/ + all( + collection: Dictionary, + pluckValue: string): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: Array, + whereValue: W): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: List, + whereValue: W): boolean; + + /** + * @see _.every + * @param whereValue _.where style callback + **/ + all( + collection: Dictionary, + whereValue: W): boolean; } //_.filter @@ -1362,7 +2214,23 @@ declare module _ { * @return Returns a new array of elements that passed the callback check. **/ filter( - collection: Collection, + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + filter( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + filter( + collection: Dictionary, callback: ListIterator, thisArg?: any): T[]; @@ -1371,47 +2239,127 @@ declare module _ { * @param pluckValue _.pluck style callback **/ filter( - collection: Collection, + collection: Array, pluckValue: string): T[]; /** * @see _.filter * @param pluckValue _.pluck style callback **/ - filter( - collection: Collection, - whereValue: W): T[]; + filter( + collection: List, + pluckValue: string): T[]; - /** - * @see _.filter - **/ - select( - collection: Collection, - callback: ListIterator, - thisArg?: any): T[]; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Dictionary, + pluckValue: string): T[]; - /** - * @see _.filter - * @param pluckValue _.pluck style callback - **/ - select( - collection: Collection, - pluckValue: string): T[]; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Array, + whereValue: W): T[]; - /** - * @see _.filter - * @param pluckValue _.pluck style callback - **/ - select( - collection: Collection, - whereValue: W): T[]; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: List, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + filter( + collection: Dictionary, + whereValue: W): T[]; + + /** + * @see _.filter + **/ + select( + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + select( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + **/ + select( + collection: Dictionary, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Array, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: List, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Dictionary, + pluckValue: string): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Array, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: List, + whereValue: W): T[]; + + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + collection: Dictionary, + whereValue: W): T[]; } interface LoDashArrayWrapper { /** * @see _.filter **/ - filter( + filter( callback: ListIterator, thisArg?: any): LoDashArrayWrapper; @@ -1419,36 +2367,36 @@ declare module _ { * @see _.filter * @param pluckValue _.pluck style callback **/ - filter( + filter( pluckValue: string): LoDashArrayWrapper; /** * @see _.filter * @param pluckValue _.pluck style callback **/ - filter( + filter( whereValue: W): LoDashArrayWrapper; - /** - * @see _.filter - **/ - select( - callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + /** + * @see _.filter + **/ + select( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; - /** - * @see _.filter - * @param pluckValue _.pluck style callback - **/ - select( - pluckValue: string): LoDashArrayWrapper; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + pluckValue: string): LoDashArrayWrapper; - /** - * @see _.filter - * @param pluckValue _.pluck style callback - **/ - select( - whereValue: W): LoDashArrayWrapper; + /** + * @see _.filter + * @param pluckValue _.pluck style callback + **/ + select( + whereValue: W): LoDashArrayWrapper; } //_.find @@ -1469,7 +2417,23 @@ declare module _ { * @return The found element, else undefined. **/ find( - collection: Collection, + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + find( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + find( + collection: Dictionary, callback: ListIterator, thisArg?: any): T; @@ -1478,7 +2442,23 @@ declare module _ { * @param _.pluck style callback **/ find( - collection: Collection, + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + find( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + find( + collection: Dictionary, whereValue: W): T; /** @@ -1486,56 +2466,168 @@ declare module _ { * @param _.where style callback **/ find( - collection: Collection, + collection: Array, pluckValue: string): T; - /** - * @see _.find - **/ - detect( - collection: Collection, - callback: ListIterator, - thisArg?: any): T; + /** + * @see _.find + * @param _.where style callback + **/ + find( + collection: List, + pluckValue: string): T; - /** - * @see _.find - * @param _.pluck style callback - **/ - detect( - collection: Collection, - whereValue: W): T; + /** + * @see _.find + * @param _.where style callback + **/ + find( + collection: Dictionary, + pluckValue: string): T; - /** - * @see _.find - * @param _.where style callback - **/ - detect( - collection: Collection, - pluckValue: string): T; + /** + * @see _.find + **/ + detect( + collection: Array, + callback: ListIterator, + thisArg?: any): T; - /** - * @see _.find - **/ - findWhere( - collection: Collection, - callback: ListIterator, - thisArg?: any): T; + /** + * @see _.find + **/ + detect( + collection: List, + callback: ListIterator, + thisArg?: any): T; - /** - * @see _.find - * @param _.pluck style callback - **/ - findWhere( - collection: Collection, - whereValue: W): T; + /** + * @see _.find + **/ + detect( + collection: Dictionary, + callback: ListIterator, + thisArg?: any): T; - /** - * @see _.find - * @param _.where style callback - **/ - findWhere( - collection: Collection, - pluckValue: string): T; + /** + * @see _.find + * @param _.pluck style callback + **/ + detect( + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + detect( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + detect( + collection: Dictionary, + whereValue: W): T; + + /** + * @see _.find + * @param _.where style callback + **/ + detect( + collection: Array, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + detect( + collection: List, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + detect( + collection: Dictionary, + pluckValue: string): T; + + /** + * @see _.find + **/ + findWhere( + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findWhere( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findWhere( + collection: Dictionary, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findWhere( + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findWhere( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findWhere( + collection: Dictionary, + whereValue: W): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findWhere( + collection: Array, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findWhere( + collection: List, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findWhere( + collection: Dictionary, + pluckValue: string): T; } //_.findLast @@ -1549,7 +2641,23 @@ declare module _ { * @return The found element, else undefined. **/ findLast( - collection: Collection, + collection: Array, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findLast( + collection: List, + callback: ListIterator, + thisArg?: any): T; + + /** + * @see _.find + **/ + findLast( + collection: Dictionary, callback: ListIterator, thisArg?: any): T; @@ -1558,7 +2666,23 @@ declare module _ { * @param _.pluck style callback **/ findLast( - collection: Collection, + collection: Array, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findLast( + collection: List, + whereValue: W): T; + + /** + * @see _.find + * @param _.pluck style callback + **/ + findLast( + collection: Dictionary, whereValue: W): T; /** @@ -1566,7 +2690,23 @@ declare module _ { * @param _.where style callback **/ findLast( - collection: Collection, + collection: Array, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findLast( + collection: List, + pluckValue: string): T; + + /** + * @see _.find + * @param _.where style callback + **/ + findLast( + collection: Dictionary, pluckValue: string): T; } @@ -1580,9 +2720,17 @@ declare module _ { * @param callback The function called per iteration. * @param thisArg The this binding of callback. **/ + forEach( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; + + /** + * @see _.forEach + **/ forEach( collection: List, - callback: ListIterator, + callback: ListIterator, thisArg?: any): List; /** @@ -1590,43 +2738,51 @@ declare module _ { **/ forEach( object: Dictionary, - callback: ObjectIterator, + callback: ObjectIterator, thisArg?: any): Dictionary; - /** - * @see _.forEach - **/ - each( - collection: List, - callback: ListIterator, - thisArg?: any): List; + /** + * @see _.forEach + **/ + each( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; - /** - * @see _.forEach - * @param object The object to iterate over - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - each( - object: Dictionary, - callback: ObjectIterator, - thisArg?: any): Dictionary; + /** + * @see _.forEach + **/ + each( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.forEach + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + each( + object: Dictionary, + callback: ObjectIterator, + thisArg?: any): Dictionary; } interface LoDashArrayWrapper { /** * @see _.forEach **/ - forEach( - callback: ListIterator, + forEach( + callback: ListIterator, thisArg?: any): LoDashArrayWrapper; - /** - * @see _.forEach - **/ - each( - callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + /** + * @see _.forEach + **/ + each( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; } interface LoDashObjectWrapper { @@ -1634,15 +2790,15 @@ declare module _ { * @see _.forEach **/ forEach( - callback: ObjectIterator, + callback: ObjectIterator, thisArg?: any): LoDashObjectWrapper; - /** - * @see _.forEach - **/ - each( - callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper; + /** + * @see _.forEach + **/ + each( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper; } //_.forEachRight @@ -1654,9 +2810,17 @@ declare module _ { * @param callback The function called per iteration. * @param thisArg The this binding of callback. **/ + forEachRight( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; + + /** + * @see _.forEachRight + **/ forEachRight( collection: List, - callback: ListIterator, + callback: ListIterator, thisArg?: any): List; /** @@ -1664,43 +2828,51 @@ declare module _ { **/ forEachRight( object: Dictionary, - callback: ObjectIterator, + callback: ObjectIterator, thisArg?: any): Dictionary; - /** - * @see _.forEachRight - **/ - eachRight( - collection: List, - callback: ListIterator, - thisArg?: any): List; + /** + * @see _.forEachRight + **/ + eachRight( + collection: Array, + callback: ListIterator, + thisArg?: any): Array; - /** - * @see _.forEachRight - * @param object The object to iterate over - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - eachRight( - object: Dictionary, - callback: ObjectIterator, - thisArg?: any): Dictionary; + /** + * @see _.forEachRight + **/ + eachRight( + collection: List, + callback: ListIterator, + thisArg?: any): List; + + /** + * @see _.forEachRight + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + eachRight( + object: Dictionary, + callback: ObjectIterator, + thisArg?: any): Dictionary; } interface LoDashArrayWrapper { /** * @see _.forEachRight **/ - forEachRight( - callback: ListIterator, + forEachRight( + callback: ListIterator, thisArg?: any): LoDashArrayWrapper; - /** - * @see _.forEachRight - **/ - eachRight( - callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + /** + * @see _.forEachRight + **/ + eachRight( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; } interface LoDashObjectWrapper { @@ -1708,18 +2880,18 @@ declare module _ { * @see _.forEachRight **/ forEachRight( - callback: ObjectIterator, + callback: ObjectIterator, thisArg?: any): LoDashObjectWrapper>; - /** - * @see _.forEachRight - * @param object The object to iterate over - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - **/ - eachRight( - callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper>; + /** + * @see _.forEachRight + * @param object The object to iterate over + * @param callback The function called per iteration. + * @param thisArg The this binding of callback. + **/ + eachRight( + callback: ObjectIterator, + thisArg?: any): LoDashObjectWrapper>; } //_.groupBy @@ -1739,11 +2911,27 @@ declare module _ { * @param thisArg The this binding of callback. * @return Returns the composed aggregate object. **/ + groupBy( + collection: Array, + callback?: ListIterator, + thisArg?: any): Dictionary; + + /** + * @see _.groupBy + **/ groupBy( collection: List, callback?: ListIterator, thisArg?: any): Dictionary; + /** + * @see _.groupBy + * @param pluckValue _.pluck style callback + **/ + groupBy( + collection: Array, + pluckValue: string): Dictionary; + /** * @see _.groupBy * @param pluckValue _.pluck style callback @@ -1752,6 +2940,14 @@ declare module _ { collection: List, pluckValue: string): Dictionary; + /** + * @see _.groupBy + * @param whereValue _.where style callback + **/ + groupBy( + collection: Array, + whereValue: W): Dictionary; + /** * @see _.groupBy * @param whereValue _.where style callback @@ -1761,24 +2957,24 @@ declare module _ { whereValue: W): Dictionary; } - interface LoDashArrayWrapper { + interface LoDashArrayWrapper { /** * @see _.groupBy **/ - groupBy( + groupBy( callback: ListIterator, thisArg?: any): _.LoDashObjectWrapper>; /** * @see _.groupBy **/ - groupBy( + groupBy( pluckValue: string): _.LoDashObjectWrapper>; /** * @see _.groupBy **/ - groupBy( + groupBy( whereValue: W): _.LoDashObjectWrapper>; } @@ -1800,11 +2996,27 @@ declare module _ { * @param thisArg The this binding of callback. * @return Returns the composed aggregate object. **/ + indexBy( + list: Array, + iterator: ListIterator, + context?: any): Dictionary; + + /** + * @see _.indexBy + **/ indexBy( list: List, iterator: ListIterator, context?: any): Dictionary; + /** + * @see _.indexBy + * @param pluckValue _.pluck style callback + **/ + indexBy( + collection: Array, + pluckValue: string): Dictionary; + /** * @see _.indexBy * @param pluckValue _.pluck style callback @@ -1813,6 +3025,14 @@ declare module _ { collection: List, pluckValue: string): Dictionary; + /** + * @see _.indexBy + * @param whereValue _.where style callback + **/ + indexBy( + collection: Array, + whereValue: W): Dictionary; + /** * @see _.indexBy * @param whereValue _.where style callback @@ -1834,7 +3054,7 @@ declare module _ { * @param args Arguments to invoke the method with. **/ invoke( - collection: Collection, + collection: Array, methodName: string, ...args: any[]): any; @@ -1842,7 +3062,39 @@ declare module _ { * @see _.invoke **/ invoke( - collection: Collection, + collection: List, + methodName: string, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Dictionary, + methodName: string, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Array, + method: Function, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: List, + method: Function, + ...args: any[]): any; + + /** + * @see _.invoke + **/ + invoke( + collection: Dictionary, method: Function, ...args: any[]): any; } @@ -1864,6 +3116,14 @@ declare module _ { * @param theArg The this binding of callback. * @return The mapped array result. **/ + map( + collection: Array, + callback: ListIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + **/ map( collection: List, callback: ListIterator, @@ -1881,6 +3141,14 @@ declare module _ { callback: ObjectIterator, thisArg?: any): TResult[]; + /** + * @see _.map + * @param pluckValue _.pluck style callback + **/ + map( + collection: Array, + pluckValue: string): TResult[]; + /** * @see _.map * @param pluckValue _.pluck style callback @@ -1889,35 +3157,50 @@ declare module _ { collection: List, pluckValue: string): TResult[]; - /** - * @see _.map - **/ - collect( - collection: List, - callback: ListIterator, - thisArg?: any): TResult[]; + /** + * @see _.map + **/ + collect( + collection: Array, + callback: ListIterator, + thisArg?: any): TResult[]; - /** - * @see _.map - **/ - collect( - object: Dictionary, - callback: ObjectIterator, - thisArg?: any): TResult[]; + /** + * @see _.map + **/ + collect( + collection: List, + callback: ListIterator, + thisArg?: any): TResult[]; - /** - * @see _.map - **/ - collect( - collection: List, - pluckValue: string): TResult[]; + /** + * @see _.map + **/ + collect( + object: Dictionary, + callback: ObjectIterator, + thisArg?: any): TResult[]; + + /** + * @see _.map + **/ + collect( + collection: Array, + pluckValue: string): TResult[]; + + /** + * @see _.map + **/ + collect( + collection: List, + pluckValue: string): TResult[]; } interface LoDashArrayWrapper { /** * @see _.map **/ - map( + map( callback: ListIterator, thisArg?: any): LoDashArrayWrapper; @@ -1925,21 +3208,21 @@ declare module _ { * @see _.map * @param pluckValue _.pluck style callback **/ - map( + map( pluckValue: string): LoDashArrayWrapper; - /** - * @see _.map - **/ - collect( - callback: ListIterator, - thisArg?: any): LoDashArrayWrapper; + /** + * @see _.map + **/ + collect( + callback: ListIterator, + thisArg?: any): LoDashArrayWrapper; - /** - * @see _.map - **/ - collect( - pluckValue: string): LoDashArrayWrapper; + /** + * @see _.map + **/ + collect( + pluckValue: string): LoDashArrayWrapper; } interface LoDashObjectWrapper { @@ -1948,14 +3231,14 @@ declare module _ { **/ map( callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper; + thisArg?: any): LoDashArrayWrapper; - /** - * @see _.map - **/ - collect( - callback: ObjectIterator, - thisArg?: any): LoDashObjectWrapper; + /** + * @see _.map + **/ + collect( + callback: ObjectIterator, + thisArg?: any): LoDashArrayWrapper; } //_.max @@ -1977,7 +3260,23 @@ declare module _ { * @return Returns the maximum value. **/ max( - collection: Collection, + collection: Array, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.max + **/ + max( + collection: List, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.max + **/ + max( + collection: Dictionary, callback?: ListIterator, thisArg?: any): T; @@ -1986,7 +3285,23 @@ declare module _ { * @param pluckValue _.pluck style callback **/ max( - collection: Collection, + collection: Array, + pluckValue: string): T; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + collection: List, + pluckValue: string): T; + + /** + * @see _.max + * @param pluckValue _.pluck style callback + **/ + max( + collection: Dictionary, pluckValue: string): T; /** @@ -1994,7 +3309,23 @@ declare module _ { * @param whereValue _.where style callback **/ max( - collection: Collection, + collection: Array, + whereValue: W): T; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + collection: List, + whereValue: W): T; + + /** + * @see _.max + * @param whereValue _.where style callback + **/ + max( + collection: Dictionary, whereValue: W): T; } @@ -2017,7 +3348,23 @@ declare module _ { * @return Returns the maximum value. **/ min( - collection: Collection, + collection: Array, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.min + **/ + min( + collection: List, + callback?: ListIterator, + thisArg?: any): T; + + /** + * @see _.min + **/ + min( + collection: Dictionary, callback?: ListIterator, thisArg?: any): T; @@ -2026,7 +3373,23 @@ declare module _ { * @param pluckValue _.pluck style callback **/ min( - collection: Collection, + collection: Array, + pluckValue: string): T; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + collection: List, + pluckValue: string): T; + + /** + * @see _.min + * @param pluckValue _.pluck style callback + **/ + min( + collection: Dictionary, pluckValue: string): T; /** @@ -2034,7 +3397,23 @@ declare module _ { * @param whereValue _.where style callback **/ min( - collection: Collection, + collection: Array, + whereValue: W): T; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + collection: List, + whereValue: W): T; + + /** + * @see _.min + * @param whereValue _.where style callback + **/ + min( + collection: Dictionary, whereValue: W): T; } @@ -2047,7 +3426,21 @@ declare module _ { * @return A new array of property values. **/ pluck( - collection: Collection, + collection: Array, + property: string): any[]; + + /** + * @see _.pluck + **/ + pluck( + collection: List, + property: string): any[]; + + /** + * @see _.pluck + **/ + pluck( + collection: Dictionary, property: string): any[]; } @@ -2066,52 +3459,154 @@ declare module _ { * @return Returns the accumulated value. **/ reduce( - collection: Collection, + collection: Array, callback: MemoIterator, accumulator: TResult, thisArg?: any): TResult; - /** - * @see _.reduce - **/ + /** + * @see _.reduce + **/ reduce( - collection: Collection, + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + reduce( + collection: Array, callback: MemoIterator, thisArg?: any): TResult; - /** - * @see _.reduce - **/ - inject( - collection: Collection, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; + /** + * @see _.reduce + **/ + reduce( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; - /** - * @see _.reduce - **/ - inject( - collection: Collection, - callback: MemoIterator, - thisArg?: any): TResult; + /** + * @see _.reduce + **/ + reduce( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; - /** - * @see _.reduce - **/ - foldl( - collection: Collection, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; + /** + * @see _.reduce + **/ + inject( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; - /** - * @see _.reduce - **/ - foldl( - collection: Collection, - callback: MemoIterator, - thisArg?: any): TResult; + /** + * @see _.reduce + **/ + inject( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + inject( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduce + **/ + foldl( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; } //_.reduceRight @@ -2126,35 +3621,103 @@ declare module _ { * @return The accumulated value. **/ reduceRight( - collection: Collection, + collection: Array, callback: MemoIterator, accumulator: TResult, thisArg?: any): TResult; - /** - * @see _.reduceRight - **/ + /** + * @see _.reduceRight + **/ reduceRight( - collection: Collection, + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Array, callback: MemoIterator, thisArg?: any): TResult; - /** - * @see _.reduceRight - **/ - foldr( - collection: Collection, - callback: MemoIterator, - accumulator: TResult, - thisArg?: any): TResult; + /** + * @see _.reduceRight + **/ + reduceRight( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; - /** - * @see _.reduceRight - **/ - foldr( - collection: Collection, - callback: MemoIterator, - thisArg?: any): TResult; + /** + * @see _.reduceRight + **/ + reduceRight( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Array, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: List, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Dictionary, + callback: MemoIterator, + accumulator: TResult, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Array, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: List, + callback: MemoIterator, + thisArg?: any): TResult; + + /** + * @see _.reduceRight + **/ + foldr( + collection: Dictionary, + callback: MemoIterator, + thisArg?: any): TResult; } //_.reject @@ -2174,7 +3737,23 @@ declare module _ { * @return A new array of elements that failed the callback check. **/ reject( - collection: Collection, + collection: Array, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.reject + **/ + reject( + collection: List, + callback: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.reject + **/ + reject( + collection: Dictionary, callback: ListIterator, thisArg?: any): T[]; @@ -2183,7 +3762,23 @@ declare module _ { * @param pluckValue _.pluck style callback **/ reject( - collection: Collection, + collection: Array, + pluckValue: string): T[]; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject( + collection: List, + pluckValue: string): T[]; + + /** + * @see _.reject + * @param pluckValue _.pluck style callback + **/ + reject( + collection: Dictionary, pluckValue: string): T[]; /** @@ -2191,7 +3786,23 @@ declare module _ { * @param whereValue _.where style callback **/ reject( - collection: Collection, + collection: Array, + whereValue: W): T[]; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject( + collection: List, + whereValue: W): T[]; + + /** + * @see _.reject + * @param whereValue _.where style callback + **/ + reject( + collection: Dictionary, whereValue: W): T[]; } @@ -2202,13 +3813,35 @@ declare module _ { * @param collection The collection to sample. * @return Returns the random sample(s) of collection. **/ - sample(collection: Collection): T; + sample(collection: Array): T; + + /** + * @see _.sample + **/ + sample(collection: List): T; + + /** + * @see _.sample + **/ + sample(collection: Dictionary): T; /** * @see _.sample * @param n The number of elements to sample. **/ - sample(collection: Collection, n: number): T[]; + sample(collection: Array, n: number): T[]; + + /** + * @see _.sample + * @param n The number of elements to sample. + **/ + sample(collection: List, n: number): T[]; + + /** + * @see _.sample + * @param n The number of elements to sample. + **/ + sample(collection: Dictionary, n: number): T[]; } //_.shuffle @@ -2219,7 +3852,17 @@ declare module _ { * @param collection The collection to shuffle. * @return Returns a new shuffled collection. **/ - shuffle(collection: Collection): T[]; + shuffle(collection: Array): T[]; + + /** + * @see _.shuffle + **/ + shuffle(collection: List): T[]; + + /** + * @see _.shuffle + **/ + shuffle(collection: Dictionary): T[]; } //_.size @@ -2230,6 +3873,11 @@ declare module _ { * @param collection The collection to inspect. * @return collection.length **/ + size(collection: Array): number; + + /** + * @see _.size + **/ size(collection: List): number; /** @@ -2265,7 +3913,23 @@ declare module _ { * @return True if any element passed the callback check, else false. **/ some( - collection: Collection, + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + some( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + some( + collection: Dictionary, callback?: ListIterator, thisArg?: any): boolean; @@ -2274,7 +3938,23 @@ declare module _ { * @param pluckValue _.pluck style callback **/ some( - collection: Collection, + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + some( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + some( + collection: Dictionary, pluckValue: string): boolean; /** @@ -2282,32 +3962,96 @@ declare module _ { * @param whereValue _.where style callback **/ some( - collection: Collection, + collection: Array, whereValue: W): boolean; - /** - * @see _.some - **/ - any( - collection: Collection, - callback?: ListIterator, - thisArg?: any): boolean; + /** + * @see _.some + * @param whereValue _.where style callback + **/ + some( + collection: List, + whereValue: W): boolean; - /** - * @see _.some - * @param pluckValue _.pluck style callback - **/ - any( - collection: Collection, - pluckValue: string): boolean; + /** + * @see _.some + * @param whereValue _.where style callback + **/ + some( + collection: Dictionary, + whereValue: W): boolean; - /** - * @see _.some - * @param whereValue _.where style callback - **/ - any( - collection: Collection, - whereValue: W): boolean; + /** + * @see _.some + **/ + any( + collection: Array, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + any( + collection: List, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + **/ + any( + collection: Dictionary, + callback?: ListIterator, + thisArg?: any): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: Array, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: List, + pluckValue: string): boolean; + + /** + * @see _.some + * @param pluckValue _.pluck style callback + **/ + any( + collection: Dictionary, + pluckValue: string): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: Array, + whereValue: W): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: List, + whereValue: W): boolean; + + /** + * @see _.some + * @param whereValue _.where style callback + **/ + any( + collection: Dictionary, + whereValue: W): boolean; } //_.sortBy @@ -2328,11 +4072,27 @@ declare module _ { * @param thisArg The this binding of callback. * @return A new array of sorted elements. **/ + sortBy( + collection: Array, + callback?: ListIterator, + thisArg?: any): T[]; + + /** + * @see _.sortBy + **/ sortBy( collection: List, callback?: ListIterator, thisArg?: any): T[]; + /** + * @see _.sortBy + * @param pluckValue _.pluck style callback + **/ + sortBy( + collection: Array, + pluckValue: string): T[]; + /** * @see _.sortBy * @param pluckValue _.pluck style callback @@ -2341,6 +4101,14 @@ declare module _ { collection: List, pluckValue: string): T[]; + /** + * @see _.sortBy + * @param whereValue _.where style callback + **/ + sortBy( + collection: Array, + whereValue: W): T[]; + /** * @see _.sortBy * @param whereValue _.where style callback @@ -2357,7 +4125,17 @@ declare module _ { * @param collection The collection to convert. * @return The new converted array. **/ - toArray(collection: Collection): T[]; + toArray(collection: Array): T[]; + + /** + * @see _.toArray + **/ + toArray(collection: List): T[]; + + /** + * @see _.toArray + **/ + toArray(collection: Dictionary): T[]; } //_.where @@ -2370,7 +4148,21 @@ declare module _ { * @return A new array of elements that have the given properties. **/ where( - list: Collection, + list: Array, + properties: U): T[]; + + /** + * @see _.where + **/ + where( + list: List, + properties: U): T[]; + + /** + * @see _.where + **/ + where( + list: Dictionary, properties: U): T[]; } @@ -2389,7 +4181,7 @@ declare module _ { **/ after( n: number, - func: Function): Function; + func: Function): Function; } interface LoDashWrapper { @@ -2412,7 +4204,7 @@ declare module _ { bind( func: Function, thisArg: any, - ...args: any[]): () => any; + ...args: any[]): () => any; } interface LoDashObjectWrapper { @@ -2437,14 +4229,14 @@ declare module _ { **/ bindAll( object: T, - ...methodNames: string[]): T; + ...methodNames: string[]): T; } interface LoDashObjectWrapper { /** * @see _.bindAll **/ - bindAll(...methodNames: string[]): LoDashWrapper; + bindAll(...methodNames: string[]): LoDashWrapper; } //_.bindKey @@ -2462,7 +4254,7 @@ declare module _ { bindKey( object: T, key: string, - ...args: any[]): Function; + ...args: any[]): Function; } interface LoDashObjectWrapper { @@ -2484,7 +4276,7 @@ declare module _ { * @param funcs Functions to compose. * @return The new composed function. **/ - compose(...funcs: Function[]): Function; + compose(...funcs: Function[]): Function; } interface LoDashObjectWrapper { @@ -2517,7 +4309,7 @@ declare module _ { createCallback( func: Dictionary, thisArg?: any, - argCount?: number): () => boolean; + argCount?: number): () => boolean; } interface LoDashWrapper { @@ -2551,7 +4343,7 @@ declare module _ { **/ curry( func: Function, - arity?: number): Function; + arity?: number): Function; } interface LoDashObjectWrapper { @@ -2583,7 +4375,7 @@ declare module _ { debounce( func: T, wait: number, - options?: DebounceSettings): T; + options?: DebounceSettings): T; } interface LoDashObjectWrapper { @@ -2600,7 +4392,7 @@ declare module _ { * Specify execution on the leading edge of the timeout. **/ leading?: boolean; - + /** * The maximum time func is allowed to be delayed before it’s called. **/ @@ -2623,7 +4415,7 @@ declare module _ { **/ defer( func: Function, - ...args: any[]): number; + ...args: any[]): number; } interface LoDashObjectWrapper { @@ -2646,7 +4438,7 @@ declare module _ { delay( func: Function, wait: number, - ...args: any[]): number; + ...args: any[]): number; } interface LoDashObjectWrapper { @@ -2670,7 +4462,7 @@ declare module _ { * @param resolver Hash function for storing the result of `fn`. * @return Returns the new memoizing function. **/ - memoize( + memoize( func: T, resolver?: Function): T; } @@ -2684,7 +4476,7 @@ declare module _ { * @param func Function to only execute once. * @return The new restricted function. **/ - once(func: T): T; + once(func: T): T; } //_.partial @@ -2733,7 +4525,7 @@ declare module _ { * @param options.trailing Specify execution on the trailing edge of the timeout. * @return The new throttled function. **/ - throttle( + throttle( func: T, wait: number, options?: ThrottleSettings): T; @@ -2784,86 +4576,86 @@ declare module _ { * @param thisArg The this binding of callback. * @return The destination object. **/ - assign( - object: T, - s1: S1, + assign( + object: T, + s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: S1, - s2: S2, + assign( + object: T, + s1: S1, + s2: S2, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: S1, - s2: S2, - s3: S3, + assign( + object: T, + s1: S1, + s2: S2, + s3: S3, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - assign( - object: T, - s1: S1, - s2: S2, - s3: S3, - s4: S4, + assign( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - extend( - object: T, - s1: S1, + extend( + object: T, + s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - extend( - object: T, - s1: S1, - s2: S2, + extend( + object: T, + s1: S1, + s2: S2, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - extend( - object: T, - s1: S1, - s2: S2, - s3: S3, + extend( + object: T, + s1: S1, + s2: S2, + s3: S3, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.assign **/ - extend( - object: T, - s1: S1, - s2: S2, - s3: S3, - s4: S4, + extend( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; } interface LoDashObjectWrapper { @@ -2914,52 +4706,52 @@ declare module _ { callback?: (objectValue: Value, sourceValue: Value) => Value, thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - s2: S2, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - s2: S2, - s3: S3, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - s2: S2, - s3: S3, - s4: S4, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; - /** - * @see _.assign - **/ - extend( - s1: S1, - s2: S2, - s3: S3, - s4: S4, - s5: S5, - callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; + /** + * @see _.assign + **/ + extend( + s1: S1, + s2: S2, + s3: S3, + s4: S4, + s5: S5, + callback?: (objectValue: Value, sourceValue: Value) => Value, + thisArg?: any): TResult; } @@ -3017,7 +4809,7 @@ declare module _ { **/ defaults( object: T, - ...sources: any[]): TResult; + ...sources: any[]): TResult; } interface LoDashObjectWrapper { @@ -3054,7 +4846,7 @@ declare module _ { * @see _.findKey * @param whereValue _.where style callback **/ - findKey, T>( + findKey, T>( object: T, whereValue: W): string; } @@ -3085,7 +4877,7 @@ declare module _ { * @see _.findLastKey * @param whereValue _.where style callback **/ - findLastKey, T>( + findLastKey, T>( object: T, whereValue: W): string; } @@ -3105,9 +4897,17 @@ declare module _ { object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; + + /** + * @see _.forIn + **/ + forIn( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forIn **/ @@ -3130,9 +4930,17 @@ declare module _ { object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; + + /** + * @see _.forInRight + **/ + forInRight( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forInRight **/ @@ -3156,9 +4964,17 @@ declare module _ { object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; + + /** + * @see _.forOwn + **/ + forOwn( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forOwn **/ @@ -3181,9 +4997,16 @@ declare module _ { object: Dictionary, callback?: ObjectIterator, thisArg?: any): Dictionary; + /** + * @see _.forOwnRight + **/ + forOwnRight( + object: T, + callback?: ObjectIterator, + thisArg?: any): T; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.forOwnRight **/ @@ -3202,22 +5025,22 @@ declare module _ { **/ functions(object: any): string[]; - /** - * @see _functions - **/ - methods(object: any): string[]; + /** + * @see _functions + **/ + methods(object: any): string[]; } - interface LoDashObjectWrapper { + interface LoDashObjectWrapper { /** * @see _.functions **/ functions(): _.LoDashArrayWrapper; - /** - * @see _.functions - **/ - methods(): _.LoDashArrayWrapper; + /** + * @see _.functions + **/ + methods(): _.LoDashArrayWrapper; } //_.has @@ -3311,7 +5134,7 @@ declare module _ { * @see _.isEmpty **/ isEmpty(value: string): boolean; - + /** * @see _.isEmpty **/ @@ -3472,44 +5295,44 @@ declare module _ { * @param thisArg The this binding of callback. * @return The destination object. **/ - merge( - object: T, - s1: S1, + merge( + object: T, + s1: S1, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: T, - s1: S1, - s2: S2, + merge( + object: T, + s1: S1, + s2: S2, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: T, - s1: S1, - s2: S2, - s3: S3, + merge( + object: T, + s1: S1, + s2: S2, + s3: S3, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; /** * @see _.merge **/ - merge( - object: T, - s1: S1, - s2: S2, - s3: S3, - s4: S4, + merge( + object: T, + s1: S1, + s2: S2, + s3: S3, + s4: S4, callback?: (objectValue: Value, sourceValue: Value) => Value, - thisArg?: any): Result; + thisArg?: any): Result; } //_.omit @@ -3524,7 +5347,7 @@ declare module _ { * @param keys The properties to omit. * @return An object without the omitted properties. **/ - omit( + omit( object: T, ...keys: string[]): Omitted; @@ -3567,7 +5390,7 @@ declare module _ { * @param keys Property names to pick * @return An object composed of the picked properties. **/ - pick( + pick( object: T, ...keys: string[]): Picked; @@ -3602,7 +5425,7 @@ declare module _ { * @return The accumulated value. **/ transform( - collection: Collection, + collection: Array, callback: MemoVoidIterator, accumulator: Acc, thisArg?: any): Acc; @@ -3611,7 +5434,41 @@ declare module _ { * @see _.transform **/ transform( - collection: Collection, + collection: List, + callback: MemoVoidIterator, + accumulator: Acc, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Dictionary, + callback: MemoVoidIterator, + accumulator: Acc, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Array, + callback?: MemoVoidIterator, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: List, + callback?: MemoVoidIterator, + thisArg?: any): Acc; + + /** + * @see _.transform + **/ + transform( + collection: Dictionary, callback?: MemoVoidIterator, thisArg?: any): Acc; } @@ -3693,7 +5550,7 @@ declare module _ { * @return A random number. **/ random(max: number, floating?: boolean): number; - + /** * @see _.random * @param min The minimum possible value. @@ -3752,13 +5609,13 @@ declare module _ { **/ template( text: string): TemplateExecutor; - + /** * @see _.template **/ template( text: string, - data: any, + data: any, options?: TemplateSettings, sourceURL?: string, variable?: string): any /* string or TemplateExecutor*/; @@ -3768,7 +5625,7 @@ declare module _ { (...data: any[]): string; source: string; } - + //_.times interface LoDashStatic { /** @@ -3779,8 +5636,8 @@ declare module _ { * @param thisArg The this binding of callback. **/ times( - n: number, - callback: (num: number) => TResult, + n: number, + callback: (num: number) => TResult, context?: any): TResult[]; } @@ -3820,24 +5677,24 @@ declare module _ { interface MemoIterator { (prev: TResult, curr: T, indexOrKey: any, list?: T[]): TResult; } - /* + /* interface MemoListIterator { (prev: TResult, curr: T, index: number, list?: T[]): TResult; } interface MemoObjectIterator { (prev: TResult, curr: T, index: string, object?: Dictionary): TResult; } - */ + */ - interface Collection { } + //interface Collection {} // Common interface between Arrays and jQuery objects - interface List extends Collection { + interface List { [index: number]: T; length: number; } - interface Dictionary extends Collection { + interface Dictionary { [index: string]: T; } } From b9c60cc42b2732611636ec25ad973fcc171420f5 Mon Sep 17 00:00:00 2001 From: Troy Gerwien Date: Sun, 6 Apr 2014 11:51:38 +0800 Subject: [PATCH 004/225] open express.d.ts interfaces - provides open interfaces for Request, Response, Application - express's interfaces remain the same, but extend the open ones --- express/express.d.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/express/express.d.ts b/express/express.d.ts index 7dd1706299..0b6323c4e2 100644 --- a/express/express.d.ts +++ b/express/express.d.ts @@ -12,6 +12,17 @@ /// + +declare module Express { + + // These open interfaces may be extended in an application-specific manner via declaration merging. + // See for example passport.d.ts (https://github.com/borisyankov/DefinitelyTyped/blob/master/passport/passport.d.ts) + export interface Request { } + export interface Response { } + export interface Application { } +} + + declare module "express" { import http = require('http'); @@ -229,7 +240,7 @@ declare module "express" { count: number; } - interface Request { + interface Request extends Express.Request { session: Session; @@ -545,7 +556,7 @@ declare module "express" { (body: any): Response; } - interface Response extends http.ServerResponse { + interface Response extends http.ServerResponse, Express.Response { /** * Set status `code`. * @@ -893,7 +904,7 @@ declare module "express" { (req: Request, res: Response, next: Function): any; } - interface Application extends IRouter { + interface Application extends IRouter, Express.Application { /** * Initialize the server. * From ce0be7b9f5a79ae99e61f99ca844ee75ac58854e Mon Sep 17 00:00:00 2001 From: Troy Gerwien Date: Sun, 6 Apr 2014 11:59:54 +0800 Subject: [PATCH 005/225] amend passport.d.ts - passport.d.ts has been amended to merge its Request extensions into express's Request interface. - removed now-unnecessary type coercions from passport-test.ts --- passport/passport-test.ts | 8 ++++---- passport/passport.d.ts | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/passport/passport-test.ts b/passport/passport-test.ts index f102b306ee..e3ee9d4f2b 100644 --- a/passport/passport-test.ts +++ b/passport/passport-test.ts @@ -7,7 +7,7 @@ import passport = require('passport'); class TestStrategy implements passport.Strategy { public name: string = 'test'; constructor() {} - authenticate(req: passport.Request) {} + authenticate(req: express.Request) {} } passport.use(new TestStrategy()); @@ -33,7 +33,7 @@ app.post('/login', res.redirect('/'); }); -app.post('/login', function(req: passport.Request, res: passport.Response, next: (err?: any) => void) { +app.post('/login', function(req, res, next) { passport.authenticate('local', function(err, user, info) { if (err) { return next(err) } if (!user) { @@ -47,12 +47,12 @@ app.post('/login', function(req: passport.Request, res: passport.Response, next: })(req, res, next); }); -app.get('/logout', function(req: passport.Request, res: passport.Response) { +app.get('/logout', function(req, res) { req.logout(); res.redirect('/'); }); -function ensureAuthenticated(req: passport.Request, res: passport.Response, next: (err?: any) => void) { +function ensureAuthenticated(req: express.Request, res: express.Response, next: (err?: any) => void) { if (req.isAuthenticated()) { return next(); } if (req.isUnauthenticated()) { res.redirect('/login'); diff --git a/passport/passport.d.ts b/passport/passport.d.ts index ae401b2528..cd86228f62 100644 --- a/passport/passport.d.ts +++ b/passport/passport.d.ts @@ -38,7 +38,16 @@ declare module 'passport' { transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void; } - interface Request extends express.Request { + interface Strategy { + name?: string; + authenticate(req: express.Request, options?: Object): void; + } +} + +declare module Express { + export interface Request { + + // These declarations are merged into express's Request type login(user: any, done: (err: any) => void): void; login(user: any, options: Object, done: (err: any) => void): void; logIn(user: any, done: (err: any) => void): void; @@ -50,11 +59,4 @@ declare module 'passport' { isAuthenticated(): boolean; isUnauthenticated(): boolean; } - interface Response extends express.Response {} - - interface Strategy { - name?: string; - authenticate(req: Request, options?: Object): void; - } } - From f578b03fcf641a0429e841026cc03819b05194ed Mon Sep 17 00:00:00 2001 From: Joshua Strobl Date: Mon, 7 Apr 2014 01:46:34 +0300 Subject: [PATCH 006/225] Added declaration that allows data to be based for on() without needing the optional selector. --- jquery/jquery.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index f38d7bf2f7..9874d13503 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2680,6 +2680,14 @@ interface JQuery { * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). */ on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, data : any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; /** * Attach an event handler function for one or more events to the selected elements. * From c5d912aca6dfd774b8963b030a423038c8760e47 Mon Sep 17 00:00:00 2001 From: Joshua Strobl Date: Mon, 7 Apr 2014 18:48:02 +0300 Subject: [PATCH 007/225] Fixed indentation in jquery.d.ts --- jquery/jquery.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 9874d13503..8f1bf2527b 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -2680,14 +2680,14 @@ interface JQuery { * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. Rest parameter args is for optional parameters passed to jQuery.trigger(). Note that the actual parameters on the event handler function must be marked as optional (? syntax). */ on(events: string, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; - /** - * Attach an event handler function for one or more events to the selected elements. - * - * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". - * @param data Data to be passed to the handler in event.data when an event is triggered. - * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. - */ - on(events: string, data : any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; + /** + * Attach an event handler function for one or more events to the selected elements. + * + * @param events One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". + * @param data Data to be passed to the handler in event.data when an event is triggered. + * @param handler A function to execute when the event is triggered. The value false is also allowed as a shorthand for a function that simply does return false. + */ + on(events: string, data : any, handler: (eventObject: JQueryEventObject, ...args: any[]) => any): JQuery; /** * Attach an event handler function for one or more events to the selected elements. * From d98910416f97ee6f5635ef7bd8e68b70565616ad Mon Sep 17 00:00:00 2001 From: miffels Date: Tue, 8 Apr 2014 12:05:23 +0200 Subject: [PATCH 008/225] Adjusting type angular.resource type definitions and tests to better reflect actual interface (particularly promises) --- angularjs/angular-resource-tests.ts | 49 +++++++++++- angularjs/angular-resource.d.ts | 112 +++++++++++++++++----------- 2 files changed, 117 insertions(+), 44 deletions(-) diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index 2870b21ad8..5a276e949d 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -19,7 +19,9 @@ actionDescriptor.params = { key: 'value' }; /////////////////////////////////////// var resourceClass: IMyResourceClass; var resource: IMyResource; -var resourceArray: IMyResource[]; +var resourceArray: ng.resource.IResourceArray; +var promise : ng.IPromise; +var arrayPromise : ng.IPromise; resource = resourceClass.delete(); resource = resourceClass.delete({ key: 'value' }); @@ -30,6 +32,15 @@ resource = resourceClass.delete({ key: 'value' }, { key: 'value' }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +promise = resource.$delete(); +promise = resource.$delete({ key: 'value' }); +promise = resource.$delete({ key: 'value' }, function () { }); +promise = resource.$delete(function () { }); +promise = resource.$delete(function () { }, function () { }); +promise = resource.$delete({ key: 'value' }, { key: 'value' }); +promise = resource.$delete({ key: 'value' }, { key: 'value' }, function () { }); +promise = resource.$delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + resource = resourceClass.get(); resource = resourceClass.get({ key: 'value' }); resource = resourceClass.get({ key: 'value' }, function () { }); @@ -39,6 +50,15 @@ resource = resourceClass.get({ key: 'value' }, { key: 'value' }); resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +promise = resource.$get(); +promise = resource.$get({ key: 'value' }); +promise = resource.$get({ key: 'value' }, function () { }); +promise = resource.$get(function () { }); +promise = resource.$get(function () { }, function () { }); +promise = resource.$get({ key: 'value' }, { key: 'value' }); +promise = resource.$get({ key: 'value' }, { key: 'value' }, function () { }); +promise = resource.$get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + resourceArray = resourceClass.query(); resourceArray = resourceClass.query({ key: 'value' }); resourceArray = resourceClass.query({ key: 'value' }, function () { }); @@ -48,6 +68,15 @@ resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }); resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }); resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +arrayPromise = resourceArray[0].query(); +arrayPromise = resourceArray[0].query({ key: 'value' }); +arrayPromise = resourceArray[0].query({ key: 'value' }, function () { }); +arrayPromise = resourceArray[0].query(function () { }); +arrayPromise = resourceArray[0].query(function () { }, function () { }); +arrayPromise = resourceArray[0].query({ key: 'value' }, { key: 'value' }); +arrayPromise = resourceArray[0].query({ key: 'value' }, { key: 'value' }, function () { }); +arrayPromise = resourceArray[0].query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + resource = resourceClass.remove(); resource = resourceClass.remove({ key: 'value' }); resource = resourceClass.remove({ key: 'value' }, function () { }); @@ -57,6 +86,15 @@ resource = resourceClass.remove({ key: 'value' }, { key: 'value' }); resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +promise = resource.$remove(); +promise = resource.$remove({ key: 'value' }); +promise = resource.$remove({ key: 'value' }, function () { }); +promise = resource.$remove(function () { }); +promise = resource.$remove(function () { }, function () { }); +promise = resource.$remove({ key: 'value' }, { key: 'value' }); +promise = resource.$remove({ key: 'value' }, { key: 'value' }, function () { }); +promise = resource.$remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + resource = resourceClass.save(); resource = resourceClass.save({ key: 'value' }); resource = resourceClass.save({ key: 'value' }, function () { }); @@ -66,6 +104,15 @@ resource = resourceClass.save({ key: 'value' }, { key: 'value' }); resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +promise = resource.$save(); +promise = resource.$save({ key: 'value' }); +promise = resource.$save({ key: 'value' }, function () { }); +promise = resource.$save(function () { }); +promise = resource.$save(function () { }, function () { }); +promise = resource.$save({ key: 'value' }, { key: 'value' }); +promise = resource.$save({ key: 'value' }, { key: 'value' }, function () { }); +promise = resource.$save({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + /////////////////////////////////////// // IResourceService /////////////////////////////////////// diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index a0cd4ab85a..942e5e120d 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -53,64 +53,90 @@ declare module ng.resource { interface IResourceClass { new(dataOrParams? : any) : T; get(): T; - get(dataOrParams: any): T; - get(dataOrParams: any, success: Function): T; + get(params: Object): T; get(success: Function, error?: Function): T; - get(params: any, data: any, success?: Function, error?: Function): T; + get(params: Object, success: Function, error?: Function): T; + get(params: Object, data: Object, success?: Function): T; + get(params: Object, data: Object, success: Function, error?: Function): T; + + query(): IResourceArray; + query(params: Object): IResourceArray; + query(success: Function, error?: Function): IResourceArray; + query(params: Object, success: Function, error?: Function): IResourceArray; + query(params: Object, data: Object, success?: Function): IResourceArray; + query(params: Object, data: Object, success: Function, error?: Function): IResourceArray; + save(): T; - save(dataOrParams: any): T; - save(dataOrParams: any, success: Function): T; + save(data: Object): T; save(success: Function, error?: Function): T; - save(params: any, data: any, success?: Function, error?: Function): T; - query(): T[]; - query(dataOrParams: any): T[]; - query(dataOrParams: any, success: Function): T[]; - query(success: Function, error?: Function): T[]; - query(params: any, data: any, success?: Function, error?: Function): T[]; + save(data: Object, success: Function, error?: Function): T; + save(params: Object, data: Object, success?: Function): T; + save(params: Object, data: Object, success: Function, error?: Function): T; + remove(): T; - remove(dataOrParams: any): T; - remove(dataOrParams: any, success: Function): T; + remove(params: Object): T; remove(success: Function, error?: Function): T; - remove(params: any, data: any, success?: Function, error?: Function): T; + remove(params: Object, success: Function, error?: Function): T; + remove(params: Object, data: Object, success?: Function): T; + remove(params: Object, data: Object, success: Function, error?: Function): T; + delete(): T; - delete(dataOrParams: any): T; - delete(dataOrParams: any, success: Function): T; + delete(params: Object): T; delete(success: Function, error?: Function): T; - delete(params: any, data: any, success?: Function, error?: Function): T; + delete(params: Object, success: Function, error?: Function): T; + delete(params: Object, data: Object, success?: Function): T; + delete(params: Object, data: Object, success: Function, error?: Function): T; } interface IResource { - $get(): T; - $get(dataOrParams: any): T; - $get(dataOrParams: any, success: Function): T; - $get(success: Function, error?: Function): T; - $get(params: any, data: any, success?: Function, error?: Function): T; - $save(): T; - $save(dataOrParams: any): T; - $save(dataOrParams: any, success: Function): T; - $save(success: Function, error?: Function): T; - $save(params: any, data: any, success?: Function, error?: Function): T; - $query(): T[]; - $query(dataOrParams: any): T[]; - $query(dataOrParams: any, success: Function): T[]; - $query(success: Function, error?: Function): T[]; - $query(params: any, data: any, success?: Function, error?: Function): T[]; - $remove(): T; - $remove(dataOrParams: any): T; - $remove(dataOrParams: any, success: Function): T; - $remove(success: Function, error?: Function): T; - $remove(params: any, data: any, success?: Function, error?: Function): T; - $delete(): T; - $delete(dataOrParams: any): T; - $delete(dataOrParams: any, success: Function): T; - $delete(success: Function, error?: Function): T; - $delete(params: any, data: any, success?: Function, error?: Function): T; - + $get(): ng.IPromise; + $get(params: Object): ng.IPromise; + $get(success: Function, error?: Function): ng.IPromise; + $get(params: Object, success: Function, error?: Function): ng.IPromise; + $get(params: Object, data: Object, success?: Function): ng.IPromise; + $get(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; + + $query(): ng.IPromise; + $query(params: Object): ng.IPromise; + $query(success: Function, error?: Function): ng.IPromise; + $query(params: Object, success: Function, error?: Function): ng.IPromise; + $query(params: Object, data: Object, success?: Function): ng.IPromise; + $query(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; + + $save(): ng.IPromise; + $save(data: Object): ng.IPromise; + $save(success: Function, error?: Function): ng.IPromise; + $save(data: Object, success: Function, error?: Function): ng.IPromise; + $save(params: Object, data: Object, success?: Function): ng.IPromise; + $save(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; + + $remove(): ng.IPromise; + $remove(params: Object): ng.IPromise; + $remove(success: Function, error?: Function): ng.IPromise; + $remove(params: Object, success: Function, error?: Function): ng.IPromise; + $remove(params: Object, data: Object, success?: Function): ng.IPromise; + $remove(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; + + $delete(): ng.IPromise; + $delete(params: Object): ng.IPromise; + $delete(success: Function, error?: Function): ng.IPromise; + $delete(params: Object, success: Function, error?: Function): ng.IPromise; + $delete(params: Object, data: Object, success?: Function): ng.IPromise; + $delete(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; + /** the promise of the original server interaction that created this instance. **/ $promise : ng.IPromise; $resolved : boolean; } + interface Array {} + + interface IResourceArray extends Array { + /** the promise of the original server interaction that created this collection. **/ + $promise : ng.IPromise; + $resolved : boolean; + } + /** when creating a resource factory via IModule.factory */ interface IResourceServiceFactoryFunction { ($resource: ng.resource.IResourceService): IResourceClass; From 341d0c519ef26cc3dbcca7a49ebbe96b8a84ecb1 Mon Sep 17 00:00:00 2001 From: enternet Date: Tue, 8 Apr 2014 14:04:43 +0300 Subject: [PATCH 009/225] RaphaelPaper.forEach() RaphaelPaper.forEach() declaration has been fixed. --- raphael/raphael.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raphael/raphael.d.ts b/raphael/raphael.d.ts index 887ab51cd2..a63c987da4 100644 --- a/raphael/raphael.d.ts +++ b/raphael/raphael.d.ts @@ -200,7 +200,7 @@ interface RaphaelPaper { clear(): void; defs: SVGDefsElement; ellipse(x: number, y: number, rx: number, ry: number): RaphaelElement; - forEach(callback: number, thisArg: any): RaphaelStatic; + forEach(callback: (el: RaphaelElement) => boolean, thisArg?: any): RaphaelStatic; getById(id: number): RaphaelElement; getElementByPoint(x: number, y: number): RaphaelElement; getElementsByPoint(x: number, y: number): RaphaelSet; From 5639237400cc91de4769fa82f0137ff8f59f231d Mon Sep 17 00:00:00 2001 From: enternet Date: Tue, 8 Apr 2014 14:19:58 +0300 Subject: [PATCH 010/225] interface SortableOptions extends SortableEvents If we look into jqueryUI internals we will see that all the config values stored in one object. Both Options and Events. For example we can call UI.sortable({opacity: value1, start: fn1, stop: fn2}) --- jqueryui/jqueryui.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 52d7d6d6a3..e000e6fb29 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -462,7 +462,7 @@ declare module JQueryUI { // Sortable ////////////////////////////////////////////////// - interface SortableOptions { + interface SortableOptions extends SortableEvents { appendTo?: any; // jQuery, Element, Selector or string axis?: string; cancel?: any; // Selector From f037b846658263f8eb8d7a01de7d072b5c7289e2 Mon Sep 17 00:00:00 2001 From: miffels Date: Tue, 8 Apr 2014 13:46:34 +0200 Subject: [PATCH 011/225] Fixing array interface and tests and adding humble co-author note --- angularjs/angular-resource-tests.ts | 86 ++++++++++++++++------------- angularjs/angular-resource.d.ts | 11 ++-- 2 files changed, 54 insertions(+), 43 deletions(-) diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index 5a276e949d..327fcaba6e 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -20,8 +20,6 @@ actionDescriptor.params = { key: 'value' }; var resourceClass: IMyResourceClass; var resource: IMyResource; var resourceArray: ng.resource.IResourceArray; -var promise : ng.IPromise; -var arrayPromise : ng.IPromise; resource = resourceClass.delete(); resource = resourceClass.delete({ key: 'value' }); @@ -32,15 +30,6 @@ resource = resourceClass.delete({ key: 'value' }, { key: 'value' }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); -promise = resource.$delete(); -promise = resource.$delete({ key: 'value' }); -promise = resource.$delete({ key: 'value' }, function () { }); -promise = resource.$delete(function () { }); -promise = resource.$delete(function () { }, function () { }); -promise = resource.$delete({ key: 'value' }, { key: 'value' }); -promise = resource.$delete({ key: 'value' }, { key: 'value' }, function () { }); -promise = resource.$delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); - resource = resourceClass.get(); resource = resourceClass.get({ key: 'value' }); resource = resourceClass.get({ key: 'value' }, function () { }); @@ -50,15 +39,6 @@ resource = resourceClass.get({ key: 'value' }, { key: 'value' }); resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); -promise = resource.$get(); -promise = resource.$get({ key: 'value' }); -promise = resource.$get({ key: 'value' }, function () { }); -promise = resource.$get(function () { }); -promise = resource.$get(function () { }, function () { }); -promise = resource.$get({ key: 'value' }, { key: 'value' }); -promise = resource.$get({ key: 'value' }, { key: 'value' }, function () { }); -promise = resource.$get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); - resourceArray = resourceClass.query(); resourceArray = resourceClass.query({ key: 'value' }); resourceArray = resourceClass.query({ key: 'value' }, function () { }); @@ -67,15 +47,7 @@ resourceArray = resourceClass.query(function () { }, function () { }); resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }); resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }); resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); - -arrayPromise = resourceArray[0].query(); -arrayPromise = resourceArray[0].query({ key: 'value' }); -arrayPromise = resourceArray[0].query({ key: 'value' }, function () { }); -arrayPromise = resourceArray[0].query(function () { }); -arrayPromise = resourceArray[0].query(function () { }, function () { }); -arrayPromise = resourceArray[0].query({ key: 'value' }, { key: 'value' }); -arrayPromise = resourceArray[0].query({ key: 'value' }, { key: 'value' }, function () { }); -arrayPromise = resourceArray[0].query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +resourceArray.push(resource); resource = resourceClass.remove(); resource = resourceClass.remove({ key: 'value' }); @@ -86,15 +58,6 @@ resource = resourceClass.remove({ key: 'value' }, { key: 'value' }); resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); -promise = resource.$remove(); -promise = resource.$remove({ key: 'value' }); -promise = resource.$remove({ key: 'value' }, function () { }); -promise = resource.$remove(function () { }); -promise = resource.$remove(function () { }, function () { }); -promise = resource.$remove({ key: 'value' }, { key: 'value' }); -promise = resource.$remove({ key: 'value' }, { key: 'value' }, function () { }); -promise = resource.$remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); - resource = resourceClass.save(); resource = resourceClass.save({ key: 'value' }); resource = resourceClass.save({ key: 'value' }, function () { }); @@ -104,6 +67,49 @@ resource = resourceClass.save({ key: 'value' }, { key: 'value' }); resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.save({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +/////////////////////////////////////// +// IResource +/////////////////////////////////////// + +var promise : ng.IPromise; +var arrayPromise : ng.IPromise; + +promise = resource.$delete(); +promise = resource.$delete({ key: 'value' }); +promise = resource.$delete({ key: 'value' }, function () { }); +promise = resource.$delete(function () { }); +promise = resource.$delete(function () { }, function () { }); +promise = resource.$delete({ key: 'value' }, { key: 'value' }); +promise = resource.$delete({ key: 'value' }, { key: 'value' }, function () { }); +promise = resource.$delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +promise = resource.$get(); +promise = resource.$get({ key: 'value' }); +promise = resource.$get({ key: 'value' }, function () { }); +promise = resource.$get(function () { }); +promise = resource.$get(function () { }, function () { }); +promise = resource.$get({ key: 'value' }, { key: 'value' }); +promise = resource.$get({ key: 'value' }, { key: 'value' }, function () { }); +promise = resource.$get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +arrayPromise = resourceArray[0].$query(); +arrayPromise = resourceArray[0].$query({ key: 'value' }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }); +arrayPromise = resourceArray[0].$query(function () { }); +arrayPromise = resourceArray[0].$query(function () { }, function () { }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, { key: 'value' }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, { key: 'value' }, function () { }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + +promise = resource.$remove(); +promise = resource.$remove({ key: 'value' }); +promise = resource.$remove({ key: 'value' }, function () { }); +promise = resource.$remove(function () { }); +promise = resource.$remove(function () { }, function () { }); +promise = resource.$remove({ key: 'value' }, { key: 'value' }); +promise = resource.$remove({ key: 'value' }, { key: 'value' }, function () { }); +promise = resource.$remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); + promise = resource.$save(); promise = resource.$save({ key: 'value' }); promise = resource.$save({ key: 'value' }, function () { }); @@ -132,3 +138,7 @@ resourceClass = resourceServiceFactoryFunction(resourceService resourceServiceFactoryFunction = function (resourceService: ng.resource.IResourceService) { return resourceClass; }; mod = mod.factory('factory name', resourceServiceFactoryFunction); + +/////////////////////////////////////// +// IResource +/////////////////////////////////////// \ No newline at end of file diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 942e5e120d..52706d68d2 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular JS 1.2 (ngResource module) // Project: http://angularjs.org -// Definitions by: Diego Vilar +// Definitions by: Diego Vilar , Michael Jess (minor enhancements) // Definitions: https://github.com/daptiv/DefinitelyTyped /// @@ -129,11 +129,12 @@ declare module ng.resource { $resolved : boolean; } - interface Array {} - - interface IResourceArray extends Array { + /** + * Really just a regular Array object with $promise and $resolve attached to it + */ + interface IResourceArray extends Array { /** the promise of the original server interaction that created this collection. **/ - $promise : ng.IPromise; + $promise : ng.IPromise; $resolved : boolean; } From fffce8af7d5cae04f62f0f6082f6e3d8adfbefb5 Mon Sep 17 00:00:00 2001 From: miffels Date: Tue, 8 Apr 2014 14:15:34 +0200 Subject: [PATCH 012/225] Simplifying instance API and adding some explanatory comments --- angularjs/angular-resource-tests.ts | 20 +++--------- angularjs/angular-resource.d.ts | 50 ++++++++++++----------------- 2 files changed, 25 insertions(+), 45 deletions(-) diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index 327fcaba6e..107d6b29e0 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -79,45 +79,35 @@ promise = resource.$delete({ key: 'value' }); promise = resource.$delete({ key: 'value' }, function () { }); promise = resource.$delete(function () { }); promise = resource.$delete(function () { }, function () { }); -promise = resource.$delete({ key: 'value' }, { key: 'value' }); -promise = resource.$delete({ key: 'value' }, { key: 'value' }, function () { }); -promise = resource.$delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +promise = resource.$delete({ key: 'value' }, function () { }, function () { }); promise = resource.$get(); promise = resource.$get({ key: 'value' }); promise = resource.$get({ key: 'value' }, function () { }); promise = resource.$get(function () { }); promise = resource.$get(function () { }, function () { }); -promise = resource.$get({ key: 'value' }, { key: 'value' }); -promise = resource.$get({ key: 'value' }, { key: 'value' }, function () { }); -promise = resource.$get({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +promise = resource.$get({ key: 'value' }, function () { }, function () { }); arrayPromise = resourceArray[0].$query(); arrayPromise = resourceArray[0].$query({ key: 'value' }); arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }); arrayPromise = resourceArray[0].$query(function () { }); arrayPromise = resourceArray[0].$query(function () { }, function () { }); -arrayPromise = resourceArray[0].$query({ key: 'value' }, { key: 'value' }); -arrayPromise = resourceArray[0].$query({ key: 'value' }, { key: 'value' }, function () { }); -arrayPromise = resourceArray[0].$query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { }); promise = resource.$remove(); promise = resource.$remove({ key: 'value' }); promise = resource.$remove({ key: 'value' }, function () { }); promise = resource.$remove(function () { }); promise = resource.$remove(function () { }, function () { }); -promise = resource.$remove({ key: 'value' }, { key: 'value' }); -promise = resource.$remove({ key: 'value' }, { key: 'value' }, function () { }); -promise = resource.$remove({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +promise = resource.$remove({ key: 'value' }, function () { }, function () { }); promise = resource.$save(); promise = resource.$save({ key: 'value' }); promise = resource.$save({ key: 'value' }, function () { }); promise = resource.$save(function () { }); promise = resource.$save(function () { }, function () { }); -promise = resource.$save({ key: 'value' }, { key: 'value' }); -promise = resource.$save({ key: 'value' }, { key: 'value' }, function () { }); -promise = resource.$save({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +promise = resource.$save({ key: 'value' }, function () { }, function () { }); /////////////////////////////////////// // IResourceService diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 52706d68d2..393362a95e 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -50,79 +50,69 @@ declare module ng.resource { // PATCH (in other words, methods with body). Otherwise, it's going // to be considered as parameters to the request. // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L461-L465 + // + // Only those methods with an HTTP body do have 'data' as first parameter: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L463 + // More specifically, those methods are POST, PUT and PATCH: + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L432 + // + // Also, static calls always return the IResource (or IResourceArray) retrieved + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L549 interface IResourceClass { new(dataOrParams? : any) : T; get(): T; get(params: Object): T; get(success: Function, error?: Function): T; get(params: Object, success: Function, error?: Function): T; - get(params: Object, data: Object, success?: Function): T; - get(params: Object, data: Object, success: Function, error?: Function): T; + get(params: Object, data: Object, success?: Function, error?: Function): T; query(): IResourceArray; query(params: Object): IResourceArray; query(success: Function, error?: Function): IResourceArray; query(params: Object, success: Function, error?: Function): IResourceArray; - query(params: Object, data: Object, success?: Function): IResourceArray; - query(params: Object, data: Object, success: Function, error?: Function): IResourceArray; + query(params: Object, data: Object, success?: Function, error?: Function): IResourceArray; save(): T; save(data: Object): T; save(success: Function, error?: Function): T; save(data: Object, success: Function, error?: Function): T; - save(params: Object, data: Object, success?: Function): T; - save(params: Object, data: Object, success: Function, error?: Function): T; + save(params: Object, data: Object, success?: Function, error?: Function): T; remove(): T; remove(params: Object): T; remove(success: Function, error?: Function): T; remove(params: Object, success: Function, error?: Function): T; - remove(params: Object, data: Object, success?: Function): T; - remove(params: Object, data: Object, success: Function, error?: Function): T; + remove(params: Object, data: Object, success?: Function, error?: Function): T; delete(): T; delete(params: Object): T; delete(success: Function, error?: Function): T; delete(params: Object, success: Function, error?: Function): T; - delete(params: Object, data: Object, success?: Function): T; - delete(params: Object, data: Object, success: Function, error?: Function): T; + delete(params: Object, data: Object, success?: Function, error?: Function): T; } + // Instance calls always return the the promise of the request which retrieved the object + // https://github.com/angular/angular.js/blob/v1.2.0/src/ngResource/resource.js#L538-L546 interface IResource { $get(): ng.IPromise; - $get(params: Object): ng.IPromise; + $get(params?: Object, success?: Function, error?: Function): ng.IPromise; $get(success: Function, error?: Function): ng.IPromise; - $get(params: Object, success: Function, error?: Function): ng.IPromise; - $get(params: Object, data: Object, success?: Function): ng.IPromise; - $get(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; $query(): ng.IPromise; - $query(params: Object): ng.IPromise; + $query(params?: Object, success?: Function, error?: Function): ng.IPromise; $query(success: Function, error?: Function): ng.IPromise; - $query(params: Object, success: Function, error?: Function): ng.IPromise; - $query(params: Object, data: Object, success?: Function): ng.IPromise; - $query(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; $save(): ng.IPromise; - $save(data: Object): ng.IPromise; + $save(params?: Object, success?: Function, error?: Function): ng.IPromise; $save(success: Function, error?: Function): ng.IPromise; - $save(data: Object, success: Function, error?: Function): ng.IPromise; - $save(params: Object, data: Object, success?: Function): ng.IPromise; - $save(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; $remove(): ng.IPromise; - $remove(params: Object): ng.IPromise; + $remove(params?: Object, success?: Function, error?: Function): ng.IPromise; $remove(success: Function, error?: Function): ng.IPromise; - $remove(params: Object, success: Function, error?: Function): ng.IPromise; - $remove(params: Object, data: Object, success?: Function): ng.IPromise; - $remove(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; $delete(): ng.IPromise; - $delete(params: Object): ng.IPromise; + $delete(params?: Object, success?: Function, error?: Function): ng.IPromise; $delete(success: Function, error?: Function): ng.IPromise; - $delete(params: Object, success: Function, error?: Function): ng.IPromise; - $delete(params: Object, data: Object, success?: Function): ng.IPromise; - $delete(params: Object, data: Object, success: Function, error?: Function): ng.IPromise; /** the promise of the original server interaction that created this instance. **/ $promise : ng.IPromise; From 2aa1127c030b8cadec83c838e5276ffda03303d6 Mon Sep 17 00:00:00 2001 From: Alexei Bykov Date: Tue, 8 Apr 2014 19:15:32 +0400 Subject: [PATCH 013/225] fixed declaration of d3.Event interface - added 'type' member into d3.Event interface --- d3/d3.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 0fb3f58b45..5f68f6f362 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -54,6 +54,7 @@ declare module D3 { y: number; keyCode: number; altKey: any; + type: string; } export interface Base extends Selectors { From cbdaec6beb4dac5ff1a982ddf522333e073d083b Mon Sep 17 00:00:00 2001 From: Aidiakapi Date: Tue, 8 Apr 2014 17:32:00 +0200 Subject: [PATCH 014/225] fix(angularjs): make Function.$inject optional The $inject member of the global Function interface should be optional, to be consistent with actual functions. --- angularjs/angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 4a9f128223..61d80df3f2 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -10,7 +10,7 @@ declare var angular: ng.IAngularStatic; // Support for painless dependency injection interface Function { - $inject:string[]; + $inject?: string[]; } /////////////////////////////////////////////////////////////////////////////// From 1efaca22797fc58df97aad212de755730ae07203 Mon Sep 17 00:00:00 2001 From: miffels Date: Tue, 8 Apr 2014 19:47:20 +0200 Subject: [PATCH 015/225] Fixing array call promise inconsistency (thanks @jackdolabany) and adding tests --- angularjs/angular-resource-tests.ts | 4 ++++ angularjs/angular-resource.d.ts | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/angularjs/angular-resource-tests.ts b/angularjs/angular-resource-tests.ts index 107d6b29e0..c80cc662de 100644 --- a/angularjs/angular-resource-tests.ts +++ b/angularjs/angular-resource-tests.ts @@ -29,6 +29,7 @@ resource = resourceClass.delete(function () { }, function () { }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }); resource = resourceClass.delete({ key: 'value' }, { key: 'value' }, function () { }, function () { }); +resource.$promise.then(function(data: IMyResource) {}); resource = resourceClass.get(); resource = resourceClass.get({ key: 'value' }); @@ -48,6 +49,7 @@ resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }); resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }); resourceArray = resourceClass.query({ key: 'value' }, { key: 'value' }, function () { }, function () { }); resourceArray.push(resource); +resourceArray.$promise.then(function(data: ng.resource.IResourceArray) {}); resource = resourceClass.remove(); resource = resourceClass.remove({ key: 'value' }); @@ -80,6 +82,7 @@ promise = resource.$delete({ key: 'value' }, function () { }); promise = resource.$delete(function () { }); promise = resource.$delete(function () { }, function () { }); promise = resource.$delete({ key: 'value' }, function () { }, function () { }); +promise.then(function(data: IMyResource) {}); promise = resource.$get(); promise = resource.$get({ key: 'value' }); @@ -94,6 +97,7 @@ arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }); arrayPromise = resourceArray[0].$query(function () { }); arrayPromise = resourceArray[0].$query(function () { }, function () { }); arrayPromise = resourceArray[0].$query({ key: 'value' }, function () { }, function () { }); +arrayPromise.then(function(data: ng.resource.IResourceArray) {}); promise = resource.$remove(); promise = resource.$remove({ key: 'value' }); diff --git a/angularjs/angular-resource.d.ts b/angularjs/angular-resource.d.ts index 393362a95e..51b93091fa 100644 --- a/angularjs/angular-resource.d.ts +++ b/angularjs/angular-resource.d.ts @@ -98,9 +98,9 @@ declare module ng.resource { $get(params?: Object, success?: Function, error?: Function): ng.IPromise; $get(success: Function, error?: Function): ng.IPromise; - $query(): ng.IPromise; - $query(params?: Object, success?: Function, error?: Function): ng.IPromise; - $query(success: Function, error?: Function): ng.IPromise; + $query(): ng.IPromise>; + $query(params?: Object, success?: Function, error?: Function): ng.IPromise>; + $query(success: Function, error?: Function): ng.IPromise>; $save(): ng.IPromise; $save(params?: Object, success?: Function, error?: Function): ng.IPromise; @@ -124,7 +124,7 @@ declare module ng.resource { */ interface IResourceArray extends Array { /** the promise of the original server interaction that created this collection. **/ - $promise : ng.IPromise; + $promise : ng.IPromise>; $resolved : boolean; } From f32f51065ce721f65633a71ded76adcee3e21b0a Mon Sep 17 00:00:00 2001 From: milkisevil Date: Tue, 8 Apr 2014 18:56:04 +0100 Subject: [PATCH 016/225] Added `Animation.isActive():boolean` See: http://api.greensock.com/js/com/greensock/core/Animation.html#isActive() --- greensock/greensock.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/greensock/greensock.d.ts b/greensock/greensock.d.ts index 7726857866..4cf521e156 100644 --- a/greensock/greensock.d.ts +++ b/greensock/greensock.d.ts @@ -24,6 +24,7 @@ declare class Animation { duration(value:number):any; eventCallback(type:string, callback?:Function, params?:any[], scope?:any):any; invalidate():any; + isActive():boolean; kill(vars?:Object, target?:Object):any; pause(atTime?:any, suppressEvents?:boolean):any; paused(value?:boolean):any; From 6bd86406f6fa4a1edf7823657d85634d13b81eaf Mon Sep 17 00:00:00 2001 From: satoru kimura Date: Wed, 9 Apr 2014 13:09:16 +0900 Subject: [PATCH 017/225] Renamed definition file for intelligibility. --- createjs/{createjs.d.ts => createjs-lib.d.ts} | 8 ++++---- easeljs/easeljs.d.ts | 4 ++-- preloadjs/preloadjs.d.ts | 2 +- soundjs/soundjs.d.ts | 2 +- tweenjs/tweenjs.d.ts | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) rename createjs/{createjs.d.ts => createjs-lib.d.ts} (99%) diff --git a/createjs/createjs.d.ts b/createjs/createjs-lib.d.ts similarity index 99% rename from createjs/createjs.d.ts rename to createjs/createjs-lib.d.ts index 3ebfd11bf5..048fde92df 100644 --- a/createjs/createjs.d.ts +++ b/createjs/createjs-lib.d.ts @@ -32,8 +32,8 @@ declare module createjs { target: any; // It is 'Object' type officially, but 'any' is easier to use. timeStamp: number; type: string; - - // other event payloads + + // other event payloads data: any; delta: number; error: string; @@ -51,7 +51,7 @@ declare module createjs { src: string; time: number; total: number; - + // methods clone(): Event; preventDefault(): void; @@ -92,7 +92,7 @@ declare module createjs { toString(): string; willTrigger(type: string): boolean; } - + export function indexOf(array: any[], searchElement: Object): number; export function proxy(method: (eventObj: Object) => boolean, scope: Object, ...arg: any[]): (eventObj: Object) => any; diff --git a/easeljs/easeljs.d.ts b/easeljs/easeljs.d.ts index 2c5be3aa34..3f629aa3f0 100644 --- a/easeljs/easeljs.d.ts +++ b/easeljs/easeljs.d.ts @@ -12,10 +12,10 @@ // Library documentation : http://www.createjs.com/Docs/EaselJS/modules/EaselJS.html -/// +/// /// -// rename the native MouseEvent, to avoid conflit with createjs's MouseEvent +// rename the native MouseEvent, to avoid conflict with createjs's MouseEvent interface NativeMouseEvent extends MouseEvent { } diff --git a/preloadjs/preloadjs.d.ts b/preloadjs/preloadjs.d.ts index 142e939b6c..0af5debfe6 100644 --- a/preloadjs/preloadjs.d.ts +++ b/preloadjs/preloadjs.d.ts @@ -12,7 +12,7 @@ // Library documentation : http://www.createjs.com/Docs/PreloadJS/modules/PreloadJS.html -/// +/// declare module createjs { export class AbstractLoader extends EventDispatcher { diff --git a/soundjs/soundjs.d.ts b/soundjs/soundjs.d.ts index 922d116675..f5a2f9b14c 100644 --- a/soundjs/soundjs.d.ts +++ b/soundjs/soundjs.d.ts @@ -12,7 +12,7 @@ // Library documentation : http://www.createjs.com/Docs/SoundJS/modules/SoundJS.html -/// +/// declare module createjs { export class FlashPlugin { diff --git a/tweenjs/tweenjs.d.ts b/tweenjs/tweenjs.d.ts index 775a05a209..f4c1dcc743 100644 --- a/tweenjs/tweenjs.d.ts +++ b/tweenjs/tweenjs.d.ts @@ -12,7 +12,7 @@ // Library documentation : http://www.createjs.com/Docs/TweenJS/modules/TweenJS.html -/// +/// declare module createjs { export class CSSPlugin { From ac17239ecfdbb21f3e31fa16cb385954c08e81bb Mon Sep 17 00:00:00 2001 From: satoru kimura Date: Wed, 9 Apr 2014 13:10:47 +0900 Subject: [PATCH 018/225] added createjs.d.ts again. --- createjs/createjs.d.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 createjs/createjs.d.ts diff --git a/createjs/createjs.d.ts b/createjs/createjs.d.ts new file mode 100644 index 0000000000..15a1149a26 --- /dev/null +++ b/createjs/createjs.d.ts @@ -0,0 +1,24 @@ +// Type definitions for EaselJS 0.7.1, TweenJS 0.5.1, SoundJS 0.5.2, PreloadJS 0.4.1 +// Project: http://www.createjs.com/#!/EaselJS +// Definitions by: Pedro Ferreira , Chris Smith , Satoru Kimura +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/* + Copyright (c) 2012 Pedro Ferreira + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +// Library documentation : http://www.createjs.com/Docs/EaselJS/modules/EaselJS.html +// Library documentation : http://www.createjs.com/Docs/PreloadJS/modules/PreloadJS.html +// Library documentation : http://www.createjs.com/Docs/SoundJS/modules/SoundJS.html +// Library documentation : http://www.createjs.com/Docs/TweenJS/modules/TweenJS.html + + +/// +/// +/// +/// +/// + From 37e590111b1505858c1ecc2f184381e7f22c84ce Mon Sep 17 00:00:00 2001 From: enternet Date: Wed, 9 Apr 2014 17:31:48 +0300 Subject: [PATCH 019/225] RaphaelPaper.forEach() returns RaphaelPaper RaphaelPaper.forEach() returns RaphaelPaper at runtime. --- raphael/raphael.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/raphael/raphael.d.ts b/raphael/raphael.d.ts index a63c987da4..fc0b26292d 100644 --- a/raphael/raphael.d.ts +++ b/raphael/raphael.d.ts @@ -200,7 +200,7 @@ interface RaphaelPaper { clear(): void; defs: SVGDefsElement; ellipse(x: number, y: number, rx: number, ry: number): RaphaelElement; - forEach(callback: (el: RaphaelElement) => boolean, thisArg?: any): RaphaelStatic; + forEach(callback: (el: RaphaelElement) => boolean, thisArg?: any): RaphaelPaper; getById(id: number): RaphaelElement; getElementByPoint(x: number, y: number): RaphaelElement; getElementsByPoint(x: number, y: number): RaphaelSet; From 9bc2b98fdb43c1692a60fb3f4e184e94d2ef75ba Mon Sep 17 00:00:00 2001 From: enternet Date: Wed, 9 Apr 2014 21:04:05 +0300 Subject: [PATCH 020/225] HighchartsLegendOptions.useHTML?: boolean HighchartsLegendOptions.useHTML is boolean property, not numeric. Sometimes i'm thinking that I'm the first person in the world who is using these definitions ( --- highcharts/highcharts.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index 64d9f92fc4..6ba9bfce77 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -371,7 +371,7 @@ interface HighchartsLegendOptions { style?: HighchartsCSSObject; symbolPadding?: number; symbolWidth?: number; - useHTML?: number; + useHTML?: boolean; width?: number; x?: number; y?: number; From 2de7bfe6276ffd9dea76187ba59198b72ab4a574 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:10:08 -0700 Subject: [PATCH 021/225] WinJS control constructors do not require an element to be passed. If no element is passed, an element is created during construction and accessible via the 'element' property. --- winjs/winjs.d.ts | 50 ++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index cdc3d27fa5..aa0b5b0be0 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -3490,7 +3490,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new AppBar. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -3646,7 +3646,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new AppBarCommand. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -3768,7 +3768,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new BackButton. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -3951,7 +3951,7 @@ declare module WinJS.UI { * @param element The DOM element associated with the DatePicker control. * @param options The set of options to be applied initially to the DatePicker control. The options are the following: calendar, current, datePattern, disabled, maxYear, minYear, monthPattern, yearPattern. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -4110,7 +4110,7 @@ declare module WinJS.UI { * @param element The DOM element that hosts the control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the pageselected event, add a property named "onpageselected" and set its value to the event handler. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -4252,7 +4252,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new Flyout. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -4615,7 +4615,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the Hub control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the contentanimating event, add a property named "oncontentanimating" to the options object and set its value to the event handler. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -4742,7 +4742,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new HubSection. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -4793,7 +4793,7 @@ declare module WinJS.UI { * @param element The element that hosts the HtmlControl. * @param options The options for configuring the page. The uri option is required in order to specify the source document for the content of the page. Other options are the ones used by the WinJS.Pages.render method. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -4811,7 +4811,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new ItemContainer. For the ItemContainer to be accessible, this element must have its role attribute set to "list" or "listbox". If tapBehavior is set to none and selectionDisabled is true, then use the "list" role; otherwise, use the "listbox" role. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -5163,7 +5163,7 @@ declare module WinJS.UI { /** * Displays data items in a customizable list or grid. **/ - class ListView { + class ListView { //#region Constructors /** @@ -5172,7 +5172,7 @@ declare module WinJS.UI { * @param element The DOM element that hosts the ListView control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the selectionchanged event, add a property named "onselectionchanged" to the options object and set its value to the event handler. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -5485,7 +5485,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new Menu. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -5631,7 +5631,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new MenuCommand. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -5728,7 +5728,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the new NavBar. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -5883,7 +5883,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new NavBarCommand. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -5978,7 +5978,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new NavBarContainer. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -6089,7 +6089,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new Rating. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the cancel event, add a property named "oncancel" to the options object and set its value to the event handler. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -6344,7 +6344,7 @@ declare module WinJS.UI { * @param element The DOM element hosts the new SearchBox. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -6479,7 +6479,7 @@ declare module WinJS.UI { * @param element The DOM element that hosts the SemanticZoom. * @param options An object that contains one or more property/value pairs to apply to the new control. This object can contain these properties: initiallyZoomedOut Boolean, zoomFactor 0.2–0.85. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -6579,7 +6579,7 @@ declare module WinJS.UI { * @param element The DOM element that will host the control. * @param options The set of properties and values to apply to the new SettingsFlyout. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -6781,7 +6781,7 @@ declare module WinJS.UI { * @param element The DOM element associated with the TimePicker control. * @param options The set of options to be applied initially to the TimePicker control. The options are the following: clock. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -6894,7 +6894,7 @@ declare module WinJS.UI { * @param element The DOM that hosts the control. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the change event, add a property named "onchange" to the options object and set its value to the event handler. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -7003,7 +7003,7 @@ declare module WinJS.UI { * @param element The DOM element associated that hosts the Tooltip. * @param options An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's properties or events. Event names must begin with "on". For example, to provide a handler for the opened event, add a property named "onopened" to the options object and set its value to the event handler. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors @@ -7119,7 +7119,7 @@ declare module WinJS.UI { * @param element The DOM element that functions as the scaling box. This element fills 100% of the width and height allotted to it. * @param options The set of options to be applied initially to the ViewBox control. There are currently no options on this control, and any options included in this parameter are ignored. **/ - constructor(element: HTMLElement, options?: any); + constructor(element?: HTMLElement, options?: any); //#endregion Constructors From 0a7bf0d88949070926e19495e76806f8902f5318 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:12:08 -0700 Subject: [PATCH 022/225] The second parameter for show/hideCommands for AppBar can be optional, especially since it is deprecated, it is actually encouraged to not specify it. --- winjs/winjs.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index aa0b5b0be0..daa071fb33 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -3562,7 +3562,7 @@ declare module WinJS.UI { * @param commands The commands to hide. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to hide the commands immediately, without animating them; otherwise, false. **/ - hideCommands(commands: any[], immediate: boolean): void; + hideCommands(commands: any[], immediate?: boolean): void; /** * Removes an event handler that the addEventListener method registered. @@ -3582,14 +3582,14 @@ declare module WinJS.UI { * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the commands immediately, without animating them; otherwise, false. **/ - showCommands(commands: any[], immediate: boolean): void; + showCommands(commands: any[], immediate?: boolean): void; /** * Shows the specified commands of the AppBar while hiding all other commands. * @param commands The commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. * @param immediate The parameter immediate is not supported and may be altered or unavailable in the future. true to show the specified commands (and hide the others) immediately, without animating them; otherwise, false. **/ - showOnlyCommands(commands: any[], immediate: boolean): void; + showOnlyCommands(commands: any[], immediate?: boolean): void; //#endregion Methods From c4cfea06a6f3a391da7bdc91309bb649733e9fa8 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:13:47 -0700 Subject: [PATCH 023/225] The 'commands' property of both AppBar and Menu can take both a single command or an array of commands. Since there is no syntax to type this duality, we should indicate an array of commands instead. --- winjs/winjs.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index daa071fb33..a27a5350e6 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -3598,7 +3598,7 @@ declare module WinJS.UI { /** * Sets the AppBarCommand objects that appear in the app bar. **/ - commands: AppBarCommand; + commands: AppBarCommand[]; /** * Gets or sets a value that indicates whether the AppBar is disabled. @@ -5598,7 +5598,7 @@ declare module WinJS.UI { /** * Sets the MenuCommand objects that appear in the menu. **/ - commands: MenuCommand; + commands: MenuCommand[]; /** * Gets the DOM element that hosts the Menu. From fac68f1264d168e734c3a6ae54b7e157d414ede1 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:14:27 -0700 Subject: [PATCH 024/225] As the docs say, these 2 properties are HTMLElements. --- winjs/winjs.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index a27a5350e6..d9d47c03fa 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -3695,7 +3695,7 @@ declare module WinJS.UI { /** * Gets or sets the HTMLElement with a 'content' type AppBarCommand that should receive focus whenever focus moves by the user pressing HOME or the arrow keys, from the previous AppBarCommand to this AppBarCommand. **/ - firstElementFocus: any; + firstElementFocus: HTMLElement; /** * Gets or sets the Flyout object displayed by this command. The specified flyout is shown when the AppBarCommand's button is invoked. @@ -3725,7 +3725,7 @@ declare module WinJS.UI { /** * Gets or sets the HTMLElement with a 'content' type AppBarCommand that should receive focus whenever focus moves by the user pressing END or the arrow keys, from the previous AppBarCommand to this AppBarCommand. **/ - lastElementFocus: any; + lastElementFocus: HTMLElement; /** * Gets or sets the function to be invoked when the command is clicked. From dcff230b754931d529f13ac8cec7a949abbef198 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:16:22 -0700 Subject: [PATCH 025/225] The 'calendar' property is a format string. --- winjs/winjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index d9d47c03fa..2cf7bfa77f 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -4011,7 +4011,7 @@ declare module WinJS.UI { /** * Gets or sets the calendar to use. **/ - calendar: any; + calendar: string; /** * Gets or sets the current date of the DatePicker. You can use either a date string or a Date object to set this property. From b69147f2a5465aefebafff2469a5a75b38d5e1bc Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:17:52 -0700 Subject: [PATCH 026/225] Fixed some any-typed properties. --- winjs/winjs.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 2cf7bfa77f..c968b788bf 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -4714,7 +4714,7 @@ declare module WinJS.UI { /** * Gets or sets the index of the first visible HubSection. **/ - sectionOnScreen: any; + sectionOnScreen: number; /** * Gets or sets the List that contains the HubSection objects that belong to this Hub. @@ -4724,7 +4724,7 @@ declare module WinJS.UI { /** * This API supports the SemanticZoom infrastructure and is not intended to be used directly from your code. **/ - zoomableView: any; + zoomableView: IZoomableView; //#endregion Properties @@ -4905,12 +4905,12 @@ declare module WinJS.UI { /** * Gets or sets the orientation of swipe gestures. **/ - swipeOrientation: any; + swipeOrientation: Orientation; /** * Gets or sets how the ItemContainer reacts when the user taps or clicks an item. **/ - tapBehavior: any; + tapBehavior: TapBehavior; //#endregion Properties @@ -5402,7 +5402,7 @@ declare module WinJS.UI { /** * Gets or sets an object that controls the layout of the ListView. **/ - layout: any; + layout: ILayout2; /** * Gets or sets a value that specifies how the ListView fetches items and adds and removes them to the DOM. Don't change the value of this property after the ListView has begun loading data. @@ -6763,7 +6763,7 @@ declare module WinJS.UI { /** * Gets or sets the tab index of this container. **/ - tabIndex: any; + tabIndex: number; //#endregion Properties From 793e49acba52b148940ef090b67e1347996f7dc6 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:19:02 -0700 Subject: [PATCH 027/225] Provided an interface for the currentItem property. Fixed up some minor typing and visibility issues in ListView. --- winjs/winjs.d.ts | 43 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index c968b788bf..716939ea02 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -3310,6 +3310,31 @@ declare module WinJS.UI { } + /** + * Used by ListView's currentItem API + **/ + interface IListViewItem { + /** + * Gets or sets index of the ListView item. + **/ + index?: number; + + /** + * Gets or sets key of the ListView item. + **/ + key?: string; + + /** + * Gets or sets whether the ListView item is focused. + **/ + hasFocus?: boolean; + + /** + * Gets or sets whether the ListView item is focused and is showing its focus visual. + **/ + showFocus?: boolean; + } + /** * Represents a selection of ListView items. **/ @@ -5330,10 +5355,10 @@ declare module WinJS.UI { **/ removeEventListener(eventName: string, eventCallback: Function, useCapture?: boolean): void; - /** - * Triggers the ListView disposal service manually. - **/ - triggerDispose(): void; + /** + * Triggers the ListView disposal service manually. + **/ + static triggerDispose(): void; //#endregion Methods @@ -5344,10 +5369,10 @@ declare module WinJS.UI { **/ automaticallyLoadPages: boolean; - /** - * Gets or sets an object that indicates which item should have keyboard focus and the focus state of that item. - **/ - currentItem: { index: number; key: string; hasFocus: boolean; showFocus: boolean }; + /** + * Gets or sets an IListViewItem that indicates which item should have keyboard focus and the focus state of that item. + **/ + currentItem: IListViewItem; /** * Gets the HTML element that hosts this ListView. @@ -5467,7 +5492,7 @@ declare module WinJS.UI { /** * Gets a ZoomableView that supports semantic zoom functionality. This API supports the SemanticZoom infrastructure and is not intended to be used directly from your code. **/ - zoomableView: IZoomableView; + zoomableView: IZoomableView>; //#endregion Properties From 722788bcc70735bb1144c69d160d66de92ac038f Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:19:33 -0700 Subject: [PATCH 028/225] This guy can be even more specialized - it takes only img tags. --- winjs/winjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 716939ea02..7ce907b2fa 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -6747,7 +6747,7 @@ declare module WinJS.UI { * @param image The img element that will display the thumbnail. * @returns A Promise that completes when the full-quality thumbnail is visible. **/ - loadThumbnail(item: IItem, image: HTMLElement): Promise; + loadThumbnail(item: IItem, image: HTMLImageElement): Promise; //#endregion Methods From 40c621ae5cade35aa1e19a688df3766d00933da8 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:19:51 -0700 Subject: [PATCH 029/225] As the docs indicate, the 2nd parameter is optional. --- winjs/winjs.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 7ce907b2fa..5ff8da71d8 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -7371,7 +7371,7 @@ declare module WinJS.UI.Fragments { * @param element Optional. The element to which the fragment is appended. * @returns A promise that is fulfilled when the fragment has been loaded. If a target element is not specified, the copied fragment is the completed value. The element is not added to the cache. See also rendercopy, where the element is added to the cache. **/ - function render(href: string, element: HTMLElement): Promise; + function render(href: string, element?: HTMLElement): Promise; /** * Loads and copies the contents of the specified URI into the specified element. @@ -7379,7 +7379,7 @@ declare module WinJS.UI.Fragments { * @param target The element to which the fragment is appended. * @returns A promise that is fulfilled when the fragment has been loaded. If a target element is not specified, the copied fragment is the completed value. The fragment is added to the cache. See also render, where the element is not added to the cache. **/ - function renderCopy(href: string, target: HTMLElement): Promise; + function renderCopy(href: string, target?: HTMLElement): Promise; //#endregion Functions From a85238496dd599a01e0dc9feacb7c131167898ca Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:21:07 -0700 Subject: [PATCH 030/225] Parameterized some utility functions. This assures that the return type and the input type are always the same. --- winjs/winjs.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 5ff8da71d8..5a0cfdbbe6 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -8135,7 +8135,7 @@ declare module WinJS.Utilities { * @param name The name of the class to add. * @returns The element. **/ - function addClass(e: HTMLElement, name: string): HTMLElement; + function addClass(e: T, name: string): T; /** * Gets a collection of elements that are the direct children of the specified element. @@ -8177,7 +8177,7 @@ declare module WinJS.Utilities { * @param element The element. * @returns The element. **/ - function empty(element: HTMLElement): HTMLElement; + function empty(element: T): T; /** * Determines whether the specified event occurred within the specified element. @@ -8322,7 +8322,7 @@ declare module WinJS.Utilities { * @param name The name of the class to remove. * @returns The element. **/ - function removeClass(e: HTMLElement, name: string): HTMLElement; + function removeClass(e: T, name: string): T; /** * Asserts that the value is compatible with declarative processing. Declarative processing is performed by WinJS.UI.processAll or WinJS.Binding.processAll. If the value is not compatible, and strictProcessing is on, an exception is thrown. All functions that have been declared using WinJS.Class.define, WinJS.Class.derive, WinJS.UI.Pages.define, or WinJS.Binding.converter are automatically marked as supported for declarative processing. Any other function that you use from a declarative context (that is, a context in which an HTML element has a data-win-control or data-win-options attribute) must be marked manually by calling this function. When you mark a function as supported for declarative processing, you are guaranteeing that the code in the function is secure from injection of third-party content. @@ -8376,7 +8376,7 @@ declare module WinJS.Utilities { * @param name The name of the class to toggle. * @returns The element. **/ - function toggleClass(e: HTMLElement, name: string): HTMLElement; + function toggleClass(e: T, name: string): T; //#endregion Functions From f3b8cfb7e33e8ad095896e2ac61ccccd1cc0fe06 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:21:51 -0700 Subject: [PATCH 031/225] Fixed some typing in WinJS.Utilities. --- winjs/winjs.d.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 5a0cfdbbe6..294de08153 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -8298,7 +8298,7 @@ declare module WinJS.Utilities { * @param func The function to be marked as compatible with declarative processing. * @returns The input function, marked as compatible with declarative processing. **/ - function markSupportedForProcessing(func: U): U; + function markSupportedForProcessing(func: U): U; /** * Returns a QueryCollection with zero or one elements matching the specified selector query. @@ -8329,7 +8329,7 @@ declare module WinJS.Utilities { * @param value The value to be tested for compatibility with declarative processing. If the value is a function it must be marked with a property supportedForProcessing with a value of true when strictProcessing is on. For more information, see WinJS.Utilities.markSupportedForProcessing. * @returns The input value. **/ - function requireSupportedForProcessing(value: any): any; + function requireSupportedForProcessing(value: T): T; /** * Sets the innerHTML property of the specified element to the specified text. @@ -8363,7 +8363,7 @@ declare module WinJS.Utilities { * Configures a logger that writes messages containing the specified tags to the JavaScript console. * @param options The tags for messages to log. Multiple tags should be separated by spaces. May contain type, tags, excludeTags and action properties. **/ - function startLog(options?: any): void; + function startLog(options?: ILogOptions): void; /** * Removes the WinJS logger that had previously been set up. @@ -8382,6 +8382,13 @@ declare module WinJS.Utilities { //#region Interfaces + interface ILogOptions { + type: string; + action?: (message: string, tags: string, type: string) => void; + excludeTags: string; + tags: string; + } + interface IPosition { left: number; top: number; From 27b4741d5c75c5d08c8c752870f924ecc307e0be Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:22:08 -0700 Subject: [PATCH 032/225] Missing property in the WinJS.Utilities namespace. --- winjs/winjs.d.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 294de08153..87217d439c 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -8380,6 +8380,15 @@ declare module WinJS.Utilities { //#endregion Functions + //#region Properties + + /** + * Gets whether the current script context has access to WinRT APIs. + **/ + var hasWinRT: boolean; + + //#endregion Properties + //#region Interfaces interface ILogOptions { From 55c1ee5cd16a00706ae593ba00d1a0394ea69171 Mon Sep 17 00:00:00 2001 From: jseanxu Date: Wed, 9 Apr 2014 15:22:55 -0700 Subject: [PATCH 033/225] As the doc says, the type of the first parameter is the VALUE (not the promise itself) to be returned by the return promise. --- winjs/winjs.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 87217d439c..20263a3bb9 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -8596,7 +8596,7 @@ declare module WinJS.Utilities.Scheduler { * @param name A description of the work item for diagnostics. The default value is an empty string. * @returns The job instance that represents this work item. **/ - function schedule(work: (jobInfo: IJobInfo) => void, priority?: Priority, thisArg?: any, name?: string): IJob; + function schedule(work: (jobInfo: IJobInfo) => any, priority?: Priority, thisArg?: any, name?: string): IJob; /** * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.aboveNormal priority. @@ -8604,7 +8604,7 @@ declare module WinJS.Utilities.Scheduler { * @param jobName A string that describes the job for diagnostic purposes. * @returns A Promise that completes within a job of aboveNormal priority. **/ - function schedulePromiseAboveNormal(promiseValue?: Promise, jobName?: string): Promise; + function schedulePromiseAboveNormal(promiseValue?: U, jobName?: string): Promise; /** * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.belowNormal priority. @@ -8612,7 +8612,7 @@ declare module WinJS.Utilities.Scheduler { * @param jobName A string that describes the job for diagnostic purposes. * @returns A Promise that completes within a job of belowNormal priority. **/ - function schedulePromiseBelowNormal(promiseValue?: Promise, jobName?: string): Promise; + function schedulePromiseBelowNormal(promiseValue?: U, jobName?: string): Promise; /** * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.high priority. @@ -8620,7 +8620,7 @@ declare module WinJS.Utilities.Scheduler { * @param jobName A string that describes the job for diagnostic purposes. * @returns A Promise that completes within a job of high priority. **/ - function schedulePromiseHigh(promiseValue?: Promise, jobName?: string): Promise; + function schedulePromiseHigh(promiseValue?: U, jobName?: string): Promise; /** * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.Idle priority. @@ -8628,7 +8628,7 @@ declare module WinJS.Utilities.Scheduler { * @param jobName A string that describes the job for diagnostic purposes. * @returns A Promise that completes within a job of idle priority. **/ - function schedulePromiseIdle(promiseValue?: Promise, jobName?: string): Promise; + function schedulePromiseIdle(promiseValue?: U, jobName?: string): Promise; /** * Schedules a job to complete the returned Promise at WinJS.Utilities.Scheduler.Priority.normal priority. @@ -8636,7 +8636,7 @@ declare module WinJS.Utilities.Scheduler { * @param jobName A string that describes the job for diagnostic purposes. * @returns A Promise that completes within a job of normal priority. **/ - function schedulePromiseNormal(promiseValue?: Promise, jobName?: string): Promise; + function schedulePromiseNormal(promiseValue?: U, jobName?: string): Promise; //#endregion Functions From d3dd12701cdae76aa1536c57b0b5f73a2446243a Mon Sep 17 00:00:00 2001 From: vvakame Date: Thu, 10 Apr 2014 18:56:36 +0900 Subject: [PATCH 034/225] add diff/diff.d.ts --- README.md | 1 + diff/diff-tests.ts | 14 ++++++++++++ diff/diff.d.ts | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 diff/diff-tests.ts create mode 100644 diff/diff.d.ts diff --git a/README.md b/README.md index 4e8d6c1702..3ef5c4d61d 100755 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ List of Definitions * [d3.js](http://d3js.org/) (from TypeScript samples) * [dhtmlxGantt](http://dhtmlx.com/docs/products/dhtmlxGantt) (by [Maksim Kozhukh](http://github.com/mkozhukh)) * [dhtmlxScheduler](http://dhtmlx.com/docs/products/dhtmlxScheduler) (by [Maksim Kozhukh](http://github.com/mkozhukh)) +* [diff](https://github.com/kpdecker/jsdiff) (by [vvakame](http://github.com/vvakame)) * [Dock Spawn](http://dockspawn.com) (by [Drew Noakes](https://drewnoakes.com)) * [docCookies](https://developer.mozilla.org/en-US/docs/Web/API/document.cookie) (by [Jon Egerton](https://github.com/jonegerton)) * [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) diff --git a/diff/diff-tests.ts b/diff/diff-tests.ts new file mode 100644 index 0000000000..1588f59477 --- /dev/null +++ b/diff/diff-tests.ts @@ -0,0 +1,14 @@ +/// + +import jsdiff = require('diff'); + +var one = 'beep boop'; +var other = 'beep boob blah'; + +var diff = jsdiff.diffChars(one, other); + +diff.forEach(function (part) { + var mark = part.added ? '+' : + part.removed ? '-' : ' '; + console.log(mark + " " + part.value); +}); diff --git a/diff/diff.d.ts b/diff/diff.d.ts new file mode 100644 index 0000000000..9ccbb10a8c --- /dev/null +++ b/diff/diff.d.ts @@ -0,0 +1,57 @@ +// Type definitions for diff +// Project: https://github.com/kpdecker/jsdiff +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module JsDiff { + interface IDiffResult { + value: string; + added?: boolean; + removed?: boolean; + } + + interface IBestPath { + newPos: number; + componenets: IDiffResult[]; + } + + class Diff { + ignoreWhitespace:boolean; + + constructor(ignoreWhitespace?:boolean); + + diff(oldString:string, newString:string):IDiffResult[]; + + pushComponent(components:IDiffResult[], value:string, added:boolean, removed:boolean):void; + + extractCommon(basePath:IBestPath, newString:string, oldString:string, diagonalPath:number):number; + + equals(left:string, right:string):boolean; + + join(left:string, right:string):string; + + tokenize(value:string):any; // return types are string or string[] + } + + function diffChars(oldStr:string, newStr:string):IDiffResult[]; + + function diffWords(oldStr:string, newStr:string):IDiffResult[]; + + function diffWordsWithSpace(oldStr:string, newStr:string):IDiffResult[]; + + function diffLines(oldStr:string, newStr:string):IDiffResult[]; + + function diffCss(oldStr:string, newStr:string):IDiffResult[]; + + function createPatch(fileName:string, oldStr:string, newStr:string, oldHeader:string, newHeader:string):string; + + function applyPatch(oldStr:string, uniDiff:string):string; + + function convertChangesToXML(changes:IDiffResult[]):string; + + function convertChangesToDMP(changes:IDiffResult[]):{0: number; 1:string;}[]; +} + +declare module "diff" { + export = JsDiff; +} From 8fd7ae819606ad4a47d15bfdba676b0c0d982e1f Mon Sep 17 00:00:00 2001 From: vvakame Date: Thu, 10 Apr 2014 19:07:43 +0900 Subject: [PATCH 035/225] improve diff-tests.ts --- diff/diff-tests.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/diff/diff-tests.ts b/diff/diff-tests.ts index 1588f59477..46d367bf68 100644 --- a/diff/diff-tests.ts +++ b/diff/diff-tests.ts @@ -12,3 +12,42 @@ diff.forEach(function (part) { part.removed ? '-' : ' '; console.log(mark + " " + part.value); }); + +// -------------------------- + +class LineDiffWithoutWhitespace extends jsdiff.Diff { + tokenize(value:string):any { + return value.split(/^/m); + } + + equals(left:string, right:string):boolean { + return left.trim() === right.trim(); + } +} + +var obj = new LineDiffWithoutWhitespace(true); +var diff = obj.diff(one, other); +printDiff(diff); + +function printDiff(diff:jsdiff.IDiffResult[]) { + function addLineHeader(decorator:string, str:string) { + return str.split("\n").map((line, index, array) => { + if (index === array.length - 1 && line === "") { + return line; + } else { + return decorator + line; + } + }).join("\n"); + } + + diff.forEach((part)=> { + if (part.added) { + console.log(addLineHeader("+", part.value)); + } else if (part.removed) { + console.log(addLineHeader("-", part.value)); + } else { + console.log(addLineHeader(" ", part.value)); + } + }); + +} \ No newline at end of file From 863f3553436f81f95995d2e19d4bca7ed720659f Mon Sep 17 00:00:00 2001 From: Brett Morgan Date: Fri, 11 Apr 2014 14:55:20 +1000 Subject: [PATCH 036/225] Making typescript compiler happy Typescript 1.0.0 error'd on this line, I suspect because Path is defined as a class not an interface. Changing from implements to extends made the error go away. hth, brett --- threejs/three.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index 687bb81231..a83568dc10 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -4968,7 +4968,7 @@ declare module THREE { /** * Defines a 2d shape plane using paths. */ - export class Shape implements Path { + export class Shape extends Path { constructor(points?: Vector2[]); holes: Path[]; From b5000368878c351e9dfeb56385d748770be82cbc Mon Sep 17 00:00:00 2001 From: Brian Dukes Date: Fri, 11 Apr 2014 10:43:57 -0500 Subject: [PATCH 037/225] Use base type in ko.virtualElements interface The knockout `virtualElements` API accepts all types of DOM nodes, not just HTML elements. For example, I was trying to insert a text node (from `document.createTextNode`), and it was seen as invalid. --- knockout/knockout.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/knockout/knockout.d.ts b/knockout/knockout.d.ts index 66ebe27199..7f8451ac5c 100644 --- a/knockout/knockout.d.ts +++ b/knockout/knockout.d.ts @@ -173,14 +173,14 @@ interface KnockoutMemoization { interface KnockoutVirtualElement {} interface KnockoutVirtualElements { - allowedBindings: { [bindingName: string]: boolean; }; + allowedBindings: { [bindingName: string]: boolean; }; emptyNode(node: KnockoutVirtualElement ): void; firstChild(node: KnockoutVirtualElement ): KnockoutVirtualElement; - insertAfter( container: KnockoutVirtualElement, nodeToInsert: HTMLElement, insertAfter: HTMLElement ): void; - nextSibling(node: KnockoutVirtualElement): HTMLElement; - prepend(node: KnockoutVirtualElement, toInsert: HTMLElement ): void; - setDomNodeChildren(node: KnockoutVirtualElement, newChildren: { length: number;[index: number]: HTMLElement; } ): void; - childNodes(node: KnockoutVirtualElement ): HTMLElement[]; + insertAfter( container: KnockoutVirtualElement, nodeToInsert: Node, insertAfter: Node ): void; + nextSibling(node: KnockoutVirtualElement): Node; + prepend(node: KnockoutVirtualElement, toInsert: Node ): void; + setDomNodeChildren(node: KnockoutVirtualElement, newChildren: { length: number;[index: number]: Node; } ): void; + childNodes(node: KnockoutVirtualElement ): Node[]; } interface KnockoutExtenders { From e4a1fe99457373593e7d87e68525ce696280310b Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sat, 12 Apr 2014 02:10:47 +1000 Subject: [PATCH 038/225] Three.js Remove dead code no longer required after https://github.com/borisyankov/DefinitelyTyped/pull/2021 --- threejs/three.d.ts | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/threejs/three.d.ts b/threejs/three.d.ts index a83568dc10..27938939aa 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -4986,49 +4986,6 @@ declare module THREE { }; getPointsHoles(divisions: number): Vector2[][]; getSpacedPointsHoles(divisions: number): Vector2[][]; - - getCurveLengths(): number; - // trick for TypeScript 0.9.5 compile passed - // from Path - actions: PathActions[]; - fromPoints(vectors: Vector2[]): void; - moveTo(x: number, y: number): void; - lineTo(x: number, y: number): void; - quadraticCurveTo(aCPx: number, aCPy: number, aX: number, aY: number): void; - bezierCurveTo(aCP1x: number, aCP1y: number, aCP2x: number, aCP2y: number, aX: number, aY: number): void; - splineThru(pts: Vector2[]): void; - arc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - absarc(aX: number, aY: number, aRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - ellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - absellipse(aX: number, aY: number, xRadius: number, yRadius: number, aStartAngle: number, aEndAngle: number, aClockwise: boolean): void; - toShapes(): Shape[]; - // from CurvePath - curves: Curve[]; - bends: Path[]; - autoClose: boolean; - add(curve: Curve): void; - checkConnection(): boolean; - closePath(): void; - getBoundingBox(): BoundingBox; - createPointsGeometry(divisions: number): Geometry; - createSpacedPointsGeometry(divisions: number): Geometry; - createGeometry(points: Vector2[]): Geometry; - addWrapPath(bendpath: Path): void; - getTransformedPoints(segments: number, bends?: Path): Vector2[]; - getTransformedSpacedPoints(segments: number, bends?: Path[]): Vector2[]; - getWrapPoints(oldPts: Vector2[], path: Path): Vector2[]; - getPoint(t: number): Vector; - getPointAt(u: number): Vector; - getPoints(divisions?: number): Vector[]; - getSpacedPoints(divisions?: number): Vector[]; - getLength(): number; - getLengths(divisions?: number): number[]; - needsUpdate: boolean; - updateArcLengths(): void; - getUtoTmapping(u: number, distance: number): number; - getNormalVector(t: number): Vector; - getTangent(t: number): Vector; - getTangentAt(u: number): Vector; } From 749437f384660f1089d27f5f274f1853dc470912 Mon Sep 17 00:00:00 2001 From: Trevor Date: Fri, 11 Apr 2014 10:23:58 -0700 Subject: [PATCH 039/225] add ajax function to View --- backbone/backbone.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 256554774a..bdbcf6e7cc 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -330,7 +330,8 @@ declare module Backbone { // SYNC function sync(method: string, model: Model, options?: JQueryAjaxSettings): any; - var emulateHTTP: boolean; + function ajax(options?: JQueryAjaxSettings): JQueryXHR; + var emulateHTTP: boolean; var emulateJSONBackbone: boolean; // Utility From 5954ef284281cab663b59c54d28e0d9aca0490fe Mon Sep 17 00:00:00 2001 From: Trevor Date: Fri, 11 Apr 2014 10:25:09 -0700 Subject: [PATCH 040/225] add options to History --- backbone/backbone.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index bdbcf6e7cc..0141640522 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -278,7 +278,8 @@ declare module Backbone { loadUrl(fragmentOverride: string): boolean; navigate(fragment: string, options?: any): boolean; started: boolean; - + options: any; + _updateHash(location: Location, fragment: string, replace: boolean): void; } From 192cf1c9c7aed53fd3dbf2b3d967006d35cffc89 Mon Sep 17 00:00:00 2001 From: Trevor Date: Fri, 11 Apr 2014 10:26:09 -0700 Subject: [PATCH 041/225] add set to Collection --- backbone/backbone.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index 0141640522..d94e9172bf 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -171,7 +171,8 @@ declare module Backbone { remove(models: Model[], options?: Silenceable): Model[]; reset(models?: Model[], options?: Silenceable): Model[]; reset(models?: any[], options?: Silenceable): Model[]; - shift(options?: Silenceable): Model; + set(models?: any[], options?: Silenceable): Model[]; + shift(options?: Silenceable): Model; sort(options?: Silenceable): Collection; unshift(model: Model, options?: AddOptions): Model; where(properies: any): Model[]; From fcc1ab786a3011287e281c36e1f52486b54abce8 Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sat, 12 Apr 2014 18:44:14 +1000 Subject: [PATCH 042/225] marionette : closes #2027 --- marionette/marionette.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 3427d6de4e..0e501f6f8a 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -223,6 +223,7 @@ declare module Marionette { constructor(options?: any); itemView: any; + children: any; //_initialEvents(); addChildView(item: View, collection: View, options?: any); From a821755ea09a5486abae91e341d7df97fa56c0ea Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sat, 12 Apr 2014 21:26:10 +1000 Subject: [PATCH 043/225] Update angular.d.ts closes #2028 --- angularjs/angular.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 61d80df3f2..c5e45258d2 100755 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -238,7 +238,7 @@ declare module ng { $parent: IScope; - $id: number; + $id: string; // Hidden members $$isolateBindings: any; From 43130d44a5e7007f838702ae9340aec3aea0afd1 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Sat, 12 Apr 2014 19:23:51 +0200 Subject: [PATCH 044/225] Add missing test functions --- casperjs/casperjs.d.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/casperjs/casperjs.d.ts b/casperjs/casperjs.d.ts index 0445f443f9..a91f84c8c2 100644 --- a/casperjs/casperjs.d.ts +++ b/casperjs/casperjs.d.ts @@ -200,6 +200,9 @@ interface Tester { assertExists(selector: string, message?: string): any; assertFalsy(subject: any, message?: string): any; assertField(inputName: string, expected: string, message?: string): any; + assertFieldName(inputName: string, expected: string, message?: string, options?: any): any; + assertFieldCSS(cssSelector: string, expected: string, message?: string): any; + assertFieldXPath(xpathSelector: string, expected: string, message?: string): any; assertHttpStatus(status: number, message?: string): any; assertMatch(subject: any, pattern: RegExp, message?: string): any; assertNot(subject: any, message?: string): any; @@ -216,6 +219,7 @@ interface Tester { assertTitleMatch(pattern: RegExp, message?: string): any; assertTruthy(subject: any, message?: string): any; assertType(input: any, type: string, message?: string): any; + assertInstanceOf(input: any, ctor: Function, message?: string): any; assertUrlMatch(pattern: string, message?: string): any; assertUrlMatch(pattern: RegExp, message?: string): any; assertVisible(selector: string, message?: string): any; @@ -237,6 +241,10 @@ interface Tester { info(message: string): any; pass(message: string): any; renderResults(exit: boolean, status: number, save: string): any; + + setup(fn: Function); + skip(nb: number, message: string); + tearDown(fn: Function); } interface Cases { From 62e032b12d0bcbca2bc90fb79cce4eb2389efea0 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Sat, 12 Apr 2014 19:48:31 +0200 Subject: [PATCH 045/225] Add some more missing functions --- casperjs/casperjs.d.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/casperjs/casperjs.d.ts b/casperjs/casperjs.d.ts index a91f84c8c2..af31bb9810 100644 --- a/casperjs/casperjs.d.ts +++ b/casperjs/casperjs.d.ts @@ -20,12 +20,14 @@ interface Casper extends EventEmitter { constructor (options: CasperOptions): Casper; + options: CasperOptions; // Properties __utils__: ClientUtils; // Methods back(): Casper; base64encode(url: string, method?: string, data?: any): string; + bypass(nb: number) click(selector: string): boolean; clickLabel(label: string, tag?: string): boolean; capture(targetFilePath: string, clipRect: ClipRect): Casper; @@ -49,11 +51,15 @@ interface Casper extends EventEmitter { forward(): Casper; log(message: string, level?: string, space?: string): Casper; fill(selector: string, values: any, submit?: boolean): void; + fillSelectors(selector: string, values: any, submit?: boolean): void; + fillXPath(selector: string, values: any, submit?: boolean): void; getCurrentUrl(): string; getElementAttribute(selector: string, attribute: string): string; + getElementsAttribute(selector: string, attribute: string): string; getElementBounds(selector: string): ElementBounds; getElementsBounds(selector: string): ElementBounds[]; getElementInfo(selector: string): ElementInfo; + getElementsInfo(selector: string): ElementInfo; getFormValues(selector: string): any; getGlobal(name: string): any; getHTML(selector?: string, outer?: boolean): string; @@ -66,24 +72,33 @@ interface Casper extends EventEmitter { resourceExists(test: Function): boolean; resourceExists(test: string): boolean; run(onComplete: Function, time?: number): Casper; + scrollTo(x: number, y, number): Casper; + scrollToBottom(): Casper; sendKeys(selector: string, keys: string, options?: any): Casper; setHttpAuth(username: string, password: string): Casper; start(url?: string, then?: (response: HttpResponse) => void): Casper; status(asString: boolean): any; then(fn: (self?: Casper) => void): Casper; + thenBypass(nb: number): Casper; + thenBypassIf(condition: any, nb: number): Casper; + thenBypassUnless(condition: any, nb: number): Casper; thenClick(selector: string): Casper; thenEvaluate(fn: () => any, ...args: any[]): Casper; thenOpen(location: string, then?: (response: HttpResponse) => void): Casper; thenOpen(location: string, options?: OpenSettings, then?: (response: HttpResponse) => void): Casper; thenOpenAndEvaluate(location: string, then?: Function, ...args: any[]): Casper; toString(): string; + unwait(): Casper; userAgent(agent: string): string; viewport(width: number, height: number): Casper; visible(selector: string): boolean; wait(timeout: number, then?: Function): Casper; waitFor(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number): Casper; + waitForAlert(then: Function, onTimeout?: Function, timeout?: number): Casper; waitForPopup(urlPattern: string, then?: Function, onTimeout?: Function, timeout?: number): Casper; waitForPopup(urlPattern: RegExp, then?: Function, onTimeout?: Function, timeout?: number): Casper; + waitForUrl(url: string, then?: Function, onTimeout?: Function, timeout?: number): Casper; + waitForUrl(url: RegExp, then?: Function, onTimeout?: Function, timeout?: number): Casper; waitForSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper; waitWhileSelector(selector: string, then?: Function, onTimeout?: Function, timeout?: number): Casper; waitForResource(testFx: Function, then?: Function, onTimeout?: Function, timeout?: number): Casper; @@ -157,10 +172,12 @@ interface CasperOptions { pageSettings?: any; remoteScripts?: any[]; safeLogs?: boolean; + silentErrors?: boolean; stepTimeout?: number; timeout?: number; verbose?: boolean; viewportSize?: any; + retryTimeout?: number; waitTimeout?: number; } From b33ddcacd8d2696a50be7ece882ce97055a40f14 Mon Sep 17 00:00:00 2001 From: "Martin D." Date: Sat, 12 Apr 2014 15:45:12 -0400 Subject: [PATCH 046/225] Add dispose method --- videojs/videojs.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/videojs/videojs.d.ts b/videojs/videojs.d.ts index 1c53eefaf9..0c56522ffe 100644 --- a/videojs/videojs.d.ts +++ b/videojs/videojs.d.ts @@ -43,6 +43,7 @@ interface VideoJSPlayer { ready(callback: () => void ): void; on(eventName: string, callback: () => void ): void; off(eventName: string, callback: () => void ): void; + dispose(): void; } interface VideoJSStatic { From 011d165c37507e2be4d8ca1787b250bf35fe38a7 Mon Sep 17 00:00:00 2001 From: "Martin D." Date: Sat, 12 Apr 2014 15:50:38 -0400 Subject: [PATCH 047/225] _V_ is deprecated Use videojs instead --- videojs/videojs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/videojs/videojs.d.ts b/videojs/videojs.d.ts index 1c53eefaf9..2cfa711b36 100644 --- a/videojs/videojs.d.ts +++ b/videojs/videojs.d.ts @@ -49,4 +49,4 @@ interface VideoJSStatic { (id: any, options?: VideoJSOptions, ready?: () => void): VideoJSPlayer; } -declare var _V_:VideoJSStatic; +declare var videojs:VideoJSStatic; From ea1a5bc764c84a3fb5ec518679e1ecf0847daaa6 Mon Sep 17 00:00:00 2001 From: Kieran Simpson Date: Sun, 13 Apr 2014 23:15:32 +1000 Subject: [PATCH 048/225] Added TS stubs for clone library. --- README.md | 1 + clone/clone-tests.ts | 9 +++++++++ clone/clone.d.ts | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 clone/clone-tests.ts create mode 100644 clone/clone.d.ts diff --git a/README.md b/README.md index f86f72820e..3472f264b8 100755 --- a/README.md +++ b/README.md @@ -57,6 +57,7 @@ List of Definitions * [Chrome](http://developer.chrome.com/extensions/) (by [Matthew Kimber](https://github.com/matthewkimber) and [otiai10](https://github.com/otiai10)) * [Chrome App](http://developer.chrome.com/apps/) (by [Adam Lay](https://github.com/AdamLay)) * [CKEditor](https://github.com/ckeditor/ckeditor-dev) (by [Ondrej Sevcik](https://github.com/ondrejsevcik)) +* [Clone](https://github.com/pvorb/node-clone) (by [Kieran Simpson](https://github.com/kierans)) * [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon)) * [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem)) * [configstore](http://github.com/yeoman/configstore) (by [Bart van der Schoor](https://github.com/Bartvds)) diff --git a/clone/clone-tests.ts b/clone/clone-tests.ts new file mode 100644 index 0000000000..12a8535349 --- /dev/null +++ b/clone/clone-tests.ts @@ -0,0 +1,9 @@ +import clone = require("clone"); + +var original = { + key: "value" +}; + +var copy = clone(original); +copy = clone(original, false); +copy = clone(original, true); diff --git a/clone/clone.d.ts b/clone/clone.d.ts new file mode 100644 index 0000000000..061c93c4d6 --- /dev/null +++ b/clone/clone.d.ts @@ -0,0 +1,17 @@ +// Type definitions for clone 0.1.11 +// Project: https://github.com/pvorb/node-clone +// Definitions by: Kieran Simpson +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/** + * See clone JS source for API docs + */ +declare module "clone" { + /** + * @param parent + * @param circular If not given, defaults to true in JS lib. + */ + function clone(parent: Object, circular?: boolean): Object + + export = clone +} From b690ed7cec142d5c1dcbb78a34e2b6c71090c7f2 Mon Sep 17 00:00:00 2001 From: Dick van den Brink Date: Sun, 13 Apr 2014 16:31:17 +0200 Subject: [PATCH 049/225] Fixed errors with noImplicitAny --- casperjs/casperjs.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/casperjs/casperjs.d.ts b/casperjs/casperjs.d.ts index af31bb9810..ad942293bc 100644 --- a/casperjs/casperjs.d.ts +++ b/casperjs/casperjs.d.ts @@ -27,7 +27,7 @@ interface Casper extends EventEmitter { // Methods back(): Casper; base64encode(url: string, method?: string, data?: any): string; - bypass(nb: number) + bypass(nb: number): any; click(selector: string): boolean; clickLabel(label: string, tag?: string): boolean; capture(targetFilePath: string, clipRect: ClipRect): Casper; @@ -72,7 +72,7 @@ interface Casper extends EventEmitter { resourceExists(test: Function): boolean; resourceExists(test: string): boolean; run(onComplete: Function, time?: number): Casper; - scrollTo(x: number, y, number): Casper; + scrollTo(x: number, y: number): Casper; scrollToBottom(): Casper; sendKeys(selector: string, keys: string, options?: any): Casper; setHttpAuth(username: string, password: string): Casper; @@ -259,9 +259,9 @@ interface Tester { pass(message: string): any; renderResults(exit: boolean, status: number, save: string): any; - setup(fn: Function); - skip(nb: number, message: string); - tearDown(fn: Function); + setup(fn: Function): any; + skip(nb: number, message: string): any; + tearDown(fn: Function): any; } interface Cases { From de65cd05cb952591da261eeb504ab09516a67616 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Mon, 14 Apr 2014 10:47:37 +0400 Subject: [PATCH 050/225] Updated rx.d.ts and rx-lite.d.ts to version 2.2.20 --- rx.js/rx-lite.d.ts | 76 ++++++++++++++++++++++++++++++++++++++++++++-- rx.js/rx.d.ts | 8 ++++- 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/rx.js/rx-lite.d.ts b/rx.js/rx-lite.d.ts index c0a27c3c46..15767ac61f 100644 --- a/rx.js/rx-lite.d.ts +++ b/rx.js/rx-lite.d.ts @@ -201,13 +201,27 @@ declare module Rx { catch(handler: (exception: any) => Observable): Observable; catchException(handler: (exception: any) => Observable): Observable; // alias for catch + catch(handler: (exception: any) => IPromise): Observable; + catchException(handler: (exception: any) => IPromise): Observable; // alias for catch catch(second: Observable): Observable; catchException(second: Observable): Observable; // alias for catch combineLatest(second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; combineLatest(second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; combineLatest(second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; combineLatest(second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; combineLatest(souces: Observable[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; + combineLatest(souces: IPromise[], resultSelector: (firstValue: T, ...otherValues: TOther[]) => TResult): Observable; concat(...sources: Observable[]): Observable; concat(...sources: IPromise[]): Observable; concat(sources: Observable[]): Observable; @@ -224,10 +238,22 @@ declare module Rx { switchLatest(): T; // alias for switch takeUntil(other: Observable): Observable; zip(second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; + zip(second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; zip(second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + zip(second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + zip(second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + zip(second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; zip(second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + zip(second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; zip(second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; - zip(second: Observable[], resultSelector: (left: T, right: Observable) => TResult): Observable; + zip(second: Observable[], resultSelector: (left: T, ...right: TOther[]) => TResult): Observable; + zip(second: IPromise[], resultSelector: (left: T, ...right: TOther[]) => TResult): Observable; asObservable(): Observable; dematerialize(): Observable; @@ -368,6 +394,39 @@ declare module Rx { catch(...sources: IPromise[]): Observable; catchException(...sources: Observable[]): Observable; // alias for catch catchException(...sources: IPromise[]): Observable; // alias for catch + + combineLatest(first: Observable, second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(first: IPromise, second: Observable, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(first: Observable, second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(first: IPromise, second: IPromise, resultSelector: (v1: T, v2: T2) => TResult): Observable; + combineLatest(first: Observable, second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: Observable, second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: Observable, second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: Observable, second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: IPromise, second: Observable, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: IPromise, second: Observable, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: IPromise, second: IPromise, third: Observable, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: IPromise, second: IPromise, third: IPromise, resultSelector: (v1: T, v2: T2, v3: T3) => TResult): Observable; + combineLatest(first: Observable, second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable, second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable, second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable, second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable, second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable, second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable, second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable, second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: IPromise, second: Observable, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: IPromise, second: Observable, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: IPromise, second: Observable, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: IPromise, second: Observable, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: IPromise, second: IPromise, third: Observable, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: IPromise, second: IPromise, third: Observable, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: IPromise, second: IPromise, third: IPromise, fourth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: IPromise, second: IPromise, third: IPromise, fourth: IPromise, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4) => TResult): Observable; + combineLatest(first: Observable, second: Observable, third: Observable, fourth: Observable, fifth: Observable, resultSelector: (v1: T, v2: T2, v3: T3, v4: T4, v5: T5) => TResult): Observable; + combineLatest(souces: Observable[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + combineLatest(souces: IPromise[], resultSelector: (...otherValues: TOther[]) => TResult): Observable; + concat(...sources: Observable[]): Observable; concat(...sources: IPromise[]): Observable; concat(sources: Observable[]): Observable; @@ -380,10 +439,23 @@ declare module Rx { merge(scheduler: IScheduler, ...sources: IPromise[]): Observable; merge(scheduler: IScheduler, sources: Observable[]): Observable; merge(scheduler: IScheduler, sources: IPromise[]): Observable; - zip(first: Observable, sources: Observable[], resultSelector: (item1: T1, right: Observable) => TResult): Observable; + + zip(first: Observable, sources: Observable[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; + zip(first: Observable, sources: IPromise[], resultSelector: (item1: T1, ...right: T2[]) => TResult): Observable; zip(source1: Observable, source2: Observable, resultSelector: (item1: T1, item2: T2) => TResult): Observable; + zip(source1: Observable, source2: IPromise, resultSelector: (item1: T1, item2: T2) => TResult): Observable; zip(source1: Observable, source2: Observable, source3: Observable, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; + zip(source1: Observable, source2: Observable, source3: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; + zip(source1: Observable, source2: IPromise, source3: Observable, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; + zip(source1: Observable, source2: IPromise, source3: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3) => TResult): Observable; zip(source1: Observable, source2: Observable, source3: Observable, source4: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable, source2: Observable, source3: Observable, source4: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable, source2: Observable, source3: IPromise, source4: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable, source2: Observable, source3: IPromise, source4: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable, source2: IPromise, source3: Observable, source4: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable, source2: IPromise, source3: Observable, source4: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable, source2: IPromise, source3: IPromise, source4: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; + zip(source1: Observable, source2: IPromise, source3: IPromise, source4: IPromise, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4) => TResult): Observable; zip(source1: Observable, source2: Observable, source3: Observable, source4: Observable, source5: Observable, resultSelector: (item1: T1, item2: T2, item3: T3, item4: T4, item5: T5) => TResult): Observable; zipArray(...sources: Observable[]): Observable; zipArray(sources: Observable[]): Observable; diff --git a/rx.js/rx.d.ts b/rx.js/rx.d.ts index 597264fa8d..1a5d775a5e 100644 --- a/rx.js/rx.d.ts +++ b/rx.js/rx.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS v2.2.18 +// Type definitions for RxJS v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: gsino // Definitions by: Igor Oleinikov @@ -66,7 +66,9 @@ declare module Rx { subscribeOn(scheduler: IScheduler): Observable; amb(rightSource: Observable): Observable; + amb(rightSource: IPromise): Observable; onErrorResumeNext(second: Observable): Observable; + onErrorResumeNext(second: IPromise): Observable; bufferWithCount(count: number, skip?: number): Observable; windowWithCount(count: number, skip?: number): Observable>; defaultIfEmpty(defaultValue?: T): Observable; @@ -81,9 +83,13 @@ declare module Rx { interface ObservableStatic { using(resourceFactory: () => TResource, observableFactory: (resource: TResource) => Observable): Observable; amb(...sources: Observable[]): Observable; + amb(...sources: IPromise[]): Observable; amb(sources: Observable[]): Observable; + amb(sources: IPromise[]): Observable; onErrorResumeNext(...sources: Observable[]): Observable; + onErrorResumeNext(...sources: IPromise[]): Observable; onErrorResumeNext(sources: Observable[]): Observable; + onErrorResumeNext(sources: IPromise[]): Observable; } interface GroupedObservable extends Observable { From 27d981af6346c4059d3a57917e92ecc8bef694f8 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Mon, 14 Apr 2014 10:51:24 +0400 Subject: [PATCH 051/225] Updated rx.aggregates.d.ts t oversion 2.2.20 --- rx.js/rx.aggregates.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rx.js/rx.aggregates.d.ts b/rx.js/rx.aggregates.d.ts index 4ba03b4c60..ea5cca99ba 100644 --- a/rx.js/rx.aggregates.d.ts +++ b/rx.js/rx.aggregates.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Aggregates package +// Type definitions for RxJS-Aggregates v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov @@ -33,7 +33,9 @@ declare module Rx { average(keySelector?: (value: T, index: number, source: Observable) => number, thisArg?: any): Observable; sequenceEqual(second: Observable, comparer: (value1: T, value2: TOther) => number): Observable; + sequenceEqual(second: IPromise, comparer: (value1: T, value2: TOther) => number): Observable; sequenceEqual(second: Observable): Observable; + sequenceEqual(second: IPromise): Observable; sequenceEqual(second: TOther[], comparer: (value1: T, value2: TOther) => number): Observable; sequenceEqual(second: T[]): Observable; From 52d7857dad794b7892d7ae7a607a4abc7f781d6d Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Mon, 14 Apr 2014 10:54:32 +0400 Subject: [PATCH 052/225] Updated rx.async.d.ts to version 2.2.20 --- rx.js/rx.async.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rx.js/rx.async.d.ts b/rx.js/rx.async.d.ts index 522b87c0d2..9a03bb33b4 100644 --- a/rx.js/rx.async.d.ts +++ b/rx.js/rx.async.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Async v2.2.18 +// Type definitions for RxJS-Async v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: zoetrope // Definitions by: Igor Oleinikov From 71b823a0e348978df67f9f88137141f53d0c43d6 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Mon, 14 Apr 2014 11:12:45 +0400 Subject: [PATCH 053/225] Updated RxJS-BackPressure to v2.2.20 --- rx.js/rx.backpressure-lite.d.ts | 8 +++++++- rx.js/rx.backpressure.d.ts | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/rx.js/rx.backpressure-lite.d.ts b/rx.js/rx.backpressure-lite.d.ts index 3cc78f6ca8..420a568f3e 100644 --- a/rx.js/rx.backpressure-lite.d.ts +++ b/rx.js/rx.backpressure-lite.d.ts @@ -14,6 +14,7 @@ declare module Rx { * @returns The observable sequence which is paused based upon the pauser. */ pausable(pauser: Observable): Observable; + pausable(pauser?: ISubject): PausableObservable; /** * Pauses the underlying observable sequence based upon the observable sequence which yields true/false, @@ -24,7 +25,7 @@ declare module Rx { * @param pauser The observable sequence used to pause the underlying sequence. * @returns The observable sequence which is paused based upon the pauser. */ - pausableBuffered(pauser: Observable): Observable; + pausableBuffered(pauser?: ISubject): PausableObservable; /** * Attaches a controller to the observable sequence with the ability to queue. @@ -38,4 +39,9 @@ declare module Rx { export interface ControlledObservable extends Observable { request(numberOfItems?: number): IDisposable; } + + export interface PausableObservable extends Observable { + pause(): void; + resume(): void; + } } diff --git a/rx.js/rx.backpressure.d.ts b/rx.js/rx.backpressure.d.ts index 4108ba4106..5ec8c3f91f 100644 --- a/rx.js/rx.backpressure.d.ts +++ b/rx.js/rx.backpressure.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-BackPressure v2.2.18 +// Type definitions for RxJS-BackPressure v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped From aca5a09c70f05c4409b55a8ff132dc83b4052fa7 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Mon, 14 Apr 2014 11:27:10 +0400 Subject: [PATCH 054/225] Updated RxJS-Experimental to v2.2.20 --- rx.js/rx.experimental.d.ts | 61 ++++++++++++++++++++++++++++---------- 1 file changed, 45 insertions(+), 16 deletions(-) diff --git a/rx.js/rx.experimental.d.ts b/rx.js/rx.experimental.d.ts index db23df3fd5..1b92599446 100644 --- a/rx.js/rx.experimental.d.ts +++ b/rx.js/rx.experimental.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS/Experimental +// Type definitions for RxJS-Experimental v2.2.20 // Project: https://github.com/Reactive-Extensions/RxJS/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -45,11 +45,12 @@ declare module Rx { /** * Runs two observable sequences in parallel and combines their last elemenets. * - * @param second Second observable sequence. + * @param second Second observable sequence or promise. * @param resultSelector Result selector function to invoke with the last elements of both sequences. * @returns An observable sequence with the result of calling the selector function with the last elements of both input sequences. */ forkJoin(second: Observable, resultSelector: (left: T, right: TSecond) => TResult): Observable; + forkJoin(second: IPromise, resultSelector: (left: T, right: TSecond) => TResult): Observable; /** * Comonadic bind operator. @@ -67,11 +68,14 @@ declare module Rx { * @example * res = Rx.Observable.if(condition, obs1, obs2); * @param condition The condition which determines if the thenSource or elseSource will be run. - * @param thenSource The observable sequence that will be run if the condition function returns true. - * @param elseSource The observable sequence that will be run if the condition function returns false. + * @param thenSource The observable sequence or promise that will be run if the condition function returns true. + * @param elseSource The observable sequence or promise that will be run if the condition function returns false. * @returns An observable sequence which is either the thenSource or elseSource. */ if(condition: () => boolean, thenSource: Observable, elseSource: Observable): Observable; + if(condition: () => boolean, thenSource: Observable, elseSource: IPromise): Observable; + if(condition: () => boolean, thenSource: IPromise, elseSource: Observable): Observable; + if(condition: () => boolean, thenSource: IPromise, elseSource: IPromise): Observable; /** * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, scheduler?: IScheduler): Observable; + if(condition: () => boolean, thenSource: IPromise, scheduler?: IScheduler): Observable; /** * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, elseSource: Observable): Observable; + ifThen(condition: () => boolean, thenSource: Observable, elseSource: IPromise): Observable; + ifThen(condition: () => boolean, thenSource: IPromise, elseSource: Observable): Observable; + ifThen(condition: () => boolean, thenSource: IPromise, elseSource: IPromise): Observable; /** * Determines whether an observable collection contains values. There is an alias for this method called 'ifThen' for browsers (condition: () => boolean, thenSource: Observable, scheduler?: IScheduler): Observable; + ifThen(condition: () => boolean, thenSource: IPromise, scheduler?: IScheduler): Observable; /** * Concatenates the observable sequences obtained by running the specified result selector for each element in source. @@ -131,19 +140,21 @@ declare module Rx { * Repeats source as long as condition holds emulating a while loop. * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: Observable): Observable; + while(condition: () => boolean, source: IPromise): Observable; /** * Repeats source as long as condition holds emulating a while loop. * There is an alias for this method called 'whileDo' for browsers (condition: () => boolean, source: Observable): Observable; + whileDo(condition: () => boolean, source: IPromise): Observable; /** * Uses selector to determine which source in sources to use. @@ -153,11 +164,14 @@ declare module Rx { * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0); * @param selector The function which extracts the value for to test in a case statement. * @param sources A object which has keys which correspond to the case statement labels. - * @param elseSource The observable sequence that will be run if the sources are not matched. + * @param elseSource The observable sequence or promise that will be run if the sources are not matched. * * @returns An observable sequence which is determined by a case statement. */ case(selector: () => string, sources: { [key: string]: Observable; }, elseSource: Observable): Observable; + case(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: Observable): Observable; + case(selector: () => string, sources: { [key: string]: Observable; }, elseSource: IPromise): Observable; + case(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: IPromise): Observable; /** * Uses selector to determine which source in sources to use. @@ -174,6 +188,7 @@ declare module Rx { * @returns An observable sequence which is determined by a case statement. */ case(selector: () => string, sources: { [key: string]: Observable; }, scheduler?: IScheduler): Observable; + case(selector: () => string, sources: { [key: string]: IPromise; }, scheduler?: IScheduler): Observable; /** * Uses selector to determine which source in sources to use. @@ -183,11 +198,14 @@ declare module Rx { * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0); * @param selector The function which extracts the value for to test in a case statement. * @param sources A object which has keys which correspond to the case statement labels. - * @param elseSource The observable sequence that will be run if the sources are not matched. + * @param elseSource The observable sequence or promise that will be run if the sources are not matched. * * @returns An observable sequence which is determined by a case statement. */ case(selector: () => number, sources: { [key: number]: Observable; }, elseSource: Observable): Observable; + case(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: Observable): Observable; + case(selector: () => number, sources: { [key: number]: Observable; }, elseSource: IPromise): Observable; + case(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: IPromise): Observable; /** * Uses selector to determine which source in sources to use. @@ -204,6 +222,7 @@ declare module Rx { * @returns An observable sequence which is determined by a case statement. */ case(selector: () => number, sources: { [key: number]: Observable; }, scheduler?: IScheduler): Observable; + case(selector: () => number, sources: { [key: number]: IPromise; }, scheduler?: IScheduler): Observable; /** * Uses selector to determine which source in sources to use. @@ -213,11 +232,14 @@ declare module Rx { * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0); * @param selector The function which extracts the value for to test in a case statement. * @param sources A object which has keys which correspond to the case statement labels. - * @param elseSource The observable sequence that will be run if the sources are not matched. + * @param elseSource The observable sequence or promise that will be run if the sources are not matched. * * @returns An observable sequence which is determined by a case statement. */ switchCase(selector: () => string, sources: { [key: string]: Observable; }, elseSource: Observable): Observable; + switchCase(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: Observable): Observable; + switchCase(selector: () => string, sources: { [key: string]: Observable; }, elseSource: IPromise): Observable; + switchCase(selector: () => string, sources: { [key: string]: IPromise; }, elseSource: IPromise): Observable; /** * Uses selector to determine which source in sources to use. @@ -234,6 +256,7 @@ declare module Rx { * @returns An observable sequence which is determined by a case statement. */ switchCase(selector: () => string, sources: { [key: string]: Observable; }, scheduler?: IScheduler): Observable; + switchCase(selector: () => string, sources: { [key: string]: IPromise; }, scheduler?: IScheduler): Observable; /** * Uses selector to determine which source in sources to use. @@ -243,11 +266,14 @@ declare module Rx { * res = Rx.Observable.case(selector, { '1': obs1, '2': obs2 }, obs0); * @param selector The function which extracts the value for to test in a case statement. * @param sources A object which has keys which correspond to the case statement labels. - * @param elseSource The observable sequence that will be run if the sources are not matched. + * @param elseSource The observable sequence or promise that will be run if the sources are not matched. * * @returns An observable sequence which is determined by a case statement. */ switchCase(selector: () => number, sources: { [key: number]: Observable; }, elseSource: Observable): Observable; + switchCase(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: Observable): Observable; + switchCase(selector: () => number, sources: { [key: number]: Observable; }, elseSource: IPromise): Observable; + switchCase(selector: () => number, sources: { [key: number]: IPromise; }, elseSource: IPromise): Observable; /** * Uses selector to determine which source in sources to use. @@ -264,25 +290,28 @@ declare module Rx { * @returns An observable sequence which is determined by a case statement. */ switchCase(selector: () => number, sources: { [key: number]: Observable; }, scheduler?: IScheduler): Observable; + switchCase(selector: () => number, sources: { [key: number]: IPromise; }, scheduler?: IScheduler): Observable; /** * Runs all observable sequences in parallel and collect their last elements. * * @example * res = Rx.Observable.forkJoin([obs1, obs2]); - * @param sources Array of source sequences. + * @param sources Array of source sequences or promises. * @returns An observable sequence with an array collecting the last elements of all the input sequences. */ forkJoin(sources: Observable[]): Observable; + forkJoin(sources: IPromise[]): Observable; /** * Runs all observable sequences in parallel and collect their last elements. * * @example * res = Rx.Observable.forkJoin(obs1, obs2, ...); - * @param args Source sequences. + * @param args Source sequences or promises. * @returns An observable sequence with an array collecting the last elements of all the input sequences. */ forkJoin(...args: Observable[]): Observable; + forkJoin(...args: IPromise[]): Observable; } } From 44912732ea6b32e9d807068735ab03b57d6faac6 Mon Sep 17 00:00:00 2001 From: Igor Oleinikov Date: Mon, 14 Apr 2014 11:31:43 +0400 Subject: [PATCH 055/225] Version bump to 2.2.20 for all other files --- rx.js/rx.binding.d.ts | 2 +- rx.js/rx.coincidence.d.ts | 2 +- rx.js/rx.joinpatterns.d.ts | 2 +- rx.js/rx.lite.d.ts | 2 +- rx.js/rx.testing.d.ts | 2 +- rx.js/rx.time.d.ts | 2 +- rx.js/rx.virtualtime.d.ts | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/rx.js/rx.binding.d.ts b/rx.js/rx.binding.d.ts index 4d165a6377..cf3744c4e2 100644 --- a/rx.js/rx.binding.d.ts +++ b/rx.js/rx.binding.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Binding v2.2.18 +// Type definitions for RxJS-Binding v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.coincidence.d.ts b/rx.js/rx.coincidence.d.ts index 02883ff542..bf9841b41e 100644 --- a/rx.js/rx.coincidence.d.ts +++ b/rx.js/rx.coincidence.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Coincidence package +// Type definitions for RxJS-Coincidence v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.joinpatterns.d.ts b/rx.js/rx.joinpatterns.d.ts index a1ec9f952d..bc1ee2e324 100644 --- a/rx.js/rx.joinpatterns.d.ts +++ b/rx.js/rx.joinpatterns.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Join package +// Type definitions for RxJS-Join v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/rx.js/rx.lite.d.ts b/rx.js/rx.lite.d.ts index e2640e9eba..e01b7e34ba 100644 --- a/rx.js/rx.lite.d.ts +++ b/rx.js/rx.lite.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Lite v2.2.18 +// Type definitions for RxJS-Lite v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: gsino // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.testing.d.ts b/rx.js/rx.testing.d.ts index f03b2de082..082fdba598 100644 --- a/rx.js/rx.testing.d.ts +++ b/rx.js/rx.testing.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Testing +// Type definitions for RxJS-Testing v2.2.20 // Project: https://github.com/Reactive-Extensions/RxJS/ // Definitions by: Igor Oleinikov // Definitions: https://github.com/borisyankov/DefinitelyTyped diff --git a/rx.js/rx.time.d.ts b/rx.js/rx.time.d.ts index 10290bfe81..18cccd4d35 100644 --- a/rx.js/rx.time.d.ts +++ b/rx.js/rx.time.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-Time v2.2.18 +// Type definitions for RxJS-Time v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: Carl de Billy // Definitions by: Igor Oleinikov diff --git a/rx.js/rx.virtualtime.d.ts b/rx.js/rx.virtualtime.d.ts index c57cbd664f..bba46a761e 100644 --- a/rx.js/rx.virtualtime.d.ts +++ b/rx.js/rx.virtualtime.d.ts @@ -1,4 +1,4 @@ -// Type definitions for RxJS-VirtualTime package 2.2.18 +// Type definitions for RxJS-VirtualTime v2.2.20 // Project: http://rx.codeplex.com/ // Definitions by: gsino // Definitions by: Igor Oleinikov From e176a57f0de63ae22695cbfba738dc94ba0cec82 Mon Sep 17 00:00:00 2001 From: Jason Jarrett Date: Mon, 14 Apr 2014 08:47:55 -0700 Subject: [PATCH 056/225] Removing circular dependency for createjs - Should help with issue #2037 - This issue was introduced in #2000 --- {createjs => createjs-lib}/createjs-lib.d.ts | 0 createjs/createjs.d.ts | 2 +- easeljs/easeljs.d.ts | 2 +- preloadjs/preloadjs.d.ts | 2 +- soundjs/soundjs.d.ts | 2 +- tweenjs/tweenjs.d.ts | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename {createjs => createjs-lib}/createjs-lib.d.ts (100%) diff --git a/createjs/createjs-lib.d.ts b/createjs-lib/createjs-lib.d.ts similarity index 100% rename from createjs/createjs-lib.d.ts rename to createjs-lib/createjs-lib.d.ts diff --git a/createjs/createjs.d.ts b/createjs/createjs.d.ts index 15a1149a26..7be29abbea 100644 --- a/createjs/createjs.d.ts +++ b/createjs/createjs.d.ts @@ -16,7 +16,7 @@ // Library documentation : http://www.createjs.com/Docs/TweenJS/modules/TweenJS.html -/// +/// /// /// /// diff --git a/easeljs/easeljs.d.ts b/easeljs/easeljs.d.ts index 3f629aa3f0..c7f2681539 100644 --- a/easeljs/easeljs.d.ts +++ b/easeljs/easeljs.d.ts @@ -12,7 +12,7 @@ // Library documentation : http://www.createjs.com/Docs/EaselJS/modules/EaselJS.html -/// +/// /// // rename the native MouseEvent, to avoid conflict with createjs's MouseEvent diff --git a/preloadjs/preloadjs.d.ts b/preloadjs/preloadjs.d.ts index 0af5debfe6..0a4a4db85d 100644 --- a/preloadjs/preloadjs.d.ts +++ b/preloadjs/preloadjs.d.ts @@ -12,7 +12,7 @@ // Library documentation : http://www.createjs.com/Docs/PreloadJS/modules/PreloadJS.html -/// +/// declare module createjs { export class AbstractLoader extends EventDispatcher { diff --git a/soundjs/soundjs.d.ts b/soundjs/soundjs.d.ts index f5a2f9b14c..b67408af2e 100644 --- a/soundjs/soundjs.d.ts +++ b/soundjs/soundjs.d.ts @@ -12,7 +12,7 @@ // Library documentation : http://www.createjs.com/Docs/SoundJS/modules/SoundJS.html -/// +/// declare module createjs { export class FlashPlugin { diff --git a/tweenjs/tweenjs.d.ts b/tweenjs/tweenjs.d.ts index f4c1dcc743..69b2948fa2 100644 --- a/tweenjs/tweenjs.d.ts +++ b/tweenjs/tweenjs.d.ts @@ -12,7 +12,7 @@ // Library documentation : http://www.createjs.com/Docs/TweenJS/modules/TweenJS.html -/// +/// declare module createjs { export class CSSPlugin { From cf3934dd970f0c1d4e3d9fb980889029e1d7879c Mon Sep 17 00:00:00 2001 From: vvakame Date: Fri, 11 Apr 2014 21:16:11 +0900 Subject: [PATCH 057/225] added atom/atom.d.ts and dependencies... --- README.md | 4 + atom/atom-tests.ts | 77 ++++ atom/atom.d.ts | 736 +++++++++++++++++++++++++++++++ emissary/emissary-tests.ts | 22 + emissary/emissary.d.ts | 51 +++ mixto/mixto-tests.ts | 16 + mixto/mixto.d.ts | 16 + pathwatcher/pathwatcher-tests.ts | 10 + pathwatcher/pathwatcher.d.ts | 87 ++++ space-pen/space-pen-tests.ts | 28 ++ space-pen/space-pen.d.ts | 616 ++++++++++++++++++++++++++ 11 files changed, 1663 insertions(+) create mode 100644 atom/atom-tests.ts create mode 100644 atom/atom.d.ts create mode 100644 emissary/emissary-tests.ts create mode 100644 emissary/emissary.d.ts create mode 100644 mixto/mixto-tests.ts create mode 100644 mixto/mixto.d.ts create mode 100644 pathwatcher/pathwatcher-tests.ts create mode 100644 pathwatcher/pathwatcher.d.ts create mode 100644 space-pen/space-pen-tests.ts create mode 100644 space-pen/space-pen.d.ts diff --git a/README.md b/README.md index 3472f264b8..424351acb6 100755 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ List of Definitions * [asciify](https://github.com/olizilla/asciify) (by [Alan](http://alan.norbauer.com)) * [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)) * [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)) @@ -77,6 +78,7 @@ List of Definitions * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) * [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [emissary](https://github.com/atom/emissary) (by [vvakame](https://github.com/vvakame)) * [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/)) * [expect.js](https://github.com/LearnBoost/expect.js) (by [Teppei Sato](https://github.com/teppeis)) @@ -209,6 +211,7 @@ List of Definitions * [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) * [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) * [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [mixto](https://github.com/atom/mixto) (by [vvakame](https://github.com/vvakame)) * [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) * [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee)) @@ -225,6 +228,7 @@ List of Definitions * [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/)) * [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)) * [Parsimmon](https://github.com/jayferd/parsimmon) (by [Bart van der Schoor](https://github.com/Bartvds)) * [PDF.js](https://github.com/mozilla/pdf.js) (by [Josh Baldwin](https://github.com/jbaldwin)) diff --git a/atom/atom-tests.ts b/atom/atom-tests.ts new file mode 100644 index 0000000000..505973c9af --- /dev/null +++ b/atom/atom-tests.ts @@ -0,0 +1,77 @@ +/// +/// +/// + +import path = require("path"); +import _atom = require("atom"); + +import pathwatcher = require("pathwatcher"); +var File = pathwatcher.File; + +class SampleView extends _atom.ScrollView { + + editorId:string; + file:pathwatcher.IFile; + editor:AtomCore.IEditor; + + static deserialize(state:any):SampleView { + return new SampleView(state); + } + + static content():any { + return this.div({class: 'sample native-key-bindings', tabindex: -1}); + } + + constructor(params:{editorId?:string; filePath?:string;} = {}) { + super(); + + this.editorId = params.editorId; + + if (this.editorId) { + this.resolveEditor(this.editorId); + } else { + this.file = new File(params.filePath); + } + } + + get jq():JQuery { + // dirty hack + return this; + } + + serialize() { + return { + deserializer: 'SampleView', + editorId: this.editorId + }; + } + + destroy() { + this.unsubscribe(); + } + + resolveEditor(editorId:string) { + var resolve = ()=> { + if (this.editor) { + this.jq.trigger("title-changed"); + } else { + var view = this.jq.parents('.pane').view(); + if (view) { + view.destroyItem(this); + } + } + }; + + if (atom.workspace) { + resolve(); + } else { + atom.packages.once("activated", ()=> { + resolve(); + }); + } + } +} + +atom.deserializers.add(SampleView); + +export = SampleView; diff --git a/atom/atom.d.ts b/atom/atom.d.ts new file mode 100644 index 0000000000..14a8dbebae --- /dev/null +++ b/atom/atom.d.ts @@ -0,0 +1,736 @@ +// Type definitions for Atom +// Project: https://atom.io/ +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// +/// + +// Policy: this definition file only declare element related to `atom`. +// if js file include to another npm package (e.g. "space-pen", "mixto" and "emissary"). +// you should create a separate file. + +// NOTE Document? You should use DevTools hehe... + +interface Window { + atom: AtomCore.IAtom; + measure(description:string, fn:Function):any; // return fn result + profile(description:string, fn:Function):any; // return fn result +} + +declare module AtomCore { + +// https://atom.io/docs/v0.84.0/advanced/view-system + interface IWorkspaceView { + prependToBottom:any; + prependToTop:any; + prependToLeft:any; + prependToRight:any; + appendToBottom:any; + appendToTop:any; + appendToLeft:any; + appendToRight:any; + + command: Function; + } + + interface IPanes { + // TBD + } + + interface TreeView { + // TBD + } + + interface ICommandPanel { + // TBD + } + + interface ITextBuffer { + // TBD + } + + interface IDisplayBuffer { + buffer: ITextBuffer; + // TBD + } + + interface ICursor { + // TBD + } + + interface ILanguageMode { + // TBD + } + + interface ISelection { + // TBD + } + + interface ISubscription { + // TBD + } + + interface IEditor { + // Serializable.includeInto(Editor); + // Delegator.includeInto(Editor); + + deserializing:boolean; + callDisplayBufferCreatedHook:boolean; + registerEditor:boolean; + buffer:ITextBuffer; + languageMode: ILanguageMode; + cursors:ICursor[]; + selections: ISelection[]; + suppressSelectionMerging:boolean; + softTabs: boolean; + displayBuffer: IDisplayBuffer; + + id:number; + behaviors:any; + declaredPropertyValues: any; + eventHandlersByEventName: any; + eventHandlersByNamespace: any; + lastOpened: number; + subscriptionCounts: any; + subscriptionsByObject: any; /* WeakMap */ + subscriptions: ISubscription[]; + + serializeParams():{id:number; softTabs:boolean; scrollTop:number; scrollLeft:number; displayBuffer:any;}; + deserializeParams(params:any):any; + subscribeToBuffer():void; + subscribeToDisplayBuffer():void; + getViewClass():any; // return type are EditorView + destroyed():void; + copy():IEditor; + getTitle():string; + getLongTitle():string; + setVisible(visible:boolean):void; + setScrollTop(scrollTop:any):void; + getScrollTop():any; + setScrollLeft(scrollLeft:any):void; + getScrollLeft():any; + setEditorWidthInChars(editorWidthInChars:any):void; + getSoftWrapColumn():any; + getSoftTabs():boolean; + setSoftTabs(softTabs:boolean):void; + getSoftWrap():any; + setSoftWrap(softWrap:any):void; + getTabText():any; + getTabLength():any; + setTabLength(tabLength:any):void; + clipBufferPosition(bufferPosition:any):void; + clipBufferRange(range:any):void; + indentationForBufferRow(bufferRow:any):void; + setIndentationForBufferRow(bufferRow:any, newLevel:any, _arg:any):void; + indentLevelForLine(line:any):number; + buildIndentString(number:any):any; + save():void; + saveAs(filePath:any):void; + getPath():any; + getText():any; + setText(text:any):void; + getTextInRange(range:any):any; + getLineCount():any; + getBuffer():any; + getUri():any; + isBufferRowBlank(bufferRow:any):void; + isBufferRowCommented(bufferRow:any):void; + nextNonBlankBufferRow(bufferRow:any):void; + getEofBufferPosition():any; + getLastBufferRow():any; + bufferRangeForBufferRow(row:any, options:any):any; + lineForBufferRow(row:any):any; + lineLengthForBufferRow(row:any):any; + scan():any; + scanInBufferRange():any; + backwardsScanInBufferRange():any; + isModified():any; + shouldPromptToSave():any; + screenPositionForBufferPosition(bufferPosition:any, options:any):any; + bufferPositionForScreenPosition(screenPosition:any, options:any):any; + screenRangeForBufferRange(bufferRange:any):any; + bufferRangeForScreenRange(screenRange:any):any; + clipScreenPosition(screenPosition:any, options:any):any; + lineForScreenRow(row:any):any; + linesForScreenRows(start:any, end:any):any; + getScreenLineCount():any; + getMaxScreenLineLength():any; + getLastScreenRow():any; + bufferRowsForScreenRows(startRow:any, endRow:any):any; + bufferRowForScreenRow(row:any):any; + scopesForBufferPosition(bufferPosition:any):any; + bufferRangeForScopeAtCursor(selector:any):any; + tokenForBufferPosition(bufferPosition:any):any; + getCursorScopes():any; + insertText(text:any, options:any):any; + insertNewline():any; + insertNewlineBelow():any; + insertNewlineAbove():any; + indent(options?:any):any; + backspace():any; + backspaceToBeginningOfWord():any; + backspaceToBeginningOfLine():any; + delete():any; + deleteToEndOfWord():any; + deleteLine():any; + indentSelectedRows():any; + outdentSelectedRows():any; + toggleLineCommentsInSelection():any; + autoIndentSelectedRows():any; + normalizeTabsInBufferRange(bufferRange:any):any; + cutToEndOfLine():any; + cutSelectedText():any; + copySelectedText():any; + pasteText(options?:any):any; + undo():any; + redo():any; + foldCurrentRow():any; + unfoldCurrentRow():any; + foldSelectedLines():any; + foldAll():any; + unfoldAll():any; + foldAllAtIndentLevel(level:any):any; + foldBufferRow(bufferRow:any):any; + unfoldBufferRow(bufferRow:any):any; + isFoldableAtBufferRow(bufferRow:any):any; + createFold(startRow:any, endRow:any):any; + destroyFoldWithId(id:any):any; + destroyFoldsIntersectingBufferRange(bufferRange:any):any; + toggleFoldAtBufferRow(bufferRow:any):any; + isFoldedAtCursorRow():any; + isFoldedAtBufferRow(bufferRow:any):any; + isFoldedAtScreenRow(screenRow:any):any; + largestFoldContainingBufferRow(bufferRow:any):any; + largestFoldStartingAtScreenRow(screenRow:any):any; + outermostFoldsInBufferRowRange(startRow:any, endRow:any):any; + moveLineUp():any; + moveLineDown():any; + duplicateLines():any; + duplicateLine():any; + mutateSelectedText(fn:Function):any; + replaceSelectedText(options:any, fn:Function):any; + getMarker(id:any):any; + getMarkers():any; + findMarkers(properties:any):any; + markScreenRange():any; + markBufferRange():any; + markScreenPosition():any; + markBufferPosition():any; + destroyMarker():any; + getMarkerCount():any; + hasMultipleCursors():any; + getCursors():any; + getCursor():any; + addCursorAtScreenPosition(screenPosition:any):any; + addCursorAtBufferPosition(bufferPosition:any):any; + addCursor(marker:any):any; + removeCursor(cursor:any):any; + addSelection(marker:any, options:any):any; + addSelectionForBufferRange(bufferRange:any, options:any):any; + setSelectedBufferRange(bufferRange:any, options:any):any; + setSelectedBufferRanges(bufferRanges:any, options:any):any; + removeSelection(selection:any):any; + clearSelections():any; + consolidateSelections():any; + getSelections():any; + getSelection(index:any):any; + getLastSelection():any; + getSelectionsOrderedByBufferPosition():any; + getLastSelectionInBuffer():any; + selectionIntersectsBufferRange(bufferRange:any):any; + setCursorScreenPosition(position:any, options:any):any; + getCursorScreenPosition():any; + getCursorScreenRow():any; + setCursorBufferPosition(position:any, options:any):any; + getCursorBufferPosition():any; + getSelectedScreenRange():any; + getSelectedBufferRange():any; + getSelectedBufferRanges():any; + getSelectedText():any; + getTextInBufferRange(range:any):any; + setTextInBufferRange(range:any, text:any):any; + getCurrentParagraphBufferRange():any; + getWordUnderCursor(options:any):any; + moveCursorUp(lineCount:any):any; + moveCursorDown(lineCount:any):any; + moveCursorLeft():any; + moveCursorRight():any; + moveCursorToTop():any; + moveCursorToBottom():any; + moveCursorToBeginningOfScreenLine():any; + moveCursorToBeginningOfLine():any; + moveCursorToFirstCharacterOfLine():any; + moveCursorToEndOfScreenLine():any; + moveCursorToEndOfLine():any; + moveCursorToBeginningOfWord():any; + moveCursorToEndOfWord():any; + moveCursorToBeginningOfNextWord():any; + moveCursorToPreviousWordBoundary():any; + moveCursorToNextWordBoundary():any; + moveCursors(fn:Function):any; + selectToScreenPosition(position:any):any; + selectRight():any; + selectLeft():any; + selectUp(rowCount:any):any; + selectDown(rowCount:any):any; + selectToTop():any; + selectAll():any; + selectToBottom():any; + selectToBeginningOfLine():any; + selectToFirstCharacterOfLine():any; + selectToEndOfLine():any; + selectToPreviousWordBoundary():any; + selectToNextWordBoundary():any; + selectLine():any; + addSelectionBelow():any; + addSelectionAbove():any; + splitSelectionsIntoLines():any; + transpose():any; + upperCase():any; + lowerCase():any; + joinLines():any; + selectToBeginningOfWord():any; + selectToEndOfWord():any; + selectToBeginningOfNextWord():any; + selectWord():any; + selectMarker(marker:any):any; + mergeCursors():any; + expandSelectionsForward():any; + expandSelectionsBackward(fn:Function):any; + finalizeSelections():any; + mergeIntersectingSelections():any; + preserveCursorPositionOnBufferReload():any; + getGrammar(): IGrammar; + setGrammar(grammer:IGrammar):void; + reloadGrammar():any; + shouldAutoIndent():any; + transact(fn:Function):any; + beginTransaction():any; + commitTransaction():any; + abortTransaction():any; + inspect():any; + logScreenLines(start:any, end:any):any; + handleGrammarChange():any; + handleMarkerCreated(marker:any):any; + getSelectionMarkerAttributes():any; + joinLine():any; + } + + interface IGrammar { + scopeName: string; + // TBD + } + + interface IPane /* extends Theorist.Model */ { + items:any[]; + activeItem:any; + + serializeParams():any; + deserializeParams(params:any):any; + getViewClass():any; // return type are PaneView + isActive():boolean; + focus():void; + blur():void; + activate():void; + getPanes():IPane[]; + getItems():any[]; + getActiveItem():any; + getActiveEditor():any; + itemAtIndex(index:number):any; + activateNextItem():any; + activatePreviousItem():any; + getActiveItemIndex():number; + activateItemAtIndex(index:number):any; + activateItem(item:any):any; + addItem(item:any, index:number):any; + addItems(items:any[], index:number):any[]; + removeItem(item:any, destroying:any):void; + moveItem(item:any, newIndex:number):void; + moveItemToPane(item:any, pane:IPane, index:number):void; + destroyActiveItem():boolean; // always return false + destroyItem(item:any):boolean; + destroyItems():any[]; + destroyInactiveItems():any[]; + destroy():void; + destroyed():any[]; + promptToSaveItem(item:any):boolean; + saveActiveItem():void; + saveActiveItemAs():void; + saveItem(item:any, nextAction:Function):void; + saveItemAs(item:any, nextAction:Function):void; + saveItems():any[]; + itemForUri(uri:any):any; + activateItemForUri(uri:any):any; + copyActiveItem():void; + splitLeft(params:any):IPane; + splitRight(params:any):IPane; + splitUp(params:any):IPane; + splitDown(params:any):IPane; + split(orientation:string, side:string, params:any):IPane; + findLeftmostSibling():IPane; + findOrCreateRightmostSibling():IPane; + } + +// https://atom.io/docs/v0.84.0/advanced/serialization + interface ISerializationStatic { + deserialize(data:ISerializationInfo):T; + new (data:T): ISerialization; + } + + interface ISerialization { + serialize():ISerializationInfo; + } + + interface ISerializationInfo { + deserializer: string; + } + + interface IBrowserWindow { + getPosition():number[]; + getSize():number[]; + } + + interface IAtomWindowDimentions { + x:number; + y:number; + width:number; + height:number; + } + + interface IProject { + // TBD + } + + interface IWorkspaceStatic { + new():IWorkspace; + } + + interface IWorkspace { + deserializeParams(params:any):any; + serializeParams():{paneContainer:any;fullScreen:boolean;}; + eachEditor(callback:Function):void; + getEditors():IEditor[]; + open(uri:string, options:any):Q.Promise; + openLicense():void; + openSync(uri:string, options:any):any; + openUriInPane(uri:string, pane:any, options:any):Q.Promise; + reopenItemSync():any; + registerOpener(opener:(urlToOpen:string)=>any):void; + unregisterOpener(opener:Function):void; + getOpeners():any; + getActivePane(): IPane; + getPanes():any; + saveAll():void; + activateNextPane():any; + activatePreviousPane():any; + paneForUri: (uri:string) => IPane; + saveActivePaneItem():any; + saveActivePaneItemAs():any; + destroyActivePaneItem():any; + destroyActivePane():any; + getActiveEditor():IEditor; + increaseFontSize():void; + decreaseFontSize():void; + resetFontSize():void; + itemOpened(item:any):void; + onPaneItemDestroyed(item:any):void; + destroyed():void; + } + + interface IAtomSettings { + appVersion: string; + bootstrapScript: string; + devMode: boolean; + initialPath: string; + pathToOpen: string; + resourcePath: string; + shellLoadTime: number; + windowState:string; + } + + interface IAtomState { + mode:string; + packageStates:any; + project:any; + syntax:any; + version:number; + windowDimensions:any; + workspace:any; + } + + interface IDeserializerManager { + deserializers:Function; + add:Function; + remove:Function; + deserialize:Function; + get:Function; + } + + interface IConfig { + get(keyPath:string):any; + // TBD + } + + interface IKeymapManager { + defaultTarget:HTMLElement; + // TBD + } + + interface IPackageManager extends Emissary.IEmitter { + packageDirPaths:string[]; + loadedPackages:any; + activePackages:any; + packageStates:any; + packageActivators:any[]; + + getApmPath():string; + getPackageDirPaths():string; + getPackageState(name:string):any; + setPackageState(name:string, state:any):void; + enablePackage(name:string):any; + disablePackage(name:string):any; + activate():void; + registerPackageActivator(activator:any, types:any):void; + activatePackages(packages:any):void; + activatePackage(name:string):void; + deactivatePackages():void; + deactivatePackage(name:string):void; + getActivePackages():any; + getActivePackage(name:string):any; + isPackageActive(name:string):boolean; + unobserveDisabledPackages():void; + observeDisabledPackages():void; + loadPackages():void; + loadPackage(nameOrPath:string):void; + unloadPackages():void; + unloadPackage(name:string):void; + getLoadedPackage(name:string):any; + isPackageLoaded(name:string):boolean; + getLoadedPackages():any; + getLoadedPackagesForTypes(types:any):any[]; + resolvePackagePath(name:string):string; + isPackageDisabled(name:string):boolean; + hasAtomEngine(packagePath:string):boolean; + isBundledPackage(name:string):boolean; + getPackageDependencies():any; + getAvailablePackagePaths():any[]; + getAvailablePackageNames():any[]; + getAvailablePackageMetadata():any[]; + } + + interface IThemeManager { + // TBD + } + + interface IContextMenuManager { + // TBD + } + + interface IMenuManager { + // TBD + } + + interface IClipboard { + // TBD + } + + interface ISyntax { + // TBD + } + + interface IWindowEventHandler { + // TBD + } + + interface IAtomStatic extends ISerializationStatic { + version: number; + loadSettings: IAtomSettings; + loadOrCreate(mode:string):IAtom; + loadState(mode:any):void; + getStatePath(mode:any):string; + getConfigDirPath():string; + getStorageDirPath():string; + getLoadSettings():IAtomSettings; + getCurrentWindow():IBrowserWindow; + getVersion():string; + isReleasedVersion():boolean; + + new(state:IAtomState):IAtom; + } + + interface IAtom { + constructor:IAtomStatic; + + state:IAtomState; + mode:string; + deserializers:IDeserializerManager; + config: IConfig; + keymaps: IKeymapManager; + keymap: IKeymapManager; + packages: IPackageManager; + themes: IThemeManager; + contextManu: IContextMenuManager; + menu: IMenuManager; + clipboard:IClipboard; + syntax:ISyntax; + windowEventHandler: IWindowEventHandler; + + // really exists? start + subscribe:Function; + unsubscribe:Function; + loadTime:number; + workspaceViewParentSelector:string; + + project: IProject; + workspaceView: IWorkspaceView; + workspace: IWorkspace; + // really exists? end + + initialize:Function; + // registerRepresentationClass:Function; + // registerRepresentationClasses:Function; + setBodyPlatformClass:Function; + getCurrentWindow():IBrowserWindow; + getWindowDimensions:Function; + setWindowDimensions:Function; + restoreWindowDimensions:Function; + storeWindowDimensions:Function; + getLoadSettings:Function; + deserializeProject: Function; + deserializeWorkspaceView:Function; + deserializePackageStates:Function; + deserializeEditorWindow:Function; + startEditorWindow:Function; + unloadEditorWindow:Function; + loadThemes:Function; + watchThemes:Function; + open:Function; + confirm:Function; + showSaveDialog:Function; + showSaveDialogSync:Function; + openDevTools:Function; + toggleDevTools:Function; + executeJavaScriptInDevTools:Function; + reload:Function; + focus:Function; + show:Function; + hide:Function; + setSize:Function; + setPosition:Function; + center:Function; + displayWindow:Function; + close:Function; + exit:Function; + inDevMode:Function; + inSpecMode:Function; + toggleFullScreen:Function; + setFullScreen:Function; + isFullScreen:Function; + getVersion:Function; + isReleasedVersion:Function; + getGitHubAuthTokenName:Function; + setGitHubAuthToken:Function; + getGitHubAuthToken:Function; + getConfigDirPath:Function; + saveSync:Function; + getWindowLoadTime():number; + crashMainProcess:Function; + crashRenderProcess:Function; + beep:Function; + getUserInitScriptPath:Function; + requireUserInitScript:Function; + requireWithGlobals:Function; + } + + interface IBufferedNodeProcessStatic { + new (arg:any):IBufferedNodeProcess; + } + + interface IBufferedNodeProcess extends IBufferedProcess { + } + + interface IBufferedProcessStatic { + new (arg:any):IBufferedProcess; + } + + interface IBufferedProcess { + process:Function; + killed:boolean; + + bufferStream:Function; + kill:Function; + } + + interface IGitStatic { + new(path:any, options:any):IGit; + } + + interface IGit { + } + + interface IPointStatic { + new(row:any, column:any):IPoint; + } + + interface IPoint { + // TBD + } + + interface IRangeStatic { + new(pointA:IPoint, pointB:IPoint):IRange; + } + + interface IRange { + // TBD + } + + interface ITaskStatic { + new(taskPath:any):ITask; + } + + interface ITask { + // TBD + } +} + +declare var atom:AtomCore.IAtom; + +declare module "atom" { + import spacePen = require("space-pen"); + + var $:typeof spacePen.$; + var $$$:typeof spacePen.$$$; + + var BufferedNodeProcess:AtomCore.IBufferedNodeProcessStatic; + var BufferedProcess:AtomCore.IBufferedProcessStatic; + var EditorView:any; + var Git:AtomCore.IGitStatic; + var Point:AtomCore.IPointStatic; + var Range:AtomCore.IRangeStatic; + + class View extends spacePen.View implements Emissary.ISubscriber { + // Subscriber.includeInto(spacePen.View); + + // inherit from Subscriber + subscribeWith(eventEmitter:any, methodName:string, args:any):any; + + addSubscription(subscription:any):any; + + subscribe(eventEmitterOrSubscription:any, ...args:any[]):any; + + subscribeToCommand(eventEmitter:any, ...args:any[]):any; + + unsubscribe(object?:any):any; + } + + class ScrollView extends View { + // TBD + } + + var SelectListView:any; + var Task:AtomCore.ITaskStatic; + var Workspace:AtomCore.IWorkspaceStatic; + var WorkspaceView:any; // WorkspaceView extends View +} diff --git a/emissary/emissary-tests.ts b/emissary/emissary-tests.ts new file mode 100644 index 0000000000..3785f52668 --- /dev/null +++ b/emissary/emissary-tests.ts @@ -0,0 +1,22 @@ +/// + +import emissary = require("emissary"); + +var Emitter = emissary.Emitter; + +var emitter = new Emitter(); + +emitter.on('foo', ()=>{}); +emitter.emit('a'); +emitter.getSubscriptionCount('b'); +emitter.on('b-subscription-added', (handler:any) =>{}); +emitter.emit('b', 'b2'); +emitter.off('foo', ()=>{}); +emitter.signal('a'); + +var Subscriber = emissary.Subscriber; + +var subscriber = new Subscriber(); +subscriber.subscribe(emitter, 'event1', ()=>{}); +subscriber.unsubscribe(); +subscriber.unsubscribe(emitter); diff --git a/emissary/emissary.d.ts b/emissary/emissary.d.ts new file mode 100644 index 0000000000..4c98193e0d --- /dev/null +++ b/emissary/emissary.d.ts @@ -0,0 +1,51 @@ +// Type definitions for emissary +// Project: https://github.com/atom/emissary +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module Emissary { + interface IEmitterStatic extends Mixto.IMixinStatic { + new ():IEmitter; + } + + interface IEmitter { + on(eventNames:string, handler:Function):any; // return value type are Signal + once(eventName:string, handler:Function):any; // return value type are Signal + signal(eventName:string):void; + behavior(eventName:string, initialValue:any):void; + emit(eventName:string, ...args:any[]):void; + off(eventNames:string, handler:Function):void; + pauseEvents(eventNames:string):void; + resumeEvents(eventNames:string):void; + incrementSubscriptionCount(eventName:string):number; + decrementSubscriptionCount(eventName:string):number; + getSubscriptionCount(eventName:string):number; + hasSubscriptions(eventName:string):boolean; + } + + interface ISubscriberStatic extends Mixto.IMixinStatic { + new ():ISubscriber; + } + + interface ISubscriber { + subscribeWith(eventEmitter:any, methodName:string, args:any):any; + + addSubscription(subscription:any):any; + + subscribe(eventEmitterOrSubscription:any, ...args:any[]):any; + + subscribeToCommand(eventEmitter:any, ...args:any[]):any; + + unsubscribe(object?:any):any; + } +} + +declare module "emissary" { + var Emitter:Emissary.IEmitterStatic; + var Subscriber:Emissary.ISubscriberStatic; + var Signal:Function; // TODO + var Behavior:Function; // TODO + var combine:Function; // TODO +} diff --git a/mixto/mixto-tests.ts b/mixto/mixto-tests.ts new file mode 100644 index 0000000000..4e6dcad726 --- /dev/null +++ b/mixto/mixto-tests.ts @@ -0,0 +1,16 @@ +/// + +import Mixin = require("mixto"); + +interface ISampleStatic extends Mixto.IMixinStatic { + new ():ISample; +} + +interface ISample { + test():string; +} + +declare var Sample: ISampleStatic; + +Sample.includeInto(Function); +Sample.extend({}); diff --git a/mixto/mixto.d.ts b/mixto/mixto.d.ts new file mode 100644 index 0000000000..1edf8bef1e --- /dev/null +++ b/mixto/mixto.d.ts @@ -0,0 +1,16 @@ +// Type definitions for mixto +// Project: https://github.com/atom/mixto +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Mixto { + interface IMixinStatic { + includeInto(constructor:any):void; + extend(object:any):void; + } +} + +declare module "mixto" { + var _tmp:Mixto.IMixinStatic; + export = _tmp; +} diff --git a/pathwatcher/pathwatcher-tests.ts b/pathwatcher/pathwatcher-tests.ts new file mode 100644 index 0000000000..4cefea3a76 --- /dev/null +++ b/pathwatcher/pathwatcher-tests.ts @@ -0,0 +1,10 @@ +/// + +import pathwatcher = require("pathwatcher"); +var File = pathwatcher.File; + +var filePath: string; +var file = new File(filePath); + +pathwatcher.watch(filePath, ()=>{ +}); diff --git a/pathwatcher/pathwatcher.d.ts b/pathwatcher/pathwatcher.d.ts new file mode 100644 index 0000000000..1f481979ba --- /dev/null +++ b/pathwatcher/pathwatcher.d.ts @@ -0,0 +1,87 @@ +// Type definitions for pathwatcher +// Project: https://github.com/atom/node-pathwatcher +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "pathwatcher" { + + import events = require("events"); + + interface IHandleWatcher extends events.EventEmitter { + onEvent(event:any, filePath:any, oldFilePath:any):any; + start():void; + closeIfNoListener():void; + close():void; + } + + interface IPathWatcher { + isWatchingParent:boolean; + path:any; + handleWatcher:IHandleWatcher; + + close():void; + } + + interface IFileStatic { + new (path:string, symlink?:boolean):IFile; + } + + interface IFile { + realPath:string; + path:string; + symlink:boolean; + cachedContents:string; + digest:string; + + handleEventSubscriptions():void; + setPath(path:string):void; + getPath():string; + getRealPathSync():string; + getBaseName():string; + write(text:string):void; + readSync(flushCache:boolean):string; + read(flushCache?:boolean):Q.Promise; + exists():boolean; + setDigest(contents:string):void; + getDigest():string; + writeFileWithPrivilegeEscalationSync (filePath:string, text:string):void; + handleNativeChangeEvent(eventType:string, eventPath:string):void; + detectResurrectionAfterDelay():void; + detectResurrection():void; + subscribeToNativeChangeEvents():void; + unsubscribeFromNativeChangeEvents():void; + } + + interface IDirectoryStatic { + new (path:string, symlink?:boolean):IDirectory; + } + + interface IDirectory { + realPath:string; + path:string; + symlink:boolean; + + getBaseName():string; + getPath():void; + getRealPathSync():string; + contains(pathToCheck:string):boolean; + relativize(fullPath:string):string; + getEntriesSync():any[]; // return type are {File | Directory}[] + getEntries(callback:Function):void; + subscribeToNativeChangeEvents():void; + unsubscribeFromNativeChangeEvents():void; + isPathPrefixOf(prefix:string, fullPath:string):boolean; + } + + function watch(path:string, callback:Function):IPathWatcher; + + function closeAllWatchers():void; + + function getWatchedPaths():string[]; + + var File:IFileStatic; + var Directory:IDirectoryStatic; +} diff --git a/space-pen/space-pen-tests.ts b/space-pen/space-pen-tests.ts new file mode 100644 index 0000000000..05c2eea03b --- /dev/null +++ b/space-pen/space-pen-tests.ts @@ -0,0 +1,28 @@ +/// + +import SpacePen = require("space-pen"); +import View = SpacePen.View; + +class Spacecraft extends View { + static content() { + this.div(()=> { + this.h1("Spacecraft"); + this.ol(()=> { + this.li("Apollo"); + this.li("Soyuz"); + this.li("Space Shuttle"); + }); + }); + } + + constructor() { + super(); + } +} + +var view = new Spacecraft(); +(view).find('ol').append('
  • Star Destroyer
  • '); + +(view).on('click', 'li', function () { + alert("They clicked on " + $(this).text()); +}); diff --git a/space-pen/space-pen.d.ts b/space-pen/space-pen.d.ts new file mode 100644 index 0000000000..64d0321557 --- /dev/null +++ b/space-pen/space-pen.d.ts @@ -0,0 +1,616 @@ +/// + +// http://atom.github.io/space-pen/ + +interface JQuery { + view():any; + views():any[]; +} + +interface JQuery { + scrollBottom():number; + scrollBottom(newValue:number):JQuery; + scrollDown():JQuery; + scrollUp():JQuery; + scrollToTop():JQuery; + scrollToBottom():JQuery; + scrollRight():number; + scrollRight(newValue:number):JQuery; + pageUp():JQuery; + pageDown():JQuery; + isOnDom():boolean; + isVisible():boolean; + isHidden():boolean; + isDisabled():boolean; + enable():JQuery; + disable():JQuery; + insertAt(index:number, element:any):JQuery; + removeAt(index:number):JQuery; + indexOf(child:any):any; + containsElement(element:any):boolean; + preempt(eventName:any, handler:Function):any; + handlers(eventName:any):any; + hasParent():boolean; + hasFocus():boolean; + flashError():number; + trueHeight():any; + trueWidth():any; + document(eventName:any, docString:string):any; + events():any; + command(eventName:any, handler:any):any; + command(eventName:any, selector:any, handler:any):any; + command(eventName:any, selector:any, options:any, handler:any):any; + iconSize(size:number):void; + intValue():number; +} + +declare class View /* implements JQuery */ { + + static builderStack:Builder[]; + + static subview(name:any, view:any):void; + + static text(str:string):void; + + static tag(tagName:any, ...args:any[]):void; + + static raw(str:string):void; + + static pushBuilder():void; + + static popBuilder():Builder; + + static buildHtml(fn:()=>void):any[]; + + static render(fn:()=>void):JQuery; + + // please override this method! + static content(...args:any[]):void; + + // tag start + static a(...args:any[]):void; + + static abbr(...args:any[]):void; + + static address(...args:any[]):void; + + static article(...args:any[]):void; + + static aside(...args:any[]):void; + + static audio(...args:any[]):void; + + static b(...args:any[]):void; + + static bdi(...args:any[]):void; + + static bdo(...args:any[]):void; + + static blockquote(...args:any[]):void; + + static body(...args:any[]):void; + + static button(...args:any[]):void; + + static canvas(...args:any[]):void; + + static caption(...args:any[]):void; + + static cite(...args:any[]):void; + + static code(...args:any[]):void; + + static colgroup(...args:any[]):void; + + static datalist(...args:any[]):void; + + static dd(...args:any[]):void; + + static del(...args:any[]):void; + + static details(...args:any[]):void; + + static dfn(...args:any[]):void; + + static div(...args:any[]):void; + + static dl(...args:any[]):void; + + static dt(...args:any[]):void; + + static em(...args:any[]):void; + + static fieldset(...args:any[]):void; + + static figcaption(...args:any[]):void; + + static figure(...args:any[]):void; + + static footer(...args:any[]):void; + + static form(...args:any[]):void; + + static h1(...args:any[]):void; + + static h2(...args:any[]):void; + + static h3(...args:any[]):void; + + static h4(...args:any[]):void; + + static h5(...args:any[]):void; + + static h6(...args:any[]):void; + + static head(...args:any[]):void; + + static header(...args:any[]):void; + + static hgroup(...args:any[]):void; + + static html(...args:any[]):void; + + static i(...args:any[]):void; + + static iframe(...args:any[]):void; + + static ins(...args:any[]):void; + + static kbd(...args:any[]):void; + + static label(...args:any[]):void; + + static legend(...args:any[]):void; + + static li(...args:any[]):void; + + static map(...args:any[]):void; + + static mark(...args:any[]):void; + + static menu(...args:any[]):void; + + static meter(...args:any[]):void; + + static nav(...args:any[]):void; + + static noscript(...args:any[]):void; + + static object(...args:any[]):void; + + static ol(...args:any[]):void; + + static optgroup(...args:any[]):void; + + static option(...args:any[]):void; + + static output(...args:any[]):void; + + static p(...args:any[]):void; + + static pre(...args:any[]):void; + + static progress(...args:any[]):void; + + static q(...args:any[]):void; + + static rp(...args:any[]):void; + + static rt(...args:any[]):void; + + static ruby(...args:any[]):void; + + static s(...args:any[]):void; + + static samp(...args:any[]):void; + + static script(...args:any[]):void; + + static section(...args:any[]):void; + + static select(...args:any[]):void; + + static small(...args:any[]):void; + + static span(...args:any[]):void; + + static strong(...args:any[]):void; + + static style(...args:any[]):void; + + static sub(...args:any[]):void; + + static summary(...args:any[]):void; + + static sup(...args:any[]):void; + + static table(...args:any[]):void; + + static tbody(...args:any[]):void; + + static td(...args:any[]):void; + + static textarea(...args:any[]):void; + + static tfoot(...args:any[]):void; + + static th(...args:any[]):void; + + static thead(...args:any[]):void; + + static time(...args:any[]):void; + + static title(...args:any[]):void; + + static tr(...args:any[]):void; + + static u(...args:any[]):void; + + static ul(...args:any[]):void; + + static video(...args:any[]):void; + + static area(...args:any[]):void; + + static base(...args:any[]):void; + + static br(...args:any[]):void; + + static col(...args:any[]):void; + + static command(...args:any[]):void; + + static embed(...args:any[]):void; + + static hr(...args:any[]):void; + + static img(...args:any[]):void; + + static input(...args:any[]):void; + + static keygen(...args:any[]):void; + + static link(...args:any[]):void; + + static meta(...args:any[]):void; + + static param(...args:any[]):void; + + static source(...args:any[]):void; + + static track(...args:any[]):void; + + static wbrk(...args:any[]):void; + + // tag end + + initialize(view:View, args:any):void; + + constructor(...args:any[]); + + buildHtml(params:any):any; + + wireOutlets(view:View):void; + + bindEventHandlers(view:View):void; + + pushStack(elems:any):any; + + end():any; + + command(commandName:any, selector:any, options:any, handler:any):any; + + preempt(eventName:any, handler:any):any; +} + +declare class Builder { + document:any[]; + postProcessingSteps:any[]; + + buildHtml():any[]; + + tag(name:string, ...args:any[]):void; + + openTag(name:string, attributes:any):void; + + closeTag(name:string):void; + + text(str:string):void; + + raw(str:string):void; + + subview(outletName:any, subview:View):void; + + extractOptions(args:any):any; +} + +declare module "space-pen" { + + // copy & paste start + class View /* implements JQueryStatic */ { + + static builderStack:Builder[]; + + static subview(name:any, view:any):void; + + static text(str:string):void; + + static tag(tagName:any, ...args:any[]):void; + + static raw(str:string):void; + + static pushBuilder():void; + + static popBuilder():Builder; + + static buildHtml(fn:()=>void):any[]; + + static render(fn:()=>void):JQuery; + + // please override this method! + static content(...args:any[]):void; + + // tag start + static a(...args:any[]):any; + + static abbr(...args:any[]):any; + + static address(...args:any[]):any; + + static article(...args:any[]):any; + + static aside(...args:any[]):any; + + static audio(...args:any[]):any; + + static b(...args:any[]):any; + + static bdi(...args:any[]):any; + + static bdo(...args:any[]):any; + + static blockquote(...args:any[]):any; + + static body(...args:any[]):any; + + static button(...args:any[]):any; + + static canvas(...args:any[]):any; + + static caption(...args:any[]):any; + + static cite(...args:any[]):any; + + static code(...args:any[]):any; + + static colgroup(...args:any[]):any; + + static datalist(...args:any[]):any; + + static dd(...args:any[]):any; + + static del(...args:any[]):any; + + static details(...args:any[]):any; + + static dfn(...args:any[]):any; + + static div(...args:any[]):any; + + static dl(...args:any[]):any; + + static dt(...args:any[]):any; + + static em(...args:any[]):any; + + static fieldset(...args:any[]):any; + + static figcaption(...args:any[]):any; + + static figure(...args:any[]):any; + + static footer(...args:any[]):any; + + static form(...args:any[]):any; + + static h1(...args:any[]):any; + + static h2(...args:any[]):any; + + static h3(...args:any[]):any; + + static h4(...args:any[]):any; + + static h5(...args:any[]):any; + + static h6(...args:any[]):any; + + static head(...args:any[]):any; + + static header(...args:any[]):any; + + static hgroup(...args:any[]):any; + + static html(...args:any[]):any; + + static i(...args:any[]):any; + + static iframe(...args:any[]):any; + + static ins(...args:any[]):any; + + static kbd(...args:any[]):any; + + static label(...args:any[]):any; + + static legend(...args:any[]):any; + + static li(...args:any[]):any; + + static map(...args:any[]):any; + + static mark(...args:any[]):any; + + static menu(...args:any[]):any; + + static meter(...args:any[]):any; + + static nav(...args:any[]):any; + + static noscript(...args:any[]):any; + + static object(...args:any[]):any; + + static ol(...args:any[]):any; + + static optgroup(...args:any[]):any; + + static option(...args:any[]):any; + + static output(...args:any[]):any; + + static p(...args:any[]):any; + + static pre(...args:any[]):any; + + static progress(...args:any[]):any; + + static q(...args:any[]):any; + + static rp(...args:any[]):any; + + static rt(...args:any[]):any; + + static ruby(...args:any[]):any; + + static s(...args:any[]):any; + + static samp(...args:any[]):any; + + static script(...args:any[]):any; + + static section(...args:any[]):any; + + static select(...args:any[]):any; + + static small(...args:any[]):any; + + static span(...args:any[]):any; + + static strong(...args:any[]):any; + + static style(...args:any[]):any; + + static sub(...args:any[]):any; + + static summary(...args:any[]):any; + + static sup(...args:any[]):any; + + static table(...args:any[]):any; + + static tbody(...args:any[]):any; + + static td(...args:any[]):any; + + static textarea(...args:any[]):any; + + static tfoot(...args:any[]):any; + + static th(...args:any[]):any; + + static thead(...args:any[]):any; + + static time(...args:any[]):any; + + static title(...args:any[]):any; + + static tr(...args:any[]):any; + + static u(...args:any[]):any; + + static ul(...args:any[]):any; + + static video(...args:any[]):any; + + static area(...args:any[]):any; + + static base(...args:any[]):any; + + static br(...args:any[]):any; + + static col(...args:any[]):any; + + static command(...args:any[]):any; + + static embed(...args:any[]):any; + + static hr(...args:any[]):any; + + static img(...args:any[]):any; + + static input(...args:any[]):any; + + static keygen(...args:any[]):any; + + static link(...args:any[]):any; + + static meta(...args:any[]):any; + + static param(...args:any[]):any; + + static source(...args:any[]):any; + + static track(...args:any[]):any; + + static wbrk(...args:any[]):any; + + // tag end + + initialize(view:View, args:any):void; + + constructor(...args:any[]); + + buildHtml(params:any):any; + + wireOutlets(view:View):void; + + bindEventHandlers(view:View):void; + + pushStack(elems:any):any; + + end():any; + + command(commandName:any, selector:any, options:any, handler:any):any; + + preempt(eventName:any, handler:any):any; + } + + class Builder { + document:any[]; + postProcessingSteps:any[]; + + buildHtml():any[]; + + tag(name:string, ...args:any[]):void; + + openTag(name:string, attributes:any):void; + + closeTag(name:string):void; + + text(str:string):void; + + raw(str:string):void; + + subview(outletName:any, subview:View):void; + + extractOptions(args:any):any; + } + // copy & paste end + + + var jQuery:JQueryStatic; + var $:JQueryStatic; + var $$:(fn:Function)=>JQuery; // same type as View.render's return type. + var $$$:(fn:Function)=>any; // same type as View.buildHtml's return type's [0]. +} From 6d626019705a0a46e97a9d24b919d7d949c38b91 Mon Sep 17 00:00:00 2001 From: vvakame Date: Tue, 15 Apr 2014 02:13:04 +0900 Subject: [PATCH 058/225] fix travis-ci --- atom/atom-tests.ts.tscparams | 1 + 1 file changed, 1 insertion(+) create mode 100644 atom/atom-tests.ts.tscparams diff --git a/atom/atom-tests.ts.tscparams b/atom/atom-tests.ts.tscparams new file mode 100644 index 0000000000..5f84b97777 --- /dev/null +++ b/atom/atom-tests.ts.tscparams @@ -0,0 +1 @@ +--noImplicitAny --module commonjs --target es5 From c238b5c2843e8c52699b7affe23a9a51e7312f53 Mon Sep 17 00:00:00 2001 From: "Martin D." Date: Mon, 14 Apr 2014 14:25:46 -0400 Subject: [PATCH 059/225] _V_ is deprecated Use videojs instead --- videojs/videojs-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/videojs/videojs-tests.ts b/videojs/videojs-tests.ts index ec2d83115b..00a70a661f 100644 --- a/videojs/videojs-tests.ts +++ b/videojs/videojs-tests.ts @@ -1,7 +1,7 @@ // Tests for Video.js API /// -_V_("example_video_1").ready(function(){ +videojs("example_video_1").ready(function(){ var myPlayer:VideoJSPlayer = this; @@ -70,4 +70,4 @@ _V_("example_video_1").ready(function(){ }; //myPlayer.addEvent("volumechange", myFunc); //myPlayer.removeEvent("volumechange", myFunc); -}); \ No newline at end of file +}); From a3456013ad809e78d8f1b8f1a7895fddff7c1028 Mon Sep 17 00:00:00 2001 From: keisuke oohashi Date: Tue, 15 Apr 2014 16:00:56 +0900 Subject: [PATCH 060/225] Created definitions for 'notify.js' --- README.md | 1 + notify.js/notify.js-tests.ts | 34 ++++++++++++ notify.js/notify.js.d.ts | 101 +++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 notify.js/notify.js-tests.ts create mode 100644 notify.js/notify.js.d.ts diff --git a/README.md b/README.md index 424351acb6..8f5708c200 100755 --- a/README.md +++ b/README.md @@ -224,6 +224,7 @@ List of Definitions * [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)) +* [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/)) diff --git a/notify.js/notify.js-tests.ts b/notify.js/notify.js-tests.ts new file mode 100644 index 0000000000..7652a0a91e --- /dev/null +++ b/notify.js/notify.js-tests.ts @@ -0,0 +1,34 @@ +/// + +function test_Notify_constructor() { + //Min + var n = new Notify("hoge") + n.show(); + + //With option + n = new Notify("hoge", {body : "fuga"}); + n.show(); + + //With Full option + n = new Notify("hoge", { + body : "fuga", + icon : "./logo.png", + tag : "user", + notifyShow : (e:Event)=> console.log("notifyShow", e), + notifyClose : ()=> console.log("notifyClose"), + notifyClick : ()=> console.log("notifyClick"), + notifyError : ()=> console.log("notifyError"), + permissionGranted : ()=> console.log("permissionGranted"), + permissionDenied : ()=> console.log("permissionDenied") + }); + n.show(); + +} + +function test_Notify_static_methods() { + Notify.needsPermission(); + Notify.requestPermission(); + Notify.requestPermission(()=> console.log("onPermissionGrantedCallback")); + Notify.requestPermission(()=> console.log("onPermissionGrantedCallback"), ()=> console.log("onPermissionDeniedCallback")); + Notify.isSupported(); +} diff --git a/notify.js/notify.js.d.ts b/notify.js/notify.js.d.ts new file mode 100644 index 0000000000..651b91ac52 --- /dev/null +++ b/notify.js/notify.js.d.ts @@ -0,0 +1,101 @@ +// Type definitions for notify.js 1.2.0 +// Project: https://github.com/alexgibson/notify.js +// Definitions by: soundTricker +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var Notify: { + new (title : string , options? : notify.INotifyOption): notify.INotify; + + /** + * Check is permission is needed for the user to receive notifications. + * @return true : needs permission, false : does not need + */ + needsPermission() : boolean; + + /** + * Asks the user for permission to display notifications + * @param onPermissionGrantedCallback A callback for permmision is granted. + * @param onPermissionDeniedCallback A callback for permmision is denied. + */ + requestPermission(onPermissionGrantedCallback?: ()=> any, onPermissionDeniedCallback? : ()=> any) : void; + + /** + * return true if the browser supports HTML5 Notification + * @param true : the browser supports HTML5 Notification, false ; the browswer does not supports HTML5 Notification. + */ + isSupported() : boolean; +} + +declare module notify { + + /** + * Interface for Web Notifications API Wrapper. + */ + interface INotify { + /** + * Show the notification. + */ + show() : void; + + /** + * Remove all event listener. + */ + destroy() : void; + + /** + * Close the notification. + */ + close() : void; + onShowNotification(e : Event) : void; + onCloseNotification() : void; + onClickNotification() : void; + onErrorNotification() : void; + handleEvent(e : Event) : void; + } + + /** + * Interface for the Notify's optional parameter. + */ + interface INotifyOption { + + /** + * notification message body + */ + body? : string; + + /** + * path for icon to display in notification + */ + icon? : string; + + /** + * unique identifier to stop duplicate notifications + */ + tag? : string; + + /** + * callback when notification is shown + */ + notifyShow? (e : Event): any; + /** + * callback when notification is closed + */ + notifyClose? : Function; + /** + * callback when notification is clicked + */ + notifyClick? : Function; + /** + * callback when notification throws an error + */ + notifyError? : Function; + /** + * callback when user has granted permission + */ + permissionGranted? : Function; + /** + * callback when user has denied permission + */ + permissionDenied? : Function; + } +} From 432cca3d5128aad8cfdea95ef5c8ced8b6093ef2 Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 13:11:04 +0200 Subject: [PATCH 061/225] Create hellojs hello.js --- hellojs | 1 + 1 file changed, 1 insertion(+) create mode 100644 hellojs diff --git a/hellojs b/hellojs new file mode 100644 index 0000000000..d39ed33aa5 --- /dev/null +++ b/hellojs @@ -0,0 +1 @@ +Enter file contents heressss From 943046170f2f6f9580c48b0c3fa4dcf835f821dd Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 13:11:38 +0200 Subject: [PATCH 062/225] Delete hellojs --- hellojs | 1 - 1 file changed, 1 deletion(-) delete mode 100644 hellojs diff --git a/hellojs b/hellojs deleted file mode 100644 index d39ed33aa5..0000000000 --- a/hellojs +++ /dev/null @@ -1 +0,0 @@ -Enter file contents heressss From 78f213ddfb8386881581d148a193ac4e83a41d78 Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 13:14:56 +0200 Subject: [PATCH 063/225] First version --- hellojs/hellojs.d.ts | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 hellojs/hellojs.d.ts diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts new file mode 100644 index 0000000000..bafa529dea --- /dev/null +++ b/hellojs/hellojs.d.ts @@ -0,0 +1,67 @@ +// Type definitions for hello.js 0.2.1 +// Project: http://knockoutjs.com +// Definitions by: Pavel Zika +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface HelloJSLoginOptions { + redirect_uri?: string; + display?: string; + scope?: string; + response_type?: string; + force?: boolean; + oauth_proxy?: string; + timeout?: number; + default_service?: string; +} + +interface HelloJSEventArgument { + network: string; + authResponse?: any; +} + +interface HelloJSStatic { + init(serviceAppIds: { [id: string]: string; }, defaultOptions?: HelloJSLoginOptions); + login(network: string, option?: HelloJSLoginOptions, callback?: () => void); + logout(network: string, callback?: () => void); + on(eventName: string, event: (auth: HelloJSEventArgument) => void): HelloJSStatic; + off(eventName: string, event: (auth: HelloJSEventArgument) => void): HelloJSStatic; + getAuthResponse(network: string): any; + service(network: string): any; + settings: HelloJSLoginOptions; + (network: string): HelloJSStaticNamed; + init(servicesDef: { [id: string]: HelloJSServiceDef; }); +} + +interface HelloJSStaticNamed { + login(option?: HelloJSLoginOptions, callback?: () => void); + logout(callback?: () => void); + getAuthResponse(): any; +} + +interface HelloJSOAuthDef { + version: number; + auth: string; + request: string; + token: string; +} + +interface HelloJSServiceDef { + name: string; + oauth: HelloJSOAuthDef; + scope?: { [id: string]: string; }; + scope_delim?: string; + autorefresh?: boolean; + base?: string; + root?: string; + get?: { [id: string]: any; } + post?: { [id: string]: any; } + del?: { [id: string]: string; } + put?: { [id: string]: any; } + wrap?: { [id: string]: (par: any) => void; } + xhr?: (par: any) => void; + jsonp?: (par: any) => void; + form?: (par: any) => void; + api?: (...par: any[]) => void; +} + +declare var hello: HelloJSStatic; From 70859516bbd66fc50728f074ddacb8b4a711d259 Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 13:20:24 +0200 Subject: [PATCH 064/225] First version --- hellojs/hellojs-test.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 hellojs/hellojs-test.ts diff --git a/hellojs/hellojs-test.ts b/hellojs/hellojs-test.ts new file mode 100644 index 0000000000..fbe36ce66d --- /dev/null +++ b/hellojs/hellojs-test.ts @@ -0,0 +1,30 @@ +hello.init( + { + 'facebook': '', + }, + { + redirect_uri: 'hello.html', + display: 'page', + } + ); + +hello('facebook').login(); + +hello('facebook').logout(); + +hello.on('auth.login', auth => { + alert('log to ' + auth.network) +}).on('auth.logout', auth => { + alert('unlog from ' + auth.network) + }); + +hello.getAuthResponse('facebook'); + +hello.login('facebook', null, () => { + var req = hello.getAuthResponse('facebook'); +}); + +hello.logout('facebook'); + +var serviceInfo = hello.service('facebook'); + From 0ae5dd994060d8a5c8b7a64d76fe3828c936d916 Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 13:29:00 +0200 Subject: [PATCH 065/225] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8f5708c200..0e8ca78c51 100755 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ List of Definitions * [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [HashSet](http://www.timdown.co.uk/jshashtable/jshashset.html) (by [Sergey Gerasimov](https://github.com/gerich-home)) * [Hashtable](http://www.timdown.co.uk/jshashtable/) (by [Sergey Gerasimov](https://github.com/gerich-home)) +* [HelloJS](http://adodson.com/hello.js) (by [Pavel Zika](https://github.com/PavelPZ)) * [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) * [Highland](http://highlandjs.org/) (by [Bart van der Schoor](https://github.com/Bartvds/)) * [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) From c876e1bfe51202725f944be0055859c347b4aec6 Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 13:33:49 +0200 Subject: [PATCH 066/225] Update hellojs.d.ts --- hellojs/hellojs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index bafa529dea..010264ffb3 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -1,5 +1,5 @@ // Type definitions for hello.js 0.2.1 -// Project: http://knockoutjs.com +// Project: http://adodson.com/hello.js // Definitions by: Pavel Zika // Definitions: https://github.com/borisyankov/DefinitelyTyped From 4051a55c9ffc48ff4c15b5513fd0ba5017540f42 Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 13:40:45 +0200 Subject: [PATCH 067/225] Update hellojs.d.ts --- hellojs/hellojs.d.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index 010264ffb3..7727f667ed 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -1,5 +1,5 @@ // Type definitions for hello.js 0.2.1 -// Project: http://adodson.com/hello.js +// Project: http://knockoutjs.com // Definitions by: Pavel Zika // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -20,21 +20,21 @@ interface HelloJSEventArgument { } interface HelloJSStatic { - init(serviceAppIds: { [id: string]: string; }, defaultOptions?: HelloJSLoginOptions); - login(network: string, option?: HelloJSLoginOptions, callback?: () => void); - logout(network: string, callback?: () => void); + init(serviceAppIds: { [id: string]: string; }, defaultOptions?: HelloJSLoginOptions):void; + login(network: string, option?: HelloJSLoginOptions, callback?: () => void): void; + logout(network: string, callback?: () => void): void; on(eventName: string, event: (auth: HelloJSEventArgument) => void): HelloJSStatic; off(eventName: string, event: (auth: HelloJSEventArgument) => void): HelloJSStatic; getAuthResponse(network: string): any; - service(network: string): any; + service(network: string): HelloJSServiceDef; settings: HelloJSLoginOptions; (network: string): HelloJSStaticNamed; - init(servicesDef: { [id: string]: HelloJSServiceDef; }); + init(servicesDef: { [id: string]: HelloJSServiceDef; }): void; } interface HelloJSStaticNamed { - login(option?: HelloJSLoginOptions, callback?: () => void); - logout(callback?: () => void); + login(option?: HelloJSLoginOptions, callback?: () => void): void; + logout(callback?: () => void): void; getAuthResponse(): any; } From 12506f5e36d2af155e721e98e885eec81c417b43 Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 13:42:15 +0200 Subject: [PATCH 068/225] Update hellojs-test.ts --- hellojs/hellojs-test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hellojs/hellojs-test.ts b/hellojs/hellojs-test.ts index fbe36ce66d..ef05088673 100644 --- a/hellojs/hellojs-test.ts +++ b/hellojs/hellojs-test.ts @@ -1,3 +1,5 @@ +/// + hello.init( { 'facebook': '', From 3a018f7d72bc07109d929aa0d1592f08e4b778b2 Mon Sep 17 00:00:00 2001 From: Pavel Zika Date: Tue, 15 Apr 2014 14:14:37 +0200 Subject: [PATCH 069/225] Update hellojs.d.ts --- hellojs/hellojs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hellojs/hellojs.d.ts b/hellojs/hellojs.d.ts index 7727f667ed..a95b80a93b 100644 --- a/hellojs/hellojs.d.ts +++ b/hellojs/hellojs.d.ts @@ -1,5 +1,5 @@ // Type definitions for hello.js 0.2.1 -// Project: http://knockoutjs.com +// Project: http://adodson.com/hello.js/ // Definitions by: Pavel Zika // Definitions: https://github.com/borisyankov/DefinitelyTyped From ca1766728bb6175728a212f712557cd6cdea9635 Mon Sep 17 00:00:00 2001 From: Eunchong Yu Date: Tue, 15 Apr 2014 22:45:27 +0900 Subject: [PATCH 070/225] Correct the type of PDFDocumentProxy.numPages and .fingerprint The type of them is a property, not a function or a method. Reference: - API spec: https://github.com/mozilla/pdf.js/blob/305274cd45ed3b4931f983b31ebd4ffb999fb4c6/test/unit/api_spec.js#L45-L50 - Impl: https://github.com/mozilla/pdf.js/blob/816f2f7e1dc604d52bbde29eb9357360dbeddbbe/src/core/core.js#L476 and #L512 --- pdf/pdf-tests.ts | 20 ++++++++++++++++++-- pdf/pdf.d.ts | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/pdf/pdf-tests.ts b/pdf/pdf-tests.ts index 90542b503a..6157307808 100644 --- a/pdf/pdf-tests.ts +++ b/pdf/pdf-tests.ts @@ -3,9 +3,18 @@ // // Fetch the PDF document from the URL using promises // +var pdfDoc: PDFDocumentProxy; +var pageNum: number; + PDFJS.getDocument('helloworld.pdf').then(function (pdf) { // Using promise to fetch the page - pdf.getPage(1).then(function (page) { + pdfDoc = pdf; + pageNum = 1; + renderPage(pageNum); +}); + +function renderPage(pageNum: number) { + pdfDoc.getPage(pageNum).then(function (page) { var scale = 1.5; var viewport = page.getViewport(scale); @@ -26,4 +35,11 @@ PDFJS.getDocument('helloworld.pdf').then(function (pdf) { }; page.render(renderContext); }); -}); +} + +function goNext() { + if (pdfDoc && pageNum < pdfDoc.numPages) { + ++pageNum; + renderPage(pageNum); + } +} diff --git a/pdf/pdf.d.ts b/pdf/pdf.d.ts index bd66604f40..94733c3e3a 100644 --- a/pdf/pdf.d.ts +++ b/pdf/pdf.d.ts @@ -74,12 +74,12 @@ interface PDFDocumentProxy { /** * Total number of pages the PDF contains. **/ - numPages(): number; + numPages: number; /** * A unique ID to identify a PDF. Not guaranteed to be unique. [jbaldwin: haha what] **/ - fingerprint(): string; + fingerprint: string; /** * True if embedded document fonts are in use. Will be set during rendering of the pages. From d9539f82c479ecb68987724159a8332ae7ce3a2b Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Tue, 15 Apr 2014 15:12:23 -0400 Subject: [PATCH 071/225] Reduce text differences with the old version (Visual Studio being mean!) --- lodash/lodash-tests.disabled.ts | 588 ++++++++++++++++---------------- lodash/lodash.d.ts | 14 +- 2 files changed, 301 insertions(+), 301 deletions(-) diff --git a/lodash/lodash-tests.disabled.ts b/lodash/lodash-tests.disabled.ts index 97c2709405..de96b3d978 100644 --- a/lodash/lodash-tests.disabled.ts +++ b/lodash/lodash-tests.disabled.ts @@ -41,16 +41,16 @@ interface IKey { var foodsOrganic: IFoodOrganic[] = [ { name: 'banana', organic: true }, - { name: 'beet', organic: false }, + { name: 'beet', organic: false }, ]; var foodsType: IFoodType[] = [ - { name: 'apple', type: 'fruit' }, + { name: 'apple', type: 'fruit' }, { name: 'banana', type: 'fruit' }, - { name: 'beet', type: 'vegetable' } + { name: 'beet', type: 'vegetable' } ]; var foodsCombined: IFoodCombined[] = [ - { 'name': 'apple', 'organic': false, 'type': 'fruit' }, - { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } + { 'name': 'apple', 'organic': false, 'type': 'fruit' }, + { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } ]; var stoogesQuotes: IStoogesQuote[] = [ @@ -63,24 +63,24 @@ var stoogesAges: IStoogesAge[] = [ ]; var stoogesCombined: IStoogesCombined[] = [ - { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } + { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, + { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } ]; var keys: IKey[] = [ - { 'dir': 'left', 'code': 97 }, - { 'dir': 'right', 'code': 100 } + { 'dir': 'left', 'code': 97 }, + { 'dir': 'right', 'code': 100 } ]; class Dog { - constructor(public name: string) { } + constructor(public name: string) {} public bark() { - console.log('Woof, woof!'); + console.log('Woof, woof!'); } } -var result: any; +var result : any; /************* * Chaining * @@ -119,14 +119,14 @@ result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1); result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1, 2, 5, 6); result = <_.LoDashWrapper>_([1, 2, 3, 4]).unshift(5, 6); -result = _.tap([1, 2, 3, 4], function (array) { console.log(array); }); -result = <_.LoDashWrapper>_('test').tap(function (value) { console.log(value); }); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function (array) { console.log(array); }); +result = _.tap([1, 2, 3, 4], function(array) { console.log(array); }); +result = <_.LoDashWrapper>_('test').tap(function(value) { console.log(value); }); +result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function(array) { console.log(array); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).tap(function (array) { console.log(array); }); result = _('test').toString(); result = _([1, 2, 3]).toString(); -result = _({ 'key1': 'test1', 'key2': 'test2' }).toString(); +result = _({'key1': 'test1', 'key2': 'test2'}).toString(); result = _('test').valueOf(); result = _([1, 2, 3]).valueOf(); @@ -140,10 +140,10 @@ result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1' // * Arrays * // *************/ result = _.compact([0, 1, false, 2, '', 3]); -result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); + result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); + result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); result = _.rest([1, 2, 3]); result = _.rest([1, 2, 3], 2); @@ -163,48 +163,48 @@ result = _.tail([1, 2, 3], (num) => num < 3) result = _.tail(foodsOrganic, 'test') result = _.tail(foodsType, { 'type': 'value' }) -result = _.findIndex(['apple', 'banana', 'beet'], function (f) { - return /^b/.test(f); +result = _.findIndex(['apple', 'banana', 'beet'], function(f) { + return /^b/.test(f); }); result = _.findIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); +result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); -result = _.findLastIndex(['apple', 'banana', 'beet'], function (f: string) { - return /^b/.test(f); +result = _.findLastIndex(['apple', 'banana', 'beet'], function(f: string) { + return /^b/.test(f); }); result = _.findLastIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple' }); +result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); result = _.first([1, 2, 3]); result = _.first([1, 2, 3], 2); -result = _.first([1, 2, 3], function (num) { - return num < 3; +result = _.first([1, 2, 3], function(num) { + return num < 3; }); result = _.first(foodsOrganic, 'organic'); result = _.first(foodsType, { 'type': 'fruit' }); -result = _.head([1, 2, 3]); -result = _.head([1, 2, 3], 2); -result = _.head([1, 2, 3], function (num) { - return num < 3; -}); -result = _.head(foodsOrganic, 'organic'); -result = _.head(foodsType, { 'type': 'fruit' }); + result = _.head([1, 2, 3]); + result = _.head([1, 2, 3], 2); + result = _.head([1, 2, 3], function(num) { + return num < 3; + }); + result = _.head(foodsOrganic, 'organic'); + result = _.head(foodsType, { 'type': 'fruit' }); -result = _.take([1, 2, 3]); -result = _.take([1, 2, 3], 2); -result = _.take([1, 2, 3], (num) => num < 3); -result = _.take(foodsOrganic, 'organic'); -result = _.take(foodsType, { 'type': 'fruit' }); + result = _.take([1, 2, 3]); + result = _.take([1, 2, 3], 2); + result = _.take([1, 2, 3], (num) => num < 3); + result = _.take(foodsOrganic, 'organic'); + result = _.take(foodsType, { 'type': 'fruit' }); result = _.flatten([1, [2], [3, [[4]]]]); result = _.flatten([1, [2], [3, [[4]]]], true); var result: any result = _.flatten(stoogesQuotes, 'quotes'); -result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); -result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); -result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); + result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); + result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); + result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); result = _.indexOf([1, 2, 3, 1, 2, 3], 2); result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); @@ -212,8 +212,8 @@ result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); result = _.initial([1, 2, 3]); result = _.initial([1, 2, 3], 2); -result = _.initial([1, 2, 3], function (num) { - return num > 1; +result = _.initial([1, 2, 3], function(num) { + return num > 1; }); result = _.initial(foodsOrganic, 'organic'); result = _.initial(foodsType, { 'type': 'vegetable' }); @@ -222,8 +222,8 @@ result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.last([1, 2, 3]); result = _.last([1, 2, 3], 2); -result = _.last([1, 2, 3], function (num) { - return num > 1; +result = _.last([1, 2, 3], function(num) { + return num > 1; }); result = _.last(foodsOrganic, 'organic'); result = _.last(foodsType, { 'type': 'vegetable' }); @@ -231,8 +231,8 @@ result = _.last(foodsType, { 'type': 'vegetable' }); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); -result = <{ [key: string]: any }>_.zipObject(['moe', 'larry'], [30, 40]); -result = <{ [key: string]: any }>_.object(['moe', 'larry'], [30, 40]); +result = <{[key: string]: any}>_.zipObject(['moe', 'larry'], [30, 40]); +result = <{[key: string]: any}>_.object(['moe', 'larry'], [30, 40]); result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); @@ -243,39 +243,39 @@ result = _.range(0, -10, -1); result = _.range(1, 4, 0); result = _.range(0); -result = _.remove([1, 2, 3, 4, 5, 6], function (num: number) { return num % 2 == 0; }); +result = _.remove([1, 2, 3, 4, 5, 6], function(num: number) { return num % 2 == 0; }); result = _.remove(foodsOrganic, 'organic'); -result = _.remove(foodsType, { 'type': 'vegetable' }); +result = _.remove(foodsType, { 'type': 'vegetable'}); result = _.sortedIndex([20, 30, 50], 40); result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); var sortedIndexDict = { - 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } + 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } }; -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word) { - return sortedIndexDict.wordToNumber[word]; +result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + return sortedIndexDict.wordToNumber[word]; }); -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word) { - return this.wordToNumber[word]; +result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { + return this.wordToNumber[word]; }, sortedIndexDict); result = _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); result = _.uniq([1, 2, 1, 3, 1]); result = _.uniq([1, 1, 2, 2, 3], true); -result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { - return letter.toLowerCase(); +result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { + return letter.toLowerCase(); }); -result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); -result = <{ x: number; }[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); +result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); +result = <{x: number;}[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); -result = _.unique([1, 2, 1, 3, 1]); -result = _.unique([1, 1, 2, 2, 3], true); -result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function (letter) { - return letter.toLowerCase(); -}); -result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function (num) { return this.floor(num); }, Math); -result = <{ x: number; }[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); + result = _.unique([1, 2, 1, 3, 1]); + result = _.unique([1, 1, 2, 2, 3], true); + result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { + return letter.toLowerCase(); + }); + result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); + result = <{x: number;}[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); @@ -294,13 +294,13 @@ result = _.contains([1, 2, 3], 1, 2); result = _.contains({ 'name': 'moe', 'age': 40 }, 'moe'); result = _.contains('curly', 'ur'); -result = _.include([1, 2, 3], 1); -result = _.include([1, 2, 3], 1, 2); -result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); -result = _.include('curly', 'ur'); + result = _.include([1, 2, 3], 1); + result = _.include([1, 2, 3], 1, 2); + result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); + result = _.include('curly', 'ur'); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return Math.floor(num); }); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function (num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); +result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); result = <_.Dictionary>_.countBy(['one', 'two', 'three'], 'length'); result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return Math.floor(num); }); @@ -311,55 +311,55 @@ result = _.every([true, 1, null, 'yes'], Boolean); result = _.every(stoogesAges, 'age'); result = _.every(stoogesAges, { 'age': 50 }); -result = _.all([true, 1, null, 'yes'], Boolean); -result = _.all(stoogesAges, 'age'); -result = _.all(stoogesAges, { 'age': 50 }); + result = _.all([true, 1, null, 'yes'], Boolean); + result = _.all(stoogesAges, 'age'); + result = _.all(stoogesAges, { 'age': 50 }); -result = _.filter([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); +result = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); result = _.filter(foodsCombined, 'organic'); result = _.filter(foodsCombined, { 'type': 'fruit' }); -result = _([1, 2, 3, 4, 5, 6]).filter(function (num) { return num % 2 == 0; }).value(); -result = _(foodsCombined).filter('organic').value(); -result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); + result = _([1, 2, 3, 4, 5, 6]).filter(function(num) { return num % 2 == 0; }).value(); + result = _(foodsCombined).filter('organic').value(); + result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); -result = _.select([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); -result = _.select(foodsCombined, 'organic'); -result = _.select(foodsCombined, { 'type': 'fruit' }); + result = _.select([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); + result = _.select(foodsCombined, 'organic'); + result = _.select(foodsCombined, { 'type': 'fruit' }); -result = _([1, 2, 3, 4, 5, 6]).select(function (num) { return num % 2 == 0; }).value(); -result = _(foodsCombined).select('organic').value(); -result = _(foodsCombined).select({ 'type': 'fruit' }).value(); + result = _([1, 2, 3, 4, 5, 6]).select(function(num) { return num % 2 == 0; }).value(); + result = _(foodsCombined).select('organic').value(); + result = _(foodsCombined).select({ 'type': 'fruit' }).value(); -result = _.find([1, 2, 3, 4], function (num) { - return num % 2 == 0; +result = _.find([1, 2, 3, 4], function(num) { + return num % 2 == 0; }); result = _.find(foodsCombined, { 'type': 'vegetable' }); result = _.find(foodsCombined, 'organic'); -result = _.detect([1, 2, 3, 4], function (num) { - return num % 2 == 0; -}); -result = _.detect(foodsCombined, { 'type': 'vegetable' }); -result = _.detect(foodsCombined, 'organic'); + result = _.detect([1, 2, 3, 4], function(num) { + return num % 2 == 0; + }); + result = _.detect(foodsCombined, { 'type': 'vegetable' }); + result = _.detect(foodsCombined, 'organic'); -result = _.findWhere([1, 2, 3, 4], function (num) { - return num % 2 == 0; -}); -result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); -result = _.findWhere(foodsCombined, 'organic'); + result = _.findWhere([1, 2, 3, 4], function(num) { + return num % 2 == 0; + }); + result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); + result = _.findWhere(foodsCombined, 'organic'); -result = _.findLast([1, 2, 3, 4], function (num) { - return num % 2 == 0; +result = _.findLast([1, 2, 3, 4], function(num) { + return num % 2 == 0; }); result = _.findLast(foodsCombined, { 'type': 'vegetable' }); result = _.findLast(foodsCombined, 'organic'); -result = _.forEach([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); +result = _.forEach([1, 2, 3], function(num) { console.log(num); }); +result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); -result = _.each([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); + result = _.each([1, 2, 3], function(num) { console.log(num); }); + result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); }); @@ -367,11 +367,11 @@ result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: numb result = <_.LoDashArrayWrapper>_([1, 2, 3]).each(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).each(function (num) { console.log(num); }); -result = _.forEachRight([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); +result = _.forEachRight([1, 2, 3], function(num) { console.log(num); }); +result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); -result = _.eachRight([1, 2, 3], function (num) { console.log(num); }); -result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { console.log(num); }); + result = _.eachRight([1, 2, 3], function(num) { console.log(num); }); + result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEachRight(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); }); @@ -379,80 +379,80 @@ result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: numb result = <_.LoDashArrayWrapper>_([1, 2, 3]).eachRight(function (num) { console.log(num); }); result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return Math.floor(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function (num) { return this.floor(num); }, Math); +result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); +result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); result = <_.Dictionary>_.groupBy(['one', 'two', 'three'], 'length'); -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); + result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return Math.floor(num); }); + result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return this.floor(num); }, Math); + result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); result = <_.Dictionary>_.indexBy(keys, 'dir'); -result = <_.Dictionary>_.indexBy(keys, function (key) { return String.fromCharCode(key.code); }); -result = <_.Dictionary>_.indexBy(keys, function (key) { this.fromCharCode(key.code); }, String); +result = <_.Dictionary>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); +result = <_.Dictionary>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); result = _.invoke([123, 456], String.prototype.split, ''); -result = _.map([1, 2, 3], function (num) { return num * 3; }); -result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { return num * 3; }); +result = _.map([1, 2, 3], function(num) { return num * 3; }); +result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); result = _.map(stoogesAges, 'name'); -result = _([1, 2, 3]).map(function (num) { return num * 3; }).value(); -result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function (num) { return num * 3; }).value(); -result = _(stoogesAges).map('name').value(); + result = _([1, 2, 3]).map(function(num) { return num * 3; }).value(); + result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function(num) { return num * 3; }).value(); + result = _(stoogesAges).map('name').value(); -result = _.collect([1, 2, 3], function (num) { return num * 3; }); -result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function (num) { return num * 3; }); +result = _.collect([1, 2, 3], function(num) { return num * 3; }); +result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); result = _.collect(stoogesAges, 'name'); -result = _([1, 2, 3]).collect(function (num) { return num * 3; }).value(); -result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function (num) { return num * 3; }).value(); -result = _(stoogesAges).collect('name').value(); + result = _([1, 2, 3]).collect(function(num) { return num * 3; }).value(); + result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function(num) { return num * 3; }).value(); + result = _(stoogesAges).collect('name').value(); result = _.max([4, 2, 8, 6]); -result = _.max(stoogesAges, function (stooge) { return stooge.age; }); +result = _.max(stoogesAges, function(stooge) { return stooge.age; }); result = _.max(stoogesAges, 'age'); result = _.min([4, 2, 8, 6]); -result = _.min(stoogesAges, function (stooge) { return stooge.age; }); +result = _.min(stoogesAges, function(stooge) { return stooge.age; }); result = _.min(stoogesAges, 'age'); result = _.pluck(stoogesAges, 'name'); -result = _.reduce([1, 2, 3], function (sum: number, num: number) { - return sum + num; +result = _.reduce([1, 2, 3], function(sum: number, num: number) { + return sum + num; }); interface ABC { - a: number; - b: number; - c: number; + a: number; + b: number; + c: number; } -result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.foldl([1, 2, 3], function (sum, num) { - return sum + num; +result = _.foldl([1, 2, 3], function(sum, num) { + return sum + num; }); -result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.inject([1, 2, 3], function (sum, num) { - return sum + num; +result = _.inject([1, 2, 3], function(sum, num) { + return sum + num; }); -result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function (r: ABC, num, key) { - r[key] = num * 3; - return r; +result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { + r[key] = num * 3; + return r; }, {}); -result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); -result = _.foldr([[0, 1], [2, 3], [4, 5]], function (a: number[], b: number[]) { return a.concat(b); }, []); +result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); +result = _.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); -result = _.reject([1, 2, 3, 4, 5, 6], function (num) { return num % 2 == 0; }); +result = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); result = _.reject(foodsCombined, 'organic'); result = _.reject(foodsCombined, { 'type': 'fruit' }); @@ -473,11 +473,11 @@ result = _.any([null, 0, 'yes', false], Boolean); result = _.any(foodsCombined, 'organic'); result = _.any(foodsCombined, { 'type': 'meat' }); -result = _.sortBy([1, 2, 3], function (num) { return Math.sin(num); }); -result = _.sortBy([1, 2, 3], function (num) { return this.sin(num); }, Math); +result = _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); +result = _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); result = _.sortBy(['banana', 'strawberry', 'apple'], 'length'); -(function (a: number, b: number, c: number, d: number) { return _.toArray(arguments).slice(1); })(1, 2, 3, 4); +(function(a: number, b: number, c: number, d: number){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); result = _.where(stoogesCombined, { 'age': 40 }); result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); @@ -489,20 +489,20 @@ var saves = ['profile', 'settings']; var asyncSave = (obj: any) => obj.done(); var done: Function; -done = _.after(saves.length, function () { - console.log('Done saving!'); +done = _.after(saves.length, function() { + console.log('Done saving!'); }); -_.forEach(saves, function (type) { - asyncSave({ 'type': type, 'complete': done }); +_.forEach(saves, function(type) { + asyncSave({ 'type': type, 'complete': done }); }); -done = _(saves.length).after(function () { - console.log('Done saving!'); +done = _(saves.length).after(function() { + console.log('Done saving!'); }).value(); -_.forEach(saves, function (type) { - asyncSave({ 'type': type, 'complete': done }); +_.forEach(saves, function(type) { + asyncSave({ 'type': type, 'complete': done }); }); var funcBind = function (greeting: string) { return greeting + ' ' + this.name }; @@ -513,8 +513,8 @@ var funcBind3: () => any = _(funcBind).bind({ 'name': 'moe' }, 'hi').value(); funcBind3(); var view = { - 'label': 'docs', - 'onClick': function () { console.log('clicked ' + this.label); } + 'label': 'docs', + 'onClick': function() { console.log('clicked ' + this.label); } }; view = _.bindAll(view); @@ -524,17 +524,17 @@ view = _(view).bindAll().value(); jQuery('#docs').on('click', view.onClick); var objectBindKey = { - 'name': 'moe', - 'greet': function (greeting: string) { - return greeting + ' ' + this.name; - } + 'name': 'moe', + 'greet': function(greeting: string) { + return greeting + ' ' + this.name; + } }; var funcBindKey: Function = _.bindKey(objectBindKey, 'greet', 'hi'); funcBindKey(); -objectBindKey.greet = function (greeting) { - return greeting + ', ' + this.name + '!'; +objectBindKey.greet = function(greeting) { + return greeting + ', ' + this.name + '!'; }; funcBindKey(); @@ -543,16 +543,16 @@ funcBindKey = _(objectBindKey).bindKey('greet', 'hi').value(); funcBindKey(); var realNameMap = { - 'curly': 'jerome' + 'curly': 'jerome' }; -var format = function (name: string) { - name = realNameMap[name.toLowerCase()] || name; - return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); +var format = function(name: string) { + name = realNameMap[name.toLowerCase()] || name; + return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); }; -var greet = function (formatted: string) { - return 'Hiya ' + formatted + '!'; +var greet = function(formatted: string) { + return 'Hiya ' + formatted + '!'; }; result = _.compose(greet, format); @@ -564,57 +564,57 @@ result = <() => boolean>_.createCallback(createCallbackObj); result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback(); result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback(); -result = _.curry(function (a, b, c) { - console.log(a + b + c); +result = _.curry(function(a, b, c) { + console.log(a + b + c); }); -result = <_.LoDashObjectWrapper>_(function (a, b, c) { - console.log(a + b + c); +result = <_.LoDashObjectWrapper>_(function(a, b, c) { + console.log(a + b + c); }).curry(); declare var source: any; -result = _.debounce(function () { }, 150); +result = _.debounce(function() {}, 150); -jQuery('#postbox').on('click', _.debounce(function () { }, 300, { - 'leading': true, - 'trailing': false +jQuery('#postbox').on('click', _.debounce(function() {}, 300, { + 'leading': true, + 'trailing': false })); -source.addEventListener('message', _.debounce(function () { }, 250, { - 'maxWait': 1000 +source.addEventListener('message', _.debounce(function() {}, 250, { + 'maxWait': 1000 }), false); -result = <_.LoDashObjectWrapper>_(function () { }).debounce(150); +result = <_.LoDashObjectWrapper>_(function() {}).debounce(150); -jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function () { }).debounce(300, { - 'leading': true, - 'trailing': false +jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function() {}).debounce(300, { + 'leading': true, + 'trailing': false })); -source.addEventListener('message', <_.LoDashObjectWrapper>_(function () { }).debounce(250, { - 'maxWait': 1000 +source.addEventListener('message', <_.LoDashObjectWrapper>_(function() {}).debounce(250, { + 'maxWait': 1000 }), false); var returnedDebounce = _.throttle(function (a) { return a * 5; }, 5); returnedThrottled(4); -result = _.defer(function () { console.log('deferred'); }); -result = <_.LoDashWrapper>_(function () { console.log('deferred'); }).defer(); +result = _.defer(function() { console.log('deferred'); }); +result = <_.LoDashWrapper>_(function() { console.log('deferred'); }).defer(); var log = _.bind(console.log, console); result = _.delay(log, 1000, 'logged later'); result = <_.LoDashWrapper>_(log).delay(1000, 'logged later'); -var fibonacci = _.memoize(function (n) { - return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); +var fibonacci = _.memoize(function(n) { + return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); }); var data = { - 'moe': { 'name': 'moe', 'age': 40 }, - 'curly': { 'name': 'curly', 'age': 60 } + 'moe': { 'name': 'moe', 'age': 40 }, + 'curly': { 'name': 'curly', 'age': 60 } }; -var stooge = _.memoize(function (name: string) { return data[name]; }, _.identity); +var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity); stooge('curly'); stooge['cache']['curly'].name = 'jerome'; @@ -623,21 +623,21 @@ stooge('curly'); var returnedMemoize = _.throttle(function (a) { return a * 5; }, 5); returnedMemoize(4); -var initialize = _.once(function () { }); +var initialize = _.once(function(){ }); initialize(); initialize();'' var returnedOnce = _.throttle(function (a) { return a * 5; }, 5); returnedOnce(4); -var greetPartial = function (greeting: string, name: string) { return greeting + ' ' + name; }; +var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; }; var hi = _.partial(greetPartial, 'hi'); hi('moe'); var defaultsDeep = _.partialRight(_.merge, _.defaults); var optionsPartialRight = { - 'variable': 'data', - 'imports': { 'jq': $ } + 'variable': 'data', + 'imports': { 'jq': $ } }; defaultsDeep(optionsPartialRight, _.templateSettings); @@ -645,16 +645,16 @@ defaultsDeep(optionsPartialRight, _.templateSettings); var throttled = _.throttle(function () { }, 100); jQuery(window).on('scroll', throttled); -jQuery('.interactive').on('click', _.throttle(function () { }, 300000, { - 'trailing': false +jQuery('.interactive').on('click', _.throttle(function() { }, 300000, { + 'trailing': false })); -var returnedThrottled = _.throttle(function (a) { return a * 5; }, 5); +var returnedThrottled = _.throttle(function (a) { return a*5; }, 5); returnedThrottled(4); -var helloWrap = function (name: string) { return 'hello ' + name; }; -var helloWrap2 = _.wrap(helloWrap, function (func) { - return 'before, ' + func('moe') + ', after'; +var helloWrap = function(name: string) { return 'hello ' + name; }; +var helloWrap2 = _.wrap(helloWrap, function(func) { + return 'before, ' + func('moe') + ', after'; }); helloWrap2(); @@ -662,93 +662,93 @@ helloWrap2(); * Objects * ***********/ interface NameAge { - name: string; - age: number; + name: string; + age: number; } result = _.assign({ 'name': 'moe' }, { 'age': 40 }); -result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function (a, b) { - return typeof a == 'undefined' ? b : a; +result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; }); result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function (a, b) { - return typeof a == 'undefined' ? b : a; +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; }); result = _.extend({ 'name': 'moe' }, { 'age': 40 }); -result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function (a, b) { - return typeof a == 'undefined' ? b : a; +result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; }); result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function (a, b) { - return typeof a == 'undefined' ? b : a; +result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { + return typeof a == 'undefined' ? b : a; }); result = _.clone(stoogesAges); result = _.clone(stoogesAges, true); -result = _.clone(stoogesAges, true, function (value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +result = _.clone(stoogesAges, true, function(value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; }); result = _.cloneDeep(stoogesAges); -result = _.cloneDeep(stoogesAges, function (value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; +result = _.cloneDeep(stoogesAges, function(value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; }); interface Food { - name: string; - type: string; + name: string; + type: string; } var foodDefaults = { 'name': 'apple' }; result = _.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' }); -result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); + result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); -result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { - return num % 2 == 0; +result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { + return num % 2 == 0; }); -result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function (num) { - return num % 2 == 1; +result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { + return num % 2 == 1; }); -result = _.forIn(new Dog('Dagny'), function (value, key) { - console.log(key); +result = _.forIn(new Dog('Dagny'), function(value, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function (value, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function(value, key) { + console.log(key); }); -result = _.forInRight(new Dog('Dagny'), function (value, key) { - console.log(key); +result = _.forInRight(new Dog('Dagny'), function(value, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function (value, key) { - console.log(key); +result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function(value, key) { + console.log(key); }); interface ZeroOne { - 0: string; - 1: string; - one: string; + 0: string; + 1: string; + one: string; } -result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function (num, key) { - console.log(key); +result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + console.log(key); }); -result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function (num, key) { - console.log(key); + result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function(num, key) { + console.log(key); + }); + +result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { + console.log(key); }); -result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function (num, key) { - console.log(key); -}); - -result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function (num, key) { - console.log(key); -}); + result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function(num, key) { + console.log(key); + }); result = _.functions(_); result = _.methods(_); @@ -759,12 +759,12 @@ result = <_.LoDashArrayWrapper>_(_).methods(); result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); interface FirstSecond { - first: string; - second: string; + first: string; + second: string; } result = _.invert({ 'first': 'moe', 'second': 'larry' }); -(function (...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); +(function(...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); (function () { return _.isArray(arguments); })(); result = _.isArray([1, 2, 3]); @@ -787,12 +787,12 @@ result = _.isEqual(moe, copy); var words = ['hello', 'goodbye']; var otherWords = ['hi', 'goodbye']; -result = _.isEqual(words, otherWords, function (a, b) { - var reGreet = /^(?:hello|hi)$/i, - aGreet = _.isString(a) && reGreet.test(a), - bGreet = _.isString(b) && reGreet.test(b); +result = _.isEqual(words, otherWords, function(a, b) { + var reGreet = /^(?:hello|hi)$/i, + aGreet = _.isString(a) && reGreet.test(a), + bGreet = _.isString(b) && reGreet.test(b); - return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; + return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; }); result = _.isFinite(-101); @@ -820,7 +820,7 @@ class Stooge { constructor( public name: string, public age: number - ) { } + ) {} } result = _.isPlainObject(new Stooge('moe', 40)); @@ -836,67 +836,67 @@ result = _.isUndefined(void 0); result = _.keys({ 'one': 1, 'two': 2, 'three': 3 }); var mergeNames = { - 'stooges': [ - { 'name': 'moe' }, - { 'name': 'larry' } - ] + 'stooges': [ + { 'name': 'moe' }, + { 'name': 'larry' } + ] }; var mergeAges = { - 'stooges': [ - { 'age': 40 }, - { 'age': 50 } - ] + 'stooges': [ + { 'age': 40 }, + { 'age': 50 } + ] }; result = _.merge(mergeNames, mergeAges); var mergeFood = { - 'fruits': ['apple'], - 'vegetables': ['beet'] + 'fruits': ['apple'], + 'vegetables': ['beet'] }; var mergeOtherFood = { - 'fruits': ['banana'], - 'vegetables': ['carrot'] + 'fruits': ['banana'], + 'vegetables': ['carrot'] }; interface FruitVeg { - fruits: string[]; - vegetables: string[] + fruits: string[]; + vegetables: string[] }; -result = _.merge(mergeFood, mergeOtherFood, function (a, b) { - return _.isArray(a) ? a.concat(b) : undefined; +result = _.merge(mergeFood, mergeOtherFood, function(a, b) { + return _.isArray(a) ? a.concat(b) : undefined; }); interface HasName { - name: string; + name: string; } result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); -result = _.omit({ 'name': 'moe', 'age': 40 }, function (value) { - return typeof value == 'number'; +result = _.omit({ 'name': 'moe', 'age': 40 }, function(value) { + return typeof value == 'number'; }); result = _.pairs({ 'moe': 30, 'larry': 40 }); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function (value, key) { - return key.charAt(0) != '_'; +result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { + return key.charAt(0) != '_'; }); -result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function (r, num) { - num *= num; - if (num % 2) { - return r.push(num) < 3; - } +result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r, num) { + num *= num; + if (num % 2) { + return r.push(num) < 3; + } }); // → [1, 9, 25] -result = <{ a: number; b: number; c: number; }>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function (r, num, key) { - r[key] = num * 3; +result = <{a:number;b:number;c:number;}>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r, num, key) { + r[key] = num * 3; }); result = _.values({ 'one': 1, 'two': 2, 'three': 3 }); @@ -910,9 +910,9 @@ result = _.escape('Moe, Larry & Curly'); result = <{ name: string }>_.identity({ 'name': 'moe' }); _.mixin({ - 'capitalize': function (string) { - return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - } + 'capitalize': function(string) { + return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); + } }); var lodash = _.noConflict(); @@ -926,10 +926,10 @@ result = _.random(1.2, 5.2); result = _.random(0, 5, true); var object = { - 'cheese': 'crumpets', - 'stuff': function () { - return 'nonsense'; - } + 'cheese': 'crumpets', + 'stuff': function() { + return 'nonsense'; + } }; result = _.result(object, 'cheese'); @@ -963,10 +963,10 @@ class Mage { } } -var mage = new Mage(); +var mage = new Mage(); result = _.times(3, <() => number>_.partial(_.random, 1, 6)); -result = _.times(3, function (n: number) { mage.castSpell(n); }); -result = _.times(3, function (n: number) { this.cast(n); }, mage); +result = _.times(3, function(n: number) { mage.castSpell(n); }); +result = _.times(3, function(n: number) { this.cast(n); }, mage); result = _.unescape('Moe, Larry & Curly'); diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 3c4b572c15..80b1940c98 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -181,15 +181,15 @@ declare module _ { **/ valueOf(): T; - /** - * @see valueOf - **/ - value(): T; - } + /** + * @see valueOf + **/ + value(): T; + } - interface LoDashWrapper extends LoDashWrapperBase> { } + interface LoDashWrapper extends LoDashWrapperBase> {} - interface LoDashObjectWrapper extends LoDashWrapperBase> { } + interface LoDashObjectWrapper extends LoDashWrapperBase> {} interface LoDashArrayWrapper extends LoDashWrapperBase> { concat(...items: T[]): LoDashArrayWrapper; From 739e9fd044c6d9b92aa48bac79223d81bac39dd4 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 16 Apr 2014 11:58:02 +0100 Subject: [PATCH 072/225] jQueryUI: started tidying datepicker Refactored jQuery UI datepicker overloads and added JSDoc. Options still to do - will follow in a later commit I hope. Removed unused optionLiteral datepicker overloads (undocumented). Made the following change to the underlying methodName overload to allow other overloads to "chain" into it. ``` datepicker(methodName: string, ...otherParams: any[]): any; ``` Moved datepicker tests to single function. Added tests for datepicker methods. Very much just first steps. A lot to do in jQuery UI I think... --- jqueryui/jqueryui-tests.ts | 32 +++++++--- jqueryui/jqueryui.d.ts | 121 +++++++++++++++++++++++++++++++++---- 2 files changed, 132 insertions(+), 21 deletions(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index 4118f9e798..213156fef9 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -44,15 +44,6 @@ function test_draggable() { helper: (event) => { return $("
    I'm a custom helper
    "); } }); $("#set div").draggable({ stack: "#set div" }); - $.datepicker.formatDate('yy-mm-dd', new Date(2007, 1 - 1, 26)); - $.datepicker.formatDate('DD, MM d, yy', new Date(2007, 7 - 1, 14), { - dayNamesShort: $.datepicker.regional['fr'].dayNamesShort, - dayNames: $.datepicker.regional['fr'].dayNames, - monthNamesShort: $.datepicker.regional['fr'].monthNamesShort, - monthNames: $.datepicker.regional['fr'].monthNames - }); - $("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends }); - $("selector").datepicker($.datepicker.regional['fr']); } function test_droppable() { @@ -1067,6 +1058,16 @@ function test_button() { function test_datepicker() { + $.datepicker.formatDate('yy-mm-dd', new Date(2007, 1 - 1, 26)); + $.datepicker.formatDate('DD, MM d, yy', new Date(2007, 7 - 1, 14), { + dayNamesShort: $.datepicker.regional['fr'].dayNamesShort, + dayNames: $.datepicker.regional['fr'].dayNames, + monthNamesShort: $.datepicker.regional['fr'].monthNamesShort, + monthNames: $.datepicker.regional['fr'].monthNames + }); + $("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends }); + $("selector").datepicker($.datepicker.regional['fr']); + $("#datepicker").datepicker(); $("#datepicker").datepicker("option", "showAnim", $(this).val()); $("#datepicker").datepicker({ @@ -1139,6 +1140,19 @@ function test_datepicker() { $.datepicker.setDefaults($.datepicker.regional[""]); $(".selector").datepicker($.datepicker.regional["fr"]); + + // Methods + var $destroyed: JQuery = $(".selector").datepicker("destroy"); + var $dialog: JQuery = $(".selector").datepicker("dialog", "10/12/2012"); + var currentDate: Date = $(".selector").datepicker("getDate"); + var $hidden: JQuery = $(".selector").datepicker("hide"); + var isDisabled: boolean = $(".selector").datepicker("isDisabled"); + var option: any = $(".selector").datepicker("option", "disabled"); + var $refreshed: JQuery = $(".selector").datepicker("refresh"); + var $setDate1: JQuery = $(".selector").datepicker("setDate", "10/12/2012"); + var $setDate2: JQuery = $(".selector").datepicker("setDate", new Date()); + var $shown: JQuery = $(".selector").datepicker("show"); + var $widget: JQuery = $(".selector").datepicker("widget"); } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index e000e6fb29..e87f096956 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -837,23 +837,120 @@ interface JQuery { buttonset(optionLiteral: string, options: JQueryUI.ButtonOptions): any; buttonset(optionLiteral: string, optionName: string, optionValue: any): JQuery; + /** + * Initialize a datepicker + */ datepicker(): JQuery; - datepicker(methodName: 'destroy'): void; - datepicker(methodName: 'dialog', date?: Date, onSelect?: () => void , pos?: any): void; - datepicker(methodName: 'dialog', date?: string, onSelect?: () => void , pos?: any): void; + /** + * Removes the datepicker functionality completely. This will return the element back to its pre-init state. + * + * @param methodName 'destroy' + */ + datepicker(methodName: 'destroy'): JQuery; + /** + * Opens the datepicker in a dialog box. + * + * @param methodName 'dialog' + * @param date The initial date. + * @param onSelect A callback function when a date is selected. The function receives the date text and date picker instance as parameters. + * @param settings The new settings for the date picker. + * @param pos The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen. + */ + datepicker(methodName: 'dialog', date: Date, onSelect?: () => void, settings?: JQueryUI.DatepickerOptions, pos?: number[]): JQuery; + /** + * Opens the datepicker in a dialog box. + * + * @param methodName 'dialog' + * @param date The initial date. + * @param onSelect A callback function when a date is selected. The function receives the date text and date picker instance as parameters. + * @param settings The new settings for the date picker. + * @param pos The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen. + */ + datepicker(methodName: 'dialog', date: Date, onSelect?: () => void, settings?: JQueryUI.DatepickerOptions, pos?: MouseEvent): JQuery; + /** + * Opens the datepicker in a dialog box. + * + * @param methodName 'dialog' + * @param date The initial date. + * @param onSelect A callback function when a date is selected. The function receives the date text and date picker instance as parameters. + * @param settings The new settings for the date picker. + * @param pos The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen. + */ + datepicker(methodName: 'dialog', date: string, onSelect?: () => void, settings?: JQueryUI.DatepickerOptions, pos?: number[]): JQuery; + /** + * Opens the datepicker in a dialog box. + * + * @param methodName 'dialog' + * @param date The initial date. + * @param onSelect A callback function when a date is selected. The function receives the date text and date picker instance as parameters. + * @param settings The new settings for the date picker. + * @param pos The position of the top/left of the dialog as [x, y] or a MouseEvent that contains the coordinates. If not specified the dialog is centered on the screen. + */ + datepicker(methodName: 'dialog', date: string, onSelect?: () => void, settings?: JQueryUI.DatepickerOptions, pos?: MouseEvent): JQuery; + /** + * Returns the current date for the datepicker or null if no date has been selected. + * + * @param methodName 'getDate' + */ datepicker(methodName: 'getDate'): Date; - datepicker(methodName: 'hide'): void; + /** + * Close a previously opened date picker. + * + * @param methodName 'hide' + */ + datepicker(methodName: 'hide'): JQuery; + /** + * Determine whether a date picker has been disabled. + * + * @param methodName 'isDisabled' + */ datepicker(methodName: 'isDisabled'): boolean; - datepicker(methodName: 'refresh'): void; - datepicker(methodName: 'setDate', date: Date): void; - datepicker(methodName: 'setDate', date: string): void; - datepicker(methodName: 'show'): void; + /** + * Gets the value currently associated with the specified optionName. + * + * @param methodName 'option' + * @param optionName The name of the option to get. + */ + datepicker(methodName: 'option', optionName: string): any; + /** + * Redraw the date picker, after having made some external modifications. + * + * @param methodName 'refresh' + */ + datepicker(methodName: 'refresh'): JQuery; + /** + * Sets the date for the datepicker. The new date may be a Date object or a string in the current date format (e.g., "01/26/2009"), a number of days from today (e.g., +7) or a string of values and periods ("y" for years, "m" for months, "w" for weeks, "d" for days, e.g., "+1m +7d"), or null to clear the selected date. + * + * @param methodName 'setDate' + * @param date The new date. + */ + datepicker(methodName: 'setDate', date: Date): JQuery; + /** + * Sets the date for the datepicker. The new date may be a Date object or a string in the current date format (e.g., "01/26/2009"), a number of days from today (e.g., +7) or a string of values and periods ("y" for years, "m" for months, "w" for weeks, "d" for days, e.g., "+1m +7d"), or null to clear the selected date. + * + * @param methodName 'setDate' + * @param date The new date. + */ + datepicker(methodName: 'setDate', date: string): JQuery; + /** + * Open the date picker. If the datepicker is attached to an input, the input must be visible for the datepicker to be shown. + * + * @param methodName 'show' + */ + datepicker(methodName: 'show'): JQuery; + /** + * Returns a jQuery object containing the datepicker. + * + * @param methodName 'widget' + */ datepicker(methodName: 'widget'): JQuery; - datepicker(methodName: string): JQuery; + + datepicker(methodName: string, ...otherParams: any[]): any; + + /** + * Initialize a datepicker with the given options + */ datepicker(options: JQueryUI.DatepickerOptions): JQuery; - datepicker(optionLiteral: string, optionName: string): any; - datepicker(optionLiteral: string, options: JQueryUI.DatepickerOptions): any; - datepicker(optionLiteral: string, optionName: string, optionValue: any): JQuery; dialog(): JQuery; dialog(methodName: 'close'): JQuery; From 9480db26457fbc39cfa6b50398eeb0dfb2da68cc Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 16 Apr 2014 13:59:31 +0100 Subject: [PATCH 073/225] jQueryUI: started adding option overloads --- jqueryui/jqueryui-tests.ts | 12 ++++++++++ jqueryui/jqueryui.d.ts | 49 ++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 7 deletions(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index 213156fef9..ae8038b056 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1153,6 +1153,18 @@ function test_datepicker() { var $setDate2: JQuery = $(".selector").datepicker("setDate", new Date()); var $shown: JQuery = $(".selector").datepicker("show"); var $widget: JQuery = $(".selector").datepicker("widget"); + + // Options + function altField() { + $(".selector").datepicker({ altField: "#actualDate" }); + + // getter + var altField = $(".selector").datepicker("option", "altField"); + + // setter + $(".selector").datepicker("option", "altField", "#actualDate"); + } + } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index e87f096956..a44c24bc4b 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -905,13 +905,6 @@ interface JQuery { * @param methodName 'isDisabled' */ datepicker(methodName: 'isDisabled'): boolean; - /** - * Gets the value currently associated with the specified optionName. - * - * @param methodName 'option' - * @param optionName The name of the option to get. - */ - datepicker(methodName: 'option', optionName: string): any; /** * Redraw the date picker, after having made some external modifications. * @@ -945,6 +938,48 @@ interface JQuery { */ datepicker(methodName: 'widget'): JQuery; + /** + * Get the altField option, after initialization + * + * @param methodName 'option' + * @param optionName 'altField' + */ + datepicker(methodName: 'option', optionName: 'altField'): any; + /** + * Set the altField option, after initialization + * + * @param methodName 'option' + * @param optionName 'altField' + * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. + */ + datepicker(methodName: 'option', optionName: 'altField', altFieldValue: string): any; + /** + * Set the altField option, after initialization + * + * @param methodName 'option' + * @param optionName 'altField' + * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. + */ + datepicker(methodName: 'option', optionName: 'altField', altFieldValue: JQuery): any; + /** + * Set the altField option, after initialization + * + * @param methodName 'option' + * @param optionName 'altField' + * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. + */ + datepicker(methodName: 'option', optionName: 'altField', altFieldValue: Element): any; + + /** + * Gets the value currently associated with the specified optionName. + * + * @param methodName 'option' + * @param optionName The name of the option to get. + */ + datepicker(methodName: 'option', optionName: string): any; + + datepicker(methodName: 'option', optionName: string, ...otherParams: any[]): any; // Used for getting and setting options + datepicker(methodName: string, ...otherParams: any[]): any; /** From 4bb54542fe6502597f50c762695fcd140a61fd89 Mon Sep 17 00:00:00 2001 From: Antonio Laguna Date: Wed, 16 Apr 2014 14:52:40 +0100 Subject: [PATCH 074/225] Adding calls interface to Jasmine --- jasmine/jasmine.d.ts | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/jasmine/jasmine.d.ts b/jasmine/jasmine.d.ts index 794538ec55..d8132b4bcd 100644 --- a/jasmine/jasmine.d.ts +++ b/jasmine/jasmine.d.ts @@ -5,13 +5,13 @@ declare function describe(description: string, specDefinitions: () => void): void; -declare function ddescribe(description: string, specDefinitions: () => void): void; +declare function ddescribe(description: string, specDefinitions: () => void): void; declare function xdescribe(description: string, specDefinitions: () => void): void; declare function it(expectation: string, assertion?: () => void): void; declare function it(expectation: string, assertion?: (done: () => void) => void): void; -declare function iit(expectation: string, assertion?: () => void): void; -declare function iit(expectation: string, assertion?: (done: () => void) => void): void; +declare function iit(expectation: string, assertion?: () => void): void; +declare function iit(expectation: string, assertion?: (done: () => void) => void): void; declare function xit(expectation: string, assertion?: () => void): void; declare function xit(expectation: string, assertion?: (done: () => void) => void): void; @@ -98,13 +98,13 @@ declare module jasmine { addReporter(reporter: Reporter): void; execute(): void; describe(description: string, specDefinitions: () => void): Suite; - ddescribe(description: string, specDefinitions: () => void): Suite; + ddescribe(description: string, specDefinitions: () => void): Suite; beforeEach(beforeEachFunction: () => void): void; currentRunner(): Runner; afterEach(afterEachFunction: () => void): void; xdescribe(desc: string, specDefinitions: () => void): XSuite; it(description: string, func: () => void): Spec; - iit(description: string, func: () => void): Spec; + iit(description: string, func: () => void): Spec; xit(desc: string, func: () => void): XSpec; compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean; compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean; @@ -354,7 +354,7 @@ declare module jasmine { identity: string; and: SpyAnd; - calls: any; + calls: Calls; mostRecentCall: { args: any[]; }; argsForCall: any[]; wasCalled: boolean; @@ -367,13 +367,32 @@ declare module jasmine { /** By chaining the spy with and.returnValue, all calls to the function will return a specific value. */ returnValue(val: any): void; /** By chaining the spy with and.callFake, all calls to the spy will delegate to the supplied function. */ - callFake(fn: Function): void; + callFake(fn: Function): void; /** By chaining the spy with and.throwError, all calls to the spy will throw the specified value. */ throwError(msg: string): void; /** When a calling strategy is used for a spy, the original stubbing behavior can be returned at any time with and.stub. */ stub(): void; } + interface Calls { + /** By chaining the spy with calls.any(), will return false if the spy has not been called at all, and then true once at least one call happens. **/ + any(): boolean; + /** By chaining the spy with calls.count(), will return the number of times the spy was called **/ + count(): number; + /** By chaining the spy with calls.argsFor(), will return the arguments passed to call number index **/ + argsFor(index: number): any[]; + /** By chaining the spy with calls.allArgs(), will return the arguments to all calls **/ + allArgs(): any[]; + /** By chaining the spy with calls.all(), will return the context (the this) and arguments passed all calls **/ + all(): any; + /** By chaining the spy with calls.mostRecent(), will return the context (the this) and arguments for the most recent call **/ + mostRecent(): any; + /** By chaining the spy with calls.first(), will return the context (the this) and arguments for the first call **/ + first(): any; + /** By chaining the spy with calls.reset(), will clears all tracking for a spy **/ + reset(): void; + } + interface Util { inherit(childClass: Function, parentClass: Function): any; formatException(e: any): any; From 042c9c7346c28b29112392e200adb9c63a49a5b8 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 16 Apr 2014 16:20:59 +0100 Subject: [PATCH 075/225] jQuery UI: started on option getters / setters --- jqueryui/jqueryui-tests.ts | 15 +++++++++++++-- jqueryui/jqueryui.d.ts | 22 +++++++++++++++++++--- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index ae8038b056..cc0fb4f72e 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1159,10 +1159,21 @@ function test_datepicker() { $(".selector").datepicker({ altField: "#actualDate" }); // getter - var altField = $(".selector").datepicker("option", "altField"); + var altField: any = $(".selector").datepicker("option", "altField"); // setter - $(".selector").datepicker("option", "altField", "#actualDate"); + var $set: JQuery = $(".selector").datepicker("option", "altField", "#actualDate"); + } + + // Options + function altFormat() { + $(".selector").datepicker({ altFormat: "yy-mm-dd" }); + + // getter + var altFormat: string = $(".selector").datepicker("option", "altFormat"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "altFormat", "yy-mm-dd"); } } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index a44c24bc4b..4bd2e433f1 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -952,7 +952,7 @@ interface JQuery { * @param optionName 'altField' * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. */ - datepicker(methodName: 'option', optionName: 'altField', altFieldValue: string): any; + datepicker(methodName: 'option', optionName: 'altField', altFieldValue: string): JQuery; /** * Set the altField option, after initialization * @@ -960,7 +960,7 @@ interface JQuery { * @param optionName 'altField' * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. */ - datepicker(methodName: 'option', optionName: 'altField', altFieldValue: JQuery): any; + datepicker(methodName: 'option', optionName: 'altField', altFieldValue: JQuery): JQuery; /** * Set the altField option, after initialization * @@ -968,7 +968,23 @@ interface JQuery { * @param optionName 'altField' * @param altFieldValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. */ - datepicker(methodName: 'option', optionName: 'altField', altFieldValue: Element): any; + datepicker(methodName: 'option', optionName: 'altField', altFieldValue: Element): JQuery; + + /** + * Get the altFormat option, after initialization + * + * @param methodName 'option' + * @param optionName 'altFormat' + */ + datepicker(methodName: 'option', optionName: 'altFormat'): string; + /** + * Set the altFormat option, after initialization + * + * @param methodName 'option' + * @param optionName 'altFormat' + * @param altFormatValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. + */ + datepicker(methodName: 'option', optionName: 'altFormat', altFormatValue: string): JQuery; /** * Gets the value currently associated with the specified optionName. From beb5e1df56f729f25085920951abaf3e0b4c41a8 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 16 Apr 2014 17:06:57 +0100 Subject: [PATCH 076/225] jQuery UI: continued on option getters / setters --- jqueryui/jqueryui-tests.ts | 20 +++++++++++++++++++- jqueryui/jqueryui.d.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index cc0fb4f72e..987b48c4f1 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1165,7 +1165,6 @@ function test_datepicker() { var $set: JQuery = $(".selector").datepicker("option", "altField", "#actualDate"); } - // Options function altFormat() { $(".selector").datepicker({ altFormat: "yy-mm-dd" }); @@ -1176,6 +1175,25 @@ function test_datepicker() { var $set: JQuery = $(".selector").datepicker("option", "altFormat", "yy-mm-dd"); } + function appendText() { + $(".selector").datepicker({ appendText: "(yyyy-mm-dd)" }); + + // getter + var appendText: string = $(".selector").datepicker("option", "appendText"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "appendText", "(yyyy-mm-dd)"); + } + + function autoSize() { + $(".selector").datepicker({ autoSize: true }); + + // getter + var autoSize: boolean = $(".selector").datepicker("option", "autoSize"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "autoSize", true); + } } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 4bd2e433f1..e2b6d1fb85 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -986,6 +986,38 @@ interface JQuery { */ datepicker(methodName: 'option', optionName: 'altFormat', altFormatValue: string): JQuery; + /** + * Get the appendText option, after initialization + * + * @param methodName 'option' + * @param optionName 'appendText' + */ + datepicker(methodName: 'option', optionName: 'appendText'): string; + /** + * Set the appendText option, after initialization + * + * @param methodName 'option' + * @param optionName 'appendText' + * @param appendTextValue The text to display after each date field, e.g., to show the required format. + */ + datepicker(methodName: 'option', optionName: 'appendText', appendTextValue: string): JQuery; + + /** + * Get the autoSize option, after initialization + * + * @param methodName 'option' + * @param optionName 'autoSize' + */ + datepicker(methodName: 'option', optionName: 'autoSize'): boolean; + /** + * Set the autoSize option, after initialization + * + * @param methodName 'option' + * @param optionName 'autoSize' + * @param autoSizeValue Set to true to automatically resize the input field to accommodate dates in the current dateFormat. + */ + datepicker(methodName: 'option', optionName: 'autoSize', autoSizeValue: string): JQuery; + /** * Gets the value currently associated with the specified optionName. * From 3458bc6328c6a674eb0ec6f3475e262865bf9f15 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 16 Apr 2014 17:25:58 +0100 Subject: [PATCH 077/225] jQuery UI: button option getters / setters --- jqueryui/jqueryui-tests.ts | 29 ++++++++++++++++++++++ jqueryui/jqueryui.d.ts | 50 +++++++++++++++++++++++++++++++++++++- 2 files changed, 78 insertions(+), 1 deletion(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index 987b48c4f1..dc3e808569 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1194,6 +1194,35 @@ function test_datepicker() { // setter var $set: JQuery = $(".selector").datepicker("option", "autoSize", true); } + + function buttonImage() { + $(".selector").datepicker({ buttonImage: "/images/datepicker.gif" }); + + // getter + var buttonImage: string = $(".selector").datepicker("option", "buttonImage"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "buttonImage", "/images/datepicker.gif"); + } + + function buttonImageOnly() { + $(".selector").datepicker({ buttonImageOnly: true }); + + // getter + var buttonImageOnly: boolean = $(".selector").datepicker("option", "buttonImageOnly"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "buttonImageOnly", true); + } + + function buttonText() { + $(".selector").datepicker({ buttonText: "Choose" }); + + var buttonText: string = $(".selector").datepicker("option", "buttonText"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "buttonText", "Choose"); + } } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index e2b6d1fb85..52b9169e44 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -1016,7 +1016,55 @@ interface JQuery { * @param optionName 'autoSize' * @param autoSizeValue Set to true to automatically resize the input field to accommodate dates in the current dateFormat. */ - datepicker(methodName: 'option', optionName: 'autoSize', autoSizeValue: string): JQuery; + datepicker(methodName: 'option', optionName: 'autoSize', autoSizeValue: boolean): JQuery; + + /** + * Get the buttonImage option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonImage' + */ + datepicker(methodName: 'option', optionName: 'buttonImage'): string; + /** + * Set the buttonImage option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonImage' + * @param buttonImageValue A URL of an image to use to display the datepicker when the showOn option is set to "button" or "both". If set, the buttonText option becomes the alt value and is not directly displayed. + */ + datepicker(methodName: 'option', optionName: 'buttonImage', buttonImageValue: string): JQuery; + + /** + * Get the buttonImageOnly option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonImageOnly' + */ + datepicker(methodName: 'option', optionName: 'buttonImageOnly'): boolean; + /** + * Set the buttonImageOnly option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonImageOnly' + * @param buttonImageOnlyValue Whether the button image should be rendered by itself instead of inside a button element. This option is only relevant if the buttonImage option has also been set. + */ + datepicker(methodName: 'option', optionName: 'buttonImageOnly', buttonImageOnlyValue: boolean): JQuery; + + /** + * Get the buttonText option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'buttonText'): string; + /** + * Set the buttonText option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @param buttonTextValue The text to display on the trigger button. Use in conjunction with the showOn option set to "button" or "both". + */ + datepicker(methodName: 'option', optionName: 'buttonText', buttonTextValue: string): JQuery; /** * Gets the value currently associated with the specified optionName. From 09733f152eab68bde93e58df9f1de7313e418d53 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 17 Apr 2014 10:10:17 +0100 Subject: [PATCH 078/225] jQuery UI: continuing getters / setters --- jqueryui/jqueryui-tests.ts | 49 ++++++++++++++++++- jqueryui/jqueryui.d.ts | 99 +++++++++++++++++++++++++++++++++++--- 2 files changed, 141 insertions(+), 7 deletions(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index dc3e808569..c922ec161a 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1065,7 +1065,6 @@ function test_datepicker() { monthNamesShort: $.datepicker.regional['fr'].monthNamesShort, monthNames: $.datepicker.regional['fr'].monthNames }); - $("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends }); $("selector").datepicker($.datepicker.regional['fr']); $("#datepicker").datepicker(); @@ -1195,6 +1194,30 @@ function test_datepicker() { var $set: JQuery = $(".selector").datepicker("option", "autoSize", true); } + function beforeShow() { + function myFunction(input, inst) { + return null; + } + + $(".selector").datepicker({ beforeShow: myFunction }); + + // getter + var beforeShow: (input: Element, inst: any) => JQueryUI.DatepickerOptions = $(".selector").datepicker("option", "beforeShow"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "beforeShow", myFunction); + } + + function beforeShowDay() { + $("#datepicker").datepicker({ beforeShowDay: $.datepicker.noWeekends }); + + // getter + var beforeShowDay: (date: Date) => any[] = $(".selector").datepicker("option", "beforeShowDay"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "beforeShowDay", $.datepicker.noWeekends); + } + function buttonImage() { $(".selector").datepicker({ buttonImage: "/images/datepicker.gif" }); @@ -1223,6 +1246,30 @@ function test_datepicker() { // setter var $set: JQuery = $(".selector").datepicker("option", "buttonText", "Choose"); } + + function calculateWeek() { + + function myWeekCalc(date: Date) { + var checkDate = new Date(date.getTime()); + checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); + var time = checkDate.getTime(); + checkDate.setMonth(7); + checkDate.setDate(28); + var week = (Math.floor(Math.round((time - checkDate.getTime()) / 86400000) / 7) + 2); + if (week < 1) { + week = 52 + week; + } + return 'FW: '+week; + } + + $(".selector").datepicker({ calculateWeek: myWeekCalc }); + + // getter + var calculateWeek: (date: Date) => string = $(".selector").datepicker("option", "calculateWeek"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "calculateWeek", myWeekCalc); + } } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 52b9169e44..39dc732600 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -93,16 +93,50 @@ declare module JQueryUI { // Datepicker ////////////////////////////////////////////////// interface DatepickerOptions { - altFieldType?: any; // Selecotr, jQuery or Element + /** + * An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. + */ + altField?: any; // Selector, jQuery or Element + /** + * The dateFormat to be used for the altField option. This allows one date format to be shown to the user for selection purposes, while a different format is actually sent behind the scenes. For a full list of the possible formats see the formatDate function + */ altFormat?: string; + /** + * The text to display after each date field, e.g., to show the required format. + */ appendText?: string; + /** + * Set to true to automatically resize the input field to accommodate dates in the current dateFormat. + */ autoSize?: boolean; - beforeShow?: (input: Element, inst: any) => void; - beforeShowDay?: (date: Date) => void; + /** + * A function that takes an input field and current datepicker instance and returns an options object to update the datepicker with. It is called just before the datepicker is displayed. + */ + beforeShow?: (input: Element, inst: any) => JQueryUI.DatepickerOptions; + /** + * A function that takes a date as a parameter and must return an array with: + * [0]: true/false indicating whether or not this date is selectable + * [1]: a CSS class name to add to the date's cell or "" for the default presentation + * [2]: an optional popup tooltip for this date + * The function is called for each day in the datepicker before it is displayed. + */ + beforeShowDay?: (date: Date) => any[]; + /** + * A URL of an image to use to display the datepicker when the showOn option is set to "button" or "both". If set, the buttonText option becomes the alt value and is not directly displayed. + */ buttonImage?: string; + /** + * Whether the button image should be rendered by itself instead of inside a button element. This option is only relevant if the buttonImage option has also been set. + */ buttonImageOnly?: boolean; + /** + * The text to display on the trigger button. Use in conjunction with the showOn option set to "button" or "both". + */ buttonText?: string; - calculateWeek?: () => any; + /** + * 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. + */ + calculateWeek?: (date: Date) => string; changeMonth?: boolean; changeYear?: boolean; closeText?: string; @@ -158,7 +192,7 @@ declare module JQueryUI { formatDate(format: string, date: Date, settings?: DatepickerFormatDateOptions): string; parseDate(format: string, date: string, settings?: DatepickerFormatDateOptions): Date; iso8601Week(date: Date): number; - noWeekends(): void; + noWeekends(date: Date): any[]; } @@ -982,7 +1016,7 @@ interface JQuery { * * @param methodName 'option' * @param optionName 'altFormat' - * @param altFormatValue An input element that is to be updated with the selected date from the datepicker. Use the altFormat option to change the format of the date within this field. Leave as blank for no alternate field. + * @param altFormatValue The dateFormat to be used for the altField option. This allows one date format to be shown to the user for selection purposes, while a different format is actually sent behind the scenes. For a full list of the possible formats see the formatDate function */ datepicker(methodName: 'option', optionName: 'altFormat', altFormatValue: string): JQuery; @@ -1018,6 +1052,42 @@ interface JQuery { */ datepicker(methodName: 'option', optionName: 'autoSize', autoSizeValue: boolean): JQuery; + /** + * Get the beforeShow option, after initialization + * + * @param methodName 'option' + * @param optionName 'beforeShow' + */ + datepicker(methodName: 'option', optionName: 'beforeShow'): (input: Element, inst: any) => JQueryUI.DatepickerOptions; + /** + * Set the beforeShow option, after initialization + * + * @param methodName 'option' + * @param optionName 'beforeShow' + * @param beforeShowValue A function that takes an input field and current datepicker instance and returns an options object to update the datepicker with. It is called just before the datepicker is displayed. + */ + datepicker(methodName: 'option', optionName: 'beforeShow', beforeShowValue: (input: Element, inst: any) => JQueryUI.DatepickerOptions): JQuery; + + /** + * Get the beforeShow option, after initialization + * + * @param methodName 'option' + * @param optionName 'beforeShowDay' + */ + datepicker(methodName: 'option', optionName: 'beforeShowDay'): (date: Date) => any[]; + /** + * Set the beforeShow option, after initialization + * + * @param methodName 'option' + * @param optionName 'beforeShowDay' + * @param beforeShowDayValue A function that takes a date as a parameter and must return an array with: + * [0]: true/false indicating whether or not this date is selectable + * [1]: a CSS class name to add to the date's cell or "" for the default presentation + * [2]: an optional popup tooltip for this date + * The function is called for each day in the datepicker before it is displayed. + */ + datepicker(methodName: 'option', optionName: 'beforeShowDay', beforeShowDayValue: (date: Date) => any[]): JQuery; + /** * Get the buttonImage option, after initialization * @@ -1066,6 +1136,23 @@ interface JQuery { */ datepicker(methodName: 'option', optionName: 'buttonText', buttonTextValue: string): JQuery; + /** + * Get the calculateWeek option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'calculateWeek'): (date: Date) => string; + /** + * Set the calculateWeek option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + /** * Gets the value currently associated with the specified optionName. * From e68f6bc24faf929bd1edc5950d1064415000cd34 Mon Sep 17 00:00:00 2001 From: vvakame Date: Fri, 18 Apr 2014 00:03:04 +0900 Subject: [PATCH 079/225] added glob/glob.d.ts --- README.md | 2 ++ glob/glob-tests.ts | 24 +++++++++++++ glob/glob.d.ts | 70 ++++++++++++++++++++++++++++++++++++ minimatch/minimatch-tests.ts | 13 +++++++ minimatch/minimatch.d.ts | 46 ++++++++++++++++++++++++ 5 files changed, 155 insertions(+) create mode 100644 glob/glob-tests.ts create mode 100644 glob/glob.d.ts create mode 100644 minimatch/minimatch-tests.ts create mode 100644 minimatch/minimatch.d.ts diff --git a/README.md b/README.md index 0e8ca78c51..4120a354ef 100755 --- a/README.md +++ b/README.md @@ -100,6 +100,7 @@ List of Definitions * [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)) * [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz)) +* [Glob](https://github.com/isaacs/node-glob) (by [vvakame](https://github.com/vvakame)) * [GoJS](http://gojs.net/) (by [Barbara Duckworth](https://github.com/barbara42)) * [Greasemonkey](http://www.greasespot.net/) (by [Kota Saito](https://github.com/kotas)) * [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt)) @@ -211,6 +212,7 @@ List of Definitions * [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg)) * [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) * [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) +* [Minimatch](https://github.com/isaacs/minimatch) (by [vvakame](https://github.com/vvakame)) * [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds)) * [mixto](https://github.com/atom/mixto) (by [vvakame](https://github.com/vvakame)) * [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) diff --git a/glob/glob-tests.ts b/glob/glob-tests.ts new file mode 100644 index 0000000000..af5ecf6d05 --- /dev/null +++ b/glob/glob-tests.ts @@ -0,0 +1,24 @@ +/// + +import glob = require("glob"); +var Glob = glob.Glob; + +(()=> { + var pattern = "test/a/**/[cg]/../[cg]"; + console.log(pattern); + + var mg = new Glob(pattern, {mark: true, sync: true}, function (er, matches) { + console.log("matches", matches) + }); + console.log("after") +})(); + +(()=> { + var pattern = "{./*/*,/*,/usr/local/*}"; + console.log(pattern); + + var mg = new Glob(pattern, {mark: true}, function (er, matches) { + console.log("matches", matches) + }); + console.log("after") +})(); diff --git a/glob/glob.d.ts b/glob/glob.d.ts new file mode 100644 index 0000000000..46ab16e0ad --- /dev/null +++ b/glob/glob.d.ts @@ -0,0 +1,70 @@ +// Type definitions for Glob +// Project: https://github.com/isaacs/node-glob +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +declare module "glob" { + + import events = require("events"); + import minimatch = require("minimatch"); + + function G(pattern:string, cb:(err:Error, matches:string[])=>void):void; + + function G(pattern:string, options:G.IOptions, cb:(err:Error, matches:string[])=>void):void; + + module G { + function sync(pattern:string, options?:IOptions):string[]; + + var Glob:IGlobStatic; + + interface IOptions extends minimatch.IOptions { + sync?: boolean; + nomount?: boolean; + matchBase?:any; + noglobstar?:any; + strict?: boolean; + dot?:boolean; + mark?:boolean; + nounique?:boolean; + nonull?:boolean; + nosort?:boolean; + nocase?:boolean; + stat?:boolean; + debug?:boolean; + globDebug?:boolean; + silent?:boolean; + } + + interface IGlobStatic extends events.EventEmitter { + new (pattern:string, cb?:(err:Error, matches:string[])=>void):IGlob; + new (pattern:string, options:any, cb?:(err:Error, matches:string[])=>void):IGlob; + } + + interface IGlob { + EOF:any; + paused:boolean; + maxDepth:number; + maxLength:number; + cache:any; + statCache:any; + changedCwd:boolean; + cwd: string; + root: string; + error: any; + aborted: boolean; + minimatch: minimatch.IMinimatch; + matches:string[]; + + log(...args:any[]):void; + abort():void; + pause():void; + resume():void; + emitMatch(m:any):void; + } + } + +export = G; +} diff --git a/minimatch/minimatch-tests.ts b/minimatch/minimatch-tests.ts new file mode 100644 index 0000000000..b50471826c --- /dev/null +++ b/minimatch/minimatch-tests.ts @@ -0,0 +1,13 @@ +/// + +import mm = require("minimatch"); + +var pattern = "**/*.ts"; +var options = { + debug: true +}; +var m = new mm.Minimatch(pattern, options); +var r = m.makeRe(); + +var f = "test.ts"; +mm.match(f, pattern, options); diff --git a/minimatch/minimatch.d.ts b/minimatch/minimatch.d.ts new file mode 100644 index 0000000000..588e93535a --- /dev/null +++ b/minimatch/minimatch.d.ts @@ -0,0 +1,46 @@ +// Type definitions for Minimatch +// Project: https://github.com/isaacs/minimatch +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "minimatch" { + + function M(target:string, pattern:string, options?:M.IOptions):void; + + module M { + function match(filename:string, pattern:string, options:IOptions):boolean; + + var Minimatch:IMinimatchStatic; + + interface IOptions { + debug?:boolean; + nobrace?:boolean; + noglobstar?:boolean; + dot?:boolean; + noext?:boolean; + nocase?:boolean; + nonull?:boolean; + matchBase?:boolean; + nocomment?:boolean; + nonegate?:boolean; + flipNegate?:boolean; + } + + interface IMinimatchStatic { + new (pattern:string, options:IOptions):IMinimatch; + } + + interface IMinimatch { + debug():void; + make():void; + parseNegate():void; + braceExpand(pattern:string, options:IOptions):void; + parse(pattern:string, isSub?:boolean):void; + makeRe():any; // regexp or boolean + match(file:string, pattern:string, options:IOptions):boolean; + matchOne(file:string, pattern:string, partial:any):boolean; + } + } + + export = M; +} From 90a326d1fd6cdf19522424880144816af4e37526 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 17 Apr 2014 16:30:03 +0100 Subject: [PATCH 080/225] jQuery UI: Mucho interface JSDoc --- jqueryui/jqueryui.d.ts | 142 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 140 insertions(+), 2 deletions(-) diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 39dc732600..083df7b463 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -1,6 +1,6 @@ // Type definitions for jQueryUI 1.9 // Project: http://jqueryui.com/ -// Definitions by: Boris Yankov +// Definitions by: Boris Yankov , John Reilly // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -137,45 +137,183 @@ declare module JQueryUI { * 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. */ calculateWeek?: (date: Date) => string; + /** + * Whether the month should be rendered as a dropdown instead of text. + */ changeMonth?: boolean; + /** + * 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. + */ changeYear?: boolean; + /** + * The text to display for the close link. Use the showButtonPanel option to display this button. + */ closeText?: string; + /** + * When true, entry in the input field is constrained to those characters allowed by the current dateFormat option. + */ constrainInput?: boolean; + /** + * The text to display for the current day link. Use the showButtonPanel option to display this button. + */ currentText?: string; + /** + * The format for parsed and displayed dates. For a full list of the possible formats see the formatDate function. + */ dateFormat?: string; + /** + * The list of long day names, starting from Sunday, for use as requested via the dateFormat option. + */ dayNames?: string[]; + /** + * The list of minimised day names, starting from Sunday, for use as column headers within the datepicker. + */ dayNamesMin?: string[]; + /** + * The list of abbreviated day names, starting from Sunday, for use as requested via the dateFormat option. + */ dayNamesShort?: string[]; + /** + * Set the date to highlight on first opening if the field is blank. Specify either an actual date via a Date object or as a string in the current dateFormat, or a number of days from today (e.g. +7) or a string of values and periods ('y' for years, 'm' for months, 'w' for weeks, 'd' for days, e.g. '+1m +7d'), or null for today. + * Multiple types supported: + * Date: A date object containing the default date. + * Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday. + * String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today. + */ defaultDateType?: any; // Date, number or string + /** + * 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"). + */ duration?: string; + /** + * Set the first day of the week: Sunday is 0, Monday is 1, etc. + */ firstDay?: number; + /** + * When true, the current day link moves to the currently selected date instead of today. + */ gotoCurrent?: boolean; + /** + * Normally the previous and next links are disabled when not applicable (see the minDate and maxDate options). You can hide them altogether by setting this attribute to true. + */ hideIfNoPrevNext?: boolean; + /** + * Whether the current language is drawn from right to left. + */ isRTL?: boolean; + /** + * The maximum selectable date. When set to null, there is no maximum. + * Multiple types supported: + * Date: A date object containing the maximum date. + * Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday. + * String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today. + */ maxDate?: any; // Date, number or string + /** + * The minimum selectable date. When set to null, there is no minimum. + * Multiple types supported: + * Date: A date object containing the minimum date. + * Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday. + * String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today. + */ minDate?: any; // Date, number or string + /** + * The list of full month names, for use as requested via the dateFormat option. + */ monthNames?: string[]; + /** + * The list of abbreviated month names, as used in the month header on each datepicker and as requested via the dateFormat option. + */ monthNamesShort?: string[]; + /** + * Whether the prevText and nextText options should be parsed as dates by the formatDate function, allowing them to display the target month names for example. + */ navigationAsDateFormat?: boolean; + /** + * The text to display for the next month link. With the standard ThemeRoller styling, this value is replaced by an icon. + */ nextText?: string; - numberOfMonths?: any; // number or [] + /** + * The number of months to show at once. + * Multiple types supported: + * Number: The number of months to display in a single row. + * Array: An array defining the number of rows and columns to display. + */ + numberOfMonths?: any; // number or number[] + /** + * Called when the datepicker moves to a new month and/or year. The function receives the selected year, month (1-12), and the datepicker instance as parameters. this refers to the associated input field. + */ onChangeMonthYear?: (year: number, month: number, inst: any) => void; + /** + * Called when the datepicker is closed, whether or not a date is selected. The function receives the selected date as text ("" if none) and the datepicker instance as parameters. this refers to the associated input field. + */ onClose?: (dateText: string, inst: any) => void; + /** + * Called when the datepicker is selected. The function receives the selected date as text and the datepicker instance as parameters. this refers to the associated input field. + */ onSelect?: (dateText: string, inst: any) => void; + /** + * The text to display for the previous month link. With the standard ThemeRoller styling, this value is replaced by an icon. + */ prevText?: string; + /** + * Whether days in other months shown before or after the current month are selectable. This only applies if the showOtherMonths option is set to true. + */ selectOtherMonths?: boolean; + /** + * The cutoff year for determining the century for a date (used in conjunction with dateFormat 'y'). Any dates entered with a year value less than or equal to the cutoff year are considered to be in the current century, while those greater than it are deemed to be in the previous century. + * Multiple types supported: + * Number: A value between 0 and 99 indicating the cutoff year. + * String: A relative number of years from the current year, e.g., "+3" or "-5". + */ shortYearCutoff?: any; // number or string + /** + * The name of the animation used to show and hide the datepicker. Use "show" (the default), "slideDown", "fadeIn", any of the jQuery UI effects. Set to an empty string to disable animation. + */ showAnim?: string; + /** + * Whether to display a button pane underneath the calendar. The button pane contains two buttons, a Today button that links to the current day, and a Done button that closes the datepicker. The buttons' text can be customized using the currentText and closeText options respectively. + */ showButtonPanel?: boolean; + /** + * When displaying multiple months via the numberOfMonths option, the showCurrentAtPos option defines which position to display the current month in. + */ showCurrentAtPos?: number; + /** + * Whether to show the month after the year in the header. + */ showMonthAfterYear?: boolean; + /** + * When the datepicker should appear. The datepicker can appear when the field receives focus ("focus"), when a button is clicked ("button"), or when either event occurs ("both"). + */ showOn?: string; + /** + * If using one of the jQuery UI effects for the showAnim option, you can provide additional settings for that animation via this option. + */ showOptions?: any; // TODO + /** + * Whether to display dates in other months (non-selectable) at the start or end of the current month. To make these days selectable use the selectOtherMonths option. + */ showOtherMonths?: boolean; + /** + * When true, a column is added to show the week of the year. The calculateWeek option determines how the week of the year is calculated. You may also want to change the firstDay option. + */ showWeek?: boolean; + /** + * Set how many months to move when clicking the previous/next links. + */ stepMonths?: number; + /** + * The text to display for the week of the year column heading. Use the showWeek option to display this column. + */ weekHeader?: string; + /** + * The range of years displayed in the year drop-down: either relative to today's year ("-nn:+nn"), relative to the currently selected year ("c-nn:c+nn"), absolute ("nnnn:nnnn"), or combinations of these formats ("nnnn:-nn"). Note that this option only affects what appears in the drop-down, to restrict which dates may be selected use the minDate and/or maxDate options. + */ yearRange?: string; + /** + * Additional text to display after the year in the month headers. + */ yearSuffix?: string; } From 48d18718006fb773a8cf9682c3d25264377195ff Mon Sep 17 00:00:00 2001 From: olamothe Date: Thu, 17 Apr 2014 11:48:03 -0400 Subject: [PATCH 081/225] Add _.partition, _.property, _.constant, _.now, --- underscore/underscore-tests.ts | 18 +++++++++++++++ underscore/underscore.d.ts | 41 +++++++++++++++++++++++++++++++++- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index d3eb87f6aa..64c45a478b 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -67,6 +67,17 @@ _.shuffle([1, 2, 3, 4, 5, 6]); _.size({ one: 1, two: 2, three: 3 }); +_.partition([0, 1, 2, 3, 4, 5], (num)=>{return num % 2 ==0}); + +interface Family { + name: string; + relation : string; +} +var isUncleMoe = _.matches({name : 'moe', relation : 'uncle'}); +_.filter([{name: 'larry', relation : 'father'}, {name : 'moe', relation : 'uncle'}], isUncleMoe); + + + /////////////////////////////////////////////////////////////////////////////////////// _.first([5, 4, 3, 2, 1]); @@ -204,6 +215,8 @@ _.isArray([1, 2, 3]); _.isObject({}); _.isObject(1); +_.property('name')(moe); + // (() => { return _.isArguments(arguments); })(1, 2, 3); _.isArguments([1, 2, 3]); @@ -235,6 +248,11 @@ _.isUndefined((window).missingVariable); /////////////////////////////////////////////////////////////////////////////////////// +var UncleMoe = {name: 'moe'}; +_.constant(UncleMoe)(); + +typeof _.now() === "number"; + var underscore = _.noConflict(); var moe2 = { name: 'moe' }; diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 9e44c0c63e..7e4bd99e1e 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Underscore 1.5.2 +// Type definitions for Underscore 1.6.0 // Project: http://underscorejs.org/ // Definitions by: Boris Yankov // Definitions by: Josh Baldwin @@ -543,6 +543,19 @@ interface UnderscoreStatic { * @return Number of values in `list`. **/ size(list: _.Collection): number; + + /** + * Split array into two arrays: + * one whose elements all satisfy predicate and one whose elements all do not satisfy predicate. + * @param array Array to split in two + * @param iterator Filter iterator function for each element in `array`. + * @param context `this` object in `iterator`, optional. + * @return Array where Array[0] are the elements in `array` that satisfies the predicate, and Array[1] the elements that did not. + **/ + partition( + array: Array, + iterator: _.ListIterator, + context?: any): T[][]; /********* * Arrays * @@ -1134,6 +1147,20 @@ interface UnderscoreStatic { **/ has(object: any, key: string): boolean; + /** + * Returns a function that will itself return the key property of any passed-in object + * @param key Property of the object + * @return Function which accept an object an returns the value of key in that object + **/ + property(key: string): (object: Object)=> any; + + /** + * Returns a predicate function that will tell you if a passed in object contains all of the key/value properties present in attrs. + * @param attrs Object with key values pair + * @return Predicate function + **/ + matches(attrs: T): _.ListIterator; + /** * Performs an optimized deep comparison between the two objects, * to determine if they should be considered equal. @@ -1270,6 +1297,13 @@ interface UnderscoreStatic { **/ identity(value: T): T; + /** + * Creates a function that returns the same value that is used as the argument of _.constant + * @param value Identity of this object. + * @return Function that return value. + **/ + constant(value: T): () => T; + /** * Invokes the given iterator function n times. * Each invocation of iterator is called with an index argument @@ -1353,6 +1387,11 @@ interface UnderscoreStatic { **/ templateSettings: _.TemplateSettings; + /** + * Returns an integer timestamp for the current time, using the fastest method available in the runtime. Useful for implementing timing/animation functions. + **/ + now(): number; + /* ********** * Chaining * *********** */ From 2f7069a43b9a504b0519c534179bd296eb59ae87 Mon Sep 17 00:00:00 2001 From: Aaron Date: Thu, 17 Apr 2014 14:53:08 -0500 Subject: [PATCH 082/225] Update colors.d.ts to work with TypeScript import The file lacked a module delcaration, so it would not work with the following code: import colors = require("colors"); The `interface` does not belong in the `module` as it's global (applying to `String` and not scoped.) --- colors/colors.d.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/colors/colors.d.ts b/colors/colors.d.ts index c87112d7c4..e6056b3540 100644 --- a/colors/colors.d.ts +++ b/colors/colors.d.ts @@ -3,6 +3,10 @@ // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped +declare module "colors" { + export function setTheme(theme:any):any; +} + interface String { bold:string; italic:string; From 2e8798ea1590d5d931684cf78320da6a0fe0d1ae Mon Sep 17 00:00:00 2001 From: Per Kastman Date: Fri, 18 Apr 2014 12:15:24 +0200 Subject: [PATCH 083/225] Added AMD support --- domready/domready.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/domready/domready.d.ts b/domready/domready.d.ts index c951f93972..14ba140117 100644 --- a/domready/domready.d.ts +++ b/domready/domready.d.ts @@ -3,4 +3,8 @@ // Definitions by: Christian Holm Nielsen // Definitions: https://github.com/borisyankov/DefinitelyTyped -declare function domready(callback: () => any) : void; \ No newline at end of file +declare function domready(callback: () => any) : void; + +declare module "domready" { + export = domready; +} From 2b686dabb5b72b273fe998fd623a96d9be49b8be Mon Sep 17 00:00:00 2001 From: Paul Vick Date: Fri, 18 Apr 2014 12:42:37 -0700 Subject: [PATCH 084/225] Add value property to jake Task object. --- jake/jake.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 2afaee338a..330aac3248 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -214,6 +214,7 @@ declare module jake{ setMaxListeners(n: number): void; listeners(event: string): Function[]; emit(event: string, ...args: any[]): boolean; + value: any; } export class DirectoryTask{ From 1c5ed8157763aa85f6fdfcf820127b518691c649 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Fri, 18 Apr 2014 21:18:09 +0100 Subject: [PATCH 085/225] Export Node functions for creating decipher correctly * createDecipher() and createDecipheriv() are functions in the crypto module, not methods of the Cipher interface. * Add pbkdf2Sync() decl --- node/node.d.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/node/node.d.ts b/node/node.d.ts index 42398496ee..34862f4b7b 100644 --- a/node/node.d.ts +++ b/node/node.d.ts @@ -1031,9 +1031,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,6 +1063,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 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; From 0e0e9511a8da33db68ae1a8b697993771d6aa0db Mon Sep 17 00:00:00 2001 From: staticfunction Date: Sat, 19 Apr 2014 06:58:14 +0800 Subject: [PATCH 086/225] added passport-facebook --- passport-facebook/passport-facebook-test.ts | 25 +++++++++++++++++ passport-facebook/passport-facebook.d.ts | 31 +++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 passport-facebook/passport-facebook-test.ts create mode 100644 passport-facebook/passport-facebook.d.ts diff --git a/passport-facebook/passport-facebook-test.ts b/passport-facebook/passport-facebook-test.ts new file mode 100644 index 0000000000..b35770479f --- /dev/null +++ b/passport-facebook/passport-facebook-test.ts @@ -0,0 +1,25 @@ +/** + * Created by jcabresos on 4/19/2014. + */ +import passport = require('passport'); +import facebook = require('passport-facebook'); + +// just some test model +var User = { + findOrCreate(id:string, provider:string, callback:(err:any, user:any) => void): void { + callback(null, {username:'james'}); + } +} + +passport.use(new facebook.Strategy({ + clientID: process.env.PASSPORT_FACEBOOK_CLIENT_ID, + clientSecret: process.env.PASSPORT_FACEBOOK_CLIENT_SECRET, + callbackURL: process.env.PASSPORT_FACEBOOK_CALLBACK_URL + }, + function(accessToken:string, refreshToken:string, profile:facebook.Profile, done:(error:any, user?:any) => void) { + User.findOrCreate(profile.id, profile.provider, function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + }) +); \ No newline at end of file diff --git a/passport-facebook/passport-facebook.d.ts b/passport-facebook/passport-facebook.d.ts new file mode 100644 index 0000000000..c6a9d97b26 --- /dev/null +++ b/passport-facebook/passport-facebook.d.ts @@ -0,0 +1,31 @@ +// Type definitions for passport-facebook 1.0.3 +// Project: https://github.com/jaredhanson/passport-facebook +// Definitions by: James Roland Cabresos +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'passport-facebook' { + + import passport = require('passport'); + import express = require('express'); + + interface Profile { + id:string; + provider:string; + displayName:string; + name:{familyName:string; givenName:string; middleName:string}; + profileUrl:string; + } + + interface User { + + } + + class Strategy implements passport.Strategy{ + constructor(options:{clientID:string; clientSecret:string; callbackURL:string}, + verify:(accessToken:string, refreshToken:string, profile:Profile, done:(error:any, user?:any) => void) => void); + name: string; + authenticate:(req: express.Request, options?: Object) => void; + } +} \ No newline at end of file From b5f170afdac4016d70798e946541f5c9bde27f37 Mon Sep 17 00:00:00 2001 From: staticfunction Date: Sat, 19 Apr 2014 07:34:37 +0800 Subject: [PATCH 087/225] Removed unused interface --- passport-facebook/passport-facebook.d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/passport-facebook/passport-facebook.d.ts b/passport-facebook/passport-facebook.d.ts index c6a9d97b26..47c9b68bb8 100644 --- a/passport-facebook/passport-facebook.d.ts +++ b/passport-facebook/passport-facebook.d.ts @@ -18,10 +18,6 @@ declare module 'passport-facebook' { profileUrl:string; } - interface User { - - } - class Strategy implements passport.Strategy{ constructor(options:{clientID:string; clientSecret:string; callbackURL:string}, verify:(accessToken:string, refreshToken:string, profile:Profile, done:(error:any, user?:any) => void) => void); From 45df9cc2da7de4cb945e905b9ae134ba95af756d Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sun, 20 Apr 2014 01:01:38 +0200 Subject: [PATCH 088/225] added definitions for joi --- README.md | 1 + joi/joi-tests.ts | 403 +++++++++++++++++++++++++++++++++++++++++++++++ joi/joi.d.ts | 377 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 781 insertions(+) create mode 100644 joi/joi-tests.ts create mode 100644 joi/joi.d.ts diff --git a/README.md b/README.md index 4120a354ef..c97da76e75 100755 --- a/README.md +++ b/README.md @@ -132,6 +132,7 @@ List of Definitions * [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/)) * [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov)) * [Jasmine-jQuery](https://github.com/velesin/jasmine-jquery) (by [Gregor Stamac](https://github.com/gstamac)) +* [Joi](https://github.com/spumko/joi) (by [Bart van der Schoor](https://github.com/Bartvds)) * [JointJS](http://www.jointjs.com/) (by [Aidan Reel](http://github.com/areel)) * [jQRangeSlider](http://ghusse.github.com/jQRangeSlider) (by [Dániel Tar](https://github.com/qcz)) * [jQuery](http://jquery.com/) (from TypeScript samples) diff --git a/joi/joi-tests.ts b/joi/joi-tests.ts new file mode 100644 index 0000000000..45a46dcd06 --- /dev/null +++ b/joi/joi-tests.ts @@ -0,0 +1,403 @@ +/// +/// + +import Joi = require('joi'); + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +var x: any = null; +var value: any = null; +var num: number = 0; +var str: string = ''; +var bool: boolean = false; +var exp: RegExp = null; +var obj: Object = null; +var date: Date = null; +var bin: NodeBuffer = null; +var err: Error = null; +var func: Function = null; + +var anyArr: any[] = []; +var numArr: number[] = []; +var strArr: string[] = []; +var boolArr: boolean[] = []; +var expArr: RegExp[] = []; +var objArr: Object[] = []; +var bufArr: NodeBuffer[] = []; +var errArr: Error[] = []; +var funcArr: Function[] = []; + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +var validOpts: Joi.ValidationOptions = null; + +validOpts = {abortEarly: bool}; +validOpts = {convert: bool}; +validOpts = {allowUnknown: bool}; +validOpts = {skipFunctions: bool}; +validOpts = {stripUnknown: bool}; +validOpts = {language: bool}; + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +var renOpts: Joi.RenameOptions = null; + +renOpts = {alias: bool}; +renOpts = {multiple: bool}; +renOpts = {override: bool}; + +var validErr: Joi.ValidationError = null; + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +var schema: Joi.Schema = null; + +var anySchema: Joi.AnySchema = null; +var numSchema: Joi.NumberSchema = null; +var strSchema: Joi.StringSchema = null; +var arrSchema: Joi.ArraySchema = null; +var boolSchema: Joi.BooleanSchema = null; +var binSchema: Joi.BinarySchema = null; +var dateSchema: Joi.DateSchema = null; +var funcSchema: Joi.FunctionSchema = null; +var objSchema: Joi.ObjectSchema = null; + +var schemaArr: Joi.Schema[] = []; + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +schema = anySchema; +schema = numSchema; +schema = strSchema; +schema = arrSchema; +schema = boolSchema; +schema = binSchema; +schema = dateSchema; +schema = funcSchema; +schema = objSchema; + +anySchema = anySchema; +anySchema = numSchema; +anySchema = strSchema; +anySchema = arrSchema; +anySchema = boolSchema; +anySchema = binSchema; +anySchema = dateSchema; +anySchema = funcSchema; +anySchema = objSchema; + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +var schemaMap: Joi.SchemaMap = null; + +schemaMap = { + a: numSchema, + b: strSchema +}; + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +anySchema = Joi.any(); + +anySchema.validate(x, (err: Joi.ValidationError, value: any) => { + +}); + +module common { + anySchema = anySchema.allow(x); + anySchema = anySchema.valid(x); + anySchema = anySchema.invalid(x); + anySchema = anySchema.default(x); + + anySchema = anySchema.required(); + anySchema = anySchema.optional(); + + anySchema = anySchema.description(str); + anySchema = anySchema.notes(str); + anySchema = anySchema.notes(strArr); + anySchema = anySchema.tags(str); + anySchema = anySchema.tags(strArr); + + anySchema = anySchema.options(validOpts); + anySchema = anySchema.strict(); +} + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +arrSchema = Joi.array(); + +arrSchema = arrSchema.min(num); +arrSchema = arrSchema.max(num); +arrSchema = arrSchema.length(num); + +arrSchema = arrSchema.includes(numSchema); +arrSchema = arrSchema.includes(numSchema, strSchema); +arrSchema = arrSchema.includes([numSchema, strSchema]); + +arrSchema = arrSchema.excludes(numSchema); +arrSchema = arrSchema.excludes(numSchema, strSchema); +arrSchema = arrSchema.excludes([numSchema, strSchema]); + +// - - - - - - - - + +module common { + arrSchema = arrSchema.allow(anyArr); + arrSchema = arrSchema.valid(anyArr); + arrSchema = arrSchema.invalid(anyArr); + arrSchema = arrSchema.default(anyArr); + + arrSchema = arrSchema.required(); + arrSchema = arrSchema.optional(); + + arrSchema = arrSchema.description(str); + arrSchema = arrSchema.notes(str); + arrSchema = arrSchema.notes(strArr); + arrSchema = arrSchema.tags(str); + arrSchema = arrSchema.tags(strArr); + + arrSchema = arrSchema.options(validOpts); + arrSchema = arrSchema.strict(); +} + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +boolSchema = Joi.bool(); +boolSchema = Joi.boolean(); + +module common { + boolSchema = boolSchema.allow(bool); + boolSchema = boolSchema.valid(bool); + boolSchema = boolSchema.invalid(bool); + boolSchema = boolSchema.default(bool); + + boolSchema = boolSchema.required(); + boolSchema = boolSchema.optional(); + + boolSchema = boolSchema.description(str); + boolSchema = boolSchema.notes(str); + boolSchema = boolSchema.notes(strArr); + boolSchema = boolSchema.tags(str); + boolSchema = boolSchema.tags(strArr); + + boolSchema = boolSchema.options(validOpts); + boolSchema = boolSchema.strict(); +} + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +binSchema = Joi.binary(); + +binSchema = binSchema.min(num); +binSchema = binSchema.max(num); +binSchema = binSchema.length(num); + +module common { + binSchema = binSchema.allow(bin); + binSchema = binSchema.valid(bin); + binSchema = binSchema.invalid(bin); + binSchema = binSchema.default(bin); + + binSchema = binSchema.required(); + binSchema = binSchema.optional(); + + binSchema = binSchema.description(str); + binSchema = binSchema.notes(str); + binSchema = binSchema.notes(strArr); + binSchema = binSchema.tags(str); + binSchema = binSchema.tags(strArr); + + binSchema = binSchema.options(validOpts); + binSchema = binSchema.strict(); +} + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +dateSchema = Joi.date(); + +dateSchema = dateSchema.min(date); +dateSchema = dateSchema.max(date); + +dateSchema = dateSchema.min(str); +dateSchema = dateSchema.max(str); + +dateSchema = dateSchema.min(num); +dateSchema = dateSchema.max(num); + +module common { + dateSchema = dateSchema.allow(date); + dateSchema = dateSchema.valid(date); + dateSchema = dateSchema.invalid(date); + dateSchema = dateSchema.default(date); + + dateSchema = dateSchema.allow(num); + dateSchema = dateSchema.valid(num); + dateSchema = dateSchema.invalid(num); + dateSchema = dateSchema.default(num); + + dateSchema = dateSchema.allow(str); + dateSchema = dateSchema.valid(str); + dateSchema = dateSchema.invalid(str); + dateSchema = dateSchema.default(str); + + dateSchema = dateSchema.required(); + dateSchema = dateSchema.optional(); + + dateSchema = dateSchema.description(str); + dateSchema = dateSchema.notes(str); + dateSchema = dateSchema.notes(strArr); + dateSchema = dateSchema.tags(str); + dateSchema = dateSchema.tags(strArr); + + dateSchema = dateSchema.options(validOpts); + dateSchema = dateSchema.strict(); +} + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +funcSchema = Joi.func(); + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +numSchema = Joi.number(); + +numSchema = numSchema.min(num); +numSchema = numSchema.max(num); +numSchema = numSchema.integer(); + +module common { + numSchema = numSchema.allow(num); + numSchema = numSchema.valid(num); + numSchema = numSchema.invalid(num); + numSchema = numSchema.default(num); + + numSchema = numSchema.required(); + numSchema = numSchema.optional(); + + numSchema = numSchema.description(str); + numSchema = numSchema.notes(str); + numSchema = numSchema.notes(strArr); + numSchema = numSchema.tags(str); + numSchema = numSchema.tags(strArr); + + numSchema = numSchema.options(validOpts); + numSchema = numSchema.strict(); +} + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +objSchema = Joi.object(); +objSchema = Joi.object(schemaMap); + +objSchema = objSchema.keys(); +objSchema = objSchema.keys(schemaMap); + +objSchema = objSchema.min(num); +objSchema = objSchema.max(num); +objSchema = objSchema.length(num); + +objSchema = objSchema.with(str, str); +objSchema = objSchema.with(str, strArr); + +objSchema = objSchema.without(str, str); +objSchema = objSchema.without(str, strArr); + +objSchema = objSchema.xor(str, str, str); +objSchema = objSchema.xor(strArr); + +objSchema = objSchema.or(str, str, str); +objSchema = objSchema.or(strArr); + +objSchema = objSchema.rename(str, str); +objSchema = objSchema.rename(str, str, renOpts); + +module common { + objSchema = objSchema.allow(obj); + objSchema = objSchema.valid(obj); + objSchema = objSchema.invalid(obj); + objSchema = objSchema.default(obj); + + objSchema = objSchema.required(); + objSchema = objSchema.optional(); + + objSchema = objSchema.description(str); + objSchema = objSchema.notes(str); + objSchema = objSchema.notes(strArr); + objSchema = objSchema.tags(str); + objSchema = objSchema.tags(strArr); + + objSchema = objSchema.options(validOpts); + objSchema = objSchema.strict(); +} + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +strSchema = Joi.string(); + +strSchema = strSchema.insensitive(); +strSchema = strSchema.min(num); +strSchema = strSchema.max(num); +strSchema = strSchema.length(num); +strSchema = strSchema.regex(exp); +strSchema = strSchema.alphanum(); +strSchema = strSchema.token(); +strSchema = strSchema.email(); +strSchema = strSchema.guid(); +strSchema = strSchema.isoDate(); + +module common { + strSchema = strSchema.allow(x); + strSchema = strSchema.allow(x, x); + strSchema = strSchema.allow(anyArr); + + strSchema = strSchema.valid(x); + strSchema = strSchema.valid(x, x); + strSchema = strSchema.valid(anyArr); + + strSchema = strSchema.invalid(x); + strSchema = strSchema.invalid(x, x); + strSchema = strSchema.invalid(anyArr); + + strSchema = strSchema.required(); + + strSchema = strSchema.optional(); + + strSchema = strSchema.description(str); + + strSchema = strSchema.notes(str); + strSchema = strSchema.notes(strArr); + + strSchema = strSchema.tags(str); + strSchema = strSchema.tags(strArr); + + strSchema = strSchema.options(validOpts); + strSchema = strSchema.strict(); + strSchema = strSchema.default(x); +} + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +schema = Joi.alternatives(schemaArr); +schema = Joi.alternatives(schema, anySchema, boolSchema); + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +Joi.validate(value, schema); +Joi.validate(value, schema, validOpts); +Joi.validate(value, schema, validOpts, (err, value) => { + x = value; + str = err.message; + str = err.details[0].path; + str = err.details[0].message; + str = err.details[0].type; +}); +// variant +Joi.validate(num, schema, validOpts, (err, value) => { + num = value; +}); + +// plain opts +Joi.validate(value, {}); + +// --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + +schema = Joi.compile(obj); diff --git a/joi/joi.d.ts b/joi/joi.d.ts new file mode 100644 index 0000000000..344738e891 --- /dev/null +++ b/joi/joi.d.ts @@ -0,0 +1,377 @@ +// Type definitions for joi v3.1.0 +// Project: https://github.com/spumko/joi +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'joi' { + + export interface ValidationOptions { + // when true, stops validation on the first error, otherwise returns all the errors found. Defaults to true. + abortEarly?: boolean; + // when true, attempts to cast values to the required types (e.g. a string to a number). Defaults to true. + convert?: boolean; + // when true, allows object to contain unknown keys which are ignored. Defaults to false. + allowUnknown?: boolean; + // when true, ignores unknown keys with a function value. Defaults to false. + skipFunctions?: boolean; + // when true, unknown keys are deleted (only when value is an object). Defaults to false. + stripUnknown?: boolean; + // overrides individual error messages. Defaults to no override ({}). + language?: Object + } + + export interface RenameOptions { + // if true, does not delete the old key name, keeping both the new and old keys in place. Defaults to false. + alias?: boolean; + // if true, allows renaming multiple keys to the same destination where the last rename wins. Defaults to false. + multiple?: boolean; + // if true, allows renaming a key over an existing key. Defaults to false. + override?: boolean; + } + + export interface ValidationError { + message: string; + details: ValidationErrorItem[]; + simple (): string; + annotated (): string; + } + + export interface ValidationErrorItem { + message: string; + type: string; + path: string; + options?: ValidationOptions; + } + + export interface SchemaMap { + [key: string]: Schema; + } + + export interface Schema extends AnySchema { + } + + export interface AnySchema> { + + validate(value: U, options?: ValidationOptions, callback?: (err: ValidationError, value: U) => void): void; + + /** + * Whitelists a value + */ + allow(value: any, ...values : any[]): T; + allow(values: any[]): T; + + /** + * Adds the provided values into the allowed whitelist and marks them as the only valid values allowed. + */ + valid(value: any, ...values : any[]): T; + valid(values: any[]): T; + + /** + * Blacklists a value + */ + invalid(value: any, ...values : any[]): T; + invalid(values: any[]): T; + + /** + * Marks a key as required which will not allow undefined as value. All keys are optional by default. + */ + required(): T; + + /** + * Marks a key as optional which will allow undefined as values. Used to annotate the schema for readability as all keys are optional by default. + */ + optional(): T; + + /** + * Annotates the key + */ + description(desc: string): T; + + /** + * Annotates the key + */ + notes(notes: string): T; + notes(notes: string[]): T; + + /** + * Annotates the key + */ + tags(notes: string): T; + tags(notes: string[]): T; + + /** + * Overrides the global validate() options for the current key and any sub-key + */ + options(options: ValidationOptions): T; + + /** + * Sets the options.convert options to false which prevent type casting for the current key and any child keys. + */ + strict(): T; + + /** + * Sets a default value if the original value is undefined + */ + default(value: any): T; + } + + export interface BooleanSchema extends AnySchema { + + } + + export interface NumberSchema extends AnySchema { + /** + * Specifies the minimum value. + */ + min(limit: number): NumberSchema; + + /** + * Specifies the maximum value. + */ + max(limit: number): NumberSchema; + + /** + * Requires the number to be an integer (no floating point). + */ + integer(): NumberSchema; + } + + export interface StringSchema extends AnySchema { + /** + * Allows the value to match any whitelist of blacklist item in a case insensitive comparison. + */ + insensitive(): StringSchema; + + /** + * Specifies the minimum number string characters. + */ + min(limit: number): StringSchema; + + /** + * Specifies the maximum number of string characters. + */ + max(limit: number): StringSchema; + + /** + * Specifies the exact string length required + */ + length(limit: number): StringSchema; + + /** + * Defines a regular expression rule. + */ + regex(pattern: RegExp): StringSchema; + + /** + * Requires the string value to only contain a-z, A-Z, and 0-9. + */ + alphanum(): StringSchema; + + /** + * Requires the string value to only contain a-z, A-Z, 0-9, and underscore _. + */ + token(): StringSchema; + + /** + * Requires the string value to be a valid email address. + */ + email(): StringSchema; + + /** + * Requires the string value to be a valid GUID. + */ + guid(): StringSchema; + + /** + * Requires the string value to be in valid ISO 8601 date format. + */ + isoDate(): StringSchema; + + } + + export interface ArraySchema extends AnySchema { + /** + * List the types allowed for the array value + */ + includes(type: Schema, ...types: Schema[]): ArraySchema; + includes(types: Schema[]): ArraySchema; + + /** + * List the types forbidden for the array values. + */ + excludes(type: Schema, ...types: Schema[]): ArraySchema; + excludes(types: Schema[]): ArraySchema; + + /** + * Specifies the minimum number of items in the array. + */ + min(limit: number): ArraySchema; + + /** + * Specifies the maximum number of items in the array. + */ + max(limit: number): ArraySchema; + + /** + * Specifies the exact number of items in the array. + */ + length(limit: number): ArraySchema; + + } + + export interface ObjectSchema extends AnySchema { + /** + * Sets the allowed object keys. + */ + keys(schema?: SchemaMap): ObjectSchema; + + /** + * Specifies the minimum number of keys in the object. + */ + min(limit: number): ObjectSchema; + + /** + * Specifies the maximum number of keys in the object. + */ + max(limit: number): ObjectSchema; + + /** + * Specifies the exact number of keys in the object. + */ + length(limit: number): ObjectSchema; + + /** + * Requires the presence of other keys whenever the specified key is present. + */ + with(key: string, peers: string): ObjectSchema; + with(key: string, peers: string[]): ObjectSchema; + + /** + * Forbids the presence of other keys whenever the specified is present. + */ + without(key: string, peers: string): ObjectSchema; + without(key: string, peers: string[]): ObjectSchema; + + /** + * Defines an exclusive relationship between a set of keys. one of them is required but not at the same time where: + */ + xor(peer1: string, peer2: string, ...peers: string[]): ObjectSchema; + xor(peers: string[]): ObjectSchema; + + /** + * Defines a relationship between keys where one of the peers is required (and more than one is allowed). + */ + or(peer1: string, peer2: string, ...peers: string[]): ObjectSchema; + or(peers: string[]): ObjectSchema; + + /** + * Renames a key to another name (deletes the renamed key). + */ + rename(from: string, to: string, options?: RenameOptions): ObjectSchema; + } + + export interface BinarySchema extends AnySchema { + /** + * Specifies the minimum length of the buffer. + */ + min(limit: number): BinarySchema; + + /** + * Specifies the maximum length of the buffer. + */ + max(limit: number): BinarySchema; + + /** + * Specifies the exact length of the buffer: + */ + length(limit: number): BinarySchema; + } + + export interface DateSchema extends AnySchema { + + /** + * Specifies the oldest date allowed. + */ + min(date: Date): DateSchema; + min(date: number): DateSchema; + min(date: string): DateSchema; + + /** + * Specifies the latest date allowed. + */ + max(date: Date): DateSchema; + max(date: number): DateSchema; + max(date: string): DateSchema; + } + + export interface FunctionSchema extends AnySchema { + + } + + // --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- + + /** + * Generates a schema object that matches any data type. + */ + export function any(): Schema; + + /** + * Generates a schema object that matches an array data type. + */ + export function array(): ArraySchema; + + /** + * Generates a schema object that matches a boolean data type (as well as the strings 'true', 'false', 'yes', and 'no'). Can also be called via bool(). + */ + export function bool(): BooleanSchema; + + export function boolean(): BooleanSchema; + + /** + * Generates a schema object that matches a Buffer data type (as well as the strings which will be converted to Buffers). + */ + export function binary(): BinarySchema; + + /** + * Generates a schema object that matches a date type (as well as a JavaScript date string or number of milliseconds). + */ + export function date(): DateSchema; + + /** + * Generates a schema object that matches a function type. + */ + export function func(): FunctionSchema; + + /** + * Generates a schema object that matches a number data type (as well as strings that can be converted to numbers). + */ + export function number(): NumberSchema; + + /** + * Generates a schema object that matches an object data type (as well as JSON strings that parsed into objects). + */ + export function object(schema?: SchemaMap): ObjectSchema; + + /** + * Generates a schema object that matches a string data type. Note that empty strings are not allowed by default and must be enabled with allow(''). + */ + export function string(): StringSchema; + + /** + * Generates a type that will match one of the provided alternative schemas + */ + export function alternatives(types: Schema[]): Schema; + export function alternatives(type1: Schema, type2: Schema, ...types: Schema[]): Schema; + + /** + * Validates a value using the given schema and options. + */ + export function validate(value: T, schema: Schema, options?: ValidationOptions, callback?: (err: ValidationError, value: T) => void): void; + export function validate(value: T, schema: Object, options?: ValidationOptions, callback?: (err: ValidationError, value: T) => void): void; + + /** + * Converts literal schema definition to joi schema object (or returns the same back if already a joi schema object). + */ + export function compile(schema: Object): Schema; + +} From 11bc968399d14802d49a99ced109f3fb1252d3ae Mon Sep 17 00:00:00 2001 From: Diullei Gomes Date: Sun, 20 Apr 2014 00:33:25 -0300 Subject: [PATCH 089/225] issue #2033 - subtract method added to Duration type --- moment/moment-external-tests.ts | 6 ++++++ moment/moment-tests.ts | 6 ++++++ moment/moment.d.ts | 3 +++ 3 files changed, 15 insertions(+) diff --git a/moment/moment-external-tests.ts b/moment/moment-external-tests.ts index 9c61168921..2fbdbb6e71 100644 --- a/moment/moment-external-tests.ts +++ b/moment/moment-external-tests.ts @@ -210,6 +210,12 @@ moment.duration(500).asSeconds(); moment.duration().minutes(); moment.duration().asMinutes(); +var adur = moment.duration(3, 'd'); +var bdur = moment.duration(2, 'd'); +adur.subtract(bdur).days(); +adur.subtract(1).days(); +adur.subtract(1, 'd').days(); + // Defining a custom language: moment.lang('en', { months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], diff --git a/moment/moment-tests.ts b/moment/moment-tests.ts index 68a718a33d..1c8b7c82cf 100644 --- a/moment/moment-tests.ts +++ b/moment/moment-tests.ts @@ -208,6 +208,12 @@ moment.duration(500).asSeconds(); moment.duration().minutes(); moment.duration().asMinutes(); +var adur = moment.duration(3, 'd'); +var bdur = moment.duration(2, 'd'); +adur.subtract(bdur).days(); +adur.subtract(1).days(); +adur.subtract(1, 'd').days(); + // Defining a custom language: moment.lang('en', { months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], diff --git a/moment/moment.d.ts b/moment/moment.d.ts index cfc19100bf..f997026fd2 100644 --- a/moment/moment.d.ts +++ b/moment/moment.d.ts @@ -50,6 +50,9 @@ interface Duration { years(): number; asYears(): number; + subtract(n: number, p: string): Duration; + subtract(n: number): Duration; + subtract(d: Duration): Duration; } interface Moment { From 28df6f4d94872e4c63e56877f7a68610fec699a4 Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 20 Apr 2014 16:42:53 +0900 Subject: [PATCH 090/225] fix minimatch/minimatch.d.ts --- minimatch/minimatch-tests.ts | 2 +- minimatch/minimatch.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/minimatch/minimatch-tests.ts b/minimatch/minimatch-tests.ts index b50471826c..a9f4f7e921 100644 --- a/minimatch/minimatch-tests.ts +++ b/minimatch/minimatch-tests.ts @@ -9,5 +9,5 @@ var options = { var m = new mm.Minimatch(pattern, options); var r = m.makeRe(); -var f = "test.ts"; +var f = ["test.ts"]; mm.match(f, pattern, options); diff --git a/minimatch/minimatch.d.ts b/minimatch/minimatch.d.ts index 588e93535a..baf2463943 100644 --- a/minimatch/minimatch.d.ts +++ b/minimatch/minimatch.d.ts @@ -8,7 +8,7 @@ declare module "minimatch" { function M(target:string, pattern:string, options?:M.IOptions):void; module M { - function match(filename:string, pattern:string, options:IOptions):boolean; + function match(filenames:string[], pattern:string, options:IOptions):string[]; var Minimatch:IMinimatchStatic; From 4dcf925ddaa74436325b54cccc31186448c8a29c Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 20 Apr 2014 16:45:09 +0900 Subject: [PATCH 091/225] fix header of space-pen/space-pen.d.ts --- space-pen/space-pen.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/space-pen/space-pen.d.ts b/space-pen/space-pen.d.ts index 64d0321557..6921786f05 100644 --- a/space-pen/space-pen.d.ts +++ b/space-pen/space-pen.d.ts @@ -1,3 +1,8 @@ +// Type definitions for SpacePen +// Project: https://github.com/atom/space-pen +// Definitions by: vvakame +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /// // http://atom.github.io/space-pen/ From 010d57952e9ba0217682ad42f639d07ebce83816 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sun, 20 Apr 2014 14:19:58 +0200 Subject: [PATCH 092/225] linked CONTRIBUTING.md to org homepage --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 13053ce7ff..3b48e78746 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1 +1 @@ -Please see the [contribution guide](https://github.com/borisyankov/DefinitelyTyped/wiki/How-to-contribute) for information on how to contribute to this project. +Please see the [contribution guide](http://definitelytyped.org/guides/contributing.html) at [definitelytyped.org](http://definitelytyped.org/guides/contributing.html) for information on how to contribute to DefinitelyTyped. From 47c6498885717782c2c59cae2bae8c71418b9332 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Sun, 20 Apr 2014 15:00:45 +0200 Subject: [PATCH 093/225] moved contributors from README.md to CONTRIBUTORS.md --- CONTRIBUTORS.md | 292 ++++++++++++++++++++++++++++++++++++++++++ README.md | 331 ++++-------------------------------------------- 2 files changed, 318 insertions(+), 305 deletions(-) create mode 100644 CONTRIBUTORS.md diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 0000000000..54ae0cdc8c --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,292 @@ +# Contributors + +This is a non-exhaustive list of definitions and their creators. If you created a definition but are not listed then feel free to send a pull request on this file with your name and url. + +All definitions files include a header with the author and editors, so at some point this list will be auto-generated. + +* [accounting.js](http://josscrowcroft.github.io/accounting.js/) (by [Sergey Gerasimov](https://github.com/gerich-home)) +* [Ace Cloud9 Editor](http://ace.ajax.org/) (by [Diullei Gomes](https://github.com/Diullei)) +* [Add To Home Screen](http://cubiq.org/add-to-home-screen) (by [James Wilkins](http://www.codeplex.com/site/users/view/jamesnw)) +* [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/)) +* [AngularFire](https://www.firebase.com/docs/angular/reference.html) (by [Dénes Harmath](https://github.com/thSoft)) +* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) +* [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib)) +* [Angular Protractor](https://github.com/angular/protractor) (by [Bill Armstrong](https://github.com/BillArmstrong)) +* [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib)) +* [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap) (by [Brian Surowiec](https://github.com/xt0rted)) +* [AppFramework](http://app-framework-software.intel.com/) (by [Kyo Ago](https://github.com/kyo-ago)) +* [Arbiter](http://arbiterjs.com/) (by [Arash Shakery](https://github.com/arash16)) +* [asciify](https://github.com/olizilla/asciify) (by [Alan](http://alan.norbauer.com)) +* [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)) +* [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)) +* [Bluebird](https://github.com/petkaantonov/bluebird) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [Bootbox](https://github.com/makeusabrew/bootbox) (by [Vincent Bortone](https://github.com/vbortone/)) +* [Bootstrap](http://twitter.github.com/bootstrap/) (by [Boris Yankov](https://github.com/borisyankov)) +* [bootstrap-notify](https://github.com/Nijikokun/bootstrap-notify) (by [Blake Niemyjski](https://github.com/niemyjski)) +* [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov)) +* [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/)) +* [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Browser Harness](https://github.com/scriby/browser-harness) (by [Chris Scribner](https://github.com/scriby)) +* [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) +* [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle)) +* [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Chrome](http://developer.chrome.com/extensions/) (by [Matthew Kimber](https://github.com/matthewkimber) and [otiai10](https://github.com/otiai10)) +* [Chrome App](http://developer.chrome.com/apps/) (by [Adam Lay](https://github.com/AdamLay)) +* [CKEditor](https://github.com/ckeditor/ckeditor-dev) (by [Ondrej Sevcik](https://github.com/ondrejsevcik)) +* [Clone](https://github.com/pvorb/node-clone) (by [Kieran Simpson](https://github.com/kierans)) +* [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon)) +* [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem)) +* [configstore](http://github.com/yeoman/configstore) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [Cordova](http://cordova.apache.org) (by [Microsoft Open Technologies, Inc.](http://msopentech.com/)) +* [Couchbase / Couchnode](https://github.com/couchbase/couchnode) (by [Basarat Ali Syed](https://github.com/basarat)) +* [Crossfilter](https://github.com/square/crossfilter) (by [Schmulik Raskin](https://github.com/schmuli)) +* [crypto-js](https://code.google.com/p/crypto-js/) (by [Gia Bảo @ Sân Đình](https://github.com/giabao)). @see [cryptojs.d.ts repo](https://github.com/giabao/cryptojs.d.ts) +* [d3.js](http://d3js.org/) (from TypeScript samples) +* [dhtmlxGantt](http://dhtmlx.com/docs/products/dhtmlxGantt) (by [Maksim Kozhukh](http://github.com/mkozhukh)) +* [dhtmlxScheduler](http://dhtmlx.com/docs/products/dhtmlxScheduler) (by [Maksim Kozhukh](http://github.com/mkozhukh)) +* [diff](https://github.com/kpdecker/jsdiff) (by [vvakame](http://github.com/vvakame)) +* [Dock Spawn](http://dockspawn.com) (by [Drew Noakes](https://drewnoakes.com)) +* [docCookies](https://developer.mozilla.org/en-US/docs/Web/API/document.cookie) (by [Jon Egerton](https://github.com/jonegerton)) +* [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) +* [doT](https://github.com/olado/doT) (by [ZombieHunter](https://github.com/ZombieHunter)) +* [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) +* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) +* [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [emissary](https://github.com/atom/emissary) (by [vvakame](https://github.com/vvakame)) +* [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/)) +* [expect.js](https://github.com/LearnBoost/expect.js) (by [Teppei Sato](https://github.com/teppeis)) +* [expectations](https://github.com/spmason/expectations) (by [vvakame](https://github.com/vvakame)) +* [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Ext JS](http://www.sencha.com/products/extjs/) (by [Brian Kotek](https://github.com/brian428)) +* [Fabric.js](http://fabricjs.com/) (by [Oliver Klemencic](https://github.com/oklemencic/)) +* [Fancybox](http://fancybox.net/) (by [Boris Yankov](https://github.com/borisyankov)) +* [File API: Directories and System](http://www.w3.org/TR/file-system-api/) (by [Kon](http://phyzkit.net/)) +* [File API: Writer](http://www.w3.org/TR/file-writer-api/) (by [Kon](http://phyzkit.net/)) +* [Finite State Machine](https://github.com/jakesgordon/javascript-state-machine) (by [Boris Yankov](https://github.com/borisyankov)) +* [Firebase](https://www.firebase.com/docs/javascript/firebase) (by [Vincent Bortone](https://github.com/vbortone)) +* [Firefox](https://developer.mozilla.org/en-US/docs/Web/API) (by [vvakame](https://github.com/vvakame)) +* [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei)) +* [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)) +* [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)) +* [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz)) +* [Glob](https://github.com/isaacs/node-glob) (by [vvakame](https://github.com/vvakame)) +* [GoJS](http://gojs.net/) (by [Barbara Duckworth](https://github.com/barbara42)) +* [Greasemonkey](http://www.greasespot.net/) (by [Kota Saito](https://github.com/kotas)) +* [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt)) +* [Grunt JS](http://gruntjs.com/) (by [Jeff May](https://github.com/jeffmay), [Basarat Ali Syed](https://github.com/basarat) and [San Chen](https://github.com/bigsan)) +* [Google API Client](https://code.google.com/p/google-api-javascript-client/) (by [Frank M](https://github.com/sgtfrankieboy)) +* [Google App Engine Channel API](https://developers.google.com/appengine/docs/java/channel/javascript) (by [vvakame](https://github.com/vvakame)) +* [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper)) +* [GoogleMaps InfoBubble](http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/) (by [Johan Nilsson](https://github.com/dashue)) +* [Google Geolocation](https://code.google.com/p/geo-location-javascript/) (by [Vincent Bortone](https://github.com/vbortone)) +* [Google Page Speed Online API](https://developers.google.com/speed/pagespeed/) (by [Frank M](https://github.com/sgtfrankieboy)) +* [Google Translate API](https://developers.google.com/translate/) (by [Frank M](https://github.com/sgtfrankieboy)) +* [Google Url Shortener](https://developers.google.com/url-shortener/) (by [Frank M](https://github.com/sgtfrankieboy)) +* [Hammer.js](http://eightmedia.github.com/hammer.js/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [HashSet](http://www.timdown.co.uk/jshashtable/jshashset.html) (by [Sergey Gerasimov](https://github.com/gerich-home)) +* [Hashtable](http://www.timdown.co.uk/jshashtable/) (by [Sergey Gerasimov](https://github.com/gerich-home)) +* [HelloJS](http://adodson.com/hello.js) (by [Pavel Zika](https://github.com/PavelPZ)) +* [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) +* [Highland](http://highlandjs.org/) (by [Bart van der Schoor](https://github.com/Bartvds/)) +* [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) +* [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov)) +* [Html2Canvas.js](https://github.com/niklasvh/html2canvas/) (by [Richard Hepburn](https://github.com/rwhepburn)) +* [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac)) +* [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)) +* [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/)) +* [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Jasmine-jQuery](https://github.com/velesin/jasmine-jquery) (by [Gregor Stamac](https://github.com/gstamac)) +* [JointJS](http://www.jointjs.com/) (by [Aidan Reel](http://github.com/areel)) +* [jQRangeSlider](http://ghusse.github.com/jQRangeSlider) (by [Dániel Tar](https://github.com/qcz)) +* [jQuery](http://jquery.com/) (from TypeScript samples) +* [jQuery Mobile](http://jquerymobile.com) (by [Boris Yankov](https://github.com/borisyankov)) +* [jQuery UI](http://jqueryui.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [jQuery.Address](https://github.com/asual/jquery-address) (by [Martin Duparc](https://github.com/martinduparc/)) +* [jQuery.areYouSure](https://github.com/codedance/jquery.AreYouSure) (by [Jon Egerton](https://github.com/jonegerton)) +* [jQuery.autosize](http://www.jacklmoore.com/autosize/) (by [Jack Moore](http://www.jacklmoore.com/)) +* [jQuery.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos)) +* [jQuery.CLEditor](http://premiumsoftware.net/CLEditor) (by [Jeffery Grajkowski](https://github.com/pushplay)) +* [jQuery.clientSideLogging](https://github.com/remybach/jQuery.clientSideLogging/) (by [Diullei Gomes](https://github.com/diullei/)) +* [jQuery.Colorbox](http://www.jacklmoore.com/colorbox/) (by [Gidon Junge](https://github.com/gjunge)) +* [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/)) +* [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) (by [Roy Goode](https://github.com/RoyGoode)) +* [jQuery.Cycle](http://jquery.malsup.com/cycle/) (by [François Guillot](http://fguillot.developpez.com/)) +* [jQuery.Cycle2](http://jquery.malsup.com/cycle2/) (by [Donny Nadolny](https://github.com/dnadolny)) +* [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.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)) +* [jQuery.gridster](http://gridster.net) (by [Josh Baldwin](https://github.com/jbaldwin/gridster.d.ts)) +* [jQuery.jNotify](http://jnotify.codeplex.com) (by [James Curran](https://github.com/jamescurran/)) +* [jQuery.joyride](http://zurb.com/playground/jquery-joyride-feature-tour-plugin) (by [Vincent Bortone](https://github.com/vbortone)) +* [jQuery.jSignature](https://github.com/willowsystems/jSignature) (by [Patrick Magee](https://github.com/pjmagee)) +* [jQuery.noty](http://needim.github.io/noty/) (by [Aaron King](https://github.com/kingdango/)) +* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb)) +* [jQuery.payment](http://needim.github.io/noty/) (by [Eric J. Smith](https://github.com/ejsmith/)) +* [jQuery.pnotify](http://sciactive.github.io/pnotify/ (by [David Sichau](https://github.com/DavidSichau/)) +* [jQuery.scrollTo](https://github.com/flesler/jquery.scrollTo) (by [Neil Stalker](https://github.com/nestalk/)) +* [jQuery.simplePagination](https://github.com/flaviusmatis/simplePagination.js) (by [Natan Vivo](https://github.com/nvivo/)) +* [jquery.superLink](http://james.padolsey.com/demos/plugins/jQuery/superLink/superlink.jquery.js) (by [Blake Niemyjski](https://github.com/niemyjski)) +* [jQuery.timeago](http://timeago.yarp.com/) (by [François Guillot](http://fguillot.developpez.com/)) +* [jQuery.Timepicker](http://fgelinas.com/code/timepicker/) (by [Anwar Javed](https://github.com/anwarjaved)) +* [jQuery.Timer](http://jchavannes.com/jquery-timer/demo) (by [Joshua Strobl](https://github.com/JoshStrobl)) +* [jQuery.TinyCarousel](http://baijs.nl/tinycarousel/) (by [Christiaan Rakowski](https://github.com/csrakowski)) +* [jQuery.TinyScrollbar](http://baijs.nl/tinyscrollbar/) (by [Christiaan Rakowski](https://github.com/csrakowski)) +* [jQuery.tooltipster](https://github.com/iamceege/tooltipster) (by [Patrick Magee](https://github.com/pjmagee)) +* [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U)) +* [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) +* [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-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)) +* [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/)) +* [JSON-Pointer](https://www.npmjs.org/package/json-pointer) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [JsRender](http://www.jsviews.com/#jsrender) (by [Kensuke MATSUZAKI](https://github.com/zakki)) +* [jStorage](http://www.jstorage.info/) (by [Danil Flores](https://github.com/dflor003/)) +* [JWPlayer](http://developer.longtailvideo.com/trac/) (by [Martin Duparc](https://github.com/martinduparc/)) +* [KeyboardJS](https://github.com/RobertWHurst/KeyboardJS) (by [Vincent Bortone](https://github.com/vbortone/)) +* [KineticJS](http://kineticjs.com/) (by [Basarat Ali Syed](https://github.com/basarat)) +* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit)) +* [Knockout.js](http://knockoutjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Knockout.DeferredUpdates](https://github.com/mbest/knockout-deferred-updates) (by [Sebastián Galiano](https://github.com/sgaliano)) +* [Knockout.ES5](https://github.com/SteveSanderson/knockout-es5) (by [Sebastián Galiano](https://github.com/sgaliano)) +* [Knockout.Mapper](https://github.com/LucasLorentz/knockout.mapper) (by [Brandon Meyer](https://github.com/BMeyerKC)) +* [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping) (by [Boris Yankov](https://github.com/borisyankov)) +* [Knockout.Postbox](https://github.com/rniemeyer/knockout-postbox) (by [Judah Gabriel Himango](https://github.com/JudahGabriel)) +* [Knockout.Rx](https://github.com/Igorbek/knockout.rx) (by [Igor Oleinikov](https://github.com/Igorbek)) +* [Knockout.Validation](https://github.com/ericmbarnard/Knockout-Validation) (by [Dan Ludwig](https://github.com/danludwig)) +* [Knockout.Viewmodel](http://coderenaissance.github.com/knockout.viewmodel/) (by [Oisin Grehan](https://github.com/oising)) +* [ko.editables](http://romanych.github.com/ko.editables/) (by [Oisin Grehan](https://github.com/oising)) +* [KoLite](https://github.com/CodeSeven/kolite) (by [Boris Yankov](https://github.com/borisyankov)) +* [Lazy.js](http://danieltao.com/lazy.js/) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [Leaflet](https://github.com/Leaflet/Leaflet) (by [Vladimir](https://github.com/rgripper)) +* [Libxmljs](https://github.com/polotek/libxmljs) (by [François de Campredon](https://github.com/fdecampredon)) +* [ladda](https://github.com/hakimel/Ladda) (by [Danil Flores](https://github.com/dflor003)) +* [Levelup](https://github.com/rvagg/node-levelup) (by [Bret Little](https://github.com/blittle)) +* [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) +* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone)) +* [localForage](https://github.com/mozilla/localForage) (by [david pichsenmeister](https://github.com/3x14159265)) +* [Lodash](http://lodash.com/) (by [Brian Zengel](https://github.com/bczengel)) +* [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle)) +* [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) +* [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg)) +* [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) +* [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) +* [Minimatch](https://github.com/isaacs/minimatch) (by [vvakame](https://github.com/vvakame)) +* [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [mixto](https://github.com/atom/mixto) (by [vvakame](https://github.com/vvakame)) +* [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) +* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) +* [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee)) +* [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz)) +* [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) +* [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) +* [Node.js](http://nodejs.org/) (from TypeScript samples) +* [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov)) +* [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)) +* [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/)) +* [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)) +* [Parsimmon](https://github.com/jayferd/parsimmon) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [PDF.js](https://github.com/mozilla/pdf.js) (by [Josh Baldwin](https://github.com/jbaldwin)) +* [PEG.js](http://pegjs.majda.cz/) (by [vvakame](https://github.com/vvakame)) +* [Persona](http://www.mozilla.org/en-US/persona) (by [James Frasca](https://github.com/Nycto)) +* [PhantomJS](http://phantomjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) +* [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov)) +* [PixiJS](https://github.com/GoodBoyDigital/pixi.js) (by [Pedro Casaubon](https://github.com/xperiments)) +* [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH)) +* [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/)) +* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar) +* [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei)) +* [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo)) +* [Rickshaw](http://code.shutterstock.com/rickshaw/) (by [Blake Niemyjski](https://github.com/niemyjski)) +* [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)) +* [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)) +* [Restangular](https://github.com/mgonto/restangular/) (by [Boris Yankov](https://github.com/borisyankov)) +* [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) +* [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Selenium WebDriverJS](https://code.google.com/p/selenium/) (by [Bill Armstrong](https://github.com/BillArmstrong)) +* [Semver](https://github.com/isaacs/node-semver) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [Sencha Touch](http://www.sencha.com/products/touch/) (by [Brian Kotek](https://github.com/brian428)) +* [SharePoint](http://sptypescript.codeplex.com) (by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru) and [Andrey Markeev](http://markeev.com)) +* [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov)) +* [simple-cw-node](https://github.com/astronaughts/simple-cw-node) (by [vvakame](https://github.com/vvakame)) +* [Sinon](http://sinonjs.org/) (by [William Sears](https://github.com/mrbigdog2u)) +* [SlickGrid](https://github.com/mleibman/SlickGrid) (by [Josh Baldwin](https://github.com/jbaldwin)) +* [smoothie](https://github.com/joewalnes/smoothie) (by [Mike H. Hawley](https://github.com/mikehhawley) and [Drew Noakes](https://drewnoakes.com)) +* [socket.io](http://socket.io) (by [William Orr](https://github.com/worr)) +* [socket.io-client](http://socket.io) (by [Maido Kaara](https://github.com/v3rm0n)) +* [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) +* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) +* [stripe](https://stripe.com/) (by [Eric J. Smith](https://github.com/ejsmith/)) +* [Store.js](https://github.com/marcuswestin/store.js/) (by [Vincent Bortone](https://github.com/vbortone)) +* [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)) +* [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)) +* [three.js](http://mrdoob.github.com/three.js/) (by [Kon](http://phyzkit.net/)) +* [Toastr](https://github.com/CodeSeven/toastr) (by [Boris Yankov](https://github.com/borisyankov)) +* [trunk8](https://github.com/rviscomi/trunk8) (by [Blake Niemyjski](https://github.com/niemyjski)) +* [TweenJS](http://www.createjs.com/#!/TweenJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) +* [tween.js](https://github.com/sole/tween.js/) (by [Adam R. Smith](https://github.com/sunetos)) +* [twitter-bootstrap-wizard](https://github.com/VinceG/twitter-bootstrap-wizard) (by [Blake Niemyjski](https://github.com/niemyjski)) +* [Twitter Typeahead](http://twitter.github.io/typeahead.js) (by [Ivaylo Gochkov](https://github.com/igochkov)) +* [Ubuntu Unity Web API](https://launchpad.net/libunity-webapps) (by [John Vrbanac](https://github.com/jmvrbanac)) +* [Underscore.js](http://underscorejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) +* [Underscore.js (Typed)](http://underscorejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) +* [Underscore-ko.js](https://github.com/kamranayub/UnderscoreKO) (by [Maurits Elbers](https://github.com/MagicMau)) +* [universal-analytics](https://github.com/peaksandpies/universal-analytics) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [update-notifier](https://github.com/yeoman/update-notifier) (by [vvakame](https://github.com/vvakame)) +* [uri-templates](https://github.com/geraintluff/uri-templates) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [urlrouter](https://github.com/fengmk2/urlrouter) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) +* [UUID.js](https://github.com/LiosK/UUID.js) (by [Jason Jarrett](https://github.com/staxmanade)) +* [Valerie](https://github.com/davewatts/valerie) (by [Howard Richards](https://github.com/conficient)) +* [Viewporter](https://github.com/zynga/viewporter) (by [Boris Yankov](https://github.com/borisyankov)) +* [Vimeo](http://developer.vimeo.com/player/js-api) (by [Daz Wilkin](https://github.com/DazWilkin/)) +* [WebRTC](http://dev.w3.org/2011/webrtc/editor/webrtc.html) (by [Ken Smith](https://github.com/smithkl42)) +* [websocket](https://github.com/Worlize/WebSocket-Node) (by [Paul Loyd](https://github.com/loyd)) +* [WinJS](http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx) (from TypeScript samples) +* [WinRT](http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx) (from TypeScript samples) +* [ws](http://einaros.github.io/ws/) (by [Paul Loyd](https://github.com/loyd)) +* [XRegExp](http://xregexp.com/) (by [Bart van der Schoor](https://github.com/Bartvds)) +* [YouTube](https://developers.google.com/youtube/) (by [Daz Wilkin](https://github.com/DazWilkin/)) +* [YouTube Analytics API](https://developers.google.com/youtube/analytics/) (by [Frank M](https://github.com/sgtfrankieboy)) +* [YouTube Data API](https://developers.google.com/youtube/v3/) (by [Frank M](https://github.com/sgtfrankieboy/)) +* [Zepto.js](http://zeptojs.com/) (by [Josh Baldwin](https://github.com/jbaldwin)) +* [Zynga Scroller](https://github.com/zynga/scroller) (by [Boris Yankov](https://github.com/borisyankov)) +* [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard) (by [Eric J. Smith](https://github.com/ejsmith)) diff --git a/README.md b/README.md index c97da76e75..4671d37859 100755 --- a/README.md +++ b/README.md @@ -1,318 +1,39 @@ -DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped) -=============== +# DefinitelyTyped [![Build Status](https://travis-ci.org/borisyankov/DefinitelyTyped.png?branch=master)](https://travis-ci.org/borisyankov/DefinitelyTyped) -The repository for *high quality* TypeScript type definitions. +> The repository for *high quality* TypeScript type definitions. + +For more information see the [definitelytyped.org](http://definitelytyped.org) website. + +## Usage -Usage ------ Include a line like this: -``` +```typescript /// ``` -[TypeScript Directory: tools, libraries, projects and learning resources](https://github.com/DefinitelyTyped/typescript-directory) +## Contributions -Contributor Guidelines ----------------------- +DefinitelyTyped only works because of contributions by users like you! -See the section: [How to contribute](https://github.com/borisyankov/DefinitelyTyped/wiki/How-to-contribute) +Please see the [contribution guide](http://definitelytyped.org/guides/contributing.html) on how to contribute to DefinitelyTyped. -Other means to get the definitions ----------------------------------- +## How to get the definitions + +* Directly from the Github repos * [NuGet packages](http://nuget.org/packages?q=DefinitelyTyped) -* [TypeScript Definition package manager](https://github.com/DefinitelyTyped/tsd) +* [TypeScript Definition manager](https://github.com/DefinitelyTyped/tsd) -List of Definitions -------------------- -* [accounting.js](http://josscrowcroft.github.io/accounting.js/) (by [Sergey Gerasimov](https://github.com/gerich-home)) -* [Ace Cloud9 Editor](http://ace.ajax.org/) (by [Diullei Gomes](https://github.com/Diullei)) -* [Add To Home Screen] (http://cubiq.org/add-to-home-screen) (by [James Wilkins] (http://www.codeplex.com/site/users/view/jamesnw)) -* [AmCharts](http://www.amcharts.com/) (by [Covobonomo](https://github.com/covobonomo/)) -* [AngularFire](https://www.firebase.com/docs/angular/reference.html) (by [Dénes Harmath](https://github.com/thSoft)) -* [AngularJS](http://angularjs.org) (by [Diego Vilar](https://github.com/diegovilar)) ([wiki](https://github.com/borisyankov/DefinitelyTyped/wiki/AngularJS-Definitions-Usage-Notes)) -* [AngularUI](http://angular-ui.github.io/) (by [Michel Salib](https://github.com/michelsalib)) -* [Angular Protractor](https://github.com/angular/protractor) (by [Bill Armstrong](https://github.com/BillArmstrong)) -* [Angular Translate](http://pascalprecht.github.io/angular-translate/) (by [Michel Salib](https://github.com/michelsalib)) -* [Angular UI Bootstrap](http://angular-ui.github.io/bootstrap) (by [Brian Surowiec](https://github.com/xt0rted)) -* [AppFramework](http://app-framework-software.intel.com/) (by [Kyo Ago](https://github.com/kyo-ago)) -* [Arbiter](http://arbiterjs.com/) (by [Arash Shakery](https://github.com/arash16)) -* [asciify](https://github.com/olizilla/asciify) (by [Alan](http://alan.norbauer.com)) -* [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)) -* [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)) -* [Bluebird](https://github.com/petkaantonov/bluebird) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [Bootbox](https://github.com/makeusabrew/bootbox) (by [Vincent Bortone](https://github.com/vbortone/)) -* [Bootstrap](http://twitter.github.com/bootstrap/) (by [Boris Yankov](https://github.com/borisyankov)) -* [bootstrap-notify](https://github.com/Nijikokun/bootstrap-notify) (by [Blake Niemyjski](https://github.com/niemyjski)) -* [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) (by [Boris Yankov](https://github.com/borisyankov)) -* [Box2DWeb](http://code.google.com/p/box2dweb/) (by [Josh Baldwin](https://github.com/jbaldwin/)) -* [Breeze](http://www.breezejs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Browser Harness](https://github.com/scriby/browser-harness) (by [Chris Scribner](https://github.com/scriby)) -* [CasperJS](http://casperjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) -* [Cheerio](https://github.com/MatthewMueller/cheerio) (by [Bret Little](https://github.com/blittle)) -* [Chosen](http://harvesthq.github.com/chosen/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Chrome](http://developer.chrome.com/extensions/) (by [Matthew Kimber](https://github.com/matthewkimber) and [otiai10](https://github.com/otiai10)) -* [Chrome App](http://developer.chrome.com/apps/) (by [Adam Lay](https://github.com/AdamLay)) -* [CKEditor](https://github.com/ckeditor/ckeditor-dev) (by [Ondrej Sevcik](https://github.com/ondrejsevcik)) -* [Clone](https://github.com/pvorb/node-clone) (by [Kieran Simpson](https://github.com/kierans)) -* [CodeMirror](http://codemirror.net) (by [François de Campredon](https://github.com/fdecampredon)) -* [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem)) -* [configstore](http://github.com/yeoman/configstore) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [Cordova](http://cordova.apache.org) (by [Microsoft Open Technologies, Inc.](http://msopentech.com/)) -* [Couchbase / Couchnode](https://github.com/couchbase/couchnode) (by [Basarat Ali Syed](https://github.com/basarat)) -* [Crossfilter](https://github.com/square/crossfilter) (by [Schmulik Raskin](https://github.com/schmuli)) -* [crypto-js](https://code.google.com/p/crypto-js/) (by [Gia Bảo @ Sân Đình](https://github.com/giabao)). @see [cryptojs.d.ts repo](https://github.com/giabao/cryptojs.d.ts) -* [d3.js](http://d3js.org/) (from TypeScript samples) -* [dhtmlxGantt](http://dhtmlx.com/docs/products/dhtmlxGantt) (by [Maksim Kozhukh](http://github.com/mkozhukh)) -* [dhtmlxScheduler](http://dhtmlx.com/docs/products/dhtmlxScheduler) (by [Maksim Kozhukh](http://github.com/mkozhukh)) -* [diff](https://github.com/kpdecker/jsdiff) (by [vvakame](http://github.com/vvakame)) -* [Dock Spawn](http://dockspawn.com) (by [Drew Noakes](https://drewnoakes.com)) -* [docCookies](https://developer.mozilla.org/en-US/docs/Web/API/document.cookie) (by [Jon Egerton](https://github.com/jonegerton)) -* [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton)) -* [doT](https://github.com/olado/doT) (by [ZombieHunter](https://github.com/ZombieHunter)) -* [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) -* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) -* [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) -* [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [emissary](https://github.com/atom/emissary) (by [vvakame](https://github.com/vvakame)) -* [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/)) -* [expect.js](https://github.com/LearnBoost/expect.js) (by [Teppei Sato](https://github.com/teppeis)) -* [expectations](https://github.com/spmason/expectations) (by [vvakame](https://github.com/vvakame)) -* [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Ext JS](http://www.sencha.com/products/extjs/) (by [Brian Kotek](https://github.com/brian428)) -* [Fabric.js](http://fabricjs.com/) (by [Oliver Klemencic](https://github.com/oklemencic/)) -* [Fancybox](http://fancybox.net/) (by [Boris Yankov](https://github.com/borisyankov)) -* [File API: Directories and System](http://www.w3.org/TR/file-system-api/) (by [Kon](http://phyzkit.net/)) -* [File API: Writer](http://www.w3.org/TR/file-writer-api/) (by [Kon](http://phyzkit.net/)) -* [Finite State Machine](https://github.com/jakesgordon/javascript-state-machine) (by [Boris Yankov](https://github.com/borisyankov)) -* [Firebase](https://www.firebase.com/docs/javascript/firebase) (by [Vincent Bortone](https://github.com/vbortone)) -* [Firefox](https://developer.mozilla.org/en-US/docs/Web/API) (by [vvakame](https://github.com/vvakame)) -* [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei)) -* [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)) -* [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)) -* [glDatePicker](http://glad.github.com/glDatePicker/) (by [Dániel Tar](https://github.com/qcz)) -* [Glob](https://github.com/isaacs/node-glob) (by [vvakame](https://github.com/vvakame)) -* [GoJS](http://gojs.net/) (by [Barbara Duckworth](https://github.com/barbara42)) -* [Greasemonkey](http://www.greasespot.net/) (by [Kota Saito](https://github.com/kotas)) -* [GreenSock Animation Platform (GSAP)](http://www.greensock.com/get-started-js/) (by [Robert S.](https://github.com/codeBelt)) -* [Grunt JS](http://gruntjs.com/) (by [Jeff May](https://github.com/jeffmay), [Basarat Ali Syed](https://github.com/basarat) and [San Chen](https://github.com/bigsan)) -* [Google API Client](https://code.google.com/p/google-api-javascript-client/) (by [Frank M](https://github.com/sgtfrankieboy)) -* [Google App Engine Channel API](https://developers.google.com/appengine/docs/java/channel/javascript) (by [vvakame](https://github.com/vvakame)) -* [GoogleMaps](https://developers.google.com/maps/) (by [Esben Nepper](https://github.com/eNepper)) -* [GoogleMaps InfoBubble](http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobubble/) (by [Johan Nilsson](https://github.com/dashue)) -* [Google Geolocation](https://code.google.com/p/geo-location-javascript/) (by [Vincent Bortone](https://github.com/vbortone)) -* [Google Page Speed Online API](https://developers.google.com/speed/pagespeed/) (by [Frank M](https://github.com/sgtfrankieboy)) -* [Google Translate API](https://developers.google.com/translate/) (by [Frank M](https://github.com/sgtfrankieboy)) -* [Google Url Shortener](https://developers.google.com/url-shortener/) (by [Frank M](https://github.com/sgtfrankieboy)) -* [Hammer.js](http://eightmedia.github.com/hammer.js/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Handlebars](http://handlebarsjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [HashSet](http://www.timdown.co.uk/jshashtable/jshashset.html) (by [Sergey Gerasimov](https://github.com/gerich-home)) -* [Hashtable](http://www.timdown.co.uk/jshashtable/) (by [Sergey Gerasimov](https://github.com/gerich-home)) -* [HelloJS](http://adodson.com/hello.js) (by [Pavel Zika](https://github.com/PavelPZ)) -* [Highcharts](http://www.highcharts.com/) (by [damianog](https://github.com/damianog)) -* [Highland](http://highlandjs.org/) (by [Bart van der Schoor](https://github.com/Bartvds/)) -* [highlight.js](https://github.com/isagalaev/highlight.js) (by [Niklas Mollenhauer](https://github.com/nikeee)) -* [History.js](https://github.com/browserstate/history.js) (by [Boris Yankov](https://github.com/borisyankov)) -* [Html2Canvas.js](https://github.com/niklasvh/html2canvas/) (by [Richard Hepburn](https://github.com/rwhepburn)) -* [Humane.js](http://wavded.github.com/humane-js/) (by [John Vrbanac](https://github.com/jmvrbanac)) -* [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)) -* [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/)) -* [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Jasmine-jQuery](https://github.com/velesin/jasmine-jquery) (by [Gregor Stamac](https://github.com/gstamac)) -* [Joi](https://github.com/spumko/joi) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [JointJS](http://www.jointjs.com/) (by [Aidan Reel](http://github.com/areel)) -* [jQRangeSlider](http://ghusse.github.com/jQRangeSlider) (by [Dániel Tar](https://github.com/qcz)) -* [jQuery](http://jquery.com/) (from TypeScript samples) -* [jQuery Mobile](http://jquerymobile.com) (by [Boris Yankov](https://github.com/borisyankov)) -* [jQuery UI](http://jqueryui.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [jQuery.Address](https://github.com/asual/jquery-address) (by [Martin Duparc](https://github.com/martinduparc/)) -* [jQuery.areYouSure](https://github.com/codedance/jquery.AreYouSure) (by [Jon Egerton](https://github.com/jonegerton)) -* [jQuery.autosize](http://www.jacklmoore.com/autosize/) (by [Jack Moore](http://www.jacklmoore.com/)) -* [jQuery.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos)) -* [jQuery.CLEditor](http://premiumsoftware.net/CLEditor) (by [Jeffery Grajkowski](https://github.com/pushplay)) -* [jQuery.clientSideLogging](https://github.com/remybach/jQuery.clientSideLogging/) (by [Diullei Gomes](https://github.com/diullei/)) -* [jQuery.Colorbox](http://www.jacklmoore.com/colorbox/) (by [Gidon Junge](https://github.com/gjunge)) -* [jQuery.contextMenu](http://medialize.github.com/jQuery-contextMenu/) (by [Natan Vivo](https://github.com/nvivo/)) -* [jQuery.Cookie](https://github.com/carhartl/jquery-cookie) (by [Roy Goode](https://github.com/RoyGoode)) -* [jQuery.Cycle](http://jquery.malsup.com/cycle/) (by [François Guillot](http://fguillot.developpez.com/)) -* [jQuery.Cycle2](http://jquery.malsup.com/cycle2/) (by [Donny Nadolny](https://github.com/dnadolny)) -* [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.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)) -* [jQuery.gridster](http://gridster.net) (by [Josh Baldwin](https://github.com/jbaldwin/gridster.d.ts)) -* [jQuery.jNotify](http://jnotify.codeplex.com) (by [James Curran](https://github.com/jamescurran/)) -* [jQuery.joyride](http://zurb.com/playground/jquery-joyride-feature-tour-plugin) (by [Vincent Bortone](https://github.com/vbortone)) -* [jQuery.jSignature] (https://github.com/willowsystems/jSignature) (by [Patrick Magee](https://github.com/pjmagee)) -* [jQuery.noty](http://needim.github.io/noty/) (by [Aaron King](https://github.com/kingdango/)) -* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb)) -* [jQuery.payment](http://needim.github.io/noty/) (by [Eric J. Smith](https://github.com/ejsmith/)) -* [jQuery.pnotify](http://sciactive.github.io/pnotify/ (by [David Sichau](https://github.com/DavidSichau/)) -* [jQuery.scrollTo](https://github.com/flesler/jquery.scrollTo) (by [Neil Stalker](https://github.com/nestalk/)) -* [jQuery.simplePagination](https://github.com/flaviusmatis/simplePagination.js) (by [Natan Vivo](https://github.com/nvivo/)) -* [jquery.superLink](http://james.padolsey.com/demos/plugins/jQuery/superLink/superlink.jquery.js) (by [Blake Niemyjski](https://github.com/niemyjski)) -* [jQuery.timeago](http://timeago.yarp.com/) (by [François Guillot](http://fguillot.developpez.com/)) -* [jQuery.Timepicker](http://fgelinas.com/code/timepicker/) (by [Anwar Javed](https://github.com/anwarjaved)) -* [jQuery.Timer](http://jchavannes.com/jquery-timer/demo) (by [Joshua Strobl](https://github.com/JoshStrobl)) -* [jQuery.TinyCarousel](http://baijs.nl/tinycarousel/) (by [Christiaan Rakowski](https://github.com/csrakowski)) -* [jQuery.TinyScrollbar](http://baijs.nl/tinyscrollbar/) (by [Christiaan Rakowski](https://github.com/csrakowski)) -* [jQuery.tooltipster] (https://github.com/iamceege/tooltipster) (by [Patrick Magee](https://github.com/pjmagee)) -* [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U)) -* [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) -* [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-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)) -* [JSONEditorOnline](https://github.com/josdejong/jsoneditoronline) (by [Vincent Bortone](https://github.com/vbortone/)) -* [JSON-Pointer](https://www.npmjs.org/package/json-pointer) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [JsRender](http://www.jsviews.com/#jsrender) (by [Kensuke MATSUZAKI](https://github.com/zakki)) -* [jStorage](http://www.jstorage.info/) (by [Danil Flores](https://github.com/dflor003/)) -* [JWPlayer](http://developer.longtailvideo.com/trac/) (by [Martin Duparc](https://github.com/martinduparc/)) -* [KeyboardJS](https://github.com/RobertWHurst/KeyboardJS) (by [Vincent Bortone](https://github.com/vbortone/)) -* [KineticJS](http://kineticjs.com/) (by [Basarat Ali Syed](https://github.com/basarat)) -* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit)) -* [Knockout.js](http://knockoutjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Knockout.DeferredUpdates](https://github.com/mbest/knockout-deferred-updates) (by [Sebastián Galiano](https://github.com/sgaliano)) -* [Knockout.ES5](https://github.com/SteveSanderson/knockout-es5) (by [Sebastián Galiano](https://github.com/sgaliano)) -* [Knockout.Mapper](https://github.com/LucasLorentz/knockout.mapper) (by [Brandon Meyer](https://github.com/BMeyerKC)) -* [Knockout.Mapping](https://github.com/SteveSanderson/knockout.mapping) (by [Boris Yankov](https://github.com/borisyankov)) -* [Knockout.Postbox](https://github.com/rniemeyer/knockout-postbox) (by [Judah Gabriel Himango](https://github.com/JudahGabriel)) -* [Knockout.Rx](https://github.com/Igorbek/knockout.rx) (by [Igor Oleinikov](https://github.com/Igorbek)) -* [Knockout.Validation](https://github.com/ericmbarnard/Knockout-Validation) (by [Dan Ludwig](https://github.com/danludwig)) -* [Knockout.Viewmodel](http://coderenaissance.github.com/knockout.viewmodel/) (by [Oisin Grehan](https://github.com/oising)) -* [ko.editables](http://romanych.github.com/ko.editables/) (by [Oisin Grehan](https://github.com/oising)) -* [KoLite](https://github.com/CodeSeven/kolite) (by [Boris Yankov](https://github.com/borisyankov)) -* [Lazy.js](http://danieltao.com/lazy.js/) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [Leaflet](https://github.com/Leaflet/Leaflet) (by [Vladimir](https://github.com/rgripper)) -* [Libxmljs](https://github.com/polotek/libxmljs) (by [François de Campredon](https://github.com/fdecampredon)) -* [ladda](https://github.com/hakimel/Ladda) (by [Danil Flores](https://github.com/dflor003)) -* [Levelup](https://github.com/rvagg/node-levelup) (by [Bret Little](https://github.com/blittle)) -* [linq.js](http://linqjs.codeplex.com/) (by [Marcin Najder](https://github.com/marcinnajder)) -* [Livestamp.js](https://github.com/mattbradley/livestampjs) (by [Vincent Bortone](https://github.com/vbortone)) -* [localForage](https://github.com/mozilla/localForage) (by [david pichsenmeister](https://github.com/3x14159265)) -* [Lodash](http://lodash.com/) (by [Brian Zengel](https://github.com/bczengel)) -* [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle)) -* [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr)) -* [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg)) -* [Meteor](https://www.meteor.com) (by [Dave Allen](https://github.com/fullflavedave)) -* [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk)) -* [Minimatch](https://github.com/isaacs/minimatch) (by [vvakame](https://github.com/vvakame)) -* [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [mixto](https://github.com/atom/mixto) (by [vvakame](https://github.com/vvakame)) -* [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) -* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) -* [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee)) -* [Mousetrap](http://craig.is/killing/mice) (by [Dániel Tar](https://github.com/qcz)) -* [msgpack.js](https://github.com/uupaa/msgpack.js) (by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)) -* [Mustache.js](https://github.com/janl/mustache.js) (by [Boris Yankov](https://github.com/borisyankov)) -* [Node.js](http://nodejs.org/) (from TypeScript samples) -* [node_redis](https://github.com/mranney/node_redis) (by [Boris Yankov](https://github.com/borisyankov)) -* [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)) -* [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/)) -* [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)) -* [Parsimmon](https://github.com/jayferd/parsimmon) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [PDF.js](https://github.com/mozilla/pdf.js) (by [Josh Baldwin](https://github.com/jbaldwin)) -* [PEG.js](http://pegjs.majda.cz/) (by [vvakame](https://github.com/vvakame)) -* [Persona](http://www.mozilla.org/en-US/persona) (by [James Frasca](https://github.com/Nycto)) -* [PhantomJS](http://phantomjs.org) (by [Jed Hunsaker](https://github.com/jedhunsaker)) -* [PhoneGap](http://phonegap.com) (by [Boris Yankov](https://github.com/borisyankov)) -* [PixiJS](https://github.com/GoodBoyDigital/pixi.js) (by [Pedro Casaubon](https://github.com/xperiments)) -* [Platform](https://github.com/bestiejs/platform.js) (by [Jake Hickman](https://github.com/JakeH)) -* [PouchDB](http://pouchdb.com) (by [Bill Sears](https://github.com/MrBigDog2U/)) -* [PreloadJS](http://www.createjs.com/#!/PreloadJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) -* [Q](https://github.com/kriskowal/q) (by Barrie Nemetchek, Andrew Gaspar) -* [Q-io](https://github.com/kriskowal/q-io) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [QUnit](http://qunitjs.com/) (by [Diullei Gomes](https://github.com/Diullei)) -* [Raven.js](https://github.com/getsentry/raven-js) (by [Santi Albo](https://github.com/santialbo)) -* [Rickshaw](http://code.shutterstock.com/rickshaw/) (by [Blake Niemyjski](https://github.com/niemyjski)) -* [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)) -* [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)) -* [Restangular](https://github.com/mgonto/restangular/) (by [Boris Yankov](https://github.com/borisyankov)) -* [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) -* [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Selenium WebDriverJS](https://code.google.com/p/selenium/) (by [Bill Armstrong](https://github.com/BillArmstrong)) -* [Semver](https://github.com/isaacs/node-semver) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [Sencha Touch](http://www.sencha.com/products/touch/) (by [Brian Kotek](https://github.com/brian428)) -* [SharePoint](http://sptypescript.codeplex.com) (by [Stanislav Vyshchepan](http://gandjustas.blogspot.ru) and [Andrey Markeev](http://markeev.com)) -* [SignalR](http://www.asp.net/signalr) (by [Boris Yankov](https://github.com/borisyankov)) -* [simple-cw-node](https://github.com/astronaughts/simple-cw-node) (by [vvakame](https://github.com/vvakame)) -* [Sinon](http://sinonjs.org/) (by [William Sears](https://github.com/mrbigdog2u)) -* [SlickGrid](https://github.com/mleibman/SlickGrid) (by [Josh Baldwin](https://github.com/jbaldwin)) -* [smoothie](https://github.com/joewalnes/smoothie) (by [Mike H. Hawley](https://github.com/mikehhawley) and [Drew Noakes](https://drewnoakes.com)) -* [socket.io](http://socket.io) (by [William Orr](https://github.com/worr)) -* [socket.io-client](http://socket.io) (by [Maido Kaara](https://github.com/v3rm0n)) -* [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev)) -* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) -* [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov)) -* [stripe](https://stripe.com/) (by [Eric J. Smith](https://github.com/ejsmith/)) -* [Store.js](https://github.com/marcuswestin/store.js/) (by [Vincent Bortone](https://github.com/vbortone)) -* [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)) -* [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)) -* [three.js](http://mrdoob.github.com/three.js/) (by [Kon](http://phyzkit.net/)) -* [Toastr](https://github.com/CodeSeven/toastr) (by [Boris Yankov](https://github.com/borisyankov)) -* [trunk8](https://github.com/rviscomi/trunk8) (by [Blake Niemyjski](https://github.com/niemyjski)) -* [TweenJS](http://www.createjs.com/#!/TweenJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) -* [tween.js](https://github.com/sole/tween.js/) (by [Adam R. Smith](https://github.com/sunetos)) -* [twitter-bootstrap-wizard](https://github.com/VinceG/twitter-bootstrap-wizard) (by [Blake Niemyjski](https://github.com/niemyjski)) -* [Twitter Typeahead](http://twitter.github.io/typeahead.js) (by [Ivaylo Gochkov](https://github.com/igochkov)) -* [Ubuntu Unity Web API](https://launchpad.net/libunity-webapps) (by [John Vrbanac](https://github.com/jmvrbanac)) -* [Underscore.js](http://underscorejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) -* [Underscore.js (Typed)](http://underscorejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/)) -* [Underscore-ko.js](https://github.com/kamranayub/UnderscoreKO) (by [Maurits Elbers](https://github.com/MagicMau)) -* [universal-analytics](https://github.com/peaksandpies/universal-analytics) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [update-notifier](https://github.com/yeoman/update-notifier) (by [vvakame](https://github.com/vvakame)) -* [uri-templates](https://github.com/geraintluff/uri-templates) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [urlrouter](https://github.com/fengmk2/urlrouter) (by [Carlos Ballesteros Velasco](https://github.com/soywiz)) -* [UUID.js](https://github.com/LiosK/UUID.js) (by [Jason Jarrett](https://github.com/staxmanade)) -* [Valerie](https://github.com/davewatts/valerie) (by [Howard Richards](https://github.com/conficient)) -* [Viewporter](https://github.com/zynga/viewporter) (by [Boris Yankov](https://github.com/borisyankov)) -* [Vimeo](http://developer.vimeo.com/player/js-api) (by [Daz Wilkin](https://github.com/DazWilkin/)) -* [WebRTC](http://dev.w3.org/2011/webrtc/editor/webrtc.html) (by [Ken Smith](https://github.com/smithkl42)) -* [websocket](https://github.com/Worlize/WebSocket-Node) (by [Paul Loyd](https://github.com/loyd)) -* [WinJS](http://msdn.microsoft.com/en-us/library/windows/apps/br229773.aspx) (from TypeScript samples) -* [WinRT](http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx) (from TypeScript samples) -* [ws](http://einaros.github.io/ws/) (by [Paul Loyd](https://github.com/loyd)) -* [XRegExp](http://xregexp.com/) (by [Bart van der Schoor](https://github.com/Bartvds)) -* [YouTube](https://developers.google.com/youtube/) (by [Daz Wilkin](https://github.com/DazWilkin/)) -* [YouTube Analytics API](https://developers.google.com/youtube/analytics/) (by [Frank M](https://github.com/sgtfrankieboy)) -* [YouTube Data API](https://developers.google.com/youtube/v3/) (by [Frank M](https://github.com/sgtfrankieboy/)) -* [Zepto.js](http://zeptojs.com/) (by [Josh Baldwin](https://github.com/jbaldwin)) -* [Zynga Scroller](https://github.com/zynga/scroller) (by [Boris Yankov](https://github.com/borisyankov)) -* [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard) (by [Eric J. Smith](https://github.com/ejsmith)) +## List of definitions -Requested Definitions ---------------------- -Here is an updated list of [definitions people have requested](https://github.com/borisyankov/DefinitelyTyped/issues?labels=Definition%3ARequest) +* See [CONTRIBUTORS.md](CONTRIBUTORS.md) + +## Requested definitions + +Here is an updated list of [definitions people have requested](https://github.com/borisyankov/DefinitelyTyped/issues?labels=Definition%3ARequest). + +## Licence + +This project is licensed under the MIT license. + +Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file. From 8afb1c1a5f133233c910db9dd920445a115e4c17 Mon Sep 17 00:00:00 2001 From: colinbreame Date: Sun, 20 Apr 2014 15:11:50 +0100 Subject: [PATCH 094/225] Make AutocompleteOptions optional The maps API treats the members of AutocompleteOptions as optional - update typings to reflect this. --- googlemaps/google.maps.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index 86a4465088..27275f098b 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -1356,9 +1356,9 @@ declare module google.maps { } export interface AutocompleteOptions { - bounds: LatLngBounds; - componentRestrictions: ComponentRestrictions; - types: string[]; + bounds?: LatLngBounds; + componentRestrictions?: ComponentRestrictions; + types?: string[]; } export interface ComponentRestrictions { From c5d83cb079e9ceae34c5d854ba4eefef28d2091e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Mon, 21 Apr 2014 00:32:05 +0200 Subject: [PATCH 095/225] #1659: Added BigInteger.js (flattened commit) --- CONTRIBUTORS.md | 1 + bigInteger/bigInteger-tests.ts | 95 +++++++++++++++++++ bigInteger/bigInteger.d.ts | 161 +++++++++++++++++++++++++++++++++ 3 files changed, 257 insertions(+) create mode 100644 bigInteger/bigInteger-tests.ts create mode 100644 bigInteger/bigInteger.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 54ae0cdc8c..d68e3061cc 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -22,6 +22,7 @@ All definitions files include a header with the author and editors, so at some p * [Atom](https://atom.io/) (by [vvakame](https://github.com/vvakame)) * [Backbone.js](http://backbonejs.org/) (by [Boris Yankov](https://github.com/borisyankov)) * [Backbone Relational](http://backbonerelational.org/) (by [Eirik Hoem](https://github.com/eirikhm)) +* [BigInteger](https://github.com/peterolson/BigInteger.js) (by [Ingo Bürk](https://github.com/Airblader)) * [BigScreen](http://brad.is/coding/BigScreen/) (by [Douglas Eichelberger](https://github.com/dduugg)) * [Bluebird](https://github.com/petkaantonov/bluebird) (by [Bart van der Schoor](https://github.com/Bartvds)) * [Bootbox](https://github.com/makeusabrew/bootbox) (by [Vincent Bortone](https://github.com/vbortone/)) diff --git a/bigInteger/bigInteger-tests.ts b/bigInteger/bigInteger-tests.ts new file mode 100644 index 0000000000..7940b86296 --- /dev/null +++ b/bigInteger/bigInteger-tests.ts @@ -0,0 +1,95 @@ +/// + +// constructor tests +var noArgument = bigInt(), + numberArgument = bigInt( 93 ), + stringArgument = bigInt( "75643564363473453456342378564387956906736546456235345" ), + bigIntArgument = bigInt( noArgument ); + +// method tests +var x = bigInt(), + isBigInteger: BigInteger, + isNumber: number, + isBoolean: boolean, + isString: string, + isDivmod: { + quotient: BigInteger; + remainder: BigInteger; + }; + +isBigInteger = x.abs(); + +isBigInteger = x.add( 0 ); +isBigInteger = x.add( x ); + +isBigInteger = x.compare( 0 ); +isBigInteger = x.compare( x ); + +isBigInteger = x.compareAbs( 0 ); +isBigInteger = x.compareAbs( x ); + +isBigInteger = x.divide( 0 ); +isBigInteger = x.divide( x ); + +isDivmod = x.divmod( 0 ); +isDivmod = x.divmod( x ); + +isBoolean = x.equals( 0 ); +isBoolean = x.equals( x ); + +isBoolean = x.greater( 0 ); +isBoolean = x.greater( x ); + +isBoolean = x.greaterOrEquals( 0 ); +isBoolean = x.greaterOrEquals( x ); + +isBoolean = x.isEven(); + +isBoolean = x.isNegative(); + +isBoolean = x.isOdd(); + +isBoolean = x.isPositive(); + +isBoolean = x.lesser( 0 ); +isBoolean = x.lesser( x ); + +isBoolean = x.lesserOrEquals( 0 ); +isBoolean = x.lesserOrEquals( x ); + +isBigInteger = x.minus( 0 ); +isBigInteger = x.minus( x ); + +isBigInteger = x.mod( 0 ); +isBigInteger = x.mod( x ); + +isBigInteger = x.multiply( 0 ); +isBigInteger = x.multiply( x ); + +isBigInteger = x.next(); + +isBoolean = x.notEquals( 0 ); +isBoolean = x.notEquals( x ); + +isBigInteger = x.over( 0 ); +isBigInteger = x.over( x ); + +isBigInteger = x.plus( 0 ); +isBigInteger = x.plus( x ); + +isBigInteger = x.pow( 0 ); +isBigInteger = x.pow( x ); + +isBigInteger = x.prev(); + +isBigInteger = x.subtract( 0 ); +isBigInteger = x.subtract( x ); + +isBigInteger = x.times( 0 ); +isBigInteger = x.times( x ); + +isNumber = x.toJSNumber(); + +isString = x.toString(); + +isNumber = x.valueOf(); \ No newline at end of file diff --git a/bigInteger/bigInteger.d.ts b/bigInteger/bigInteger.d.ts new file mode 100644 index 0000000000..ed03fc5ea1 --- /dev/null +++ b/bigInteger/bigInteger.d.ts @@ -0,0 +1,161 @@ +// Type definitions for BigInteger.js +// Project: https://github.com/peterolson/BigInteger.js +// Definitions by: Ingo Bürk +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +interface BigInteger { + /** Returns the absolute value of a bigInt. */ + abs(): BigInteger; + + /** Performs addition */ + add( number: number ): BigInteger; + /** Performs addition */ + add( number: BigInteger ): BigInteger; + + /** Alias for the add method. */ + plus( number: number ): BigInteger; + /** Alias for the add method. */ + plus( number: BigInteger ): BigInteger; + + /** Alias for the subtract method. */ + minus( number: number ): BigInteger; + /** Alias for the subtract method. */ + minus( number: BigInteger ): BigInteger; + + /** Performs subtraction. */ + subtract( number: number ): BigInteger; + /** Performs subtraction. */ + subtract( number: BigInteger ): BigInteger; + + /** Performs multiplication. */ + multiply( number: number ): BigInteger; + /** Performs multiplication. */ + multiply( number: BigInteger ): BigInteger; + + /** Alias for the multiply method. */ + times( number: number ): BigInteger; + /** Alias for the multiply method. */ + times( number: BigInteger ): BigInteger; + + /** Performs integer division, disregarding the remainder. */ + divide( number: number ): BigInteger; + /** Performs integer division, disregarding the remainder. */ + divide( number: BigInteger ): BigInteger; + + /** Alias for the divide method. */ + over( number: number ): BigInteger; + /** Alias for the divide method. */ + over( number: BigInteger ): BigInteger; + + /** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */ + pow( number: number ): BigInteger; + /** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */ + pow( number: BigInteger ): BigInteger; + + /** Adds one to the number. */ + next(): BigInteger; + + /** Subtracts one from the number. */ + prev(): BigInteger; + + /** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */ + mod( number: number ): BigInteger; + /** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */ + mod( number: BigInteger ): BigInteger; + + /** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */ + divmod( number: number ): { quotient: BigInteger; remainder: BigInteger }; + /** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */ + divmod( number: BigInteger ): { quotient: BigInteger; remainder: BigInteger }; + + /** Checks if the first number is greater than the second. */ + greater( number: number ): boolean; + /** Checks if the first number is greater than the second. */ + greater( number: BigInteger ): boolean; + + /** Checks if the first number is greater than or equal to the second. */ + greaterOrEquals( number: number ): boolean; + /** Checks if the first number is greater than or equal to the second. */ + greaterOrEquals( number: BigInteger ): boolean; + + /** Checks if the first number is lesser than the second. */ + lesser( number: number ): boolean; + /** Checks if the first number is lesser than the second. */ + lesser( number: BigInteger ): boolean; + + /** Checks if the first number is less than or equal to the second. */ + lesserOrEquals( number: number ): boolean; + /** Checks if the first number is less than or equal to the second. */ + lesserOrEquals( number: BigInteger ): boolean; + + /** Returns true if the number is even, false otherwise. */ + isEven(): boolean; + + /** Returns true if the number is odd, false otherwise. */ + isOdd(): boolean; + + /** Return true if the number is positive, false otherwise. Returns true for 0 and false for -0. */ + isPositive(): boolean; + + /** Returns true if the number is negative, false otherwise. Returns false for 0 and true for -0. */ + isNegative(): boolean; + + /** + * Performs a comparison between two numbers. If the numbers are equal, it returns 0. + * If the first number is greater, it returns 1. If the first number is lesser, it returns -1. + */ + compare( number: number ): BigInteger; + /** + * Performs a comparison between two numbers. If the numbers are equal, it returns 0. + * If the first number is greater, it returns 1. If the first number is lesser, it returns -1. + */ + compare( number: BigInteger ): BigInteger; + + /** Performs a comparison between the absolute value of two numbers. */ + compareAbs( number: number ): BigInteger; + /** Performs a comparison between the absolute value of two numbers. */ + compareAbs( number: BigInteger ): BigInteger; + + /** Checks if two numbers are equal. */ + equals( number: number ): boolean; + /** Checks if two numbers are equal. */ + equals( number: BigInteger ): boolean; + + /** Checks if two numbers are not equal. */ + notEquals( number: number ): boolean; + /** Checks if two numbers are not equal. */ + notEquals( number: BigInteger ): boolean; + + /** Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range. */ + toJSNumber(): number; + + /** Converts a bigInt to a string. */ + toString(): string; + + /** Converts a bigInt to a native Javascript number. This override allows you to use native arithmetic operators without explicit conversion. */ + valueOf(): number; +} + +interface BigIntegerStatic { + /** Equivalent to bigInt(1) */ + one: BigInteger; + /** Equivalent to bigInt(0) */ + zero: BigInteger; + /** Equivalent to bigInt(-1) */ + minusOne: BigInteger; + + /** Equivalent to bigInt(0) */ + (): BigInteger; + /** Parse a Javascript number into a bigInt */ + ( number: number ): BigInteger; + /** Parse a string into a bigInt */ + ( string: string ): BigInteger; + /** no-op */ + ( bigInt: BigInteger ): BigInteger; +} + +declare var bigInt: BigIntegerStatic; + +declare module "BigInteger" { + export = bigInt; +} \ No newline at end of file From 6416531210d6a22e582214a5f683334469c0970d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Mon, 21 Apr 2014 00:42:58 +0200 Subject: [PATCH 096/225] #2073 BigInteger.js: added string signatures for all methods --- bigInteger/bigInteger-tests.ts | 19 ++++++++++++++++ bigInteger/bigInteger.d.ts | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/bigInteger/bigInteger-tests.ts b/bigInteger/bigInteger-tests.ts index 7940b86296..225b2118de 100644 --- a/bigInteger/bigInteger-tests.ts +++ b/bigInteger/bigInteger-tests.ts @@ -21,27 +21,35 @@ isBigInteger = x.abs(); isBigInteger = x.add( 0 ); isBigInteger = x.add( x ); +isBigInteger = x.add( "100" ); isBigInteger = x.compare( 0 ); isBigInteger = x.compare( x ); +isBigInteger = x.compare( "100" ); isBigInteger = x.compareAbs( 0 ); isBigInteger = x.compareAbs( x ); +isBigInteger = x.compareAbs( "100" ); isBigInteger = x.divide( 0 ); isBigInteger = x.divide( x ); +isBigInteger = x.divide( "100" ); isDivmod = x.divmod( 0 ); isDivmod = x.divmod( x ); +isDivmod = x.divmod( "100" ); isBoolean = x.equals( 0 ); isBoolean = x.equals( x ); +isBoolean = x.equals( "100" ); isBoolean = x.greater( 0 ); isBoolean = x.greater( x ); +isBoolean = x.greater( "100" ); isBoolean = x.greaterOrEquals( 0 ); isBoolean = x.greaterOrEquals( x ); +isBoolean = x.greaterOrEquals( "100" ); isBoolean = x.isEven(); @@ -53,40 +61,51 @@ isBoolean = x.isPositive(); isBoolean = x.lesser( 0 ); isBoolean = x.lesser( x ); +isBoolean = x.lesser( "100" ); isBoolean = x.lesserOrEquals( 0 ); isBoolean = x.lesserOrEquals( x ); +isBoolean = x.lesserOrEquals( "100" ); isBigInteger = x.minus( 0 ); isBigInteger = x.minus( x ); +isBigInteger = x.minus( "100" ); isBigInteger = x.mod( 0 ); isBigInteger = x.mod( x ); +isBigInteger = x.mod( "100" ); isBigInteger = x.multiply( 0 ); isBigInteger = x.multiply( x ); +isBigInteger = x.multiply( "100" ); isBigInteger = x.next(); isBoolean = x.notEquals( 0 ); isBoolean = x.notEquals( x ); +isBoolean = x.notEquals( "100" ); isBigInteger = x.over( 0 ); isBigInteger = x.over( x ); +isBigInteger = x.over( "100" ); isBigInteger = x.plus( 0 ); isBigInteger = x.plus( x ); +isBigInteger = x.plus( "100" ); isBigInteger = x.pow( 0 ); isBigInteger = x.pow( x ); +isBigInteger = x.pow( "100" ); isBigInteger = x.prev(); isBigInteger = x.subtract( 0 ); isBigInteger = x.subtract( x ); +isBigInteger = x.subtract( "100" ); isBigInteger = x.times( 0 ); isBigInteger = x.times( x ); +isBigInteger = x.times( "100" ); isNumber = x.toJSNumber(); diff --git a/bigInteger/bigInteger.d.ts b/bigInteger/bigInteger.d.ts index ed03fc5ea1..a98fad7e79 100644 --- a/bigInteger/bigInteger.d.ts +++ b/bigInteger/bigInteger.d.ts @@ -11,46 +11,64 @@ interface BigInteger { add( number: number ): BigInteger; /** Performs addition */ add( number: BigInteger ): BigInteger; + /** Performs addition */ + add( number: string ): BigInteger; /** Alias for the add method. */ plus( number: number ): BigInteger; /** Alias for the add method. */ plus( number: BigInteger ): BigInteger; + /** Alias for the add method. */ + plus( number: string ): BigInteger; /** Alias for the subtract method. */ minus( number: number ): BigInteger; /** Alias for the subtract method. */ minus( number: BigInteger ): BigInteger; + /** Alias for the subtract method. */ + minus( number: string ): BigInteger; /** Performs subtraction. */ subtract( number: number ): BigInteger; /** Performs subtraction. */ subtract( number: BigInteger ): BigInteger; + /** Performs subtraction. */ + subtract( number: string ): BigInteger; /** Performs multiplication. */ multiply( number: number ): BigInteger; /** Performs multiplication. */ multiply( number: BigInteger ): BigInteger; + /** Performs multiplication. */ + multiply( number: string ): BigInteger; /** Alias for the multiply method. */ times( number: number ): BigInteger; /** Alias for the multiply method. */ times( number: BigInteger ): BigInteger; + /** Alias for the multiply method. */ + times( number: string ): BigInteger; /** Performs integer division, disregarding the remainder. */ divide( number: number ): BigInteger; /** Performs integer division, disregarding the remainder. */ divide( number: BigInteger ): BigInteger; + /** Performs integer division, disregarding the remainder. */ + divide( number: string ): BigInteger; /** Alias for the divide method. */ over( number: number ): BigInteger; /** Alias for the divide method. */ over( number: BigInteger ): BigInteger; + /** Alias for the divide method. */ + over( number: string ): BigInteger; /** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */ pow( number: number ): BigInteger; /** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */ pow( number: BigInteger ): BigInteger; + /** Performs exponentiation. If the exponent is less than 0, pow returns 0. bigInt.zero.pow(0) returns 1. */ + pow( number: string ): BigInteger; /** Adds one to the number. */ next(): BigInteger; @@ -62,31 +80,43 @@ interface BigInteger { mod( number: number ): BigInteger; /** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */ mod( number: BigInteger ): BigInteger; + /** Performs division and returns the remainder, disregarding the quotient. The sign of the remainder will match the sign of the dividend. */ + mod( number: string ): BigInteger; /** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */ divmod( number: number ): { quotient: BigInteger; remainder: BigInteger }; /** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */ divmod( number: BigInteger ): { quotient: BigInteger; remainder: BigInteger }; + /** Performs division and returns an object with two properties: quotient and remainder. The sign of the remainder will match the sign of the dividend. */ + divmod( number: string ): { quotient: BigInteger; remainder: BigInteger }; /** Checks if the first number is greater than the second. */ greater( number: number ): boolean; /** Checks if the first number is greater than the second. */ greater( number: BigInteger ): boolean; + /** Checks if the first number is greater than the second. */ + greater( number: string ): boolean; /** Checks if the first number is greater than or equal to the second. */ greaterOrEquals( number: number ): boolean; /** Checks if the first number is greater than or equal to the second. */ greaterOrEquals( number: BigInteger ): boolean; + /** Checks if the first number is greater than or equal to the second. */ + greaterOrEquals( number: string ): boolean; /** Checks if the first number is lesser than the second. */ lesser( number: number ): boolean; /** Checks if the first number is lesser than the second. */ lesser( number: BigInteger ): boolean; + /** Checks if the first number is lesser than the second. */ + lesser( number: string ): boolean; /** Checks if the first number is less than or equal to the second. */ lesserOrEquals( number: number ): boolean; /** Checks if the first number is less than or equal to the second. */ lesserOrEquals( number: BigInteger ): boolean; + /** Checks if the first number is less than or equal to the second. */ + lesserOrEquals( number: string ): boolean; /** Returns true if the number is even, false otherwise. */ isEven(): boolean; @@ -110,21 +140,32 @@ interface BigInteger { * If the first number is greater, it returns 1. If the first number is lesser, it returns -1. */ compare( number: BigInteger ): BigInteger; + /** + * Performs a comparison between two numbers. If the numbers are equal, it returns 0. + * If the first number is greater, it returns 1. If the first number is lesser, it returns -1. + */ + compare( number: string ): BigInteger; /** Performs a comparison between the absolute value of two numbers. */ compareAbs( number: number ): BigInteger; /** Performs a comparison between the absolute value of two numbers. */ compareAbs( number: BigInteger ): BigInteger; + /** Performs a comparison between the absolute value of two numbers. */ + compareAbs( number: string ): BigInteger; /** Checks if two numbers are equal. */ equals( number: number ): boolean; /** Checks if two numbers are equal. */ equals( number: BigInteger ): boolean; + /** Checks if two numbers are equal. */ + equals( number: string ): boolean; /** Checks if two numbers are not equal. */ notEquals( number: number ): boolean; /** Checks if two numbers are not equal. */ notEquals( number: BigInteger ): boolean; + /** Checks if two numbers are not equal. */ + notEquals( number: string ): boolean; /** Converts a bigInt into a native Javascript number. Loses precision for numbers outside the range. */ toJSNumber(): number; From f723f78dc43ee468aa9c3d69975a6e511b3efb3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ingo=20B=C3=BCrk?= Date: Mon, 21 Apr 2014 01:52:28 +0200 Subject: [PATCH 097/225] #2073: fix spelling --- .../bigInteger-tests.ts => big-integer/big-integer-tests.ts | 2 +- bigInteger/bigInteger.d.ts => big-integer/big-integer.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename bigInteger/bigInteger-tests.ts => big-integer/big-integer-tests.ts (98%) rename bigInteger/bigInteger.d.ts => big-integer/big-integer.d.ts (99%) diff --git a/bigInteger/bigInteger-tests.ts b/big-integer/big-integer-tests.ts similarity index 98% rename from bigInteger/bigInteger-tests.ts rename to big-integer/big-integer-tests.ts index 225b2118de..3b9fb8745f 100644 --- a/bigInteger/bigInteger-tests.ts +++ b/big-integer/big-integer-tests.ts @@ -1,4 +1,4 @@ -/// +/// // constructor tests var noArgument = bigInt(), diff --git a/bigInteger/bigInteger.d.ts b/big-integer/big-integer.d.ts similarity index 99% rename from bigInteger/bigInteger.d.ts rename to big-integer/big-integer.d.ts index a98fad7e79..dfadc49629 100644 --- a/bigInteger/bigInteger.d.ts +++ b/big-integer/big-integer.d.ts @@ -197,6 +197,6 @@ interface BigIntegerStatic { declare var bigInt: BigIntegerStatic; -declare module "BigInteger" { +declare module "big-integer" { export = bigInt; } \ No newline at end of file From 1975cba549763a5f35db7e0845e0075c75db64c0 Mon Sep 17 00:00:00 2001 From: "Omid K. Rad" Date: Wed, 16 Apr 2014 15:54:26 -0700 Subject: [PATCH 098/225] 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 ceff786637..0c8fdbf0f7 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 c13f86684a7f7684efc451e911b3cb488d2eadbd Mon Sep 17 00:00:00 2001 From: "Omid K. Rad" Date: Thu, 10 Apr 2014 13:28:10 -0700 Subject: [PATCH 099/225] Use power of Generics to infer types --- underscore/underscore-tests.ts | 59 ++++++++++++++++----------------- underscore/underscore.d.ts | 60 ++++++++++++++++++++++------------ 2 files changed, 68 insertions(+), 51 deletions(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 64c45a478b..8e0162b58c 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -3,10 +3,10 @@ declare var $; _.each([1, 2, 3], (num) => alert(num.toString())); -_.each({ one: 1, two: 2, three: 3 }, (value) => alert(value.toString())); +_.each({ one: 1, two: 2, three: 3 }, (value, key) => alert(value.toString())); _.map([1, 2, 3], (num) => num * 3); -_.map({ one: 1, two: 2, three: 3 }, (value: number, key?: string) => value * 3); +_.map({ one: 1, two: 2, three: 3 }, (value, key) => value * 3); //var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0); // https://typescript.codeplex.com/workitem/1960 var sum = _.reduce([1, 2, 3], (memo, num) => memo + num, 0); @@ -16,18 +16,20 @@ var list = [[0, 1], [2, 3], [4, 5]]; //var flat = _.reduceRight(list, (a, b) => a.concat(b), []); // https://typescript.codeplex.com/workitem/1960 var flat = _.reduceRight(list, (a, b) => a.concat(b), []); -var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); +var even = _.find([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); -var evens = _.filter([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); +var firstCapitalLetter = _.find({ a: 'a', b: 'B', c: 'C', d: 'd' }, l => l === l.toUpperCase()); + +var evens = _.filter([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); + +var capitalLetters = _.filter({ a: 'a', b: 'B', c: 'C', d: 'd' }, l => l === l.toUpperCase()); var listOfPlays = [{ title: "Cymbeline", author: "Shakespeare", year: 1611 }, { title: "The Tempest", author: "Shakespeare", year: 1611 }, { title: "Other", author: "Not Shakespeare", year: 2012 }]; _.where(listOfPlays, { author: "Shakespeare", year: 1611 }); -var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); +var odds = _.reject([1, 2, 3, 4, 5, 6], (num) => num % 2 == 0); -//_.every([true, 1, null, 'yes'], _.identity); // https://typescript.codeplex.com/workitem/1960 -_.every([true, 1, null, 'yes'], _.identity); -_.every<{}>([true, 1, null, 'yes']); +_.every([true, 1, null, 'yes'], _.identity); _.any([null, 0, 'yes', false]); @@ -49,7 +51,7 @@ _.sortBy([1, 2, 3, 4, 5, 6], (num) => Math.sin(num)); _([1.3, 2.1, 2.4]).groupBy((e) => Math.floor(e)); -_.groupBy([1.3, 2.1, 2.4], (num: number) => Math.floor(num).toString()); +_.groupBy([1.3, 2.1, 2.4], (num) => Math.floor(num).toString()); _.groupBy(['one', 'two', 'three'], 'length'); _.indexBy(stooges, 'age')['40'].age; @@ -59,7 +61,7 @@ _(stooges) .indexBy('age') .value()['40'].age; -_.countBy([1, 2, 3, 4, 5], (num) => (num % 2 == 0) ? 'even' : 'odd'); +_.countBy([1, 2, 3, 4, 5], (num) => (num % 2 == 0) ? 'even' : 'odd'); _.shuffle([1, 2, 3, 4, 5, 6]); @@ -87,19 +89,19 @@ _.rest([5, 4, 3, 2, 1]); _.compact([0, 1, false, 2, '', 3]); _.flatten([1, 2, 3, 4]); -_.flatten([1, [2]]); +_.flatten([1, [2]]); // typescript doesn't like the elements being different -_.flatten([1, [2], [3, [[4]]]]); -_.flatten([1, [2], [3, [[4]]]], true); +_.flatten([1, [2], [3, [[4]]]]); +_.flatten([1, [2], [3, [[4]]]], true); _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); _.difference([1, 2, 3, 4, 5], [5, 2, 10]); _.uniq([1, 2, 1, 3, 1, 4]); _.zip(['moe', 'larry', 'curly'], [30, 40, 50], [true, false, false]); -var r = _.object<{ [key: string]: number }>(['moe', 'larry', 'curly'], [30, 40, 50]); -_.object([['moe', 30], ['larry', 40], ['curly', 50]]); +var r = _.object(['moe', 'larry', 'curly'], [30, 40, 50]); +_.object([['moe', 30], ['larry', 40], ['curly', 50]]); _.indexOf([1, 2, 3], 2); _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); _.sortedIndex([10, 20, 30, 40, 50], 35); @@ -183,18 +185,15 @@ _.clone(['i', 'am', 'an', 'object!']); _([1, 2, 3, 4]) .chain() - .filter((num: number) => { - return num % 2 == 0; - }).tap(alert) - .map((num: number) => { - return num * num; - }) + .filter((num) => { return num % 2 == 0; }) + .tap(alert) + .map((num) => { return num * num; }) .value(); _.chain([1, 2, 3, 200]) - .filter(function (num: number) { return num % 2 == 0; }) + .filter((num) => { return num % 2 == 0; }) .tap(alert) - .map(function (num: number) { return num * num }) + .map((num) => { return num * num; }) .value(); _.has({ a: 1, b: 2, c: 3 }, "b"); @@ -259,7 +258,7 @@ var moe2 = { name: 'moe' }; moe2 === _.identity(moe); var genie; -var r2 = _.times(3, (n) => { return n * n }); +var r2 = _.times(3, (n) => { return n * n }); _(3).times(function (n) { genie.grantWishNumber(n); }); _.random(0, 100); @@ -301,29 +300,27 @@ _(['test', 'test']).pick(['test2', 'test2']); //////////////// Chain Tests function chain_tests() { // https://typescript.codeplex.com/workitem/1960 - var numArray: number[] = _.chain([1, 2, 3, 4, 5, 6, 7, 8]) + var numArray = _.chain([1, 2, 3, 4, 5, 6, 7, 8]) .filter(num => num % 2 == 0) .map(num => num * num) .value(); - var strArray: string[] = _([1, 2, 3, 4]) + var strArray = _([1, 2, 3, 4]) .chain() .filter(num => num % 2 == 0) .tap(alert) .map(num => "string" + num) .value(); - var n : number = _.chain([1, 2, 3, 200]) + var n = _.chain([1, 2, 3, 200]) .filter(num => num % 2 == 0) .tap(alert) .map(num => num * num) .max() .value(); - //If using alternate definition of map (~ line 2200), .value returns any - // because.map matches _Chain as opposed to _ChainOfArrays , which breaks typing on flatten - var hoverOverValueShouldBeNumberNotAny : number = _([1, 2, 3]).chain() - .map(num=> [num, num + 1]) + var hoverOverValueShouldBeNumberNotAny = _([1, 2, 3]).chain() + .map(num => [num, num + 1]) .flatten() .find(num => num % 2 == 0) .value(); diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 7e4bd99e1e..cc9a3e6e9d 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -23,7 +23,7 @@ declare module _ { /** * underscore.js template settings, set templateSettings or pass as an argument - * to 'template()' to overide defaults. + * to 'template()' to override defaults. **/ interface TemplateSettings { /** @@ -200,7 +200,7 @@ interface UnderscoreStatic { /** * The right-associative version of reduce. Delegates to the JavaScript 1.8 version of - * reduceRight, if it exists. Foldr is not as useful in JavaScript as it would be in a + * reduceRight, if it exists. `foldr` is not as useful in JavaScript as it would be in a * language with lazy evaluation. * @param list Reduces the elements of this array. * @param iterator Reduce iterator function for each element in `list`. @@ -233,7 +233,15 @@ interface UnderscoreStatic { * @return The first acceptable found element in `list`, if nothing is found undefined/null is returned. **/ find( - list: _.Collection, + list: _.List, + iterator: _.ListIterator, + context?: any): T; + + /** + * @see _.find + **/ + find( + list: _.Dictionary, iterator: _.ListIterator, context?: any): T; @@ -254,7 +262,15 @@ interface UnderscoreStatic { * @return The filtered list of elements. **/ filter( - list: _.Collection, + list: _.List, + iterator: _.ListIterator, + context?: any): T[]; + + /** + * @see _.filter + **/ + filter( + list: _.Dictionary, iterator: _.ListIterator, context?: any): T[]; @@ -297,7 +313,15 @@ interface UnderscoreStatic { * @return The rejected list of elements. **/ reject( - list: _.Collection, + list: _.List, + iterator: _.ListIterator, + context?: any): T[]; + + /** + * @see _.reject + **/ + reject( + list: _.Dictionary, iterator: _.ListIterator, context?: any): T[]; @@ -497,7 +521,7 @@ interface UnderscoreStatic { * @return An object with the group names as properties where each property contains the number of elements in that group. **/ countBy( - list: _.Collection, + list: _.List, iterator?: _.ListIterator, context?: any): _.Dictionary; @@ -506,7 +530,7 @@ interface UnderscoreStatic { * @param iterator Function name **/ countBy( - list: _.Collection, + list: _.Dictionary, iterator: string, context?: any): _.Dictionary; @@ -603,7 +627,7 @@ interface UnderscoreStatic { /** * Returns everything but the last entry of the array. Especially useful on the arguments object. * Pass n to exclude the last n elements from the result. - * @param array Retreive all elements except the last `n`. + * @param array Retrieve all elements except the last `n`. * @param n Leaves this many elements behind, optional. * @return Returns everything but the last `n` elements of `array`. **/ @@ -711,7 +735,7 @@ interface UnderscoreStatic { * advance that the array is sorted, passing true for isSorted will run a much faster algorithm. If * you want to compute unique items based on a transformation, pass an iterator function. * @param array Array to remove duplicates from. - * @param isSorted True if `array` is already sorted, optiona, default = false. + * @param isSorted True if `array` is already sorted, optional, default = false. * @param iterator Transform the elements of `array` before comparisons for uniqueness. * @param context 'this' object in `iterator`, optional. * @return Copy of `array` where all elements are unique. @@ -817,7 +841,7 @@ interface UnderscoreStatic { * @param array The array to search for the last index of `value`. * @param value The value to search for within `array`. * @param from The starting index for the search, optional. - * @return The index of the last occurance of `value` within `array`. + * @return The index of the last occurrence of `value` within `array`. **/ lastIndexOf( array: _.List, @@ -918,7 +942,7 @@ interface UnderscoreStatic { /** * Much like setTimeout, invokes function after wait milliseconds. If you pass the optional arguments, * they will be forwarded on to the function when it is invoked. - * @param fn Function to delay `waitMS` amount of ms. + * @param func Function to delay `waitMS` amount of ms. * @param wait The amount of milliseconds to delay `fn`. * @arguments Additional arguments to pass to `fn`. **/ @@ -954,7 +978,7 @@ interface UnderscoreStatic { * if you call it again any number of times during the wait period, as soon as that period is over. * If you'd like to disable the leading-edge call, pass {leading: false}, and if you'd like to disable * the execution on the trailing-edge, pass {trailing: false}. - * @param fn Function to throttle `waitMS` ms. + * @param func Function to throttle `waitMS` ms. * @param wait The number of milliseconds to wait before `fn` can be invoked again. * @param options Allows for disabling execution of the throttled function on either the leading or trailing edge. * @return `fn` with a throttle of `wait`. @@ -1030,14 +1054,14 @@ interface UnderscoreStatic { /** * Retrieve all the names of the object's properties. - * @param object Retreive the key or property names from this object. + * @param object Retrieve the key or property names from this object. * @return List of all the property names on `object`. **/ keys(object: any): string[]; /** * Return all of the values of the object's properties. - * @param object Retreive the values of all the properties on this object. + * @param object Retrieve the values of all the properties on this object. * @return List of all the values on `object`. **/ values(object: any): any[]; @@ -2233,9 +2257,7 @@ interface _Chain { * Wrapped type `any[]`. * @see _.map **/ - map(iterator: (value: T, index: number, list: T[]) => TArray[], context?: any): _ChainOfArrays; - //Not sure why this won't work, might be a TypeScript error? - //map(iterator: _.ListIterator, context?: any): _ChainOfArrays; + map(iterator: _.ListIterator, context?: any): _ChainOfArrays; /** * Wrapped type `any[]`. @@ -2247,9 +2269,7 @@ interface _Chain { * Wrapped type `any[]`. * @see _.map **/ - map(iterator: (element: T, key: string, list: any) => TArray[], context?: any): _ChainOfArrays; - //Not sure why this won't work, might be a TypeScript error? - //map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; + map(iterator: _.ObjectIterator, context?: any): _ChainOfArrays; /** * Wrapped type `any[]`. From 63c560a05f51ac7796031627db215e3bb990f000 Mon Sep 17 00:00:00 2001 From: Seon-Wook Park Date: Tue, 22 Apr 2014 15:43:58 +0200 Subject: [PATCH 100/225] 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 54ae0cdc8c..b26e55b1b5 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 0000000000..3e7b4afaf9 --- /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 0000000000..12ffb08bbc --- /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 101/225] 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 54ae0cdc8c..9f4f84f19c 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 0000000000..f1751d9015 --- /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 0000000000..7eae246a80 --- /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 0000000000..8a3464a6df --- /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 0000000000..3ae6778b5d --- /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 0000000000..bf4fea4496 --- /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 0000000000..3bfe35bf04 --- /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 0000000000..62645defb1 --- /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 0000000000..0faea1593c --- /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 0000000000..641a368749 --- /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 0000000000..af0f2d799b --- /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 0000000000..ea3432e1cf --- /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 0000000000..75f6c71a03 --- /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 0000000000..a1ce563520 --- /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 0000000000..de2ec72c86 --- /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 0000000000..dbf03db04b --- /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 0000000000..0d551a5d4b --- /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 0000000000..14ee55c203 --- /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 0000000000..1eb9c61cff --- /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 0000000000..36f0e5c15d --- /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 0000000000..bfaa7a51f1 --- /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 0000000000..e8172b800e --- /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 0000000000..cbc46d6fb7 --- /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 0000000000..13b314af8e --- /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 0000000000..2ebd18a150 --- /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 0000000000..b3b68dd200 --- /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 0000000000..9c8aaac2ef --- /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 0000000000..bdd705b0e3 --- /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 0000000000..c427dbf171 --- /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 0000000000..aa7f0341ff --- /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 0000000000..01d44ab630 --- /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 0000000000..98ed2371be --- /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 0000000000..e31b130aca --- /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 0000000000..74e33ce678 --- /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 0000000000..b02581aefe --- /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 0000000000..563fbebdd9 --- /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 0000000000..547d93532f --- /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 0000000000..1f68aa44cb --- /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 0000000000..c8317ac5cf --- /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 0000000000..b156ff1403 --- /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 0000000000..4e76fab7d5 --- /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 0000000000..9484d16406 --- /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 0000000000..50b9c3f369 --- /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 0000000000..bf41affd1c --- /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 0000000000..0ce655272f --- /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 0000000000..4888d41e2e --- /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 0000000000..d011b11f76 --- /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 0000000000..499b427a62 --- /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 0000000000..8ebd618ff6 --- /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 0000000000..c75a4ddb00 --- /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 0000000000..d3c03fc774 --- /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 102/225] 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 9f4f84f19c..4e7cb6074f 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 0000000000..d422c3abc5 --- /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 0000000000..e6a1d100e9 --- /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 103/225] 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 0000000000..8c287bb2e7 --- /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 0000000000..6e1d7bd8c1 --- /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 104/225] Added node-uuid to README.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d68e3061cc..88263116ec 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 b03204e6f034d0962cd9a459642f17b8f02fd5d8 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 23 Apr 2014 09:50:10 +0100 Subject: [PATCH 105/225] jQuery UI: changeMonth and changeYear JSDoc --- jqueryui/jqueryui-tests.ts | 18 ++++++++++++++++++ jqueryui/jqueryui.d.ts | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index c922ec161a..e2aac42a09 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1270,6 +1270,24 @@ function test_datepicker() { // setter var $set: JQuery = $(".selector").datepicker("option", "calculateWeek", myWeekCalc); } + + function changeMonth() { + $(".selector").datepicker({ changeMonth: true }); + + var changeMonth: boolean = $(".selector").datepicker("option", "changeMonth"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "changeMonth", true); + } + + function changeYear() { + $(".selector").datepicker({ changeYear: true }); + + var changeYear: boolean = $(".selector").datepicker("option", "changeYear"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "changeYear", true); + } } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 083df7b463..2ccd2c262e 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -1287,10 +1287,41 @@ interface JQuery { * @param methodName 'option' * @param optionName 'buttonText' * @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; + /** + * Get the changeMonth option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'changeMonth'): boolean; + /** + * Set the changeMonth option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @param changeMonthValue Whether the month should be rendered as a dropdown instead of text. + */ + datepicker(methodName: 'option', optionName: 'changeMonth', changeMonthValue: boolean): JQuery; + + /** + * Get the changeYear option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'changeYear'): boolean; + /** + * Set the changeYear option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + /** * Gets the value currently associated with the specified optionName. * From a71f0ee0f91e681c729c9c717f701a477168614b Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Wed, 23 Apr 2014 13:45:09 +0200 Subject: [PATCH 106/225] added Google Analytics beacon so we have some github stats in the GA account to compare to the sites --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4671d37859..479e04cc89 100755 --- a/README.md +++ b/README.md @@ -37,3 +37,5 @@ Here is an updated list of [definitions people have requested](https://github.co This project is licensed under the MIT license. Copyrights on the definition files are respective of each contributor listed at the beginning of each definition file. + +[![Analytics](https://ga-beacon.appspot.com/UA-47495295-4/borisyankov/DefinitelyTyped)](https://github.com/igrigorik/ga-beacon) \ No newline at end of file From c16618cc4304b83e840ac3b7fa89be2d0771c3f8 Mon Sep 17 00:00:00 2001 From: soywiz Date: Wed, 23 Apr 2014 14:24:16 +0200 Subject: [PATCH 107/225] - Added tspromise definition --- tspromise/tspromise-test.ts | 21 +++++++++++++++++++++ tspromise/tspromise.d.ts | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tspromise/tspromise-test.ts create mode 100644 tspromise/tspromise.d.ts diff --git a/tspromise/tspromise-test.ts b/tspromise/tspromise-test.ts new file mode 100644 index 0000000000..79903f0ce2 --- /dev/null +++ b/tspromise/tspromise-test.ts @@ -0,0 +1,21 @@ +/// + +import Promise = require('tspromise'); + +var MyFuncFunc = Promise.async((a: boolean, b: number) => { + console.log('[a] ' + a); + yield(Promise.waitAsync(1000)); + console.log('[b]' + b); +}); + +MyFuncFunc(true, 10); + +Promise.all([Promise.waitAsync(10), Promise.waitAsync(20)]).then(() => { + return new Promise((resolve, reject) => { + resolve('test'); + }); +}).then(() => { + throw (new Error()); +}).catch((e) => { + console.log(e.message); +}); \ No newline at end of file diff --git a/tspromise/tspromise.d.ts b/tspromise/tspromise.d.ts new file mode 100644 index 0000000000..8608d105cc --- /dev/null +++ b/tspromise/tspromise.d.ts @@ -0,0 +1,35 @@ +/// +declare class Thenable { + then(onFulfilled: (value: T) => Thenable, onRejected?: (error: Error) => TR): Thenable; + then(onFulfilled: (value: T) => Thenable, onRejected?: (error: Error) => void): Thenable; + then(onFulfilled: (value: T) => TR, onRejected?: (error: Error) => void): Thenable; + then(onFulfilled: (value: T) => TR, onRejected?: (error: Error) => TR): Thenable; + catch(onRejected: (error: Error) => T): Thenable; +} + +interface NodeCallback { + (err: Error, value: T): void; +} + +declare module "tspromise" { + class Promise extends Thenable { + constructor(callback: (resolve: (value?: T) => void, reject?: (error: Error) => void) => void); + static resolve(value?: T): Thenable; + static resolve(promise: Thenable): Thenable; + static reject(error: Error): Thenable; + static all(promises: Thenable[]): Thenable; + static async(callback: () => TR): () => Thenable; + static async(callback: (p1: T1) => TR): (p1: T1) => Thenable; + static async(callback: (p1: T1, p2: T2) => TR): (p1: T1, p2: T2) => Thenable; + static async(callback: (p1: T1, p2: T2, p3: T3) => TR): (p1: T1, p2: T2, p3: T3) => Thenable; + static async(callback: (p1: T1, p2: T2, p3: T3, p4: T4) => TR): (p1: T1, p2: T2, p3: T3, p4: T4) => Thenable; + static spawn(generatorFunction: () => TR): Thenable; + static rewriteFolderSync(path: string): void; + static waitAsync(time: number): Thenable<{}>; + static nfcall(obj: any, methodName: String, ...args: any[]): Thenable; + } + + export = Promise; +} + +declare function yield(promise: Thenable): T; From 6550e264a59748eb7027a417b05390d693e2aebe Mon Sep 17 00:00:00 2001 From: soywiz Date: Wed, 23 Apr 2014 14:26:24 +0200 Subject: [PATCH 108/225] - Added info to definition --- tspromise/tspromise.d.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tspromise/tspromise.d.ts b/tspromise/tspromise.d.ts index 8608d105cc..0d1132ed1e 100644 --- a/tspromise/tspromise.d.ts +++ b/tspromise/tspromise.d.ts @@ -1,4 +1,9 @@ -/// +// Type definitions for tspromise 0.0.4 +// Project: https://github.com/soywiz/tspromise +// Definitions by: Carlos Ballesteros Velasco +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// declare class Thenable { then(onFulfilled: (value: T) => Thenable, onRejected?: (error: Error) => TR): Thenable; then(onFulfilled: (value: T) => Thenable, onRejected?: (error: Error) => void): Thenable; From f1d0dcabb728013aa5dbbbc82f5f603de7d977e0 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Wed, 23 Apr 2014 17:08:19 +0100 Subject: [PATCH 109/225] jQueryUI: Finished the c's --- jqueryui/jqueryui-tests.ts | 27 +++++++++++++++++++++ jqueryui/jqueryui.d.ts | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index e2aac42a09..136bb2c962 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1288,6 +1288,33 @@ function test_datepicker() { // setter var $set: JQuery = $(".selector").datepicker("option", "changeYear", true); } + + function closeText() { + $(".selector").datepicker({ closeText: "Close" }); + + var closeText: string = $(".selector").datepicker("option", "closeText"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "closeText", "Close"); + } + + function constrainInput() { + $(".selector").datepicker({ constrainInput: false }); + + var constrainInput: boolean = $(".selector").datepicker("option", "constrainInput"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "constrainInput", false); + } + + function currentText() { + $(".selector").datepicker({ currentText: "Now" }); + + var currentText: string = $(".selector").datepicker("option", "currentText"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "currentText", "Now"); + } } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 2ccd2c262e..57f10c08ee 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -1322,6 +1322,54 @@ interface JQuery { */ datepicker(methodName: 'option', optionName: 'changeYear', changeYearValue: boolean): JQuery; + /** + * Get the closeText option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'closeText'): string; + /** + * Set the closeText option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + + /** + * Get the constrainInput option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'constrainInput'): boolean; + /** + * Set the constrainInput option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + + /** + * Get the currentText option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'currentText'): string; + /** + * Set the currentText option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + /** * Gets the value currently associated with the specified optionName. * From 89c5eaf231206eb2b7c851e46c31766433abad48 Mon Sep 17 00:00:00 2001 From: Max Ackley Date: Wed, 23 Apr 2014 10:49:21 -0700 Subject: [PATCH 110/225] 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 d68e3061cc..96e221802b 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 0000000000..e50fe1d5f2 --- /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 0000000000..0b0cb7ebff --- /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 111/225] (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 a5b7de20d9..0cc4321afb 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 112/225] 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 22473e13e2..9643c9e6b3 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 79a48d8772e6b677ad0e2bc471e0724909c7a0ab Mon Sep 17 00:00:00 2001 From: John Reilly Date: Thu, 24 Apr 2014 15:47:53 +0100 Subject: [PATCH 113/225] jQueryUI: now the d's --- jqueryui/jqueryui-tests.ts | 47 ++++++++++++++++++ jqueryui/jqueryui.d.ts | 98 +++++++++++++++++++++++++++++++++++++- 2 files changed, 144 insertions(+), 1 deletion(-) diff --git a/jqueryui/jqueryui-tests.ts b/jqueryui/jqueryui-tests.ts index 136bb2c962..b83006c3a8 100644 --- a/jqueryui/jqueryui-tests.ts +++ b/jqueryui/jqueryui-tests.ts @@ -1315,6 +1315,53 @@ function test_datepicker() { // setter var $set: JQuery = $(".selector").datepicker("option", "currentText", "Now"); } + + function dateFormat() { + $(".selector").datepicker({ dateFormat: "yy-mm-dd" }); + + var dateFormat: string = $(".selector").datepicker("option", "dateFormat"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "dateFormat", "yy-mm-dd"); + } + + function dayNames() { + $(".selector").datepicker({ dayNames: ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"] }); + + var dayNames: string[] = $(".selector").datepicker("option", "dayNames"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "dayNames", ["Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"]); + } + + function dayNamesMin() { + $(".selector").datepicker({ dayNamesMin: ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"] }); + + var dayNamesMin: string[] = $(".selector").datepicker("option", "dayNamesMin"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "dayNamesMin", ["Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa"]); + } + + function dayNamesShort() { + $(".selector").datepicker({ dayNamesShort: ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"] }); + + var dayNamesShort: string[] = $(".selector").datepicker("option", "dayNamesShort"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "dayNamesShort", ["Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"]); + } + + function defaultDate() { + $(".selector").datepicker({ defaultDate: +7 }); + + var defaultDate: any = $(".selector").datepicker("option", "defaultDate"); + + // setter + var $set: JQuery = $(".selector").datepicker("option", "defaultDate", +7); + $set = $(".selector").datepicker("option", "defaultDate", new Date()); + $set = $(".selector").datepicker("option", "defaultDate", "+1m +7d"); + } } diff --git a/jqueryui/jqueryui.d.ts b/jqueryui/jqueryui.d.ts index 57f10c08ee..5019a99504 100644 --- a/jqueryui/jqueryui.d.ts +++ b/jqueryui/jqueryui.d.ts @@ -180,7 +180,7 @@ declare module JQueryUI { * Number: A number of days from today. For example 2 represents two days from today and -1 represents yesterday. * String: A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today. */ - defaultDateType?: any; // Date, number or string + defaultDate?: any; // Date, number or string /** * 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"). */ @@ -1370,6 +1370,102 @@ interface JQuery { */ datepicker(methodName: 'option', optionName: 'currentText', currentTextValue: string): JQuery; + /** + * Get the dateFormat option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'dateFormat'): string; + /** + * Set the dateFormat option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + + /** + * Get the dayNames option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'dayNames'): string[]; + /** + * Set the dayNames option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + + /** + * Get the dayNamesMin option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'dayNamesMin'): string[]; + /** + * Set the dayNamesMin option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + + /** + * Get the dayNamesShort option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + */ + datepicker(methodName: 'option', optionName: 'dayNamesShort'): string[]; + /** + * Set the dayNamesShort option, after initialization + * + * @param methodName 'option' + * @param optionName 'buttonText' + * @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; + + /** + * Get the defaultDate option, after initialization + * + * @param methodName 'option' + * @param optionName 'defaultDate' + */ + datepicker(methodName: 'option', optionName: 'defaultDate'): any; + /** + * Set the defaultDate option, after initialization + * + * @param methodName 'option' + * @param optionName 'defaultDate' + * @param defaultDateValue A date object containing the default date. + */ + datepicker(methodName: 'option', optionName: 'defaultDate', defaultDateValue: Date): JQuery; + /** + * Set the defaultDate option, after initialization + * + * @param methodName 'option' + * @param optionName 'defaultDate' + * @param defaultDateValue A number of days from today. For example 2 represents two days from today and -1 represents yesterday. + */ + datepicker(methodName: 'option', optionName: 'defaultDate', defaultDateValue: number): JQuery; + /** + * Set the defaultDate option, after initialization + * + * @param methodName 'option' + * @param optionName 'defaultDate' + * @param defaultDateValue A string in the format defined by the dateFormat option, or a relative date. Relative dates must contain value and period pairs; valid periods are "y" for years, "m" for months, "w" for weeks, and "d" for days. For example, "+1m +7d" represents one month and seven days from today. + */ + datepicker(methodName: 'option', optionName: 'defaultDate', defaultDateValue: string): JQuery; + /** * Gets the value currently associated with the specified optionName. * From 45b1c617ad3979914fb407398440b37a42f4bb4b Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Thu, 24 Apr 2014 17:41:01 +0200 Subject: [PATCH 114/225] changed joi header to v4.0.0 --- joi/joi.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/joi/joi.d.ts b/joi/joi.d.ts index 344738e891..10bc7225e7 100644 --- a/joi/joi.d.ts +++ b/joi/joi.d.ts @@ -1,4 +1,4 @@ -// Type definitions for joi v3.1.0 +// Type definitions for joi v4.0.0 // Project: https://github.com/spumko/joi // Definitions by: Bart van der Schoor // Definitions: https://github.com/borisyankov/DefinitelyTyped From 58b7a009bf87c3a887f6961e3def8d499df2e808 Mon Sep 17 00:00:00 2001 From: AdaskoTheBeAsT Date: Thu, 24 Apr 2014 23:08:39 +0200 Subject: [PATCH 115/225] www.jstree.com definition file added amazing tree jstree definition file added --- jquery.jstree/jquery.jstree.d.ts | 696 +++++++++++++++++++++++++++++++ 1 file changed, 696 insertions(+) create mode 100644 jquery.jstree/jquery.jstree.d.ts diff --git a/jquery.jstree/jquery.jstree.d.ts b/jquery.jstree/jquery.jstree.d.ts new file mode 100644 index 0000000000..55e3c6f418 --- /dev/null +++ b/jquery.jstree/jquery.jstree.d.ts @@ -0,0 +1,696 @@ +/// + +interface JQueryStatic { + /** + * holds all jstree related functions and variables, + * including the actual class and methods to create, + * access and manipulate instances. + * @property jstree + * @type {JSTreeStatic} + */ + jstree?: JSTreeStatic; + +} + +interface JSTreeStatic { + /** + * specifies the jstree version in use + * @property version + * @type {string} + */ + version: string; + + /** + * holds all the default options used when creating new instances + * @property defaults + * @type {JSTreeStaticDefaults} + */ + defaults: JSTreeStaticDefaults; + + /** + * stores all loaded jstree plugins (used internally) + */ + plugins: any[]; + + /** + * creates a jstree instance + * @param el the element to create the instance on, can be jQuery extended or a selector + * @param options {JSTreeOptions} options for this instance (extends `$.jstree.defaults`) + * @returns {JSTree} the new instance + */ + create(el: any, options?: JSTreeStaticDefaults): JSTree; + + /** + * the jstree class constructor, used only internally + * @param id {number} this instance's index + */ + core(id: number): void; + + /** + * get a reference to an existing instance + * @param needle + * @returns {JSTree} the instance or `null` if not found + */ + reference(needle: any): JSTree; +} + +interface JSTreeStaticDefaults { + /** + * configure which plugins will be active on an instance. + * Should be an array of strings, where each element is a plugin name. + * The default is [] + */ + plugins: string[]; + /** + * stores all defaults for the core + */ + core: JSTreeStaticDefaultsCore; + /** + * stores all defaults for the checkbox plugin + */ + checkbox?: JSTreeStaticDefaultsCheckbox; + /** + * stores all defaults for the contextmenu plugin + */ + contextmenu?: JSTreeStaticDefaultsContextMenu; + /** + * stores all defaults for the drag'n'drop plugin + */ + dnd?: JSTreeStaticDefaultsDragNDrop; + /** + * stores all defaults for the search plugin + */ + search?: JSTreeStaticDefaultsSearch; + /** + * the settings function used to sort the nodes. + * It is executed in the tree's context, + * accepts two nodes as arguments and should return 1 or -1. + */ + sort?: (x: any, y: any) => number; + /** + * stores all defaults for the state plugin + */ + state?: JSTreeStaticDefaultsState; + /** + * An object storing all types as key value pairs, + * where the key is the type name and the value is an object + * that could contain following keys (all optional). + * max_children the maximum number of immediate children this node type can have. + * Do not specify or set to -1 for unlimited. + * max_depth the maximum number of nesting this node type can have. + * A value of 1 would mean that the node can have children, but no grandchildren. + * Do not specify or set to -1 for unlimited. + * valid_children an array of node type strings, that nodes of this type can have as children. + * Do not specify or set to -1 for no limits. + * icon a string - can be a path to an icon or a className, if using an image + * that is in the current directory use a ./ prefix, otherwise it will be detected as a class. + * Omit to use the default icon from your theme. + * There are two predefined types: + * # represents the root of the tree, for example max_children would control the maximum number of root nodes. + * default represents the default node - any settings here will be applied to all nodes that do not have a type specified. + */ + types?: any; +} + +interface JSTreeStaticDefaultsCore { + /** + * data configuration + */ + data?: any; + /** + * configure the various strings used throughout the tree + */ + strings?: any; + /** + * + */ + check_callback?: (operation: string, node: any, node_parent: any, node_position: any) => void; + /** + * the open / close animation duration in milliseconds + * set this to false to disable the animation (default is 200) + */ + animation?: any; + /** + * a boolean indicating if multiple nodes can be selected + */ + multiple?: boolean; + /** + * theme configuration object + */ + themes?:JSTreeStaticDefaultsCoreThemes; +} + +interface JSTreeStaticDefaultsCoreThemes { + /** + * the name of the theme to use (if left as false the default theme is used) + */ + name?: string; + /** + * the URL of the theme's CSS file, leave this as false if you have manually + * included the theme CSS (recommended). + * You can set this to true too which will try to autoload the theme. + */ + url?: string; + /** + * the location of all jstree themes - only used if url is set to true + */ + dir?: string; + /** + * a boolean indicating if connecting dots are shown + */ + dots?: boolean; + /** + * a boolean indicating if node icons are shown + */ + icons?: boolean; + /** + * a boolean indicating if the tree background is striped + */ + stripes?: boolean; + /** + * a string (or boolean false) specifying the theme + * variant to use (if the theme supports variants) + */ + variant?: any; + /** + * a boolean specifying if a reponsive version of the theme should kick + * in on smaller screens (if the theme supports it). Defaults to true. + */ + responsive?: boolean; + /** + * if left as true all parents of all selected nodes will be opened + * once the tree loads (so that all selected nodes are visible to the user) + */ + expand_selected_onload?:boolean; + +} + +interface JSTreeStaticDefaultsCheckbox { + /** + * a boolean indicating if checkboxes should be visible + * (can be changed at a later time using show_checkboxes() + * and hide_checkboxes). Defaults to true. + */ + visible: boolean; + /** + * a boolean indicating if checkboxes should cascade down + * and have an undetermined state. Defaults to true. + */ + three_state: boolean; + /** + * a boolean indicating if clicking anywhere on the node + * should act as clicking on the checkbox. Defaults to true. + */ + whole_node: boolean; + /** + * a boolean indicating if the selected style of a node + * should be kept, or removed. Defaults to true. + */ + keep_selected_style: boolean; +} + +interface JSTreeStaticDefaultsContextMenu { + /** + * a boolean indicating if the node should be selected + * when the context menu is invoked on it. Defaults to true. + */ + select_node: boolean; + /** + * a boolean indicating if the menu should be shown aligned + * with the node. Defaults to true, otherwise the mouse coordinates are used. + */ + show_at_node: boolean; + /** + * an object of actions, or a function that accepts a node + * and returns an object of actions available for that node + * Each action consists of a key (a unique name) and a value which is an object with the following properties: + * separator_before - a boolean indicating if there should be a separator before this item + * separator_after - a boolean indicating if there should be a separator after this item + * _disabled - a boolean indicating if this action should be disabled + * label - a string - the name of the action + * action - a function to be executed if this item is chosen + */ + items: any; +} + +interface JSTreeStaticDefaultsDragNDrop { + /** + * a boolean indicating if a copy should be possible + * while dragging (by pressint the meta key or Ctrl). Defaults to true. + */ + copy: boolean; + /** + * a number indicating how long a node should remain hovered + * while dragging to be opened. Defaults to 500. + */ + open_timeout: number; +} + +interface JSTreeStaticDefaultsSearch { + /** + * a jQuery-like AJAX config, which jstree uses + * if a server should be queried for results. + * A str (which is the search string) parameter will be added with the request. + * The expected result is a JSON array with nodes that need to be opened + * so that matching nodes will be revealed. Leave this setting as false to not query the server. + */ + ajax: any; + /** + * Indicates if the search should be fuzzy + * or not (should chnd3 match child node 3). Default is true. + */ + fuzzy: boolean; + /** + * Indicates if the search should be case sensitive. Default is false. + */ + case_sensitive: boolean; + /** + * Indicates if the tree should be filtered to show only matching nodes + * (keep in mind this can be a heavy on large trees in old browsers). Default is false. + */ + show_only_matches: boolean; + /** + * Indicates if all nodes opened to reveal the search result, + * should be closed when the search is cleared or a new search is performed. Default is true. + */ + close_opened_onclear: boolean; +} + +interface JSTreeStaticDefaultsState { + /** + * A string for the key to use when saving the current tree + * (change if using multiple trees in your project). Defaults to jstree. + */ + key: string; + /** + * A space separated list of events that trigger a state save. + * Defaults to changed.jstree open_node.jstree close_node.jstree. + */ + events: string; +} + +interface JQuery { + jstree(): JSTree; + jstree(options: JSTreeStaticDefaults): JSTree; + jstree(arg: boolean): JSTree; + jstree(...args: any[]): JSTree; +} + +interface JSTree extends JQuery { + /** + * destroy an instance + */ + destroy: () => void; + /** + * returns the jQuery extended instance container + */ + get_container: () => JQuery; + /** + * get the JSON representation of a node + * (or the actual jQuery extended DOM node) + * by using any input (child DOM element, ID string, selector, etc) + */ + get_node: (obj: any, as_dom?: boolean) => JQuery; + /** + * get the next visible node that is below the obj node. + * If strict is set to true only sibling nodes are returned. + */ + get_next_dom: (obj:any,strict?:boolean) => JQuery; + /** + * get the previous visible node that is above the obj node. + * If strict is set to true only sibling nodes are returned. + */ + get_prev_dom: (obj: any, strict?: boolean) => JQuery; + /** + * get the parent ID of a node + */ + get_parent: (obj: any) => string; + /** + * get a jQuery collection of all the children of a node (node must be rendered) + */ + get_children_dom: (obj: any) => JQuery; + /** + * checks if a node has children + */ + is_parent: (obj: any) => boolean; + /** + * checks if a node is loaded (its children are available) + */ + is_loaded: (obj: any) => boolean; + /** + * check if a node is currently loading (fetching children) + */ + is_loading: (obj: any) => boolean; + /** + * check if a node is opened + */ + is_open: (obj: any) => boolean; + /** + * check if a node is in a closed state + */ + is_closed: (obj: any) => boolean; + /** + * check if a node has no children + */ + is_leaf: (obj: any) => boolean; + /** + * loads a node (fetches its children using the core.data setting). + * Multiple nodes can be passed to by using an array. + * @param obj mixed + * @param callback a function to be executed once loading is conplete, + * the function is executed in the instance's scope and receives two arguments + * the node and a boolean status + */ + load_node: (obj: any, callback: any) => boolean; + /** + * redraws all nodes that need to be redrawn or optionally - the whole tree + * @param full if set to `true` all nodes are redrawn. + */ + redraw: (full?: boolean) => void; + /** + * opens a node, revaling its children. If the node is not loaded + * it will be loaded and opened once ready. + * @param obj the node to open + * @param callback a function to execute once the node is opened + * @param animation the animation duration in milliseconds when opening the node + * (overrides the `core.animation` setting). Use `false` for no animation. + */ + open_node: (obj: any, callback?: any, animation?: any) => void; + /** + * opens a node, revaling its children. If the node is not loaded + * it will be loaded and opened once ready. + * @param obj the node to close + * @param animation the animation duration in milliseconds when closing the node + * (overrides the `core.animation` setting). Use `false` for no animation. + */ + close_node: (obj: any, animation?: any) => void; + /** + * toggles a node - closing it if it is open, opening it if it is closed + */ + toggle_node: (obj: any) => void; + /** + * opens all nodes within a node (or the tree), revaling their children. + * If the node is not loaded it will be loaded and opened once ready. + * @param obj the node to open recursively, omit to open all nodes in the tree + * @param animation the animation duration in milliseconds when opening the nodes, the default is no animation + * @param original_obj to the node that started the process (internal use) + */ + open_all: (obj?: any, animation?: number, original_obj?: any) => void; + /** + * closes all nodes within a node (or the tree), revaling their children + * @param obj the node to close recursively, omit to close all nodes in the tree + * @param animation the animation duration in milliseconds when closing the nodes, the default is no animation + */ + close_all: (obj?: any, animation?: number) => void; + /** + * checks if a node is disabled (not selectable) + */ + is_disabled: (obj: any) => boolean; + /** + * enables a node - so that it can be selected + */ + enable_node: (obj: any) => boolean; + /** + * disables a node - so that it can not be selected + */ + disable_node: (obj: any) => boolean; + /** + * select a node + * @param obj an array can be used to select multiple nodes + * @param supress_event if set to `true` the `changed.jstree` event won't be triggered + * @param prevent_open if set to `true` parents of the selected node won't be opened + */ + select_node: (obj: any, supress_event?: boolean, prevent_open?: boolean) => void; + /** + * deselect a node + * @param obj an array can be used to deselect multiple nodes + * @param supress_event if set to `true` the `changed.jstree` event won't be triggered + */ + deselect_node: (obj: any, supress_event?: boolean) => void; + /** + * select all nodes in the tree + * @param supress_event if set to `true` the `changed.jstree` event won't be triggered + */ + select_all: (supress_event?: boolean) => void; + /** + * deselect all selected nodes + * @param supress_event if set to `true` the `changed.jstree` event won't be triggered + */ + deselect_all: (supress_event?: boolean) => void; + /** + * checks if a node is selected + */ + is_selected: (obj: any) => boolean; + /** + * get an array of all selected node IDs + * @param full if set to `true` the returned array will consist of the full node objects, + * otherwise - only IDs will be returned + */ + get_selected: (full?: any) => string[]; + /** + * refreshes the tree - all nodes are reloaded with calls to load_node. + */ + refresh: () => void; + /** + * set (change) the ID of a node + * @param obj the node + * @param id the new ID + */ + set_id: (obj: any, id: string) => void; + /** + * get the text value of a node + */ + get_text: (obj: any) => string; + /** + * gets a JSON representation of a node (or the whole tree) + */ + get_json: (obj?: any, options?: JSTreeGetJsonOptions) => any; + /** + * create a new node (do not confuse with load_node) + * @param obj the parent node + * @param node the data for the new node (a valid JSON object, or a simple string with the name) + * @param pos the index at which to insert the node, "first" and "last" are also supported, default is "last" + * @param callback a function to be called once the node is created + * @param is_loaded internal argument indicating if the parent node was succesfully loaded + * @returns the ID of the newly create node + */ + create_node: (obj?: any, node?: any, pos?: any, callback?: any, is_loaded?: boolean) => string; + /** + * set the text value of a node + * @param obj the node, you can pass an array to rename multiple nodes to the same name + * @param val the new text value + */ + rename_node: (obj: any, val: string) => boolean; + /** + * remove a node + * @param obj the node, you can pass an array to delete multiple nodes + */ + delete_node: (obj: any) => boolean; + /** + * move a node to a new parent + * @param obj the node to move, pass an array to move multiple nodes + * @param par the new parent + * @param pos the position to insert at ("first" and "last" are supported, as well as "before" and "after"), defaults to `0` + * @param callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position + * @param internal parameter indicating if the parent node has been loaded + */ + move_node: (obj: any, par: any, pos?: any, callback?: any, internal?: boolean) => void; + /** + * copy a node to a new parent + * @param obj the node to copy, pass an array to copy multiple nodes + * @param par the new parent + * @param pos the position to insert at ("first" and "last" are supported, as well as "before" and "after"), defaults to `0` + * @param callback a function to call once the move is completed, receives 3 arguments - the node, the new parent and the position + * @param internal parameter indicating if the parent node has been loaded + */ + copy_node: (obj: any, par: any, pos?: any, callback?: any, internal?: boolean) => void; + /** + * cut a node (a later call to paste(obj) would move the node) + * @param obj multiple objects can be passed using an array + */ + cut: (obj: any) => void; + /** + * copy a node (a later call to paste(obj) would copy the node) + * @param obj multiple objects can be passed using an array + */ + copy: (obj: any) => void; + /** + * get the current buffer (any nodes that are waiting for a paste operation) + * @returns an object consisting of `mode` ("copy_node" or "move_node"), + * `node` (an array of objects) and `inst` (the instance) + */ + get_buffer: () => any; + /** + * check if there is something in the buffer to paste + */ + can_paste: () => boolean; + /** + * copy or move the previously cut or copied nodes to a new parent + * @param obj the new parent + */ + paste: (obj: any) => void; + /** + * put a node in edit mode (input field to rename the node) + * @param obj + * @param default_text the text to populate the input with (if omitted the node text value is used) + */ + edit: (obj: any, default_text?: string) => void; + /** + * changes the theme + * @param theme_name the name of the new theme to apply + * @param theme_url the location of the CSS file for this theme. + * Omit or set to `false` if you manually included the file. + * Set to `true` to autoload from the `core.themes.dir` directory. + */ + set_theme: (theme_name: string, theme_url?: any) => void; + /** + * gets the name of the currently applied theme name + */ + get_theme: () => string; + /** + * changes the theme variant (if the theme has variants) + * @param variant_name the variant to apply (if `false` is used the current variant is removed) + */ + set_theme_variant: (variant_name: any) => void; + /** + * gets the name of the currently applied theme variant name + */ + get_theme_variant: () => string; + /** + * shows a striped background on the container (if the theme supports it) + */ + show_stripes: () => void; + /** + * hides the striped background on the container + */ + hide_stripes: () => void; + /** + * toggles the striped background on the container + */ + toggle_stripes: () => void; + /** + * shows the connecting dots (if the theme supports it) + */ + show_dots: () => void; + /** + * hides the connecting dots + */ + hide_dots: () => void; + /** + * toggles the connecting dots + */ + toggle_dots: () => void; + /** + * show the node icons + */ + show_icons: () => void; + /** + * hide the node icons + */ + hide_icons: () => void; + /** + * toggle the node icons + */ + toggle_icons: () => void; + /** + * set the node icon for a node + * @param obj + * @param icon the new icon - can be a path to an icon or a className, + * if using an image that is in the current directory use a `./` prefix, + * otherwise it will be detected as a class + */ + set_icon: (obj: any, icon: string) => void; + /** + * get the node icon for a node + */ + get_icon: (obj: any) => string; + /** + * hide the icon on an individual node + */ + hide_icon: (obj: any) => void; + /** + * show the icon on an individual node + */ + show_icon: (obj: any) => void; + /* + * checkbox plugin: show the node checkbox icons + */ + show_checkboxes: () => void; + /* + * checkbox plugin: hide the node checkbox icons + */ + hide_checkboxes: () => void; + /* + * checkbox plugin: toggle the node icons + */ + toggle_checkboxes: () => void; + /** + * context menu plugin: show the context menu for a node + * @param obj the node + * @param x the x-coordinate relative to the document to show the menu at + * @param y the y-coordinate relative to the document to show the menu at + */ + show_contextmenu: (obj: any, x?: number, y?: number) => void; + /** + * search plugin: used to search the tree nodes for a given string + * @param str the search string + * @param skip_async if set to true server will not be queried even if configured + */ + search: (str: string, skip_async?: boolean) => void; + /** + * search plugin: used to clear the last search (removes classes and shows all nodes if filtering is on) + */ + clear_search: () => void; + /** + * state plugin: save the state + */ + save_state: () => void; + /** + * state plugin: restore the state from the user's computer + */ + restore_state: () => void; + /** + * state plugin: clear the state on the user's computer + */ + clear_state: () => void; + /** + * types plugin: used to retrieve the type settings object for a node + * @param obj the node to find the rules for + */ + get_rules: (obj: any) => any; + /** + * types plugin: used to retrieve the type string or settings object for a node + * @param obj the node to find the rules for + * @param rules if set to `true` instead of a string the settings object will be returned + */ + get_type: (obj: any, rules?: any) => any; + /** + * types plugin: used to change a node's type + * @param obj the node to change + * @param type the new type + */ + set_type: (obj: any, type: string) => any; + //bind(eventType: string, handler?: (event: any, data: JSTreeBindOptions) => any): JSTree; +} + +interface JSTreeGetJsonOptions { + /** + * do not return state information + */ + no_state: boolean; + /** + * do not return ID + */ + no_id: boolean; + /** + * do not include children + */ + no_children: boolean; +} + +interface JSTreeBindOptions { + inst?: any; + args?: any; + rslt?: any; + rlbk?: any; +} \ No newline at end of file From c4d0c9a5515c036e60e3809b4327eadf4056c643 Mon Sep 17 00:00:00 2001 From: "Omid K. Rad" Date: Thu, 24 Apr 2014 17:45:31 -0700 Subject: [PATCH 116/225] Backbone Generics --- backbone-relational/backbone-relational.d.ts | 25 +- backbone/backbone-tests.ts | 157 +++++++----- backbone/backbone.d.ts | 248 ++++++++++--------- backgrid/backgrid-tests.ts | 6 +- backgrid/backgrid.d.ts | 20 +- giraffe/giraffe-tests.ts | 12 +- giraffe/giraffe.d.ts | 75 +++--- jointjs/jointjs.d.ts | 14 +- knockback/knockback.d.ts | 6 +- marionette/marionette.d.ts | 164 ++++++------ 10 files changed, 395 insertions(+), 332 deletions(-) diff --git a/backbone-relational/backbone-relational.d.ts b/backbone-relational/backbone-relational.d.ts index 56dd2e9e83..4f4aa45cc6 100644 --- a/backbone-relational/backbone-relational.d.ts +++ b/backbone-relational/backbone-relational.d.ts @@ -5,12 +5,15 @@ /// - /// declare module Backbone { - export class RelationalModel extends Model { - static extend(properties:any, classProperties?:any):any; // do not use, prefer TypeScript's extend functionality + class RelationalModel extends Model { + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + //private static extend(properties:any, classProperties?:any):any; + relations:any; subModelTypes:any; subModelTypeAttribute:any; @@ -58,7 +61,7 @@ declare module Backbone { setRelated(related:Model):void; - setRelated(related:Collection):void; + setRelated(related:Collection):void; getReverseRelations(model:RelationalModel):Relation; @@ -78,15 +81,15 @@ declare module Backbone { setKeyContents(keyContents:number[]):void; - setKeyContents(keyContents:Collection):void; + setKeyContents(keyContents:Collection):void; onChange(model:Model, attr:any, options:any):void; - handleAddition(model:Model, coll:Collection, options:any):void; + handleAddition(model:Model, coll:Collection, options:any):void; - handleRemoval(model:Model, coll:Collection, options:any):void; + handleRemoval(model:Model, coll:Collection, options:any):void; - handleReset(coll:Collection, options:any):void; + handleReset(coll:Collection, options:any):void; tryAddRelated(model:Model, coll:any, options:any):void; @@ -135,9 +138,9 @@ declare module Backbone { processOrphanRelations():void; - retroFitRelation(relation:RelationalModel, create:boolean):Collection; + retroFitRelation(relation:RelationalModel, create:boolean):Collection; - getCollection(type:RelationalModel, create:boolean):Collection; + getCollection(type:RelationalModel, create:boolean):Collection; getObjectByName(name:string):any; @@ -158,7 +161,7 @@ declare module Backbone { update(model:RelationalModel):void; - unregister(model:RelationalModel, collection:Collection, options:any):void; + unregister(model:RelationalModel, collection:Collection, options:any):void; reset():void; diff --git a/backbone/backbone-tests.ts b/backbone/backbone-tests.ts index c1292c1c25..bf44c56f77 100644 --- a/backbone/backbone-tests.ts +++ b/backbone/backbone-tests.ts @@ -4,7 +4,7 @@ function test_events() { var object = new Backbone.Events(); - object.on("alert", (msg) => alert("Triggered " + msg)); + object.on("alert", (eventName: string) => alert("Triggered " + eventName)); object.trigger("alert", "an event"); @@ -18,48 +18,74 @@ function test_events() { object.off(); } +class SettingDefaults extends Backbone.Model { + + // 'defaults' could be set in one of the following ways: + + defaults() { + return { + name: "Joe" + } + } + + constructor(attributes?: any, options?: any) { + this.defaults = { + name: "Joe" + } + // super has to come last + super(attributes, options); + } + + // or set it like this + initialize() { + this.defaults = { + name: "Joe" + } + + } + + // same patterns could be used for setting 'Router.routes' and 'View.events' +} + +class Sidebar extends Backbone.Model { + + promptColor() { + var cssColor = prompt("Please enter a CSS color:"); + this.set({ color: cssColor }); + } +} + +class Note extends Backbone.Model { + initialize() { } + author() { } + coordinates() { } + allowedToEdit(account: any) { + return true; + } +} + +class PrivateNote extends Note { + allowedToEdit(account: any) { + return account.owns(this); + } + + set(attributes: any, options?: any): Backbone.Model { + return Backbone.Model.prototype.set.call(this, attributes, options); + } +} + function test_models() { - var Sidebar = Backbone.Model.extend({ - promptColor: function () { - var cssColor = prompt("Please enter a CSS color:"); - this.set({ color: cssColor }); - } - }); - var sidebar = new Sidebar(); - sidebar.on('change:color', (model, color) => $('#sidebar').css({ background: color })); + sidebar.on('change:color', (model: {}, color: string) => $('#sidebar').css({ background: color })); sidebar.set({ color: 'white' }); sidebar.promptColor(); - //////// - - var Note = Backbone.Model.extend({ - initialize: () => { }, - author: () => { }, - coordinates: () => { }, - allowedToEdit: (account) => { - return true; - } - }); - - var PrivateNote = Note.extend({ - - allowedToEdit: function (account) { - return account.owns(this); - } - - }); - ////////// - var note = Backbone.Model.extend({ - set: function (attributes, options) { - Backbone.Model.prototype.set.call(this, attributes, options); - } - }); + var note = new PrivateNote(); - note.get("title") + note.get("title"); note.set({ title: "March 20", content: "In his eyes she eclipses..." }); @@ -69,7 +95,7 @@ function test_models() { class Employee extends Backbone.Model { reports: EmployeeCollection; - constructor (options? ) { + constructor(attributes?: any, options?: any) { super(options); this.reports = new EmployeeCollection(); this.reports.url = '../api/employees/' + this.id + '/reports'; @@ -80,29 +106,38 @@ class Employee extends Backbone.Model { } } -class EmployeeCollection extends Backbone.Collection { - findByName(key) { } +class EmployeeCollection extends Backbone.Collection { + findByName(key: any) { } } + +class Book extends Backbone.Model { + title: string; + author: string; +} + +class Library extends Backbone.Collection { + model: typeof Book; +} + +class Books extends Backbone.Collection { } + function test_collection() { - var Book: Backbone.Model; - var Library = Backbone.Collection.extend({ - model: Book + + var books = new Library(); + + books.each(book => { + book.get("title"); }); - var Books: Backbone.Collection; - - Books.each(function (book) { - }); - - var titles = Books.map(function (book) { + var titles = books.map(book => { return book.get("title"); }); - var publishedBooks = Books.filter(function (book) { + var publishedBooks = books.filter(book => { return book.get("published") === true; }); - var alphabetical = Books.sortBy(function (book) { + var alphabetical = books.sortBy((book: Book): number => { return null; }); } @@ -121,26 +156,26 @@ module v1Changes { function test_listenTo() { var model = new Employee; - var view = new Backbone.View; + var view = new Backbone.View(); view.listenTo(model, 'invalid', () => { }); } function test_listenToOnce() { var model = new Employee; - var view = new Backbone.View; + var view = new Backbone.View(); view.listenToOnce(model, 'invalid', () => { }); } function test_stopListening() { var model = new Employee; - var view = new Backbone.View; + var view = new Backbone.View(); view.stopListening(model, 'invalid', () => { }); view.stopListening(model, 'invalid'); view.stopListening(model); } } - module modelandcollection { + module ModelAndCollection { function test_url() { Employee.prototype.url = () => '/employees'; EmployeeCollection.prototype.url = () => '/employees'; @@ -168,7 +203,7 @@ module v1Changes { } } - module model { + module Model { function test_validationError() { var model = new Employee; if (model.validationError) { @@ -195,17 +230,17 @@ module v1Changes { model.destroy({ wait: true, success: (m?, response?, options?) => { }, - error: (m?, jqxhr?: JQueryXHR, options?) => { } + error: (m?, jqxhr?, options?) => { } }); model.destroy({ success: (m?, response?, options?) => { }, - error: (m?, jqxhr?: JQueryXHR) => { } + error: (m?, jqxhr?) => { } }); model.destroy({ success: () => { }, - error: (m?, jqxhr?: JQueryXHR) => { } + error: (m?, jqxhr?) => { } }); } @@ -220,7 +255,7 @@ module v1Changes { wait: true, validate: false, success: (m?, response?, options?) => { }, - error: (m?, jqxhr?: JQueryXHR, options?) => { } + error: (m?, jqxhr?, options?) => { } }); model.save({ @@ -229,7 +264,7 @@ module v1Changes { }, { success: () => { }, - error: (m?, jqxhr?: JQueryXHR) => { } + error: (m?, jqxhr?) => { } }); } @@ -240,7 +275,7 @@ module v1Changes { } } - module collection { + module Collection { function test_fetch() { var collection = new EmployeeCollection; collection.fetch({ reset: true }); @@ -256,7 +291,7 @@ module v1Changes { } } - module router { + module Router { function test_navigate() { var router = new Backbone.Router; @@ -264,4 +299,4 @@ module v1Changes { router.navigate('/employees', true); } } -} \ No newline at end of file +} diff --git a/backbone/backbone.d.ts b/backbone/backbone.d.ts index d94e9172bf..6fa7e6d608 100644 --- a/backbone/backbone.d.ts +++ b/backbone/backbone.d.ts @@ -6,6 +6,7 @@ /// +/// declare module Backbone { @@ -67,7 +68,7 @@ declare module Backbone { } class Events { - on(eventName: any, callback?: Function, context?: any): any; + on(eventName: string, callback?: Function, context?: any): any; off(eventName?: string, callback?: Function, context?: any): any; trigger(eventName: string, ...args: any[]): any; bind(eventName: string, callback: Function, context?: any): any; @@ -86,17 +87,22 @@ declare module Backbone { sync(...arg: any[]): JQueryXHR; } - interface OptionalDefaults { - defaults?(): any; - } + class Model extends ModelBase { - class Model extends ModelBase implements OptionalDefaults { - - static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; attributes: any; changed: any[]; cid: string; + /** + * Default attributes for the model. It can be an object hash or a method returning an object hash. + * For assigning an object hash, do it like this: this.defaults = { attribute: value, ... }; + * That works only if you set it in the constructor or the initialize method. + **/ + defaults(): any; id: any; idAttribute: string; validationError: any; @@ -127,7 +133,7 @@ declare module Backbone { unset(attribute: string, options?: Silenceable): Model; validate(attributes: any, options?: any): any; - _validate(attrs: any, options: any): boolean; + private _validate(attrs: any, options: any): boolean; // mixins from underscore @@ -141,115 +147,125 @@ declare module Backbone { omit(...keys: string[]): any; } - class Collection extends ModelBase { + class Collection extends ModelBase { - static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; - model: any; - models: any; - collection: Model; + // TODO: this really has to be typeof TModel + //model: typeof TModel; + model: { new(): TModel; }; // workaround + models: TModel[]; + collection: TModel; length: number; - constructor(models?: any, options?: any); + constructor(models?: TModel[], options?: any); fetch(options?: CollectionFetchOptions): JQueryXHR; - comparator(element: Model): any; - comparator(compare: Model, to?: Model): any; + comparator(element: TModel): number; + comparator(compare: TModel, to?: TModel): number; - add(model: Model, options?: AddOptions): Collection; - add(model: any, options?: AddOptions): Collection; - add(models: Model[], options?: AddOptions): Collection; - add(models: any[], options?: AddOptions): Collection; - at(index: number): Model; - get(id: any): Model; - create(attributes: any, options?: ModelSaveOptions): Model; + add(model: TModel, options?: AddOptions): Collection; + add(models: TModel[], options?: AddOptions): Collection; + at(index: number): TModel; + get(id: string): TModel; + create(attributes: any, options?: ModelSaveOptions): TModel; pluck(attribute: string): any[]; - push(model: Model, options?: AddOptions): Model; - pop(options?: Silenceable): Model; - remove(model: Model, options?: Silenceable): Model; - remove(models: Model[], options?: Silenceable): Model[]; - reset(models?: Model[], options?: Silenceable): Model[]; - reset(models?: any[], options?: Silenceable): Model[]; - set(models?: any[], options?: Silenceable): Model[]; - shift(options?: Silenceable): Model; - sort(options?: Silenceable): Collection; - unshift(model: Model, options?: AddOptions): Model; - where(properies: any): Model[]; - findWhere(properties: any): Model; + push(model: TModel, options?: AddOptions): TModel; + pop(options?: Silenceable): TModel; + remove(model: TModel, options?: Silenceable): TModel; + remove(models: TModel[], options?: Silenceable): TModel[]; + reset(models?: TModel[], options?: Silenceable): TModel[]; + set(models?: TModel[], options?: Silenceable): TModel[]; + shift(options?: Silenceable): TModel; + sort(options?: Silenceable): Collection; + unshift(model: TModel, options?: AddOptions): TModel; + where(properies: any): TModel[]; + findWhere(properties: any): TModel; - _prepareModel(attrs?: any, options?: any): any; - _removeReference(model: Model): void; - _onModelEvent(event: string, model: Model, collection: Collection, options: any): void; + private _prepareModel(attrs?: any, options?: any): any; + private _removeReference(model: TModel): void; + private _onModelEvent(event: string, model: TModel, collection: Collection, options: any): void; // mixins from underscore - all(iterator: (element: Model, index: number) => boolean, context?: any): boolean; - any(iterator: (element: Model, index: number) => boolean, context?: any): boolean; - collect(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[]; + all(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; + any(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; + collect(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[]; chain(): any; - compact(): Model[]; + compact(): TModel[]; contains(value: any): boolean; - countBy(iterator: (element: Model, index: number) => any): any[]; - countBy(attribute: string): any[]; + countBy(iterator: (element: TModel, index: number) => any): _.Dictionary; + countBy(attribute: string): _.Dictionary; detect(iterator: (item: any) => boolean, context?: any): any; // ??? - difference(...model: Model[]): Model[]; - drop(): Model; - drop(n: number): Model[]; - each(iterator: (element: Model, index: number, list?: any) => void , context?: any): any; - every(iterator: (element: Model, index: number) => boolean, context?: any): boolean; - filter(iterator: (element: Model, index: number) => boolean, context?: any): Model[]; - find(iterator: (element: Model, index: number) => boolean, context?: any): Model; - first(): Model; - first(n: number): Model[]; - flatten(shallow?: boolean): Model[]; - foldl(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any; - forEach(iterator: (element: Model, index: number, list?: any) => void , context?: any): any; + difference(...model: TModel[]): TModel[]; + drop(): TModel; + drop(n: number): TModel[]; + each(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any; + every(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; + filter(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[]; + find(iterator: (element: TModel, index: number) => boolean, context?: any): TModel; + first(): TModel; + first(n: number): TModel[]; + flatten(shallow?: boolean): TModel[]; + foldl(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; + forEach(iterator: (element: TModel, index: number, list?: any) => void, context?: any): any; + groupBy(iterator: (element: TModel, index: number) => string, context?: any): _.Dictionary; + groupBy(attribute: string, context?: any): _.Dictionary; include(value: any): boolean; - indexOf(element: Model, isSorted?: boolean): number; - initial(): Model; - initial(n: number): Model[]; - inject(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any; - intersection(...model: Model[]): Model[]; + indexOf(element: TModel, isSorted?: boolean): number; + initial(): TModel; + initial(n: number): TModel[]; + inject(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; + intersection(...model: TModel[]): TModel[]; isEmpty(object: any): boolean; invoke(methodName: string, arguments?: any[]): any; - last(): Model; - last(n: number): Model[]; - lastIndexOf(element: Model, fromIndex?: number): number; - map(iterator: (element: Model, index: number, context?: any) => any[], context?: any): any[]; - max(iterator?: (element: Model, index: number) => any, context?: any): Model; - min(iterator?: (element: Model, index: number) => any, context?: any): Model; + last(): TModel; + last(n: number): TModel[]; + lastIndexOf(element: TModel, fromIndex?: number): number; + map(iterator: (element: TModel, index: number, context?: any) => any[], context?: any): any[]; + max(iterator?: (element: TModel, index: number) => any, context?: any): TModel; + min(iterator?: (element: TModel, index: number) => any, context?: any): TModel; object(...values: any[]): any[]; - reduce(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any; + reduce(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any; select(iterator: any, context?: any): any[]; size(): number; shuffle(): any[]; - some(iterator: (element: Model, index: number) => boolean, context?: any): boolean; - sortBy(iterator: (element: Model, index: number) => number, context?: any): Model[]; - sortBy(attribute: string, context?: any): Model[]; - sortedIndex(element: Model, iterator?: (element: Model, index: number) => number): number; + some(iterator: (element: TModel, index: number) => boolean, context?: any): boolean; + sortBy(iterator: (element: TModel, index: number) => number, context?: any): TModel[]; + sortBy(attribute: string, context?: any): TModel[]; + sortedIndex(element: TModel, iterator?: (element: TModel, index: number) => number): number; range(stop: number, step?: number): any; range(start: number, stop: number, step?: number): any; - reduceRight(iterator: (memo: any, element: Model, index: number) => any, initialMemo: any, context?: any): any[]; - reject(iterator: (element: Model, index: number) => boolean, context?: any): Model[]; - rest(): Model; - rest(n: number): Model[]; - tail(): Model; - tail(n: number): Model[]; + reduceRight(iterator: (memo: any, element: TModel, index: number) => any, initialMemo: any, context?: any): any[]; + reject(iterator: (element: TModel, index: number) => boolean, context?: any): TModel[]; + rest(): TModel; + rest(n: number): TModel[]; + tail(): TModel; + tail(n: number): TModel[]; toArray(): any[]; - union(...model: Model[]): Model[]; - uniq(isSorted?: boolean, iterator?: (element: Model, index: number) => boolean): Model[]; - without(...values: any[]): Model[]; - zip(...model: Model[]): Model[]; + union(...model: TModel[]): TModel[]; + uniq(isSorted?: boolean, iterator?: (element: TModel, index: number) => boolean): TModel[]; + without(...values: any[]): TModel[]; + zip(...model: TModel[]): TModel[]; } - interface OptionalRoutes { - routes?(): any; - } + class Router extends Events { - class Router extends Events implements OptionalRoutes { + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; - static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality + /** + * Routes hash or a method returning the routes hash that maps URLs with parameters to methods on your Router. + * For assigning routes as object hash, do it like this: this.routes = { "route": callback, ... }; + * That works only if you set it in the constructor or the initialize method. + **/ + routes(): any; constructor(options?: RouterOptions); initialize(options?: RouterOptions): void; @@ -257,9 +273,9 @@ declare module Backbone { navigate(fragment: string, options?: NavigateOptions): Router; navigate(fragment: string, trigger?: boolean): Router; - _bindRoutes(): void; - _routeToRegExp(route: string): RegExp; - _extractParameters(route: RegExp, fragment: string): string[]; + private _bindRoutes(): void; + private _routeToRegExp(route: string): RegExp; + private _extractParameters(route: RegExp, fragment: string): string[]; } var history: History; @@ -279,14 +295,14 @@ declare module Backbone { loadUrl(fragmentOverride: string): boolean; navigate(fragment: string, options?: any): boolean; started: boolean; - options: any; - - _updateHash(location: Location, fragment: string, replace: boolean): void; + options: any; + + private _updateHash(location: Location, fragment: string, replace: boolean): void; } - interface ViewOptions { - model?: Backbone.Model; - collection?: Backbone.Collection; + interface ViewOptions { + model?: TModel; + collection?: Backbone.Collection; el?: any; id?: string; className?: string; @@ -294,35 +310,41 @@ declare module Backbone { attributes?: any[]; } - interface OptionalEvents { - events?(): any; - } + class View extends Events { - class View extends Events implements OptionalEvents { + /** + * Do not use, prefer TypeScript's extend functionality. + **/ + private static extend(properties: any, classProperties?: any): any; - static extend(properties: any, classProperties?: any): any; // do not use, prefer TypeScript's extend functionality + constructor(options?: ViewOptions); - constructor(options?: ViewOptions); + /** + * Events hash or a method returning the events hash that maps events/selectors to methods on your View. + * For assigning events as object hash, do it like this: this.events = { "event:selector": callback, ... }; + * That works only if you set it in the constructor or the initialize method. + **/ + events(): any; $(selector: string): JQuery; - model: Model; - collection: Collection; - make(tagName: string, attrs?: any, opts?: any): View; - setElement(element: HTMLElement, delegate?: boolean): View; - setElement(element: JQuery, delegate?: boolean): View; + model: TModel; + collection: Collection; + //template: (json, options?) => string; + make(tagName: string, attrs?: any, opts?: any): View; + setElement(element: HTMLElement, delegate?: boolean): View; + setElement(element: JQuery, delegate?: boolean): View; id: string; cid: string; className: string; tagName: string; - options: any; el: any; $el: JQuery; - setElement(element: any): View; + setElement(element: any): View; attributes: any; $(selector: any): JQuery; - render(): View; - remove(): View; + render(): View; + remove(): View; make(tagName: any, attributes?: any, content?: any): any; delegateEvents(events?: any): any; undelegateEvents(): any; @@ -333,14 +355,12 @@ declare module Backbone { // SYNC function sync(method: string, model: Model, options?: JQueryAjaxSettings): any; function ajax(options?: JQueryAjaxSettings): JQueryXHR; - var emulateHTTP: boolean; + var emulateHTTP: boolean; var emulateJSONBackbone: boolean; // Utility function noConflict(): typeof Backbone; function setDomLibrary(jQueryNew: any): any; - - var $: JQueryStatic; } declare module "backbone" { diff --git a/backgrid/backgrid-tests.ts b/backgrid/backgrid-tests.ts index 0c681a1d34..a29a4ae7e6 100644 --- a/backgrid/backgrid-tests.ts +++ b/backgrid/backgrid-tests.ts @@ -23,7 +23,7 @@ class TestModel extends Backbone.Model { } -class TestCollection extends Backbone.Collection { +class TestCollection extends Backbone.Collection { constructor(models?: any, options?: any) { this.model = TestModel; @@ -41,11 +41,11 @@ class TestCollection extends Backbone.Collection { } } -class TestView extends Backbone.View { +class TestView extends Backbone.View { gridView: Backgrid.Grid; testCollection: TestCollection; - constructor(viewOptions?: Backbone.ViewOptions) { + constructor(viewOptions?: Backbone.ViewOptions) { this.testCollection = new TestCollection(); this.gridView = new Backgrid.Grid({ columns: [new Backgrid.Column({name: "FirstName", cell: "string", label: "First Name"}), diff --git a/backgrid/backgrid.d.ts b/backgrid/backgrid.d.ts index 73cb12450e..fcae05d800 100644 --- a/backgrid/backgrid.d.ts +++ b/backgrid/backgrid.d.ts @@ -9,20 +9,20 @@ declare module Backgrid { interface GridOptions { columns: Column[]; - collection: Backbone.Collection; + collection: Backbone.Collection; header: Header; body: Body; row: Row; footer: Footer; } - class Header extends Backbone.View { + class Header extends Backbone.View { } - class Footer extends Backbone.View { + class Footer extends Backbone.View { } - class Row extends Backbone.View { + class Row extends Backbone.View { } class Command { @@ -50,19 +50,19 @@ declare module Backgrid { initialize(options?: any); } - class Body extends Backbone.View { + class Body extends Backbone.View { tagName: string; initialize(options?: any); - insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any); + insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any); moveToNextCell(model: Backbone.Model, cell: Column, command: Command); refresh(): Body; remove(): Body; - removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any); + removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any); render(): Body; } - class Grid extends Backbone.View { + class Grid extends Backbone.View { body: Backgrid.Body; className: string; footer: any; @@ -72,10 +72,10 @@ declare module Backgrid { initialize(options: any); getSelectedModels(): Backbone.Model[]; insertColumn(...options: any[]): Grid; - insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any); + insertRow(model: Backbone.Model, collection: Backbone.Collection, options: any); remove():Grid; removeColumn(...options: any[]): Grid; - removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any); + removeRow(model: Backbone.Model, collection: Backbone.Collection, options: any); render():Grid; } diff --git a/giraffe/giraffe-tests.ts b/giraffe/giraffe-tests.ts index 70365bb59b..4cd6694da2 100644 --- a/giraffe/giraffe-tests.ts +++ b/giraffe/giraffe-tests.ts @@ -3,13 +3,13 @@ class User extends Giraffe.Model { } -class MainView extends Giraffe.View { +class MainView extends Giraffe.View { constructor(options?) { this.appEvents = { 'startup': 'app_onStartup' - } - super(options) + } + super(options); } app_onStartup() { @@ -23,15 +23,15 @@ class MyApp extends Giraffe.App { this.routes= { '': 'home' } - super() + super(); } home() { - this.attach( new MainView ) + this.attach(new MainView); } } var app= new MyApp(); -app.start(); \ No newline at end of file +app.start(); diff --git a/giraffe/giraffe.d.ts b/giraffe/giraffe.d.ts index 24c41aa243..9987548980 100644 --- a/giraffe/giraffe.d.ts +++ b/giraffe/giraffe.d.ts @@ -38,8 +38,8 @@ declare module Giraffe { interface AppMap { [ cid:string ]: App; } - interface ViewMap { - [ cid:string ]: View; + interface ViewMap { + [ cid:string ]: View; } interface StringMap { [ def:string ]: string; @@ -49,7 +49,7 @@ declare module Giraffe { var apps: AppMap; var defaultOptions: DefaultOptions; var version: string; - var views: ViewMap; + var views: ViewMap; function bindAppEvents( instance:GiraffeObject ): GiraffeObject; function bindDataEvents( instance:GiraffeObject ): GiraffeObject; @@ -64,9 +64,10 @@ declare module Giraffe { function wrapFn( obj:any, name:string, before:Function, after:Function); - class Collection extends Backbone.Collection implements GiraffeObject { + class Collection extends Backbone.Collection implements GiraffeObject { app: App; - model: Model; + //model: typeof TModel; + model: { new (): TModel; }; // workaround } class Model extends Backbone.Model implements GiraffeObject { @@ -85,46 +86,46 @@ declare module Giraffe { reload( url:string ); } - class View extends Backbone.View implements GiraffeObject { + class View extends Backbone.View implements GiraffeObject { app: App; appEvents: StringMap; - children: View[]; + children: View[]; dataEvents: StringMap; defaultOptions: DefaultOptions; documentTitle: string; - parent: View; + parent: View; template: any; ui: StringMap; - attachTo( el:any, options?:AttachmentOptions ): View; - attach( view:View, options?:AttachmentOptions ): View; + attachTo( el:any, options?:AttachmentOptions ): View; + attach( view:View, options?:AttachmentOptions ): View; isAttached( el:any ): boolean; - render( options?:any ): View; + render( options?:any ): View; beforeRender(); afterRender(); templateStrategy(): string; serialize(): any; - setParent( parent:View ): View; + setParent( parent:View ): View; - addChild( child:View ): View; - addChildren( children:View[] ): View; - removeChild( child:View, preserve?:boolean ): View; - removeChildren( preserve?:boolean ): View; + addChild( child:View ): View; + addChildren( children:View[] ): View; + removeChild( child:View, preserve?:boolean ): View; + removeChildren( preserve?:boolean ): View; - detach( preserve?:boolean ): View; - detachChildren( preserve?:boolean ): View; + detach( preserve?:boolean ): View; + detachChildren( preserve?:boolean ): View; invoke( method:string, ...args:any[] ); - dispose(): View; - beforeDispose(): View; - afterDispose(): View; + dispose(): View; + beforeDispose(): View; + afterDispose(): View; - static detachByElement( el:any, preserve?:boolean ): View; - static getClosestView( el:any ): View; - static getByCid( cid:string ): View; + static detachByElement( el:any, preserve?:boolean ): View; + static getClosestView( el:any ): View; + static getByCid( cid:string ): View; static to$El( el:any, parent?:any, allowParentMatch?:boolean ): JQuery; static setDocumentEvents( events:string[], prefix?:string ): string[]; static removeDocumentEvents( prefix?:string ); @@ -132,7 +133,7 @@ declare module Giraffe { static setTemplateStrategy( strategy:any, instance?:any ); } - class App extends View { + class App extends View { routes: StringMap; addInitializer( initializer:( options?:any, callback?:()=>void )=>void ): App; @@ -146,23 +147,23 @@ declare module Giraffe { app: App; } - class CollectionView extends View { + class CollectionView extends View { - collection: Collection; - modelView: View; + collection: Collection; + modelView: View; modelViewArgs: any[]; modelViewEl: any; renderOnChange: boolean; - findByModel( model:Model ): View; - addOne( model:Model ): View; - removeOne( model:Model ): View; + findByModel( model:Model ): View; + addOne( model:Model ): View; + removeOne( model:Model ): View; static getDefaults( ctx:any ): any; } - class FastCollectionView extends View { - collection: Collection; + class FastCollectionView extends View { + collection: Collection; modelTemplate: any; modelTemplateStrategy: string; modelEl: any; @@ -170,11 +171,11 @@ declare module Giraffe { modelSerialize(): any; - addAll(): View; - addOne( model:Model ): View; - removeOne( model:Model ): View; + addAll(): View; + addOne( model:Model ): View; + removeOne( model:Model ): View; - removeByIndex( index:number ): View; + removeByIndex( index:number ): View; findElByModel( model:Model ): JQuery; findElByIndex( index:number ): JQuery; findModelByEl( el:any ): Model; diff --git a/jointjs/jointjs.d.ts b/jointjs/jointjs.d.ts index f4e0926ea7..c2ff9c1c75 100644 --- a/jointjs/jointjs.d.ts +++ b/jointjs/jointjs.d.ts @@ -38,20 +38,19 @@ declare module joint { attr(attrs: any): Cell; } - - class Element extends Cell { position(x: number, y: number): Element; translate(tx: number, ty?: number): Element; resize(width: number, height: number): Element; rotate(angle: number, absolute): Element; } + interface IDefaults { type: string; } class Link extends Cell { - defaults: IDefaults; + defaults(): IDefaults; disconnect(): Link; label(idx?: number, value?: any): any; // @todo: returns either a label under idx or Link if both idx and value were passed } @@ -65,7 +64,7 @@ declare module joint { linkView: LinkView; } - class Paper extends Backbone.View { + class Paper extends Backbone.View { options: IOptions; setDimensions(width: number, height: number); scale(sx: number, sy?: number, ox?: number, oy?: number): Paper; @@ -80,7 +79,8 @@ declare module joint { class ElementView extends CellView { scale(sx: number, sy: number); } - class CellView extends Backbone.View { + + class CellView extends Backbone.View { getBBox(): { x: number; y: number; width: number; height: number; }; highlight(el?: any); unhighlight(el?: any); @@ -94,7 +94,9 @@ declare module joint { } } + module ui { } + module shapes { module basic { class Generic extends joint.dia.Element { } @@ -104,6 +106,7 @@ declare module joint { class Image extends Generic { } } } + module util { function uuid(): string; function guid(obj: any): string; @@ -112,4 +115,5 @@ declare module joint { function deepMixin(objects: any[]): any; function deepSupplement(objects: any[], defaultIndicator?: any): any; } + } diff --git a/knockback/knockback.d.ts b/knockback/knockback.d.ts index 50848e6841..71773ab92b 100644 --- a/knockback/knockback.d.ts +++ b/knockback/knockback.d.ts @@ -126,8 +126,8 @@ declare module Knockback { } interface CollectionObservable extends KnockoutObservableArray { - collection(colleciton: Backbone.Collection); - collection(): Backbone.Collection; + collection(colleciton: Backbone.Collection); + collection(): Backbone.Collection; destroy(); shareOptions(): CollectionOptions; filters(id: any) : Backbone.Model; @@ -163,7 +163,7 @@ declare module Knockback { } interface Static extends Utils { - collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable; + collectionObservable(model?: Backbone.Collection, options?: CollectionOptions): CollectionObservable; /** Base class for observing model attributes. */ observable( /** the model to observe (can be null) */ diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 0e501f6f8a..7a52d7453c 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -11,49 +11,49 @@ declare module Backbone { // Backbone.BabySitter - class ChildViewContainer { + class ChildViewContainer { constructor(initialViews?: any[]); - add(view: View, customIndex?: number); - findByModel(model): View; - findByModelCid(modelCid): View; - findByCustom(index: number): View; - findByIndex(index: number): View; - findByCid(cid): View; - remove(view: View); + add(view: View, customIndex?: number); + findByModel(model): View; + findByModelCid(modelCid): View; + findByCustom(index: number): View; + findByIndex(index: number): View; + findByCid(cid): View; + remove(view: View); call(method); apply(method: any, args?: any[]); //mixins from Collection (copied from Backbone's Collection declaration) - all(iterator: (element: View, index: number) => boolean, context?: any): boolean; - any(iterator: (element: View, index: number) => boolean, context?: any): boolean; + all(iterator: (element: View, index: number) => boolean, context?: any): boolean; + any(iterator: (element: View, index: number) => boolean, context?: any): boolean; contains(value: any): boolean; detect(iterator: (item: any) => boolean, context?: any): any; - each(iterator: (element: View, index: number, list?: any) => void , context?: any); - every(iterator: (element: View, index: number) => boolean, context?: any): boolean; - filter(iterator: (element: View, index: number) => boolean, context?: any): View[]; - find(iterator: (element: View, index: number) => boolean, context?: any): View; - first(): View; - forEach(iterator: (element: View, index: number, list?: any) => void , context?: any); + each(iterator: (element: View, index: number, list?: any) => void , context?: any); + every(iterator: (element: View, index: number) => boolean, context?: any): boolean; + filter(iterator: (element: View, index: number) => boolean, context?: any): View[]; + find(iterator: (element: View, index: number) => boolean, context?: any): View; + first(): View; + forEach(iterator: (element: View, index: number, list?: any) => void , context?: any); include(value: any): boolean; - initial(): View; - initial(n: number): View[]; + initial(): View; + initial(n: number): View[]; invoke(methodName: string, arguments?: any[]); isEmpty(object: any): boolean; - last(): View; - last(n: number): View[]; - lastIndexOf(element: View, fromIndex?: number): number; - map(iterator: (element: View, index: number, context?: any) => any[], context?: any): any[]; + last(): View; + last(n: number): View[]; + lastIndexOf(element: View, fromIndex?: number): number; + map(iterator: (element: View, index: number, context?: any) => any[], context?: any): any[]; pluck(attribute: string): any[]; - reject(iterator: (element: View, index: number) => boolean, context?: any): View[]; - rest(): View; - rest(n: number): View[]; + reject(iterator: (element: View, index: number) => boolean, context?: any): View[]; + rest(): View; + rest(n: number): View[]; select(iterator: any, context?: any): any[]; - some(iterator: (element: View, index: number) => boolean, context?: any): boolean; + some(iterator: (element: View, index: number) => boolean, context?: any): boolean; toArray(): any[]; - without(...values: any[]): View[]; + without(...values: any[]): View[]; } // Backbone.Wreqr @@ -107,7 +107,7 @@ declare module Marionette { function getOption(target, optionName): any; function triggerMethod(name, ...args: any[]): any; - function MonitorDOMRefresh(view: Backbone.View): void; + function MonitorDOMRefresh(view: Backbone.View): void; function bindEntityEvents(target, entity, bindings); function unbindEntityEvents(target, entity, bindings); @@ -121,24 +121,24 @@ declare module Marionette { close(); } - class Region extends Backbone.Events { + class Region extends Backbone.Events { - static buildRegion(regionConfig, defaultRegionType): Region; + static buildRegion(regionConfig, defaultRegionType): Region; el: any; - show(view: Backbone.View): void; + show(view: Backbone.View): void; ensureEl(): void; - open(view: Backbone.View): void; + open(view: Backbone.View): void; close(): void; - attachView(view: Backbone.View); + attachView(view: Backbone.View); reset(); } - class RegionManager extends Controller { + class RegionManager extends Controller { addRegions(regionDefinitions, defaults?): any; - addRegion(name, definition): Region; - get (name: string): Region; + addRegion(name, definition): Region; + get(name: string): Region; removeRegion(name): void; removeRegions(): void; closeRegions(): void; @@ -146,33 +146,33 @@ declare module Marionette { //mixins from Collection (copied from Backbone's Collection declaration) - all(iterator: (element: Region, index: number) => boolean, context?: any): boolean; - any(iterator: (element: Region, index: number) => boolean, context?: any): boolean; + all(iterator: (element: Region, index: number) => boolean, context?: any): boolean; + any(iterator: (element: Region, index: number) => boolean, context?: any): boolean; contains(value: any): boolean; detect(iterator: (item: any) => boolean, context?: any): any; - each(iterator: (element: Region, index: number, list?: any) => void , context?: any); - every(iterator: (element: Region, index: number) => boolean, context?: any): boolean; - filter(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; - find(iterator: (element: Region, index: number) => boolean, context?: any): Region; - first(): Region; - forEach(iterator: (element: Region, index: number, list?: any) => void , context?: any); + each(iterator: (element: Region, index: number, list?: any) => void , context?: any); + every(iterator: (element: Region, index: number) => boolean, context?: any): boolean; + filter(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; + find(iterator: (element: Region, index: number) => boolean, context?: any): Region; + first(): Region; + forEach(iterator: (element: Region, index: number, list?: any) => void , context?: any); include(value: any): boolean; - initial(): Region; - initial(n: number): Region[]; + initial(): Region; + initial(n: number): Region[]; invoke(methodName: string, arguments?: any[]); isEmpty(object: any): boolean; - last(): Region; - last(n: number): Region[]; - lastIndexOf(element: Region, fromIndex?: number): number; - map(iterator: (element: Region, index: number, context?: any) => any[], context?: any): any[]; + last(): Region; + last(n: number): Region[]; + lastIndexOf(element: Region, fromIndex?: number): number; + map(iterator: (element: Region, index: number, context?: any) => any[], context?: any): any[]; pluck(attribute: string): any[]; - reject(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; - rest(): Region; - rest(n: number): Region[]; + reject(iterator: (element: Region, index: number) => boolean, context?: any): Region[]; + rest(): Region; + rest(n: number): Region[]; select(iterator: any, context?: any): any[]; - some(iterator: (element: Region, index: number) => boolean, context?: any): boolean; + some(iterator: (element: Region, index: number) => boolean, context?: any): boolean; toArray(): any[]; - without(...values: any[]): Region[]; + without(...values: any[]): Region[]; } class TemplateCache { @@ -187,7 +187,7 @@ declare module Marionette { static render(template, data): void; } - class View extends Backbone.View { + class View extends Backbone.View { constructor(options?: any); @@ -208,72 +208,72 @@ declare module Marionette { triggerMethod(name, ...args: any[]): any; } - class ItemView extends View { + class ItemView extends View { constructor(options?: any); ui: any; serializeData(): any; - render(): ItemView; + render(): ItemView; close(); } - class CollectionView extends View { + class CollectionView extends View { constructor(options?: any); itemView: any; children: any; //_initialEvents(); - addChildView(item: View, collection: View, options?: any); + addChildView(item: View, collection: View, options?: any); onShowCalled(); triggerBeforeRender(); triggerRendered(); - render(): CollectionView; + render(): CollectionView; - getItemView(item: any): ItemView; - addItemView(item: any, ItemView: ItemView, index: Number); - addChildViewEventForwarding(view: View); - renderItemView(view: View, index: Number); + getItemView(item: any): ItemView; + addItemView(item: any, ItemView: ItemView, index: Number); + addChildViewEventForwarding(view: View); + renderItemView(view: View, index: Number); buildItemView(item: any, ItemViewType: any, itemViewOptions: any): any; removeItemView(item: any); - removeChildView(view: View); + removeChildView(view: View); checkEmpty(); - appendHtml(collectionView: View, itemView: View, index: Number); + appendHtml(collectionView: View, itemView: View, index: Number); close(); closeChildren(); } - class CompositeView extends CollectionView { + class CompositeView extends CollectionView { constructor(options?: any); itemView: any; itemViewContainer: string; - render(): CompositeView; + render(): CompositeView; appendHtml(cv: any, iv: any); renderModel(): any; } - class Layout extends ItemView { + class Layout extends ItemView { constructor(options?: any); - addRegion(name: string, definition: any): Region; + addRegion(name: string, definition: any): Region; addRegions(regions: any): any; - render(): Layout; + render(): Layout; removeRegion(name: string); } interface AppRouterOptions extends Backbone.RouterOptions { - appRoutes: any; - controller: any; + appRoutes: any; + controller: any; } class AppRouter extends Backbone.Router { @@ -284,7 +284,7 @@ declare module Marionette { } - class Application extends Backbone.Events { + class Application extends Backbone.Events { vent: Backbone.Wreqr.EventAggregator; commands: Backbone.Wreqr.Commands; @@ -297,15 +297,15 @@ declare module Marionette { start(options?); addRegions(regions); closeRegions(): void; - removeRegion(region: Region); - getRegion(regionName: string): Region; + removeRegion(region: Region); + getRegion(regionName: string): Region; module(moduleNames, moduleDefinition); } // modules mapped for convenience, but you should probably use TypeScript modules instead - class Module extends Backbone.Events { + class Module extends Backbone.Events { - constructor(moduleName: string, app: Application); + constructor(moduleName: string, app: Application); submodules: any; triggerMethod(name, ...args: any[]): any; @@ -319,7 +319,7 @@ declare module Marionette { } declare module 'backbone.marionette' { - import Backbone = require('backbone'); - - export = Marionette; + import Backbone = require('backbone'); + + export = Marionette; } From 4d233b71518a91c4e65bf03dbe4a8d8709412040 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Fri, 25 Apr 2014 09:57:57 +0100 Subject: [PATCH 117/225] 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 b83006c3a8..79263027fe 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 5019a99504..26492bf200 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 bb05b91c9ca3e806ecb0471166a2edcc3b2ec5a1 Mon Sep 17 00:00:00 2001 From: JeremyCBrooks Date: Sun, 13 Apr 2014 11:24:48 -0400 Subject: [PATCH 118/225] added definition for jquery total-storage fixed failing test updated CONTRIBUTORS --- CONTRIBUTORS.md | 1 + .../jquery.total-storage-tests.ts | 21 ++++++ .../jquery.total-storage.d.ts | 64 +++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 jquery.total-storage/jquery.total-storage-tests.ts create mode 100644 jquery.total-storage/jquery.total-storage.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index d68e3061cc..dd09cf2830 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -151,6 +151,7 @@ All definitions files include a header with the author and editors, so at some p * [jQuery.TinyCarousel](http://baijs.nl/tinycarousel/) (by [Christiaan Rakowski](https://github.com/csrakowski)) * [jQuery.TinyScrollbar](http://baijs.nl/tinyscrollbar/) (by [Christiaan Rakowski](https://github.com/csrakowski)) * [jQuery.tooltipster](https://github.com/iamceege/tooltipster) (by [Patrick Magee](https://github.com/pjmagee)) +* [jQuery.total-storage](https://github.com/Upstatement/jquery-total-storage) (by [Jeremy Brooks](https://github.com/JeremyCBrooks/)) * [jQuery.Transit](http://ricostacruz.com/jquery.transit/) (by [MrBigDog2U](https://github.com/MrBigDog2U)) * [jQuery.Validation](http://bassistance.de/jquery-plugins/jquery-plugin-validation/) (by [Boris Yankov](https://github.com/borisyankov)) * [jQuery.Watermark](http://jquery-watermark.googlecode.com) (by [Anwar Javed](https://github.com/anwarjaved)) diff --git a/jquery.total-storage/jquery.total-storage-tests.ts b/jquery.total-storage/jquery.total-storage-tests.ts new file mode 100644 index 0000000000..0ba3700eee --- /dev/null +++ b/jquery.total-storage/jquery.total-storage-tests.ts @@ -0,0 +1,21 @@ +// Type definitions for jQueryTotalStorage 1.1.2 +// Project: https://github.com/Upstatement/jquery-total-storage +// Definitions by: Jeremy Brooks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// +/// + +//direct call +$.totalStorage("test_key1", "test_value"); +var val1:string = $.totalStorage("test_key"); + +//set/get +$.totalStorage.setItem("test_key2", 123); +var val2:number = $.totalStorage.getItem("test_key2"); + +//get all items +var list = $.totalStorage.getAll(); + +//delete item +var deleted = $.totalStorage.deleteItem("test_key1"); \ No newline at end of file diff --git a/jquery.total-storage/jquery.total-storage.d.ts b/jquery.total-storage/jquery.total-storage.d.ts new file mode 100644 index 0000000000..8bfed0a4d3 --- /dev/null +++ b/jquery.total-storage/jquery.total-storage.d.ts @@ -0,0 +1,64 @@ +// Type definitions for jQueryTotalStorage 1.1.2 +// Project: https://github.com/Upstatement/jquery-total-storage +// Definitions by: Jeremy Brooks +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +/** +* @desc Set the value of a key to a string +* @example $.totalStorage('the_key', 'the_value'); +* @desc Set the value of a key to a number +* @example $.totalStorage('the_key', 800.2); +* @desc Set the value of a key to a complex Array +* @example var myArray = new Array(); +* myArray.push({name:'Jared', company:'Upstatement', zip:63124}); +* myArray.push({name:'McGruff', company:'Police', zip:60652}; +* $.totalStorage('people', myArray); +* //to return: +* $.totalStorage('people'); +* +*/ + +interface JQueryTotalStorage { + + /** + * @desc Set or get a key's value + * @param key Key to set. + * @param value Value to set for key. If ommited, current value for key is returned. + * @param options Not implemented. + */ + (key: string, value?: any, options?: JQueryTotalStorageOptions): any; + + /** + * @desc Set a key's value + * @param key Key to set. + * @param value Value to set for key. + */ + setItem(key: string, value: any): any; + + /** + * @desc Get a key's value + * @param key Key to get. + */ + getItem(key: string): any; + + /** + * @desc Get all set values + */ + getAll(): any[]; + + /** + * @desc Delete item by key + * @param key Key of item to delete + */ + deleteItem(key: string): boolean; +} + +interface JQueryTotalStorageOptions { + //not implemented... +} + +interface JQueryStatic { + totalStorage: JQueryTotalStorage; +} \ No newline at end of file From 4fa6f7c29bec19e0d6420d91e2131d17c2a4570e Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Sat, 26 Apr 2014 08:59:37 +1000 Subject: [PATCH 119/225] 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 f646bcbf21..fb971a0997 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 120/225] 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 fb971a0997..2bf0d91b47 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 121/225] 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 db9ec042d4..9c828fdf7b 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 122/225] 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 d68e3061cc..7806a004a8 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 0000000000..0b26f6175b --- /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 0000000000..ff974f15e2 --- /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 123/225] 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 8207933bcd..b5d9ed5496 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 27938939aa..1c5a4e8cad 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 124/225] 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 12ffb08bbc..20259f0a7c 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 114f930fbd62b5de7715feb6e144bf2c44b52888 Mon Sep 17 00:00:00 2001 From: Keats Date: Sun, 27 Apr 2014 09:55:40 +0100 Subject: [PATCH 125/225] Update Restangular definition Add enhanced promises Add new methods up to current 1.4 Rewrite tests to make them more realistic --- restangular/restangular-tests.ts | 240 ++++++++++++++++--------------- restangular/restangular.d.ts | 180 +++++++++++++---------- 2 files changed, 228 insertions(+), 192 deletions(-) diff --git a/restangular/restangular-tests.ts b/restangular/restangular-tests.ts index 9643c9e6b3..9d5aa9fb4f 100644 --- a/restangular/restangular-tests.ts +++ b/restangular/restangular-tests.ts @@ -1,145 +1,159 @@ /// -function test_basic() { - var $scope; - Restangular.all('accounts'); - Restangular.one('accounts', 1234); - Restangular.all('users').getList().then(function (users) { - $scope.user = users[0]; - }) - $scope.cars = $scope.user.getList('cars'); - $scope.user.sendMessage(); - $scope.user.one('message', 123).all('unread').getList(); +var myApp = angular.module('testModule'); - var baseAccounts = Restangular.all('accounts'); +myApp.config((RestangularProvider: restangular.IProvider) => { + RestangularProvider.setBaseUrl('/api/v1'); + RestangularProvider.setExtraFields(['name']); + RestangularProvider.setResponseExtractor(function (response, operation) { + return response.data; + }); - $scope.allAccounts = baseAccounts.getList(); + RestangularProvider.setDefaultHttpFields({ cache: true }); + RestangularProvider.setMethodOverriders(["put", "patch"]); - var newAccount = { name: "Gonto's account" }; + RestangularProvider.setErrorInterceptor(function (response) { + console.error('' + response.status + ' ' + response.data); + }); - baseAccounts.post(newAccount); + RestangularProvider.setRequestSuffix('.json'); - Restangular.one('accounts', 123).one('buildings', 456).get() + RestangularProvider.setRequestInterceptor(function (element, operation, route, url) { + }); - Restangular.one('accounts', 123).all('buildings').getList() + RestangularProvider.addElementTransformer('accounts', false, function (elem) { + elem.accountName = 'Changed'; + return elem; + }); - baseAccounts.getList().then(function (accounts) { + RestangularProvider.setRestangularFields({ + id: "_id", + route: "restangularRoute", + selfLink: "self.href" + }); - var firstAccount = accounts[0]; - $scope.buildings = firstAccount.getList("buildings"); - $scope.loggedInPlaces = firstAccount.getList("places", { query: 'wuut' }, { 'x-user': 'mgonto' }) + RestangularProvider.addRequestInterceptor(function(element, operation, route, url) { + delete element.name; + return element; + }); - firstAccount.name = "Gonto" - - var editFirstAccount = Restangular.copy(firstAccount); - - firstAccount.put(); - editFirstAccount.put(); - - firstAccount.remove(); - - var myBuilding = { - name: "Gonto's Building", - place: "Argentina" - }; + RestangularProvider.setFullRequestInterceptor(function(element, operation, route, url, headers, params, httpConfig) { + delete element.name; + return { + element: element, + params: params, + headers: headers, + httpConfig: httpConfig + }; + }); +}); - firstAccount.post("Buildings", myBuilding).then(function () { - console.log("Object saved OK"); - }, function () { - console.log("There was an error saving"); - }); - - - firstAccount.getList("users", { query: 'wuut' }).then(function (users) { - - users.post({ userName: 'unknown' }); - - - users.customGET("messages", { param: "myParam" }) - - var firstUser = users[0]; - - $scope.userFromServer = firstUser.get(); - - firstUser.head() - - }); - - }, function errorCallback() { - alert("Oops error from server :("); - }) - - var account = Restangular.one("accounts", 123); - - $scope.account = account.get({ single: true }); - - account.customPOST({ name: "My Message" }, "messages", { param: "myParam" }, {}) +interface MyAppScope extends ng.IScope { + accounts: string[]; + allAccounts: any[]; + account: any; + buildings: restangular.ICollectionPromise; + loggedInPlaces: restangular.ICollectionPromise; + userFromServer: restangular.IPromise; } -function test_config() { - RestangularProvider.setBaseUrl('/api/v1'); - RestangularProvider.setExtraFields(['name']); - RestangularProvider.setResponseExtractor(function (response, operation) { - return response.data; +myApp.controller('TestCtrl', ( + $scope: MyAppScope, + Restangular: restangular.IService + ) => { + var baseAccounts = Restangular.all('accounts'); + + baseAccounts.getList().then(function(accounts) { + $scope.allAccounts = accounts; + }); + + $scope.accounts = Restangular.all('accounts').getList().$object; + var newAccount = {name: "Gonto's account"}; + baseAccounts.post(newAccount); + + Restangular.allUrl('googlers', 'http://www.google.com/').getList(); + Restangular.oneUrl('googlers', 'http://www.google.com/1').get(); + Restangular.one('accounts', 123).one('buildings', 456).get(); + Restangular.one('accounts', 123).getList('buildings'); + + baseAccounts.getList().then(function (accounts) { + var firstAccount = accounts[0]; + $scope.buildings = firstAccount.getList("buildings"); + $scope.loggedInPlaces = firstAccount.getList("places", {query: "param"}, {'x-user': 'mgonto'}); + + firstAccount.name = "Gonto"; + var editFirstAccount = Restangular.copy(firstAccount); + + firstAccount.put(); + editFirstAccount.put(); + + firstAccount.save(); + + firstAccount.remove(); + + var myBuilding = { + name: "Gonto's Building", + place: "Argentina" + }; + + firstAccount.post("Buildings", myBuilding).then(function() { + console.log("Object saved OK"); + }, function() { + console.log("There was an error saving"); }); - RestangularProvider.setDefaultHttpFields({ cache: true }); - RestangularProvider.setMethodOverriders(["put", "patch"]); + firstAccount.getList("users", {query: "params"}).then(function(users) { + users.post({userName: 'unknown'}); + users.customGET("messages", {param: "myParam"}); - RestangularProvider.setErrorInterceptor(function (response) { + var firstUser = users[0]; + $scope.userFromServer = firstUser.get(); + firstUser.head() + + }); + + }, function errorCallback() { + alert("Oops error from server :("); + }); + + var account = Restangular.one("accounts", 123); + + $scope.account = account.get({single: true}); + + account.customPOST({name: "My Message"}, "messages", {param: "myParam"}, {}); + + Restangular.one('accounts', 123).withHttpConfig({timeout: 100}).getList('buildings'); + $scope.account = Restangular.one('accounts', 123); + $scope.account.withHttpConfig({timeout: 100}).put(); + + var myRestangular = Restangular.withConfig((configurer: restangular.IProvider) => { + configurer.setBaseUrl('/api/v1'); + configurer.setExtraFields(['name']); + + configurer.setErrorInterceptor(function (response) { console.error('' + response.status + ' ' + response.data); }); + configurer.setResponseExtractor(function (response, operation) { + return response.data; + }); + configurer.setDefaultHttpFields({ cache: true }); + configurer.setMethodOverriders(["put", "patch"]); - RestangularProvider.setRestangularFields({ + configurer.setRestangularFields({ id: "_id", route: "restangularRoute" }); - RestangularProvider.setRequestSuffix('.json'); + configurer.setRequestSuffix('.json'); - RestangularProvider.setRequestInterceptor(function (element, operation, route, url) { + configurer.setRequestInterceptor(function (element, operation, route, url) { }); - RestangularProvider.addElementTransformer('accounts', false, function (elem) { + configurer.addElementTransformer('accounts', false, function (elem) { elem.accountName = 'Changed'; return elem; }); - - var myRestangular = Restangular.withConfig((configurer: RestangularProvider) => { - configurer.setBaseUrl('/api/v1'); - configurer.setExtraFields(['name']); - - configurer.setErrorInterceptor(function (response) { - console.error('' + response.status + ' ' + response.data); - }); - configurer.setResponseExtractor(function (response, operation) { - return response.data; - }); - configurer.setDefaultHttpFields({ cache: true }); - configurer.setMethodOverriders(["put", "patch"]); - - configurer.setRestangularFields({ - id: "_id", - route: "restangularRoute" - }); - - configurer.setRequestSuffix('.json'); - - configurer.setRequestInterceptor(function (element, operation, route, url) { - }); - - configurer.addElementTransformer('accounts', false, function (elem) { - elem.accountName = 'Changed'; - return elem; - }); - }); -} - -function test_withHttpConfig() { - var $scope; - Restangular.one('accounts', 123).withHttpConfig({timeout: 100}).getList('buildings'); - $scope.account = Restangular.one('accounts', 123); - $scope.account.withHttpConfig({timeout: 100}).put(); -} + }); +}); diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index 0cc4321afb..9fd397bf57 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Restangular v1.2.2 +// Type definitions for Restangular v1.4.0 // Project: https://github.com/mgonto/restangular // Definitions by: Boris Yankov // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -6,7 +6,23 @@ /// -interface RestangularRequestConfig { + +declare module restangular { + + interface IPromise extends ng.IPromise { + call(methodName: string, params?: any): IPromise; + get(fieldName: string): IPromise; + $object: T; +} + + interface ICollectionPromise extends ng.IPromise { + push(object: any): ICollectionPromise; + call(methodName: string, params?: any): ICollectionPromise; + get(fieldName: string): ICollectionPromise; + $object: T[]; + } + + interface IRequestConfig { params?: any; headers?: any; cache?: any; @@ -15,81 +31,9 @@ interface RestangularRequestConfig { transformRequest?: any; transformResponse?: any; timeout?: any; // number | promise -} + } -interface Restangular extends RestangularCustom { - one(route: string, id?: number): RestangularElement; - one(route: string, id?: string): RestangularElement; - oneUrl(route: string, url: string): RestangularElement; - all(route: string): RestangularCollection; - allUrl(route: string, url: string): RestangularCollection; - copy(fromElement: any): RestangularElement; - withConfig(configurer: (RestangularProvider: RestangularProvider) => any): Restangular; - restangularizeElement(parent: any, element: any, route: string, collection?: any, reqParams?: any): RestangularElement; - restangularizeCollection(parent: any, element: any, route: string): RestangularCollection; - stripRestangular(element: any): any; -} - -interface RestangularElement extends Restangular { - get(queryParams?: any, headers?: any): ng.IPromise; - getList(subElement: any, queryParams?: any, headers?: any): ng.IPromise; - put(queryParams?: any, headers?: any): ng.IPromise; - post(subElement: any, elementToPost: any, queryParams?: any, headers?: any): ng.IPromise; - remove(queryParams?: any, headers?: any): ng.IPromise; - head(queryParams?: any, headers?: any): ng.IPromise; - trace(queryParams?: any, headers?: any): ng.IPromise; - options(queryParams?: any, headers?: any): ng.IPromise; - patch(queryParams?: any, headers?: any): ng.IPromise; - withHttpConfig(httpConfig: RestangularRequestConfig): RestangularElement; - getRestangularUrl(): string; -} - -interface RestangularCollection extends Restangular { - getList(queryParams?: any, headers?: any): ng.IPromise; - post(elementToPost: any, queryParams?: any, headers?: any): ng.IPromise; - head(queryParams?: any, headers?: any): ng.IPromise; - trace(queryParams?: any, headers?: any): ng.IPromise; - options(queryParams?: any, headers?: any): ng.IPromise; - patch(queryParams?: any, headers?: any): ng.IPromise; - putElement(idx: any, params: any, headers: any): ng.IPromise; - withHttpConfig(httpConfig: RestangularRequestConfig): RestangularCollection; - getRestangularUrl(): string; -} - -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(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; -} - -interface RestangularProvider { - setBaseUrl(baseUrl: string): void; - setExtraFields(fields: string[]): void; - setParentless(parentless: boolean, routes: string[]): void; - setDefaultHttpFields(httpFields: any): void; - addElementTransformer(route: string, transformer: Function): void; - addElementTransformer(route: string, isCollection: boolean, transformer: Function): void; - setOnElemRestangularized(callback: (elem: any, isCollection: boolean, what: string, restangular: Restangular) => any): void; - setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred) => any): void; - setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: RestangularResponse, deferred: ng.IDeferred) => any): void; - setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; - setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any) => {element: any; headers: any; params: any}): void; - setErrorInterceptor(errorInterceptor: (response: RestangularResponse) => any): void; - setRestangularFields(fields: {[fieldName: string]: string}): void; - setMethodOverriders(overriders: string[]): void; - setDefaultRequestParams(params: any): void; - setDefaultRequestParams(methods: any, params: any): void; - setFullResponse(fullResponse: boolean): void; - setDefaultHeaders(headers: any): void; - setRequestSuffix(suffix: string): void; - setUseCannonicalId(useCannonicalId: boolean): void; -} - -interface RestangularResponse { + interface IResponse { status: number; data: any; config: { @@ -97,7 +41,85 @@ interface RestangularResponse { url: string; params: any; } -} + } -declare var Restangular: Restangular; -declare var RestangularProvider: RestangularProvider; + interface IProvider { + setBaseUrl(baseUrl: string): void; + setExtraFields(fields: string[]): void; + setParentless(parentless: boolean, routes: string[]): void; + setDefaultHttpFields(httpFields: any): void; + addElementTransformer(route: string, transformer: Function): void; + addElementTransformer(route: string, isCollection: boolean, transformer: Function): void; + setTransformOnlyServerElements(active: boolean): void; + setOnElemRestangularized(callback: (elem: any, isCollection: boolean, what: string, restangular: IService) => any): void; + setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: ng.IDeferred) => any): void; + setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: ng.IDeferred) => any): void; + addResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: ng.IDeferred) => any): void; + setRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; + addRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string) => any): void; + setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: IRequestConfig) => {element: any; headers: any; params: any}): void; + addFullRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: IRequestConfig) => {headers: any; params: any; element: any; httpConfig: IRequestConfig}): void; + setErrorInterceptor(errorInterceptor: (response: IResponse, deferred: ng.IDeferred) => any): void; + setRestangularFields(fields: {[fieldName: string]: string}): void; + setMethodOverriders(overriders: string[]): void; + setJsonp(jsonp: boolean): void; + setDefaultRequestParams(params: any): void; + setDefaultRequestParams(method: string, params: any): void; + setDefaultRequestParams(methods: string[], params: any): void; + setFullResponse(fullResponse: boolean): void; + setDefaultHeaders(headers: any): void; + setRequestSuffix(suffix: string): void; + setUseCannonicalId(useCannonicalId: boolean): void; + setEncodeIds(encode: boolean): void; + } + + interface ICustom { + customGET(path: string, params?: any, headers?: any): IPromise; + customGETLIST(path: string, params?: any, headers?: any): ICollectionPromise; + customDELETE(path: string, params?: any, headers?: any): IPromise; + customPOST(elem?: any, path?: string, params?: any, headers?: any): IPromise; + customPUT(elem?: any, path?: string, params?: any, headers?: any): IPromise; + customOperation(operation: string, path: string, params?: any, headers?: any, elem?: any): IPromise; + addRestangularMethod(name: string, operation: string, path?: string, params?: any, headers?: any, elem?: any): IPromise; + } + + interface IService extends ICustom { + one(route: string, id?: number): IElement; + one(route: string, id?: string): IElement; + oneUrl(route: string, url: string): IElement; + all(route: string): IElement; + allUrl(route: string, url: string): IElement; + copy(fromElement: any): IElement; + withConfig(configurer: (RestangularProvider: IProvider) => any): IService; + restangularizeElement(parent: any, element: any, route: string, collection?: any, reqParams?: any): IElement; + restangularizeCollection(parent: any, element: any, route: string): ICollection; + stripRestangular(element: any): any; + } + + interface IElement extends IService { + get(queryParams?: any, headers?: any): IPromise; + getList(subElement?: any, queryParams?: any, headers?: any): ICollectionPromise; + put(queryParams?: any, headers?: any): IPromise; + post(subElement: any, elementToPost: any, queryParams?: any, headers?: any): IPromise; + post(elementToPost: any, queryParams?: any, headers?: any): IPromise; + remove(queryParams?: any, headers?: any): IPromise; + head(queryParams?: any, headers?: any): IPromise; + trace(queryParams?: any, headers?: any): IPromise; + options(queryParams?: any, headers?: any): IPromise; + patch(queryParams?: any, headers?: any): IPromise; + withHttpConfig(httpConfig: IRequestConfig): IElement; + getRestangularUrl(): string; + } + + interface ICollection extends IService { + getList(queryParams?: any, headers?: any): ICollectionPromise; + post(elementToPost: any, queryParams?: any, headers?: any): IPromise; + head(queryParams?: any, headers?: any): IPromise; + trace(queryParams?: any, headers?: any): IPromise; + options(queryParams?: any, headers?: any): IPromise; + patch(queryParams?: any, headers?: any): IPromise; + putElement(idx: any, params: any, headers: any): IPromise; + withHttpConfig(httpConfig: IRequestConfig): ICollection; + getRestangularUrl(): string; + } +} From 1d55f70e34b851d9bd2c9a855fb923e64db70ffb Mon Sep 17 00:00:00 2001 From: Anand Prakash Date: Sun, 27 Apr 2014 17:29:43 -0700 Subject: [PATCH 126/225] Fixed local, roaming and temp definitions on WinJS.Application object. These should be instances on IOHelper as defined in WinJS. --- winjs/winjs.d.ts | 161 +++++++++++++++-------------------------------- 1 file changed, 49 insertions(+), 112 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index 20263a3bb9..d14238eeeb 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -25,7 +25,49 @@ and limitations under the License. **/ interface Element { winControl: any; // TODO: This should be control? -}/** +} + +/** + * Utility class for easy access to operations on application folders +**/ +interface IOHelper { + /** + * Instance of the currently wrapped application folder + **/ + folder: Windows.Storage.StorageFolder; + + /** + * Determines whether the specified file exists in the folder. + * @param filename The name of the file. + * @returns A promise that completes with a value of either true (if the file exists) or false. + **/ + exists(filename: string): WinJS.Promise; + + /** + * Reads the specified file. If the file doesn't exist, the specified default value is returned. + * @param fileName The file to read from. + * @param def The default value to be returned if the file failed to open. + * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. + **/ + readText(fileName: string, def?: string): WinJS.Promise; + + /** + * Deletes a file from the folder. + * @param fileName The file to be deleted. + * @returns A promise that is fulfilled when the file has been deleted. + **/ + remove(fileName: string): WinJS.Promise; + + /** + * Writes the specified text to the specified file. + * @param fileName The name of the file. + * @param text The content to be written to the file. + * @returns A promise that completes with a value that is the number of characters written. + **/ + writeText(fileName: string, text: string): WinJS.Promise; +} + +/** * Provides application-level functionality, for example activation, storage, and application events. **/ declare module WinJS.Application { @@ -34,128 +76,23 @@ declare module WinJS.Application { /** * The local storage of the application. **/ - var local: { - //#region Methods - - /** - * Determines whether the specified file exists in the folder. - * @param filename The name of the file. - * @returns A promise that completes with a value of either true (if the file exists) or false. - **/ - exists(filename: string): Promise; - - /** - * Reads the specified file. If the file doesn't exist, the specified default value is returned. - * @param fileName The file to read from. - * @param def The default value to be returned if the file failed to open. - * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. - **/ - readText(fileName: string, def?: string): Promise; - - /** - * Deletes a file from the folder. - * @param fileName The file to be deleted. - * @returns A promise that is fulfilled when the file has been deleted. - **/ - remove(fileName: string): Promise; - - /** - * Writes the specified text to the specified file. - * @param fileName The name of the file. - * @param text The content to be written to the file. - * @returns A promise that completes with a value that is the number of characters written. - **/ - writeText(fileName: string, text: string): Promise; - - //#endregion Methods - - }; + var local: IOHelper; /** * The roaming storage of the application. **/ - var roaming: { - //#region Methods + var roaming: IOHelper; - /** - * Determines whether the specified file exists in the folder. - * @param filename The name of the file. - * @returns A promise that completes with a value of either true (if the file exists) or false. - **/ - exists(filename: string): Promise; - - /** - * Reads the specified file. If the file doesn't exist, the specified default value is returned. - * @param fileName The file to read from. - * @param def The default value to be returned if the file failed to open. - * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. - **/ - readText(fileName: string, def?: string): Promise; - - /** - * Deletes a file from the folder. - * @param fileName The file to be deleted. - * @returns A promise that is fulfilled when the file has been deleted. - **/ - remove(fileName: string): Promise; - - /** - * Writes the specified text to the specified file. - * @param fileName The name of the file. - * @param text The content to be written to the file. - * @returns A promise that completes with a value that is the number of characters written. - **/ - writeText(fileName: string, text: string): Promise; - - //#endregion Methods - - }; + /** + * The temp storage of the application. + **/ + var temp: IOHelper; /** * An object used for storing app information that can be used to restore the app's state after it has been suspended and then resumed. Data that can usefully be contained in this object includes the current navigation page or any information the user has added to the input controls on the page. You should not add information about customization (for example colors) or user-defined lists of content. **/ var sessionState: any; - /** - * The temp storage of the application. - **/ - var temp: { - //#region Methods - - /** - * Determines whether the specified file exists in the folder. - * @param filename The name of the file. - * @returns A promise that completes with a value of either true (if the file exists) or false. - **/ - exists(filename: string): Promise; - - /** - * Reads the specified file. If the file doesn't exist, the specified default value is returned. - * @param fileName The file to read from. - * @param def The default value to be returned if the file failed to open. - * @returns A promise that completes with a value that is either the contents of the file, or the specified default value. - **/ - readText(fileName: string, def?: string): Promise; - - /** - * Deletes a file from the folder. - * @param fileName The file to be deleted. - * @returns A promise that is fulfilled when the file has been deleted. - **/ - remove(fileName: string): Promise; - - /** - * Writes the specified text to the specified file. - * @param fileName The name of the file. - * @param text The text to write. - * @returns A Promise that completes with the number of bytes successfully written to the file. - **/ - writeText(fileName: string, text: string): Promise; - - //#endregion Methods - - }; - //#endregion Objects //#region Methods From 5051de332ff6c146df87526fe810f6b2d3313bd2 Mon Sep 17 00:00:00 2001 From: Anand Prakash Date: Sun, 27 Apr 2014 17:33:12 -0700 Subject: [PATCH 127/225] Changed QueryCollection to be an interface instead of class so that it can extend Array interface. In WinJS implementaion, QueryCollection extends Array and all Array members should be available on QueryCollection. --- winjs/winjs.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index d14238eeeb..f58c11d12d 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -76,17 +76,17 @@ declare module WinJS.Application { /** * The local storage of the application. **/ - var local: IOHelper; + var local: IOHelper; /** * The roaming storage of the application. **/ - var roaming: IOHelper; + var roaming: IOHelper; /** * The temp storage of the application. **/ - var temp: IOHelper; + var temp: IOHelper; /** * An object used for storing app information that can be used to restore the app's state after it has been suspended and then resumed. Data that can usefully be contained in this object includes the current navigation page or any information the user has added to the input controls on the page. You should not add information about customization (for example colors) or user-defined lists of content. @@ -7904,7 +7904,7 @@ declare module WinJS.Utilities { /** * Represents the result of a query selector, and provides various operations that perform actions over the elements of the collection. **/ - class QueryCollection { + interface QueryCollection extends Array { //#region Constructors /** From bfe38c6de7878946433025a4b69e34f53dc6ffab Mon Sep 17 00:00:00 2001 From: Anand Prakash Date: Sun, 27 Apr 2014 17:35:19 -0700 Subject: [PATCH 128/225] Made element parameter optional in WinJS.Utilities.query as it is optional in WinJS implementation. See http://msdn.microsoft.com/en-us/library/windows/apps/br229847.aspx. --- winjs/winjs.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index f58c11d12d..a2e95e557f 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -8243,7 +8243,7 @@ declare module WinJS.Utilities { * @param element Optional. The root element at which to start the query. If this parameter is omitted, the scope of the query is the entire document. * @returns A QueryCollection with zero or one elements matching the specified selector query. **/ - function query(query: any, element: HTMLElement): QueryCollection; + function query(query: any, element?: HTMLElement): QueryCollection; /** * Ensures that the specified function executes only after the DOMContentLoaded event has fired for the current page. The DOMContentLoaded event occurs after the page has been parsed but before all the resources are loaded. From 63ae54c867e3123af911927e7b2eab4b7f89174c Mon Sep 17 00:00:00 2001 From: Anand Prakash Date: Sun, 27 Apr 2014 18:38:43 -0700 Subject: [PATCH 129/225] Added constructor support for QueryCollection interface --- winjs/winjs.d.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/winjs/winjs.d.ts b/winjs/winjs.d.ts index a2e95e557f..b5ded7a592 100644 --- a/winjs/winjs.d.ts +++ b/winjs/winjs.d.ts @@ -7905,17 +7905,6 @@ declare module WinJS.Utilities { * Represents the result of a query selector, and provides various operations that perform actions over the elements of the collection. **/ interface QueryCollection extends Array { - //#region Constructors - - /** - * Initializes a new instance of a QueryCollection. - * @constructor - * @param items The items resulting from the query. - **/ - constructor(items: T[]); - - //#endregion Constructors - //#region Methods /** @@ -8062,6 +8051,14 @@ declare module WinJS.Utilities { } + /** + * Constructor support for QueryCollection interface + **/ + export var QueryCollection: { + new (items: T[]): QueryCollection; + prototype: QueryCollection; + } + //#endregion Objects //#region Functions From 5b115418e10781bb8027913418dbc37129b5f15e Mon Sep 17 00:00:00 2001 From: Vladimir Kotikov Date: Mon, 28 Apr 2014 17:05:34 +0400 Subject: [PATCH 130/225] 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 a6f7bc0868..f054c12d09 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 4aefa5ecfd..569f9a2096 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 3751152be1..21d1a17e38 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 807dab42a7..8d28a69c8f 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 131/225] 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 3e7b4afaf9..46851ab523 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 20259f0a7c..f9c833bd13 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 132/225] 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 743ed187ec..192051ab47 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 bc8b1ce28e..5f671662dc 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 2b0a720a93..3a8605b731 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 ca0a5e7b83..5c9bb19aec 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 2bf0d91b47..86923c56ec 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 957cf5793e..e5ee74621b 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 39f02a53a6..7a1abbae31 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 a77a4b39b6..5598bac17d 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 34862f4b7b..beeb3775a6 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 f4ac32e9e5..21b8969884 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 cbe37214e7..f9d1c10d14 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 860f70ea35..f416dee814 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 cc22b89eaa..d984e1beac 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 2a3dbae405..5e5393ea56 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 133/225] 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 beeb3775a6..6be669a01a 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 134/225] 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 68dbf8be51..a960741649 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 cadb323dbc..39bf01fb82 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 6be669a01a..8966fa18b9 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 135/225] 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 e725de98c8..ebed2a4908 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 3625b3f81a..0a724a7fbf 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 8760a5c2d4..3bec0c6eb3 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 8966fa18b9..d0a67ffef7 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 3469ea04ab..8999d1cc4d 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 f9d1c10d14..cc321e24bc 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 f416dee814..df0e288e97 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 8a617c4241..1491085a2f 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 136/225] 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 ebed2a4908..5326abaeb5 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 0a724a7fbf..c7e213aa17 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 3bec0c6eb3..3f98c948ed 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 330aac3248..904a8084bf 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 d0a67ffef7..11af9e5b12 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 8999d1cc4d..beb8319247 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 cc321e24bc..9c39633767 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 df0e288e97..9e6f9c4b5b 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 088f8056b138e7249c3ec28b22c4ba5ae5e42e5e Mon Sep 17 00:00:00 2001 From: SkyKnight Date: Mon, 28 Apr 2014 21:22:58 +0200 Subject: [PATCH 137/225] missing optional parameter in EM.exportEntities http://www.breezejs.com/documentation/exportimport --- breeze/breeze.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 3614e34461..4ecb9bca64 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -382,7 +382,7 @@ declare module breeze { executeQuery(query: EntityQuery, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Q.Promise; executeQueryLocally(query: EntityQuery): Entity[]; - exportEntities(entities?: Entity[]): string; + exportEntities(entities?: Entity[], includeMetadata?: boolean): string; fetchEntityByKey(typeName: string, keyValue: any, checkLocalCacheFirst?: boolean): Q.Promise; fetchEntityByKey(typeName: string, keyValues: any[], checkLocalCacheFirst?: boolean): Q.Promise; fetchEntityByKey(entityKey: EntityKey, checkLocalCacheFirst?: boolean): Q.Promise; From 77329c13e49aa8471fd4fb1ec11757af0115e85b Mon Sep 17 00:00:00 2001 From: SkyKnight Date: Mon, 28 Apr 2014 21:25:51 +0200 Subject: [PATCH 138/225] optional second parameter of getAdapterInstance according to description on page http://www.breezejs.com/documentation/customizing-ajax adapterName is not required --- breeze/breeze.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/breeze/breeze.d.ts b/breeze/breeze.d.ts index 4ecb9bca64..fab5dd0772 100644 --- a/breeze/breeze.d.ts +++ b/breeze/breeze.d.ts @@ -877,7 +877,7 @@ declare module breeze.config { var dataService: string; var functionRegistry: Object; export function getAdapter(interfaceName: string, adapterName: string): Object; - export function getAdapterInstance(interfaceName: string, adapterName: string): Object; + export function getAdapterInstance(interfaceName: string, adapterName?: string): Object; export function initializeAdapterInstance(interfaceName: string, adapterName: string, isDefault: boolean): void; export function initializeAdapterInstances(config: Object): void; var interfaceInitialized: Event; 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 139/225] 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 e8172b800e..24b85ec4df 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 cbc46d6fb7..714703934c 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; From fb6da7e0ab86520969b145c3c51a174bd59fd660 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 22:37:39 +0200 Subject: [PATCH 140/225] external module for uuid, removed var with global interfaces for existing users --- node-uuid/node-uuid.d.ts | 13 ++++++++----- node-uuid/node-uuid.tests.ts | 2 ++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/node-uuid/node-uuid.d.ts b/node-uuid/node-uuid.d.ts index 8c287bb2e7..48a3422049 100644 --- a/node-uuid/node-uuid.d.ts +++ b/node-uuid/node-uuid.d.ts @@ -34,16 +34,19 @@ interface UUIDOptions { interface UUID { v1(options?: UUIDOptions, buffer?: number[], offset?: number): string - v1(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + v1(options?: UUIDOptions, buffer?: Buffer, offset?: number): string v2(options?: UUIDOptions, buffer?: number[], offset?: number): string - v2(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + v2(options?: UUIDOptions, buffer?: Buffer, offset?: number): string v3(options?: UUIDOptions, buffer?: number[], offset?: number): string - v3(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + v3(options?: UUIDOptions, buffer?: Buffer, offset?: number): string v4(options?: UUIDOptions, buffer?: number[], offset?: number): string - v4(options?: UUIDOptions, buffer?: NodeBuffer, offset?: number): string + v4(options?: UUIDOptions, buffer?: Buffer, offset?: number): string } -declare var uuid: UUID; +declare module 'uuid' { + var uuid: UUID; + export = uuid; +} diff --git a/node-uuid/node-uuid.tests.ts b/node-uuid/node-uuid.tests.ts index 6e1d7bd8c1..49c8f165a5 100644 --- a/node-uuid/node-uuid.tests.ts +++ b/node-uuid/node-uuid.tests.ts @@ -1,5 +1,7 @@ /// +import uuid = require('node-uuid'); + var uid1: string = uuid.v1() var uid2: string = uuid.v2() var uid3: string = uuid.v3() From 9ecabb04af17c7e09a15257999000269b08fa3b7 Mon Sep 17 00:00:00 2001 From: AdaskoTheBeAsT Date: Mon, 28 Apr 2014 23:37:13 +0200 Subject: [PATCH 141/225] jstree definition file jstree definition file after rework --- CONTRIBUTORS.md | 1 + jstree/jstree-test.ts | 67 ++++++++++ .../jquery.jstree.d.ts => jstree/jstree.d.ts | 119 ++++++++++++++++-- 3 files changed, 175 insertions(+), 12 deletions(-) create mode 100644 jstree/jstree-test.ts rename jquery.jstree/jquery.jstree.d.ts => jstree/jstree.d.ts (86%) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a3f729ca96..faf480ebb0 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -168,6 +168,7 @@ All definitions files include a header with the author and editors, so at some p * [JSON-Pointer](https://www.npmjs.org/package/json-pointer) (by [Bart van der Schoor](https://github.com/Bartvds)) * [JsRender](http://www.jsviews.com/#jsrender) (by [Kensuke MATSUZAKI](https://github.com/zakki)) * [jStorage](http://www.jstorage.info/) (by [Danil Flores](https://github.com/dflor003/)) +* [jsTree](http://www.jstree.com/) (by [Adam Pluciński](https://github.com/adaskothebeast)) * [JWPlayer](http://developer.longtailvideo.com/trac/) (by [Martin Duparc](https://github.com/martinduparc/)) * [KeyboardJS](https://github.com/RobertWHurst/KeyboardJS) (by [Vincent Bortone](https://github.com/vbortone/)) * [KineticJS](http://kineticjs.com/) (by [Basarat Ali Syed](https://github.com/basarat)) diff --git a/jstree/jstree-test.ts b/jstree/jstree-test.ts new file mode 100644 index 0000000000..ddd1c60ddd --- /dev/null +++ b/jstree/jstree-test.ts @@ -0,0 +1,67 @@ +/// + +// gets version of lib +var version: string = $.jstree.version; + +// create new instance +var instance1: JSTree = $('div').jstree(); + +// get existing reference +var existingReference: JSTree = $.jstree.reference('sds'); + +// advanced tree creation +var advancedTree = $("#briefcasetree").jstree({ + plugins: ['contextmenu', 'dnd', 'state', 'types', 'unique'], + core: { + check_callback: true, + data: { + cache: false, + url: 'Briefcase/GetProjectTree', + async: true, + type: 'GET', + dataType: 'json' + } + }, + types: { + max_depth: -2, + max_children: -2, + valid_children: ['root_folder_all', 'root_folder'], + types: { + root_folder_all: { + valid_children: ['sub_folder_all'], + start_drag: false, + move_node: false, + delete_node: false, + remove: false + }, + sub_folder_all: { + valid_children: ['sub_folder_all', 'saved_all'], + start_drag: false, + move_node: false, + delete_node: false, + remove: false + }, + saved_all: { + valid_children: [], + start_drag: false, + move_node: false, + delete_node: false, + remove: false + }, + root_folder: { + valid_children: ['sub_folder'], + start_drag: false, + move_node: false, + delete_node: false, + remove: false + }, + sub_folder: { + valid_children: ['sub_folder', 'saved_single'] + }, + saved_single: { + valid_children: 'none' + } + } + } + }); + diff --git a/jquery.jstree/jquery.jstree.d.ts b/jstree/jstree.d.ts similarity index 86% rename from jquery.jstree/jquery.jstree.d.ts rename to jstree/jstree.d.ts index 55e3c6f418..161ad5618f 100644 --- a/jquery.jstree/jquery.jstree.d.ts +++ b/jstree/jstree.d.ts @@ -1,3 +1,8 @@ +// Type definitions for jsTree v3.0.0 +// Project: http://www.jstree.com/ +// Definitions by: Adam Pluciski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + /// interface JQueryStatic { @@ -48,10 +53,44 @@ interface JSTreeStatic { /** * get a reference to an existing instance - * @param needle - * @returns {JSTree} the instance or `null` if not found + * + * __Examples__ + * + * $.jstree.reference('tree'); + * $.jstree.reference('#tree'); + * $.jstree.reference('branch'); + * $.jstree.reference('#branch'); + * + * @param {String} selector + * @returns {JSTree|null} the instance or `null` if not found */ - reference(needle: any): JSTree; + reference(selector: string): JSTree; + + /** + * get a reference to an existing instance + * + * __Examples__ + * + * $.jstree.reference(document.getElementByID('tree')); + * $.jstree.reference(document.getElementByID('branch')); + * + * @param {HTMLElement} element + * @returns {JSTree|null} the instance or `null` if not found + */ + reference(element: HTMLElement): JSTree; + + /** + * get a reference to an existing instance + * + * __Examples__ + * + * $.jstree.reference($('#tree')); + * $.jstree.reference($('#branch')); + * + * @param {JQuery} object + * @returns {JSTree|null} the instance or `null` if not found + */ + reference(object: JQuery): JSTree; } interface JSTreeStaticDefaults { @@ -121,10 +160,18 @@ interface JSTreeStaticDefaultsCore { * configure the various strings used throughout the tree */ strings?: any; + /** - * + * */ - check_callback?: (operation: string, node: any, node_parent: any, node_position: any) => void; + check_callback?: (operation: string, node: any, node_parent: any, node_position: any) => boolean; + + /** + * a callback called with a single object parameter in the instance's scope + * when something goes wrong (operation prevented, ajax failed, etc) + */ + error: () => any; + /** * the open / close animation duration in milliseconds * set this to false to disable the animation (default is 200) @@ -137,7 +184,12 @@ interface JSTreeStaticDefaultsCore { /** * theme configuration object */ - themes?:JSTreeStaticDefaultsCoreThemes; + themes?: JSTreeStaticDefaultsCoreThemes; + /** + * if left as true all parents of all selected nodes will be opened + * once the tree loads (so that all selected nodes are visible to the user) + */ + expand_selected_onload?: boolean; } interface JSTreeStaticDefaultsCoreThemes { @@ -177,11 +229,6 @@ interface JSTreeStaticDefaultsCoreThemes { * in on smaller screens (if the theme supports it). Defaults to true. */ responsive?: boolean; - /** - * if left as true all parents of all selected nodes will be opened - * once the tree loads (so that all selected nodes are visible to the user) - */ - expand_selected_onload?:boolean; } @@ -236,7 +283,7 @@ interface JSTreeStaticDefaultsContextMenu { interface JSTreeStaticDefaultsDragNDrop { /** * a boolean indicating if a copy should be possible - * while dragging (by pressint the meta key or Ctrl). Defaults to true. + * while dragging (by pressint the meta key or Ctrl). Defaults to 'true'. */ copy: boolean; /** @@ -244,6 +291,26 @@ interface JSTreeStaticDefaultsDragNDrop { * while dragging to be opened. Defaults to 500. */ open_timeout: number; + + /** + * a function invoked each time a node is about to be dragged, + * invoked in the tree's scope and receives the nodes about to be dragged + * as an argument (array) - return `false` to prevent dragging + */ + is_draggable: boolean; + + /** + * a boolean indicating if checks should constantly be made + * while the user is dragging the node (as opposed to checking only on drop), + * default is `true` + */ + check_while_dragging: boolean; + + /** + * a boolean indicating if nodes from this tree should only be copied + * with dnd (as opposed to moved), default is `false` + */ + always_copy: boolean; } interface JSTreeStaticDefaultsSearch { @@ -274,6 +341,11 @@ interface JSTreeStaticDefaultsSearch { * should be closed when the search is cleared or a new search is performed. Default is true. */ close_opened_onclear: boolean; + + /** + * Indicates if only leaf nodes should be included in search results. Default is `false`. + */ + search_leaves_only: boolean; } interface JSTreeStaticDefaultsState { @@ -287,6 +359,20 @@ interface JSTreeStaticDefaultsState { * Defaults to changed.jstree open_node.jstree close_node.jstree. */ events: string; + + /** + * Time in milliseconds after which the state will expire. + * Defaults to 'false' meaning - no expire. + */ + ttl: any; + + /** + * A function that will be executed prior to restoring state + * with one argument - the state object. Can be used + * to clear unwanted parts of the state. + */ + filter: any; + } interface JQuery { @@ -612,6 +698,11 @@ interface JSTree extends JQuery { * show the icon on an individual node */ show_icon: (obj: any) => void; + /** + */ + redraw_node: (obj: any, deep:boolean, is_callback:boolean) => any; + activate_node: (obj: any, e: any) => any; + /* * checkbox plugin: show the node checkbox icons */ @@ -625,6 +716,10 @@ interface JSTree extends JQuery { */ toggle_checkboxes: () => void; /** + * context menu plugin + */ + teardown: () => void; + /** * context menu plugin: show the context menu for a node * @param obj the node * @param x the x-coordinate relative to the document to show the menu at From ac79fdd11b4240a36b75a378a7e7ebb5f4c5b92a Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 23:42:21 +0200 Subject: [PATCH 142/225] added definitions for lockfile --- lockfile/lockfile-tests.ts | 31 +++++++++++++++++++++++++++++++ lockfile/lockfile.d.ts | 24 ++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 lockfile/lockfile-tests.ts create mode 100644 lockfile/lockfile.d.ts diff --git a/lockfile/lockfile-tests.ts b/lockfile/lockfile-tests.ts new file mode 100644 index 0000000000..49aa423d94 --- /dev/null +++ b/lockfile/lockfile-tests.ts @@ -0,0 +1,31 @@ +/// + +import lockfile = require('lockfile'); + +var bool: boolean; +var num: number; +var path: string; + +var opts: lockfile.Options; +var callback: (err: Error) => { + +}; + +opts = { + wait: num, + stale: num, + retries: num, + retryWait: num +}; + +lockfile.lock(path, opts, callback); +lockfile.lock(path, callback); +lockfile.lockSync(path, opts); + +lockfile.unlock(path, callback);; +lockfile.unlockSync(path); + +lockfile.check(path, opts, callback); +lockfile.check(path, callback); + +bool = lockfile.checkSync(path, opts); diff --git a/lockfile/lockfile.d.ts b/lockfile/lockfile.d.ts new file mode 100644 index 0000000000..99dfbe28d9 --- /dev/null +++ b/lockfile/lockfile.d.ts @@ -0,0 +1,24 @@ +// Type definitions for lockfile v0.4.2 +// Project: https://github.com/isaacs/lockfile +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'lockfile' { + export interface Options { + wait?: number; + stale?: number; + retries?: number; + retryWait?: number; + } + + export function lock(path: string, opts: Options, callback: (err: Error) => void): void; + export function lock(path: string, callback: (err: Error) => void): void; + export function lockSync(path: string, opts: Options):void; + + export function unlock(path: string, callback: (err: Error) => void): void; + export function unlockSync(path: string):void; + + export function check(path: string, opts: Options, callback: (err: Error) => void): void; + export function check(path: string, callback: (err: Error) => void): void; + export function checkSync(path: string, opts: Options): boolean; +} From 9259180be85f4e7dfdbefda8a0078502650ff927 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 23:19:28 +0200 Subject: [PATCH 143/225] added definitions for tape --- tape/tape-tests.ts | 106 +++++++++++++++++++++++++++++ tape/tape.d.ts | 161 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 267 insertions(+) create mode 100644 tape/tape-tests.ts create mode 100644 tape/tape.d.ts diff --git a/tape/tape-tests.ts b/tape/tape-tests.ts new file mode 100644 index 0000000000..2c4e4ec1bb --- /dev/null +++ b/tape/tape-tests.ts @@ -0,0 +1,106 @@ +/// + +/// + +import tape = require('tape'); + +var x: any; +var value: any; +var err: any; +var a: any; +var b: any; +var err: any; +var num: number; +var name: string; +var msg: string; +var rs: NodeJS.ReadableStream; + +var cb: tape.TestCase; +var t: tape.Test; + +tape(name, cb); +tape(name, (test: tape.Test) => { + t = test; +}); + +tape.skip(name, cb); +tape.only(name, cb); + +rs = tape.createStream(); +rs = tape.createStream(x); + +var tx = tape.createHarness(); +tx(name, cb); +tape.skip(name, cb); +tape.only(name, cb); + +tape(name, (test: tape.Test) => { + + test.plan(num); + test.end(); + + test.fail(msg); + test.pass(msg); + test.skip(msg); + + test.ok(value, msg); + test.true(value, msg); + test.assert(value, msg); + + test.notOk(value, msg); + test.false(value, msg); + test.notok(value, msg); + + test.error(err, msg); + test.ifError(err, msg); + test.ifErr(err, msg); + test.iferror(err, msg); + + test.equal(a, b, msg); + test.equals(a, b, msg); + test.isEqual(a, b, msg); + test.is(a, b, msg); + test.strictEqual(a, b, msg); + test.strictEquals(a, b, msg); + + test.notEqual(a, b, msg); + test.notEquals(a, b, msg); + test.notStrictEqual(a, b, msg); + test.notStrictEquals(a, b, msg); + test.isNotEqual(a, b, msg); + test.isNot(a, b, msg); + test.not(a, b, msg); + test.doesNotEqual(a, b, msg); + test.notEqual(a, b, msg); + test.isInequal(a, b, msg); + + test.deepEqual(a, b, msg); + test.deepEquals(a, b, msg); + test.isEquivalent(a, b, msg); + test.same(a, b, msg); + + test.notDeepEqual(a, b, msg); + test.notEquivalent(a, b, msg); + test.notDeeply(a, b, msg); + test.notSame(a, b, msg); + test.isNotDeepEqual(a, b, msg); + test.isNotDeeply(a, b, msg); + test.isNotEquivalent(a, b, msg); + test.isInequivalent(a, b, msg); + + test.deepLooseEqual(a, b, msg); + test.looseEqual(a, b, msg); + test.looseEquals(a, b, msg); + + test.notDeepLooseEqual(a, b, msg); + test.notLooseEqual(a, b, msg); + test.notLooseEquals(a, b, msg); + + test.throws(() => { + + }, value, msg); + + test.doesNotThrow(() => { + + }, value, msg); +}); diff --git a/tape/tape.d.ts b/tape/tape.d.ts new file mode 100644 index 0000000000..4746e148a0 --- /dev/null +++ b/tape/tape.d.ts @@ -0,0 +1,161 @@ +// Type definitions for tape v2.12.3 +// Project: https://github.com/substack/tape +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'tape' { + export = tape; + + /** + * Create a new test with an optional name string. cb(t) fires with the new test object t once all preceeding tests have finished. Tests execute serially. + */ + function tape(name: string, cb: tape.TestCase): void; + module tape { + + interface TestCase { + (test: Test): void; + } + + /** + * Generate a new test that will be skipped over. + */ + export function skip(name: string, cb: tape.TestCase): void; + + /** + * Like test(name, cb) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored + */ + export function only(name: string, cb: tape.TestCase): void; + + /** + * Create a new test harness instance, which is a function like test(), but with a new pending stack and test state. + */ + export function createHarness(): typeof tape; + /** + * Create a stream of output, bypassing the default output stream that writes messages to console.log(). + */ + export function createStream(opts?: any): NodeJS.ReadableStream; + + interface Test { + /** + * Create a subtest with a new test handle st from cb(st) inside the current test cb(st) will only fire when t finishes. Additional tests queued up after t will not be run until all subtests finish. + */ + test(name: string, cb: tape.TestCase): void; + + /** + * Declare that n assertions should be run. end() will be called automatically after the nth assertion. If there are any more assertions after the nth, or after end() is called, they will generate errors. + */ + plan(n: number): void; + + /** + * Declare the end of a test explicitly. + */ + end(): void; + + /** + * Generate a failing assertion with a message msg. + */ + fail(msg?: string): void; + + /** + * Generate a passing assertion with a message msg. + */ + pass(msg?: string): void; + + /** + * Generate an assertion that will be skipped over. + */ + skip(msg?: string): void; + + /** + * Assert that value is truthy with an optional description message msg. + */ + ok(value: any, msg?: string): void; + true(value: any, msg?: string): void; + assert(value: any, msg?: string): void; + + /** + * Assert that value is falsy with an optional description message msg. + */ + notOk(value: any, msg?: string): void; + false(value: any, msg?: string): void; + notok(value: any, msg?: string): void; + + /** + * Assert that err is falsy. If err is non-falsy, use its err.message as the description message. + */ + error(err: any, msg?: string): void; + ifError(err: any, msg?: string): void; + ifErr(err: any, msg?: string): void; + iferror(err: any, msg?: string): void; + + /** + * Assert that a === b with an optional description msg. + */ + equal(a: any, b: any, msg?: string): void; + equals(a: any, b: any, msg?: string): void; + isEqual(a: any, b: any, msg?: string): void; + is(a: any, b: any, msg?: string): void; + strictEqual(a: any, b: any, msg?: string): void; + strictEquals(a: any, b: any, msg?: string): void; + + /** + * Assert that a !== b with an optional description msg. + */ + notEqual(a: any, b: any, msg?: string): void; + notEquals(a: any, b: any, msg?: string): void; + notStrictEqual(a: any, b: any, msg?: string): void; + notStrictEquals(a: any, b: any, msg?: string): void; + isNotEqual(a: any, b: any, msg?: string): void; + isNot(a: any, b: any, msg?: string): void; + not(a: any, b: any, msg?: string): void; + doesNotEqual(a: any, b: any, msg?: string): void; + isInequal(a: any, b: any, msg?: string): void; + + /** + * Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with strict comparisons (===) on leaf nodes and an optional description msg. + */ + deepEqual(a: any, b: any, msg?: string): void; + deepEquals(a: any, b: any, msg?: string): void; + isEquivalent(a: any, b: any, msg?: string): void; + same(a: any, b: any, msg?: string): void; + + /** + * Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with strict comparisons (===) on leaf nodes and an optional description msg. + */ + notDeepEqual(a: any, b: any, msg?: string): void; + notEquivalent(a: any, b: any, msg?: string): void; + notDeeply(a: any, b: any, msg?: string): void; + notSame(a: any, b: any, msg?: string): void; + isNotDeepEqual(a: any, b: any, msg?: string): void; + isNotDeeply(a: any, b: any, msg?: string): void; + isNotEquivalent(a: any, b: any, msg?: string): void; + isInequivalent(a: any, b: any, msg?: string): void; + + /** + * Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with loose comparisons (==) on leaf nodes and an optional description msg. + */ + deepLooseEqual(a: any, b: any, msg?: string): void; + looseEqual(a: any, b: any, msg?: string): void; + looseEquals(a: any, b: any, msg?: string): void; + + /** + * Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with loose comparisons (==) on leaf nodes and an optional description msg. + */ + notDeepLooseEqual(a: any, b: any, msg?: string): void; + notLooseEqual(a: any, b: any, msg?: string): void; + notLooseEquals(a: any, b: any, msg?: string): void; + + /** + * Assert that the function call fn() throws an exception. + */ + throws(fn: () => void, expected: any, msg?: string): void; + + /** + * Assert that the function call fn() does not throw an exception. + */ + doesNotThrow(fn: () => void, expected: any, msg?: string): void; + } + } +} From 01b7049c180f3e283dad69ce88fba78baf67bc21 Mon Sep 17 00:00:00 2001 From: Bart van der Schoor Date: Mon, 28 Apr 2014 23:35:04 +0200 Subject: [PATCH 144/225] added definitions for lru-cache --- lru-cache/lru-cache-tests.ts | 56 ++++++++++++++++++++++++++++++++++++ lru-cache/lru-cache.d.ts | 34 ++++++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 lru-cache/lru-cache-tests.ts create mode 100644 lru-cache/lru-cache.d.ts diff --git a/lru-cache/lru-cache-tests.ts b/lru-cache/lru-cache-tests.ts new file mode 100644 index 0000000000..9121ca7914 --- /dev/null +++ b/lru-cache/lru-cache-tests.ts @@ -0,0 +1,56 @@ +/// + +import lru = require('lru-cache'); + +var x: any; +var num: number; +var bool: boolean; +var key: string; +var strArr: string[]; + +interface Foo { + foo(): void; +} + +var foo: Foo; +var fooArr: Foo[]; + +var opts: lru.Options; +opts = { + max: num, + maxAge: num, + stale: bool +}; +var cache: lru.Cache = lru({ + max: num, + maxAge: num, + length: (value: Foo) => { + return num + }, + dispose: (key: string, value: Foo) => { + + }, + stale: bool +}); + +cache = lru(num); + +cache.set(key, foo); +foo = cache.get(key); +foo = cache.peek(key); +bool = cache.has(key); +cache.del(key); +cache.reset(); + +cache.forEach((value: Foo, key: string, cache: lru.Cache) => { + +}); +cache.forEach((value: Foo, key: string, cache: lru.Cache) => { + +}, x); +cache.forEach((value, key, cache) => { + foo = cache.peek(key); +}); + +strArr = cache.keys(); +fooArr = cache.values(); diff --git a/lru-cache/lru-cache.d.ts b/lru-cache/lru-cache.d.ts new file mode 100644 index 0000000000..ae028a553e --- /dev/null +++ b/lru-cache/lru-cache.d.ts @@ -0,0 +1,34 @@ +// Type definitions for lru-cache v2.5.0 +// Project: https://github.com/isaacs/node-lru-cache +// Definitions by: Bart van der Schoor +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module 'lru-cache' { + function LRU(opts: LRU.Options): LRU.Cache; + function LRU(max: number): LRU.Cache; + + module LRU { + interface Options { + max?: number; + maxAge?: number; + length?: (value: T) => number; + dispose?: (key: string, value: T) => void; + stale?: boolean; + } + + interface Cache { + set(key: string, value: T): void; + get(key: string): T; + peek(key: string): T; + has(key: string): boolean + del(key: string): void; + reset(): void; + forEach(iter: (value: T, key: string, cache: Cache) => void, thisp?: any): void; + + keys(): string[]; + values(): T[]; + } + } + + export = LRU; +} From d5c287f16a080bdb18a92025cc47975b41834369 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?De=CC=81nes=20Harmath?= Date: Tue, 29 Apr 2014 00:03:57 +0200 Subject: [PATCH 145/225] Add type definition for Elm --- CONTRIBUTORS.md | 1 + elm/elm-tests.ts | 42 ++++++++++++++++++++++++++++++++++++++++++ elm/elm.d.ts | 28 ++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 elm/elm-tests.ts create mode 100644 elm/elm.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index a3f729ca96..74c0363b02 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -58,6 +58,7 @@ All definitions files include a header with the author and editors, so at some p * [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem)) * [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4)) * [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin)) +* [Elm](http://elm-lang.org) (by [Dénes Harmath](https://github.com/thSoft)) * [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [emissary](https://github.com/atom/emissary) (by [vvakame](https://github.com/vvakame)) * [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/elm/elm-tests.ts b/elm/elm-tests.ts new file mode 100644 index 0000000000..dd0c601975 --- /dev/null +++ b/elm/elm-tests.ts @@ -0,0 +1,42 @@ +/// + +// Based on https://gist.github.com/evancz/8521339 + +interface Elm { + Shanghai: ElmModule; +} + +interface ShanghaiPorts { + coordinates: PortToElm>; + incomingShip: PortToElm; + outgoingShip: PortToElm; + totalCapacity: PortFromElm; +} + +interface Ship { + name: string; + capacity: number; +} + +// initialize the Shanghai component which keeps track of +// shipping data in and out of the Port of Shanghai. +var shanghai = Elm.worker(Elm.Shanghai, { + coordinates: [0, 0], + incomingShip: { name: "", capacity: 0 }, + outgoingShip: "" +}); + +function logger(x: any) { console.log(x) } +shanghai.ports.totalCapacity.subscribe(logger); +// send some ships to the port of Shanghai +shanghai.ports.incomingShip.send({ + name: "Mary Mærsk", + capacity: 18270 +}); +shanghai.ports.incomingShip.send({ + name: "Emma Mærsk", + capacity: 15500 +}); +// have those ships leave the port of Shanghai +shanghai.ports.outgoingShip.send("Mary Mærsk"); +shanghai.ports.outgoingShip.send("Emma Mærsk"); \ No newline at end of file diff --git a/elm/elm.d.ts b/elm/elm.d.ts new file mode 100644 index 0000000000..1185394be8 --- /dev/null +++ b/elm/elm.d.ts @@ -0,0 +1,28 @@ +// Type definitions for Elm 0.12 +// Project: http://elm-lang.org +// Definitions by: Dénes Harmath +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare var Elm: Elm; + +interface Elm { + embed

    (elmModule: ElmModule

    , element: Node, initialValues?: Object): ElmComponent

    ; + fullscreen

    (elmModule: ElmModule

    , initialValues?: Object): ElmComponent

    ; + worker

    (elmModule: ElmModule

    , initialValues?: Object): ElmComponent

    ; +} + +interface ElmModule

    { +} + +interface ElmComponent

    { + ports: P; +} + +interface PortToElm { + send(value: V): void; +} + +interface PortFromElm { + subscribe(handler: (value: V) => void): void; + unsubscribe(handler: (value: V) => void): void; +} \ No newline at end of file From ab899ff5c4eb8ae26bbbd230854543e1769540e9 Mon Sep 17 00:00:00 2001 From: Steve Taylor Date: Tue, 29 Apr 2014 11:07:42 +0930 Subject: [PATCH 146/225] Updated fullCalendar to 1.6.4. Fixed typos, cleaned up comment formatting and added some documentation links in comments. --- fullCalendar/fullCalendar.d.ts | 257 ++++++++++++++++++++++----------- 1 file changed, 172 insertions(+), 85 deletions(-) diff --git a/fullCalendar/fullCalendar.d.ts b/fullCalendar/fullCalendar.d.ts index fd1303f69e..84e6ee6cc1 100644 --- a/fullCalendar/fullCalendar.d.ts +++ b/fullCalendar/fullCalendar.d.ts @@ -7,29 +7,37 @@ declare module FullCalendar { export interface Calendar { + /** - * Formats a Date object into a string. - */ + * Formats a Date object into a string. + */ formatDate(date: Date, format: string, options?: Options): string; + /** - * Formats a date range (two Date objects) into a string. - */ + * Formats a date range (two Date objects) into a string. + */ formatDates(date1: Date, date2: Date, format: string, options?: Options): string; + /** - * Parses a string into a Date object. - */ + * Parses a string into a Date object. + */ parseDate(dateString: string, ignoreTimezone?: boolean): Date; + /** - * Parses an ISO8601 string into a Date object. - */ + * Parses an ISO8601 string into a Date object. + */ parseISO8601(dateString: string, ignoreTimezone?: boolean): Date; + /** - * Gets the version of Fullcalendar - */ + * Gets the version of Fullcalendar + */ version: string; } export interface Options { + + // General display - http://arshaw.com/fullcalendar/docs/display/ + header?: { left: string; center: string; @@ -43,22 +51,31 @@ declare module FullCalendar { firstDay?: number; isRTL?: boolean; weekends?: boolean; + hiddenDays?: number[]; weekMode?: string; weekNumbers?: boolean; weekNumberCalculation?: any; // String/Function height?: number; contentHeight?: number; - aspectRation?: number; - viewDisplay?: (view: View) => void; - windowResize?: (view: View) => void; + aspectRatio?: number; + handleWindowResize?: boolean; + viewRender?: (view: View, element: JQuery) => void; + viewDestroy?: (view: View, element: JQuery) => void; dayRender?: (date: Date, cell: HTMLTableDataCellElement) => void; + windowResize?: (view: View) => void; + + // Views - http://arshaw.com/fullcalendar/docs/views/ defaultView?: string; + // Current Date - http://arshaw.com/fullcalendar/docs/current_date/ + year?: number; month?: number; date?: number; + // Text/Time Customization - http://arshaw.com/fullcalendar/docs/text/ + timeFormat?: any; // String/ViewOptionHash columnFormat?: any; // String/ViewOptionHash titleFormat?: any; // String/ViewOptionHash @@ -69,11 +86,15 @@ declare module FullCalendar { dayNamesShort?: Array; weekNumberTitle?: number; + // Clicking & Hovering - http://arshaw.com/fullcalendar/docs/mouse/ + dayClick?: (date: Date, allDay: boolean, jsEvent: MouseEvent, view: View) => void; eventClick?: (event: EventObject, jsEvent: MouseEvent, view: View) => any; // return type boolean or void eventMouseover?: (event: EventObject, jsEvent: MouseEvent, view: View) => void; eventMouseout?: (event: EventObject, jsEvent: MouseEvent, view: View) => void; + // Selection - http://arshaw.com/fullcalendar/docs/selection/ + selectable?: any; // Boolean/ViewOptionHash selectHelper?: any; // Boolean/Function unselectAuto?: boolean; @@ -81,26 +102,51 @@ declare module FullCalendar { select?: (startDate: Date, endDate: Date, allDay: boolean, jsEvent: MouseEvent, view: View) => void; unselect?: (view: View, jsEvent: Event) => void; - eventSources?: Array; + // Event Data - http://arshaw.com/fullcalendar/docs/event_data/ + + /** + * This has one of the following types: + * + * - EventObject[] + * - string (JSON feed) + * - (start: Date, end: Date, callback: {(events: EventObject[]) => void;}) => void; + */ + events?: any; + + /** + * An array, each element being one of the following types: + * + * - EventSource + * - EventObject[] + * - string (JSON feed) + * - (start: Date, end: Date, callback: {(events: EventObject[]) => void;}) => void; + */ + eventSources?: any[]; + allDayDefault?: boolean; ignoreTimezone?: boolean; - eventDataTransform?: (eventData: any) => EventObject; startParam?: string; endParam?: string lazyFetching?: boolean; + eventDataTransform?: (eventData: any) => EventObject; loading?: (isLoading: boolean, view: View) => void; + // Event Rendering - http://arshaw.com/fullcalendar/docs/event_rendering/ + eventColor?: string; eventBackgroundColor?: string; eventBorderColor?: string; eventTextColor?: string; eventRender?: (event: EventObject, element: HTMLDivElement, view: View) => void; eventAfterRender?: (event: EventObject, element: HTMLDivElement, view: View) => void; - eventAllAfterRender?: (view: View) => void; + eventAfterAllRender?: (view: View) => void; + eventDestroy?: (event: EventObject, element: JQuery, view: View) => void; + + // Event Dragging & Resizing editable?: boolean; - disableDragging?: boolean; - disableResizing?: boolean; + eventStartEditable?: boolean; + eventDurationEditable?: boolean; dragRevertDuration?: number; dragOpacity?: any; // Float/ViewOptionHash eventDragStart?: (event: EventObject, jsEvent: MouseEvent, ui: any, view: View) => void; @@ -119,7 +165,7 @@ declare module FullCalendar { name: string; title: string; start: Date; - End: Date; + end: Date; visStart: Date; visEnd: Date; } @@ -137,6 +183,9 @@ declare module FullCalendar { ''?: any; } + /** + * Agenda Options - http://arshaw.com/fullcalendar/docs/agenda/ + */ export interface AgendaOptions { allDaySlot?: boolean; allDayText?: string; @@ -147,6 +196,7 @@ declare module FullCalendar { firstHour?: number; minTime?: any; // Integer/String maxTime?: any; // Integer/String + slotEventOverlap?: boolean; } export interface ButtonTextObject { @@ -177,7 +227,16 @@ declare module FullCalendar { } export interface EventSource extends JQueryAjaxSettings { + + /** + * This has one of the following types: + * + * - EventObject[] + * - string (JSON feed) + * - (start: Date, end: Date, callback: {(events: EventObject[]) => void;}) => void; + */ events?: any; + color?: string; backgroundColor?: string; borderColor?: string; @@ -194,117 +253,145 @@ declare module FullCalendar { } interface JQuery { + /** - * Get/Set option value - */ + * Get/Set option value + */ fullCalendar(method: 'option', option: string, value?: any): void; + /** - * Immediately forces the calendar to render and/or readjusts its size. - */ + * Immediately forces the calendar to render and/or readjusts its size. + */ fullCalendar(method: 'render'): void; + /** - * Restores the element to the state before FullCalendar was initialized. - */ + * Restores the element to the state before FullCalendar was initialized. + */ fullCalendar(method: 'destroy'): void; + /** - * Moves the calendar one step back (either by a month, week, or day). - */ - fullCalendar(method: 'prev'): void; - /** - * Moves the calendar one step forward (either by a month, week, or day). - */ - fullCalendar(method: 'next'): void; - /** - * Moves the calendar back one year. - */ - fullCalendar(method: 'prevYear'): void; - /** - * Moves the calendar forward one year. - */ - fullCalendar(method: 'nextYear'): void; - /** - * Moves the calendar to the current date. - */ - fullCalendar(method: 'today'): void; - /** - * Returns the View Object for the current view. - */ + * Returns the View Object for the current view. + */ fullCalendar(method: 'getView'): FullCalendar.View; + /** - * Immediately switches to a different view. - */ + * Immediately switches to a different view. + */ fullCalendar(method: 'changeView', viewName: string): void; + /** - * Moves the calendar to an arbitrary year/month/date. - */ + * Moves the calendar one step back (either by a month, week, or day). + */ + fullCalendar(method: 'prev'): void; + + /** + * Moves the calendar one step forward (either by a month, week, or day). + */ + fullCalendar(method: 'next'): void; + + /** + * Moves the calendar back one year. + */ + fullCalendar(method: 'prevYear'): void; + + /** + * Moves the calendar forward one year. + */ + fullCalendar(method: 'nextYear'): void; + + /** + * Moves the calendar to the current date. + */ + fullCalendar(method: 'today'): void; + + /** + * Moves the calendar to an arbitrary year/month/date. + */ fullCalendar(method: 'gotoDate', year: number, month?: number, date?: number): void; + /** - * Moves the calendar to an arbitrary date. - */ + * Moves the calendar to an arbitrary date. + */ fullCalendar(method: 'gotoDate', date: Date): void; + /** - * Moves the calendar forward/backward an arbitrary amount of time. - */ + * Moves the calendar forward/backward an arbitrary amount of time. + */ fullCalendar(method: 'incrementDate', year: number, month?: number, date?: number): void; + /** - * Returns a Date object for the current date of the calendar. - */ + * Returns a Date object for the current date of the calendar. + */ fullCalendar(method: 'getDate'): Date; + /** - * A method for programmatically selecting a period of time. - */ + * A method for programmatically selecting a period of time. + */ fullCalendar(method: 'select', startDate: Date, endDate: Date, allDay: boolean): void; + /** - * A method for programmatically clearing the current selection. - */ + * A method for programmatically clearing the current selection. + */ fullCalendar(method: 'unselect'): void; + /** - * Reports changes to an event and renders them on the calendar. - */ + * Reports changes to an event and renders them on the calendar. + */ fullCalendar(method: 'updateEvent', event: FullCalendar.EventObject): void; + /** - * Retrieves events that FullCalendar has in memory. - */ + * Retrieves events that FullCalendar has in memory. + */ fullCalendar(method: 'clientEvents', idOrfilter?: any): Array; + /** - * Retrieves events that FullCalendar has in memory. - */ + * Retrieves events that FullCalendar has in memory. + */ fullCalendar(method: 'clientEvents', idOrfilter?: (e: FullCalendar.EventObject) => boolean): Array; + /** - * Removes events from the calendar. - */ + * Removes events from the calendar. + */ fullCalendar(method: 'removeEvents', idOrfilter?: any): void; + /** - * Removes events from the calendar. - */ + * Removes events from the calendar. + */ fullCalendar(method: 'removeEvents', idOrfilter?: (e: FullCalendar.EventObject) => boolean): void; + /** - * Refetches events from all sources and rerenders them on the screen. - */ + * Refetches events from all sources and rerenders them on the screen. + */ fullCalendar(method: 'refetchEvents'): void; + /** - * Dynamically adds an event source. - */ + * Dynamically adds an event source. + */ fullCalendar(method: 'addEventSource', source: any): void; + /** - * Dynamically removes an event source. - */ + * Dynamically removes an event source. + */ fullCalendar(method: 'removeEventSource', source: any): void; + /** - * Renders a new event on the calendar. - */ + * Renders a new event on the calendar. + */ fullCalendar(method: 'renderEvent', event: FullCalendar.EventObject, stick?: boolean): void; + /** - * Rerenders all events on the calendar. - */ + * Rerenders all events on the calendar. + */ fullCalendar(method: 'rerenderEvents'): void; + /** - * Create calendar object - */ + * Create calendar object + */ fullCalendar(options: FullCalendar.Options): JQuery; + /** - * Generic method function - */ + * Generic method function + */ fullCalendar(method: string, arg1: any, arg2: any, arg3: any): void; } From 47c26a46641dfd6d3c794b1e5fd3697e714ce825 Mon Sep 17 00:00:00 2001 From: Utkarsh Upadhyay Date: Tue, 29 Apr 2014 10:37:33 +0200 Subject: [PATCH 147/225] Allow setting of styles/properties via objects. Additionally: 1. Make the type for setting attributes via objects slightly stricter. 2. Add tests for style/property setting via object maps. --- d3/d3-tests.ts | 15 +++++++++++++++ d3/d3.d.ts | 4 +++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index aab65c06c0..5bee2b84ae 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -2286,6 +2286,21 @@ function attrObjTest () { .attr({"xlink:href": function(d, i) { return d + "-" + i + ".png"; }}); } +// Test for setting styles as an object +// From https://github.com/mbostock/d3/blob/master/test/selection/style-test.js +function styleObjTest () { + d3.select('body') + .style({"background-color": "white", opacity: .42}); +} + +// Test for setting styles as an object +// From https://github.com/mbostock/d3/blob/master/test/selection/property-test.js +function propertyObjTest () { + d3.select('body') + .property({bgcolor: "purple", opacity: .41}); +} + + // Test for brushes // This triggers a bug (shown below) in the 0.9.0 compiler, but works with // 0.9.1 compiler. diff --git a/d3/d3.d.ts b/d3/d3.d.ts index 5f68f6f362..0b049726bc 100644 --- a/d3/d3.d.ts +++ b/d3/d3.d.ts @@ -710,7 +710,7 @@ declare module D3 { (name: string): string; (name: string, value: any): Selection; (name: string, valueFunction: (data: any, index: number) => any): Selection; - (attrValueMap : any): Selection; + (attrValueMap : Object): Selection; }; classed: { @@ -723,12 +723,14 @@ declare module D3 { (name: string): string; (name: string, value: any, priority?: string): Selection; (name: string, valueFunction: (data: any, index: number) => any, priority?: string): Selection; + (styleValueMap : Object): Selection; }; property: { (name: string): void; (name: string, value: any): Selection; (name: string, valueFunction: (data: any, index: number) => any): Selection; + (propertyValueMap : Object): Selection; }; text: { From e113f195f3b60e76b2c1079621c510fbe37e3a36 Mon Sep 17 00:00:00 2001 From: Utkarsh Upadhyay Date: Tue, 29 Apr 2014 10:38:44 +0200 Subject: [PATCH 148/225] Re-enable the test for brush() This was failing with 0.9.0. Now the test no longer crashes the compiler. --- d3/d3-tests.ts | 86 +++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 53 deletions(-) diff --git a/d3/d3-tests.ts b/d3/d3-tests.ts index 5bee2b84ae..1a1acc3240 100644 --- a/d3/d3-tests.ts +++ b/d3/d3-tests.ts @@ -2302,61 +2302,41 @@ function propertyObjTest () { // Test for brushes -// This triggers a bug (shown below) in the 0.9.0 compiler, but works with -// 0.9.1 compiler. +function brushTest() { + var xScale = d3.scale.linear(), + yScale = d3.scale.linear(); -// Stack trace: -// /usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:38215 -// return (type === this.semanticInfoChain.anyTypeSymbol) || type.isError(); -// ^ -// TypeError: Cannot call method 'isError' of null -// at PullTypeResolver.isAnyOrEquivalent (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:38215:76) -// at PullTypeResolver.resolveNameExpression (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:39953:39) -// at PullTypeResolver.resolveAST (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:39758:37) -// at PullTypeResolver.computeIndexExpressionSymbol (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:40933:37) -// at PullTypeResolver.resolveIndexExpression (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:40925:45) -// at PullTypeResolver.resolveAST (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:39870:33) -// at PullTypeResolver.resolveOverloads (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:42917:43) -// at PullTypeResolver.computeCallExpressionSymbol (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:41373:34) -// at PullTypeResolver.resolveCallExpression (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:41175:29) -// at PullTypeChecker.typeCheckCallExpression (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:45111:58) -// at PullTypeChecker.typeCheckAST (/usr/local/share/npm/lib/node_modules/typescript/bin/tsc.js:43786:33) + var xMin = 0, xMax = 1, + yMin = 0, yMax = 1; -// function brushTest() { -// var xScale = d3.scale.linear(), -// yScale = d3.scale.linear(); -// -// var xMin = 0, xMax = 1, -// yMin = 0, yMax = 1; -// -// // Setting only x scale. -// var brush1 = d3.svg.brush() -// .x(xScale) -// .on('brush', function () { -// var extent = brush1.extent(); -// xMin = Math.max(extent[0], 0); -// xMax = Math.min(extent[1], 1); -// brush1.extent([xMin, xMax]); -// }); -// -// // Setting both the x and y scale -// var brush2 = d3.svg.brush() -// .x(xScale) -// .y(yScale) -// .on('brush', function () { -// var extent = brush2.extent(); -// var xExtent = extent[0], -// yExtent = extent[1]; -// -// xMin = Math.max(xExtent[0], 0); -// xMax = Math.min(xExtent[1], 1); -// -// yMin = Math.max(yExtent[0], 0); -// yMax = Math.min(yExtent[1], 1); -// -// brush1.extent([[xMin, xMax], [yMin, yMax]]); -// }); -// } + // Setting only x scale. + var brush1 = d3.svg.brush() + .x(xScale) + .on('brush', function () { + var extent = brush1.extent(); + xMin = Math.max(extent[0], 0); + xMax = Math.min(extent[1], 1); + brush1.extent([xMin, xMax]); + }); + + // Setting both the x and y scale + var brush2 = d3.svg.brush() + .x(xScale) + .y(yScale) + .on('brush', function () { + var extent = brush2.extent(); + var xExtent = extent[0], + yExtent = extent[1]; + + xMin = Math.max(xExtent[0], 0); + xMax = Math.min(xExtent[1], 1); + + yMin = Math.max(yExtent[0], 0); + yMax = Math.min(yExtent[1], 1); + + brush1.extent([[xMin, xMax], [yMin, yMax]]); + }); +} // Tests for area From 7c8a67a4026c233af5eb8d81e38890999cd0f5ff Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 29 Apr 2014 13:48:00 +0100 Subject: [PATCH 149/225] jQuery: Add more specific val setters --- jquery/jquery.d.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 8f1bf2527b..6d8551f44b 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1512,7 +1512,19 @@ interface JQuery { * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. */ - val(func: (index: number, value: any) => any): JQuery; + val(func: (index: number, value: string) => any): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: string[]) => any): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: number) => any): JQuery; /** * Get the value of style properties for the first element in the set of matched elements. From c259dba094121a389b41c573d5000dda7bdf2092 Mon Sep 17 00:00:00 2001 From: John Reilly Date: Tue, 29 Apr 2014 13:52:47 +0100 Subject: [PATCH 150/225] jQuery: Add even more specific val setters --- jquery/jquery.d.ts | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/jquery/jquery.d.ts b/jquery/jquery.d.ts index 6d8551f44b..b378dfd0ac 100644 --- a/jquery/jquery.d.ts +++ b/jquery/jquery.d.ts @@ -1512,19 +1512,37 @@ interface JQuery { * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. */ - val(func: (index: number, value: string) => any): JQuery; + val(func: (index: number, value: string) => string): JQuery; /** * Set the value of each element in the set of matched elements. * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. */ - val(func: (index: number, value: string[]) => any): JQuery; + val(func: (index: number, value: string[]) => string): JQuery; /** * Set the value of each element in the set of matched elements. * * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. */ - val(func: (index: number, value: number) => any): JQuery; + val(func: (index: number, value: number) => string): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: string) => string[]): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: string[]) => string[]): JQuery; + /** + * Set the value of each element in the set of matched elements. + * + * @param func A function returning the value to set. this is the current element. Receives the index position of the element in the set and the old value as arguments. + */ + val(func: (index: number, value: number) => string[]): JQuery; /** * Get the value of style properties for the first element in the set of matched elements. From 7b8666ad0e9c74d2bf0b38ff47ed65cf265cd4fe Mon Sep 17 00:00:00 2001 From: nktpro Date: Tue, 29 Apr 2014 06:09:02 -0700 Subject: [PATCH 151/225] Add less.tree.Attribute typing --- less/less.d.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/less/less.d.ts b/less/less.d.ts index 1ab9293c47..1b063e39c3 100644 --- a/less/less.d.ts +++ b/less/less.d.ts @@ -497,6 +497,16 @@ declare module "less" { toCSS(env?: Options): string; eval(): UnicodeDescriptor; } + + export class Attribute implements IInjectable { + constructor(value: string); + + value: string; + + toCSS(env?: Options): string; + genCSS(env?: Options, output): string; + eval(): Attribute; + } export var debugInfo: DebugInfoFunction; export function find(obj: any[], fun: Function): any; @@ -539,4 +549,4 @@ declare module "less" { export function writeError(ctx, options: { color: boolean; }): void; export var version: number[]; -} \ No newline at end of file +} From 9ca5d2fbca5a8efa1740f847c4c924cbe736b86a Mon Sep 17 00:00:00 2001 From: nktpro Date: Tue, 29 Apr 2014 06:12:02 -0700 Subject: [PATCH 152/225] Fixed optional argument --- less/less.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/less/less.d.ts b/less/less.d.ts index 1b063e39c3..d5787913b9 100644 --- a/less/less.d.ts +++ b/less/less.d.ts @@ -504,7 +504,7 @@ declare module "less" { value: string; toCSS(env?: Options): string; - genCSS(env?: Options, output): string; + genCSS(env: Options, output): string; eval(): Attribute; } From cc3aeaae755173cfb0e0ab4cf84d424e40503876 Mon Sep 17 00:00:00 2001 From: Jared Reynolds Date: Tue, 29 Apr 2014 14:05:14 -0700 Subject: [PATCH 153/225] Added definitions for chai-datetime - Added explicit "any" types to chai definitions --- chai-datetime/chai-datetime-tests.ts | 47 ++++++++++++++++++++++++++++ chai-datetime/chai-datetime.d.ts | 33 +++++++++++++++++++ chai/chai.d.ts | 32 +++++++++---------- 3 files changed, 96 insertions(+), 16 deletions(-) create mode 100644 chai-datetime/chai-datetime-tests.ts create mode 100644 chai-datetime/chai-datetime.d.ts diff --git a/chai-datetime/chai-datetime-tests.ts b/chai-datetime/chai-datetime-tests.ts new file mode 100644 index 0000000000..0b7ff729ff --- /dev/null +++ b/chai-datetime/chai-datetime-tests.ts @@ -0,0 +1,47 @@ +/// +/// +/// + +var expect = chai.expect; + +function test_equalTime(){ + var date: Date = new Date(2014, 1, 1); + expect(date).to.be.equalTime(date); + date.should.be.equalTime(date); + assert.equalTime(date, date); +} + +function test_beforeTime(){ + var date: Date = new Date(2014, 1, 1); + expect(date).to.be.beforeTime(date); + date.should.be.beforeTime(date); + assert.beforeTime(date, date); +} + +function test_afterTime(){ + var date: Date = new Date(2014, 1, 1); + expect(date).to.be.afterTime(date); + date.should.be.afterTime(date); + assert.afterTime(date, date); +} + +function test_equalDate(){ + var date: Date = new Date(2014, 1, 1); + expect(date).to.equalDate(date); + date.should.equalDate(date); + assert.equalDate(date, date); +} + +function test_beforeDate(){ + var date: Date = new Date(2014, 1, 1); + expect(date).to.beforeDate(date); + date.should.beforeDate(date); + assert.beforeDate(date, date); +} + +function test_afterDate(){ + var date: Date = new Date(2014, 1, 1); + expect(date).to.afterDate(date); + date.should.afterDate(date); + assert.afterDate(date, date); +} \ No newline at end of file diff --git a/chai-datetime/chai-datetime.d.ts b/chai-datetime/chai-datetime.d.ts new file mode 100644 index 0000000000..432f6bb247 --- /dev/null +++ b/chai-datetime/chai-datetime.d.ts @@ -0,0 +1,33 @@ +// Type definitions for chai-datetime +// Project: https://github.com/gaslight/chai-datetime.git +// Definitions by: Cliff Burger +// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module chai { + + interface Expect { + afterDate(date: Date): boolean; + beforeDate(date: Date): boolean; + equalDate(date: Date): boolean; + + afterTime(date: Date): boolean; + beforeTime(date: Date): boolean; + equalTime(date: Date): boolean; + } + + interface Assert { + afterDate(leftDate: Date, rightDate: Date): boolean; + beforeDate(leftDate: Date, rightDate: Date): boolean; + equalDate(leftDate: Date, rightDate: Date): boolean; + + afterTime(leftDate: Date, rightDate: Date): boolean; + beforeTime(leftDate: Date, rightDate: Date): boolean; + equalTime(leftDate: Date, rightDate: Date): boolean; + } +} + +interface Date { + should: chai.Expect; +} diff --git a/chai/chai.d.ts b/chai/chai.d.ts index 7318744012..d840aba964 100644 --- a/chai/chai.d.ts +++ b/chai/chai.d.ts @@ -9,28 +9,28 @@ declare module chai { function expect(target: any, message?: string): Expect; // Provides a way to extend the internals of Chai - function use(fn: (chai: any, utils: any) => void); + function use(fn: (chai: any, utils: any) => void): any; interface ExpectStatic { (target: any): Expect; } interface Assertions { - attr(name, value?); - css(name, value?); - data(name, value?); - class(className); - id(id); - html(html); - text(text); - value(value); - visible; - hidden; - selected; - checked; - disabled; - empty; - exist; + attr(name: string, value?: string): any; + css(name: string, value?: string): any; + data(name: string, value?: string): any; + class(className: string): any; + id(id: string): any; + html(html: string): any; + text(text: string): any; + value(value: string): any; + visible: any; + hidden: any; + selected: any; + checked: any; + disabled: any; + empty: any; + exist: any; } interface Expect extends LanguageChains, NumericComparison, TypeComparison, Assertions { From b7d67743e7d6aacdc8313164d9fcc9455a332aac Mon Sep 17 00:00:00 2001 From: Roland Zwaga Date: Wed, 30 Apr 2014 10:28:02 +0200 Subject: [PATCH 154/225] added definitions for missing ngGrid interfaces and created tests for them --- ng-grid/ng-grid-tests.ts | 277 +++++++++++++++++++++++++- ng-grid/ng-grid.d.ts | 418 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 689 insertions(+), 6 deletions(-) diff --git a/ng-grid/ng-grid-tests.ts b/ng-grid/ng-grid-tests.ts index 53763b1a51..d636753ba0 100644 --- a/ng-grid/ng-grid-tests.ts +++ b/ng-grid/ng-grid-tests.ts @@ -1,4 +1,5 @@ -/// +/// +/// var options1: ngGrid.IGridOptions = { data: [{ 'Name': 'Bob' }, { 'Name': 'Jane' }] @@ -25,3 +26,277 @@ var options4: ngGrid.IGridOptions = { currentPage: 1 } }; + +var columnDef: ngGrid.IColumnDef = { + width:{}, + minWidth:{}, + visible:false, + field:'', + displayName:'', + sortable:false, + resizable:false, + groupable:false, + pinnable:false, + editableCellTemplate:'', + enableCellEdit:false, + cellEditableCondition:'', + sortFn:(a:any, b:any):number=> { return 0 }, + cellTemplate:'', + cellClass:'', + headerClass:'', + headerCellTemplate:'', + cellFilter:'', + aggLabelFilter:'', + pinned:false +} + +var searchProvider: ngGrid.ISearchProvider = {}; +searchProvider.fieldMap = {}; +searchProvider.extFilter = false; +searchProvider.evalFilter(); + +var nr:number; + +var selectionProvider: ngGrid.ISelectionProvider = {}; +selectionProvider.multi = false; +selectionProvider.selectedItems = []; +selectionProvider.selectedIndex = 1; +selectionProvider.lastClickedRow = {}; +selectionProvider.ignoreSelectedItemChanges = false; +selectionProvider.pKeyParser = {}; +selectionProvider.ChangeSelection({}, {}); +nr = selectionProvider.getSelection({}); +nr = selectionProvider.getSelectionIndex({}); +selectionProvider.setSelection({}, false); +selectionProvider.toggleSelectAll(true, false, false); + +var eventProvider: ngGrid.IEventProvider = {}; +eventProvider.colToMove = {}; +eventProvider.groupToMove = {}; +eventProvider.assignEvents(); +eventProvider.assignGridEventHandlers(); +eventProvider.dragStart({}); +eventProvider.dragOver({}); +eventProvider.setDraggables(); +eventProvider.onGroupMouseDown({}); +eventProvider.onGroupDrop({}); +eventProvider.onHeaderMouseDown({}); +eventProvider.onHeaderDrop({}); + +var aggregate: ngGrid.IAggregate = {}; +aggregate.rowIndex = 0; +aggregate.offsetTop = 0; +aggregate.entity = {}; +aggregate.label = ''; +aggregate.field = ''; +aggregate.depth = 0; +aggregate.parent = {}; +aggregate.children = []; +aggregate.aggChildren = []; +aggregate.aggIndex = 0; +aggregate.collapsed = false; +aggregate.groupInitState = false; +aggregate.rowFactory = {}; +aggregate.rowHeight = 0; +aggregate.isAggRow = false; +aggregate.offsetLeft = 0; +aggregate.aggLabelFilter = {}; + +var rowConfig: ngGrid.IRowConfig = {}; +rowConfig.enableCellSelection = false; +rowConfig.enableRowSelection = false; +rowConfig.jqueryUITheme = false; +rowConfig.rowClasses = ['']; +rowConfig.rowHeight = 0; +rowConfig.selectWithCheckboxOnly = false; +rowConfig.selectedItems = []; +rowConfig.afterSelectionChangeCallback(); +rowConfig.beforeSelectionChangeCallback(); + +var renderedRange: ngGrid.IRenderedRange = {}; +renderedRange.bottomRow = 0; +renderedRange.topRow = 0; + +var rowFactory: ngGrid.IRowFactory = {}; +rowFactory.aggCache= null; +rowFactory.dataChanged= false; +rowFactory.groupedData= null; +rowFactory.numberOfAggregates = 0; +rowFactory.parentCache= []; +rowFactory.parsedData= []; +rowFactory.renderedRange = {}; +rowFactory.rowConfig = {}; +rowFactory.rowHeight = 0; +rowFactory.selectionProvider = {}; +rowFactory.UpdateViewableRange({}); +aggregate = rowFactory.buildAggregateRow({}, 0); +var row:ngGrid.IRow = rowFactory.buildEntityRow({}, 0); +rowFactory.filteredRowsChanged(); +rowFactory.fixRowCache(); +rowFactory.getGrouping({}); +rowFactory.parseGroupData({}); +rowFactory.renderedChange(); +rowFactory.renderedChangeNoGroups(); + +var dimension: ngGrid.IDimension = {}; +dimension.outerHeight = 0; +dimension.outerWidth = 0; +dimension.autoFitHeight = false; + +var elmDimension: ngGrid.IElementDimension = {}; +elmDimension.rootMaxH = 0; +elmDimension.rootMaxW = 0; +elmDimension.rowIndexCellW = 0; +elmDimension.rowSelectedCellW = 0; +elmDimension.scrollH = 0; +elmDimension.scrollW = 0; + +var row: ngGrid.IRow = {}; +row.entity= {}; +row.config = {}; +row.selectionProvider = {}; +row.rowIndex = 0; +row.utils= {}; +row.selected = false; +row.cursor = ''; +row.offsetTop = 0; +row.rowDisplayIndex = 0; +row.afterSelectionChange(); +row.beforeSelectionChange(); +row.setSelection(false); +row.continueSelection({}); +row.ensureEntity({}); +var b:boolean = row.toggleSelected({}); +row.alternatingRowClass(); +var a:any = row.getProperty(''); +var r:ngGrid.IRow = row.copy(); +row.setVars({}); + +var column: ngGrid.IColumn = {}; +column.colDef = {}; +column.width = 0; +column.groupIndex = 0; +column.isGroupedBy = false; +column.minWidth = 0; +column.maxWidth = 0; +column.enableCellEdit = false; +column.cellEditableCondition = {}; +column.headerRowHeight = 0; +column.displayName = ''; +column.index = 0; +column.isAggCol = false; +column.cellClass = ''; +column.sortPriority = 0; +column.cellFilter = {}; +column.field = ''; +column.aggLabelFilter = {}; +column.visible = false; +column.sortable = false; +column.resizable = false; +column.pinnable = false; +column.pinned = false; +column.originalIndex = 0; +column.groupable = false; +column.sortDirection = ''; +column.sortingAlgorithm = ()=>{}; +column.headerClass = ''; +column.cursor = ''; +column.headerCellTemplate = ''; +column.cellTemplate = ''; +var s:string = column.groupedByClass(); +column.toggleVisible(); +b = column.showSortButtonUp(); +b = column.showSortButtonDown(); +b = column.noSortVisible(); +b = column.sort({}); +a = column.gripClick(); +a = column.gripOnMouseDown({}); +column.onMouseMove({}); +column.gripOnMouseUp({}); +var c:ngGrid.IColumn = column.copy(); +column.setVars(c); + +var gridScope: ngGrid.IGridScope = {}; +gridScope.elementsNeedMeasuring = false; +gridScope.columns = []; +gridScope.renderedRows = []; +gridScope.renderedColumns = []; +gridScope.headerRow = {}; +gridScope.rowHeight = 0; +gridScope.jqueryUITheme = {}; +gridScope.showSelectionCheckbox = false; +gridScope.enableCellSelection = false; +gridScope.enableCellEditOnFocus = false; +gridScope.footer = {}; +gridScope.selectedItems = []; +gridScope.multiSelect = false; +gridScope.showFooter = false; +gridScope.footerRowHeight = 0; +gridScope.showColumnMenu = false; +gridScope.forceSyncScrolling = false; +gridScope.showMenu = false; +gridScope.configGroups = []; +gridScope.gridId = ''; +gridScope.enablePaging = false; +gridScope.pagingOptions = {}; +gridScope.i18n = {}; +gridScope.selectionProvider = {}; +gridScope.adjustScrollLeft(0); +gridScope.adjustScrollTop(0, true); +gridScope.toggleShowMenu(); +gridScope.toggleSelectAll(); +nr = gridScope.totalFilteredItemsLength(); +a = gridScope.showGroupPanel(); +nr = gridScope.topPanelHeight(); +nr = gridScope.viewportDimHeight(); +gridScope.groupBy({}); +gridScope.removeGroup(0); +gridScope.togglePin({}); +nr = gridScope.totalRowWidth(); +a = gridScope.headerScrollerDim(); + +var gridInstance: ngGrid.IGridInstance = {}; +gridInstance.$canvas = {}; +gridInstance.$viewport = {}; +gridInstance.$groupPanel = {}; +gridInstance.$footerPanel = {}; +gridInstance.$headerScroller = {}; +gridInstance.$headerContainer = {}; +gridInstance.$headers = {}; +gridInstance.$topPanel = {}; +gridInstance.$root = {}; +gridInstance.config = {}; +gridInstance.data = {}; +gridInstance.elementDims = {}; +gridInstance.eventProvider = {}; +gridInstance.filteredRows = [{}]; +gridInstance.footerController = {}; +gridInstance.gridId = ''; +gridInstance.lastSortedColumns = [{}]; +gridInstance.lateBindColumns = false; +gridInstance.maxCanvasHt = 0; +gridInstance.prevScrollIndex = 0; +gridInstance.prevScrollTop = 0; +gridInstance.rootDim = {}; +gridInstance.rowCache = [{}]; +gridInstance.rowFactory = {}; +gridInstance.rowMap = [{}]; +gridInstance.searchProvider = {}; +gridInstance.styleProvider = {}; +gridInstance.buildColumnDefsFromData(); +gridInstance.buildColumns(); +gridInstance.calcMaxCanvasHeight(); +gridInstance.clearSortingData(); +gridInstance.configureColumnWidths(); +gridInstance.fixColumnIndexes(); +gridInstance.fixGroupIndexes(); +var p:ng.IPromise = gridInstance.getTemplate(''); +p = gridInstance.init(); +p = gridInstance.initTemplates(); +gridInstance.minRowsToRender(); +gridInstance.refreshDomSizes(); +gridInstance.resizeOnData({}); +gridInstance.setRenderedRows([{}]); +gridInstance.sortActual(); +gridInstance.sortColumnsInit(); +gridInstance.sortData({}, {}); \ No newline at end of file diff --git a/ng-grid/ng-grid.d.ts b/ng-grid/ng-grid.d.ts index 70f4f569f8..dbf3666b4e 100644 --- a/ng-grid/ng-grid.d.ts +++ b/ng-grid/ng-grid.d.ts @@ -1,23 +1,318 @@ // Type definitions for ng-grid // Project: http://angular-ui.github.io/ng-grid/ -// Definitions by: Ken Smith +// Definitions by: Ken Smith and Roland Zwaga and Kent Cooper // DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped // These are very definitely preliminary. Please feel free to improve. +// Changelog: +// 25/4/2014: Added interfaces for all classes and services + +/// + declare class ngGridReorderable { constructor(); } declare module ngGrid { + export interface IDomAccessProvider { + previousColumn:IColumn; + grid:IGridInstance; + changeUserSelect(elm:ng.IAugmentedJQuery, value:string):void; + focusCellElement($scope:IGridScope, index:number):void; + selectionHandlers($scope:IGridScope, elm:ng.IAugmentedJQuery):void; + } + + export interface IStyleProvider { + new($scope:IGridScope, grid:IGridInstance):IStyleProvider; + } + + export interface ISearchProvider { + new($scope:IGridScope, grid:IGridInstance, $filter:ng.IFilterService):ISearchProvider; + fieldMap:any; + extFilter:boolean; + evalFilter():void; + } + + export interface ISelectionProvider { + new(grid:IGridInstance, $scope:IGridScope, $parse:ng.IParseService):ISelectionProvider; + multi:boolean; + selectedItems:any[]; + selectedIndex:number; + lastClickedRow:any; + ignoreSelectedItemChanges:boolean; + pKeyParser:ng.ICompiledExpression; + ChangeSelection(rowItem:any, event:any):void; + getSelection(entity:any):number; + getSelectionIndex(entity:any):number; + setSelection(rowItem:IRow, isSelected:boolean):void; + toggleSelectAll(checkAll:boolean, bypass:boolean, selectFiltered:boolean):void; + } + + export interface IEventProvider { + new(grid:IGridInstance, $scope:IGridScope, domUtilityService:any, $timeout:ng.ITimeoutService):IEventProvider; + colToMove:IColumn; + groupToMove:any; + assignEvents():void; + assignGridEventHandlers():void; + dragStart(event:any):void; + dragOver(event:any):void; + setDraggables():void; + onGroupMouseDown(event:any):void; + onGroupDrop(event:any):void; + onHeaderMouseDown(event:any):void; + onHeaderDrop(event:any):void; + } + + + export interface IAggregate { + new(aggEntity:any, rowFactory:IRowFactory, rowHeight:number, groupInitState:boolean):IAggregate; + rowIndex:number; + offsetTop:number; + entity:any; + label:string; + field:string; + depth:number; + parent:any; + children:any[]; + aggChildren:any[]; + aggIndex:number; + collapsed:boolean; + groupInitState:boolean; + rowFactory:IRowFactory; + rowHeight:number; + isAggRow:boolean; + offsetLeft:number; + aggLabelFilter:any; + } + + export interface IRowConfig { + enableCellSelection:boolean; + enableRowSelection:boolean; + jqueryUITheme:boolean; + rowClasses:string[]; + rowHeight:number; + selectWithCheckboxOnly:boolean; + selectedItems:any[]; + + afterSelectionChangeCallback():void; + beforeSelectionChangeCallback():void; + } + + export interface IRenderedRange { + new(top:number, bottom:number):IRenderedRange; + bottomRow:number; + topRow:number; + } + + export interface IRowFactory { + aggCache:any; + dataChanged:boolean; + groupedData:any; + numberOfAggregates:number; + parentCache:any[]; + parsedData:any[]; + renderedRange:IRenderedRange; + rowConfig:IRowConfig; + rowHeight:number; + selectionProvider:ISelectionProvider; + + UpdateViewableRange(newRange:IRenderedRange):void; + buildAggregateRow(aggEntity:any, rowIndex:number):IAggregate; + buildEntityRow(entity:any, rowIndex:number):IRow; + filteredRowsChanged():void; + fixRowCache():void; + getGrouping(groups:any):void; + parseGroupData(groupData:any):void; + renderedChange():void; + renderedChangeNoGroups():void; + } + + export interface IDimension { + new(options:any):IDimension; + outerHeight?:number; + outerWidth?:number; + autoFitHeight?:boolean; + } + + export interface IElementDimension { + rootMaxH?:number; + rootMaxW?:number; + rowIndexCellW?:number; + rowSelectedCellW?:number; + scrollH?:number; + scrollW?:number; + } + + export interface IRow { + new(entity:any, config:IRowConfig, selectionProvider:ISelectionProvider, rowIndex:number, $utils:any):IRow; + entity:any; + config:IRowConfig; + selectionProvider:ISelectionProvider; + rowIndex:number; + utils:any; + selected:boolean; + cursor:string; + offsetTop:number; + rowDisplayIndex:number; + afterSelectionChange():void; + beforeSelectionChange():void; + setSelection(isSelected:boolean):void; + continueSelection(event:any):void; + ensureEntity(expected:any):void; + toggleSelected(event:any):boolean; + alternatingRowClass():void; + getProperty(path:string):any; + copy():IRow; + setVars(fromRow:IRow):void; + } + + export interface IColumn { + new(config:IGridOptions, $scope:IGridScope, grid:IGridInstance, domUtilityService:any, $templateCache:ng.ITemplateCacheService, $utils:any):IColumn; + colDef:IColumnDef; + width:number; + groupIndex:number; + isGroupedBy:boolean; + minWidth:number; + maxWidth:number; + enableCellEdit:boolean; + cellEditableCondition:any; + headerRowHeight:number; + displayName:string; + index:number; + isAggCol:boolean; + cellClass:string; + sortPriority:number; + cellFilter:any; + field:string; + aggLabelFilter:any; + visible:boolean; + sortable:boolean; + resizable:boolean; + pinnable:boolean; + pinned:boolean; + originalIndex:number; + groupable:boolean; + sortDirection:string; + sortingAlgorithm:Function; + headerClass:string; + cursor:string; + headerCellTemplate:string; + cellTemplate:string; + groupedByClass():string; + toggleVisible():void; + showSortButtonUp():boolean; + showSortButtonDown():boolean; + noSortVisible():boolean; + sort(event:any):boolean; + gripClick():any; + gripOnMouseDown(event:any):any; + onMouseMove(event:any):void; + gripOnMouseUp(event:any):void; + copy():IColumn; + setVars(fromCol:IColumn):void; + } + + export interface IGridScope extends ng.IScope { + elementsNeedMeasuring:boolean; + columns:any[]; + renderedRows:any[]; + renderedColumns:any[]; + headerRow:any; + rowHeight:number; + jqueryUITheme:any; + showSelectionCheckbox:boolean; + enableCellSelection:boolean; + enableCellEditOnFocus:boolean; + footer:IFooter; + selectedItems:any[]; + multiSelect:boolean; + showFooter:boolean; + footerRowHeight:number; + showColumnMenu:boolean; + forceSyncScrolling:boolean; + showMenu:boolean; + configGroups:any[]; + gridId:string; + enablePaging:boolean; + pagingOptions:IPagingOptions; + i18n:any; + selectionProvider:ISelectionProvider; + adjustScrollLeft(scrollLeft:number):void; + adjustScrollTop(scrollTop:number, force:boolean):void; + toggleShowMenu():void; + toggleSelectAll():void; + totalFilteredItemsLength():number; + showGroupPanel():any; + topPanelHeight():number; + viewportDimHeight():number; + groupBy(col:IColumn):void; + removeGroup(index:number):void; + togglePin(col:IColumn):void; + totalRowWidth():number; + headerScrollerDim():any; + } + + export interface IGridInstance { + $canvas:ng.IAugmentedJQuery; + $viewport:ng.IAugmentedJQuery; + $groupPanel:ng.IAugmentedJQuery; + $footerPanel:ng.IAugmentedJQuery; + $headerScroller:ng.IAugmentedJQuery; + $headerContainer:ng.IAugmentedJQuery; + $headers:ng.IAugmentedJQuery; + $topPanel:ng.IAugmentedJQuery; + $root:ng.IAugmentedJQuery; + config:IGridOptions; + data:any; + elementDims:IElementDimension; + eventProvider:IEventProvider; + filteredRows:IRow[]; + footerController:any; + gridId:string; + lastSortedColumns:IColumn[]; + lateBindColumns:boolean; + maxCanvasHt:number; + prevScrollIndex:number; + prevScrollTop:number; + rootDim:IDimension; + rowCache:IRow[]; + rowFactory:IRowFactory; + rowMap:IRow[]; + searchProvider:ISearchProvider; + styleProvider:IStyleProvider; + + buildColumnDefsFromData():void; + buildColumns():void; + calcMaxCanvasHeight():void; + clearSortingData():void; + configureColumnWidths():void; + fixColumnIndexes():void; + fixGroupIndexes():void; + getTemplate(key:string):ng.IPromise; + init():ng.IPromise; + initTemplates():ng.IPromise; + minRowsToRender():void; + refreshDomSizes():void; + resizeOnData(col:IColumn):void; + setRenderedRows(newRows:IRow[]):void; + sortActual():void; + sortColumnsInit():void; + sortData(col:IColumn, event:any):void; + } + + export interface IFooter { + new($scope:IGridScope, grid:IGridInstance):IFooter; + } + export interface IGridOptions { /** Define an aggregate template to customize the rows when grouped. See github wiki for more details. */ aggregateTemplate?: string; /** Callback for when you want to validate something after selection. */ - afterSelectionChange?: (rowItem?: any, event?: any) => void ; + afterSelectionChange?: (rowItem?: IRow, event?: any) => void ; /** Callback if you want to inspect something before selection, return false if you want to cancel the selection. return true otherwise. @@ -25,7 +320,7 @@ declare module ngGrid { use rowItem.changeSelection(event) method after returning false initially. Note: when shift+ Selecting multiple items in the grid this will only get called once and the rowItem will be an array of items that are queued to be selected. */ - beforeSelectionChange?: (rowItem?: any, event?: any) => boolean ; + beforeSelectionChange?: (rowItem?: IRow, event?: any) => boolean ; /** checkbox templates. */ checkboxCellTemplate?: string; @@ -176,11 +471,68 @@ declare module ngGrid { } export interface IColumnDef { + /** + * This can be an absolute numberor it can also be defined in percentages (20%, 30%), + * in weighted *s, or "auto" (which sizes the column based on data length) + * (much like WPF/Silverlight)/ note: "auto" only works in single page apps currently because the re-size + * happens on "document.ready + */ + width?: any; + + /** The minum width the column is allowed to be. See width for the different options */ + minWidth?: any; + + /** Set the default visiblity of the column */ + visible?: boolean; + + /** Can also be a property path on your data model. "foo.bar.myField", "Name.First", etc..*/ field?: string; - width?: any; //**this can be a string containing a relatively, absolute size units or a number: '30%','54px',45 /* + + /** What to display in the column header */ displayName?: string; - cellTemplate?: string; + + /** Restrict or allow the column to be sorted */ + sortable?: boolean; + + /** Restrict or allow the column to be resized */ + resizable?: boolean; + + /** Allows the column to be grouped with drag and drop, but has no effect on gridOptions.groups */ + groupable?: boolean; + + /** Allows the column to be pinned when enablePinning is set to true */ + pinnable?: boolean; + + /** The template to use while editing */ + editableCellTemplate?: string; + + /** Allows the cell to use an edit template when focused (grid option enableCellSelection must be enabled)*/ enableCellEdit?: boolean; + + /** Controls when to use the edit template on per-row basis using an angular expression (enableCellEdit must also be true for editing)*/ + cellEditableCondition?: string; + + /** The funtion to use when filtering values in this column */ + sortFn?: (a: any, b: any) => number; + + /** Html template used to render the cell */ + cellTemplate?: string; + + /** User defined CSS class name */ + cellClass?: string; + + /** User defined CSS class name for the header cell */ + headerClass?: string; + + /** Html template used to render the header cell */ + headerCellTemplate?: string; + + /** string name for filter to use on the cell ('currency', 'date', etc..) */ + cellFilter?: string; + + /** String name for filter to use on the aggregate label ('currency', 'date', etc..) defaults to cellFilter if not set. */ + aggLabelFilter?: string; + pinned?: boolean; } @@ -199,4 +551,60 @@ declare module ngGrid { /** currentPage: the uhm... current page. */ currentPage?: number; } + + export interface IPlugin { + init(childScope:IGridScope, gridInstance:IGridInstance, services:any):void; + } + + export module service { + + export interface IDomUtilityService { + eventStorage:any; + numberOfGrids:number; + immediate:number; + AssignGridContainers($scope:IGridScope, rootel:ng.IAugmentedJQuery, grid:IGridInstance):void; + getRealWidth(obj:IDimension):number; + UpdateGridLayout($scope:IGridScope, grid:IGridInstance):void; + setStyleText(grid:IGridInstance, css:string):void; + BuildStyles($scope:IGridScope, grid:IGridInstance, digest:boolean):void; + setColLeft(col:IColumn, colLeft:number, grid:IGridInstance):void; + RebuildGrid($scope:IGridScope, grid:IGridInstance):void; + digest($scope:IGridScope):void; + ScrollH:number; + ScrollW:number; + LetterW:number; + } + + export interface ISortInfo { + fields:string[]; + } + + export interface ISortService { + colSortFnCache:any; + isCustomSort:boolean; + isSorting:boolean; + guessSortFn(item:any):(a:any, b:any)=>number; + basicSort(a:any, b:any):number; + sortNumber(a:number, b:number):number; + sortNumberStr(a:string, b:string):number; + sortAlpha(a:string, b:string):number; + sortDate(a:Date, b:Date):number; + sortBool(a:boolean, b:boolean):number; + sortData(sortInfo:ISortInfo, data:any):void; + Sort(sortInfo:ISortInfo, data:any):void; + getSortFn(col:IColumn, data:any):(a:any, b:any)=>number; + } + + export interface IUtilityService { + visualLength(node:any):number; + forIn(obj:any, action:(value:any, property:string)=>{}):void; + evalProperty(entity:any, path:string):any; + endsWith(str:string, suffix:string):boolean; + isNullOrUndefined(obj:any):boolean; + getElementsByClassName(cl:string):any[]; + newId():string; + seti18n($scope:IGridScope, language:string):void; + getInstanceType(o:any):string; + } + } } From 0a86e768900ecc778df194303167266d28e08e56 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Thu, 1 May 2014 19:41:46 +0900 Subject: [PATCH 155/225] add mongoose type file --- mongoose/mongoose-tests.ts | 366 ++++++++++++++++++++++++++++++ mongoose/mongoose.d.ts | 453 +++++++++++++++++++++++++++++++++++++ 2 files changed, 819 insertions(+) create mode 100644 mongoose/mongoose-tests.ts create mode 100644 mongoose/mongoose.d.ts diff --git a/mongoose/mongoose-tests.ts b/mongoose/mongoose-tests.ts new file mode 100644 index 0000000000..38c469ca15 --- /dev/null +++ b/mongoose/mongoose-tests.ts @@ -0,0 +1,366 @@ +/// + +var fs = require('fs'); +import mongoose = require('mongoose'); + +var createInstance = new mongoose.Mongoose(); + +var Schema = mongoose.Schema; +var CreateSchema = new Schema({}); + +mongoose.connect('mongodb://user:pass@localhost:port/database'); +mongoose.connect('mongodb://hostA:27501,hostB:27501', { mongos: true }); + +var conn: mongoose.Connection = mongoose.createConnection('mongodb://user:pass@localhost:port/database'); +conn = mongoose.createConnection('mongodb://user:pass@localhost:port/database,mongodb://anotherhost:port,mongodb://yetanother:port', { replset: { strategy: 'ping', rs_name: 'testSet' }}); +conn = mongoose.createConnection('localhost', 'database', 27014); +conn = mongoose.createConnection('localhost', 'database', 27014, { server: { auto_reconnect: false }, user: 'username', pass: 'mypassword' }); +conn = mongoose.createConnection(); +conn.open('localhost', 'database', 27014, {}); + +var db = mongoose.createConnection(); +db.openSet("mongodb://user:pwd@localhost:27020/testing,mongodb://example.com:27020,mongodb://localhost:27019"); +db.openSet('mongodb://mongosA:27501,mongosB:27501', 'db', { mongos: true }, (err: any) => {}); +db.close(); + +var collection = db.collection('collection1'); + +mongoose.connection.on('error', (err: any) => {}); +mongoose.disconnect(); + +mongoose.set('test', 1234567890); +var value = mongoose.get('test'); +mongoose.set('debug', true); + +interface IActor extends mongoose.Document { + name: string; +} +mongoose.model('Actor', new Schema({ name: String })); +db.model('Actor', new Schema({ name: String })); +var schema: mongoose.Schema = new Schema({ name: String }, { collection: 'actor' }); +schema.set('collection', 'actor'); +var Model = mongoose.model('Actor', schema, 'actor'); + +var names: string[] = mongoose.modelNames(); +var names: string[] = db.modelNames(); +mongoose.plugin((schema: mongoose.Schema) => { +}, { index: true }); + + +var aggregate = new mongoose.Aggregate(); +var aggregate = new mongoose.Aggregate({ $project: { a: 1, b: 1 } }); +var aggregate = new mongoose.Aggregate({ $project: { a: 1, b: 1 } }, { $skip: 5 }); +var aggregate = new mongoose.Aggregate([{ $project: { a: 1, b: 1 } }, { $skip: 5 }]); +aggregate.append({ $project: { field: 1 }}, { $limit: 2 }); +aggregate.append([{ $match: { daw: 'Logic Audio X' }} ]); +aggregate.group({ _id: "$department" }); +aggregate.skip(10); +aggregate.limit(10); +aggregate.match({ department: { $in: [ "sales", "engineering" ] } }); +aggregate.near({ + near: [40.724, -73.997], + distanceField: "dist.calculated", // required + maxDistance: 0.008, + query: { type: "public" }, + includeLocs: "dist.location", + uniqueDocs: true, + num: 5 +}); +aggregate.project("a b -_id"); +aggregate.project({a: 1, b: 1, _id: 0}); +aggregate.project({ + newField: '$b.nested', + plusTen: { $add: ['$val', 10]}, + sub: { + name: '$a' + } +}); +aggregate.project({ salary_k: { $divide: [ "$salary", 1000 ] } }); +aggregate.sort({ field: 'asc', test: -1 }); +aggregate.sort('field -test'); +aggregate.unwind("tags"); +aggregate.unwind("a", "b", "c"); +var p = aggregate.exec(); +aggregate.read('primaryPreferred').exec((err: any, result: {}) => {}); + + +var p = new mongoose.Promise; +var p2 = p.then(function() { throw new Error('shucks') }).end(); +setTimeout(function() { + p.fulfill({}); +}, 10); +var promise = new mongoose.Promise(); +promise.then(function (meetups: number) { + return new mongoose.Promise(); +}).then(function (people: string[]) { + if (people.length < 10000) { + throw new Error('Too few people!!!'); + } else { + throw new Error('Still need more people!!!'); + } +}).then(null, function (err: Error) { +}).end(); + + +Model.findOne({ name: 'john' }, (err: any, doc: mongoose.Document) => { + doc.invalidate('size', 'must be less than 20', 14); + doc.validate((err: any) => { }); + + doc.set('documents.0.title', 'changed'); + doc.get('documents.0'); + doc.set({ + 'path' : 1, + 'path2' : { + 'path' : 2 + } + }); + doc.set('path', 'value', { strict: false }); + doc.set('path3', '1', Number); + doc.get('path3', Number); + doc.id; + doc._id; + + doc.isModified(); + doc.isModified('documents'); + doc.isModified('documents.0.title'); + doc.isDirectModified('documents.0.title'); + doc.isDirectModified('documents'); + doc.isSelected('name'); + + doc.markModified('mixed.type'); + doc.populate('user'); + doc.populate('other', (err: any, doc: mongoose.Document) => {}); + doc.populated('author'); + doc.save(); + + doc.toJSON({ getters: true, virtuals: false }); + var data: any = doc.toObject(); + delete data['age']; + delete data['weight']; + data['isAwesome'] = true; +}); + +Model.model('User').findById('id', (err: any, res: IActor) => {}); +Model.count({ type: 'jungle' }, (err: any, count: number) => {}); +Model.remove((err: any, res: IActor[]) => {}); +Model.save((err: any, res: IActor, numberAffected: number) => {}); +Model.create({ type: 'jelly bean' }, { type: 'snickers' }, (err: any, res1: IActor, res2: IActor) => {}); +Model.create({ type: 'jawbreaker' }); +Model.distinct('url', { clicks: {$gt: 100}}, (err: any, result: IActor[]) => {}); +Model.distinct('url'); + +Model.aggregate( + { $group: { _id: null, maxBalance: { $max: '$balance' }}}, + { $project: { _id: 0, maxBalance: 1 }}, + (err: any, res: IActor[]) => {}); +Model.aggregate() + .group({ _id: null, maxBalance: { $max: '$balance' } }) + .select('-id maxBalance') + .exec((err: any, res: IActor[]) => {}); +Model.ensureIndexes((err) => {}); + +Model.find({ name: 'john', age: { $gte: 18 }}); +Model.find({ name: 'john', age: { $gte: 18 }}, (err: any, docs: IActor[]) => {}); +Model.find({ name: /john/i }, 'name friends', (err: any, docs: IActor[]) => {}); +Model.find({ name: /john/i }, null, { skip: 10 }); +Model.find({ name: /john/i }, null, { skip: 10 }, (err: any, docs: IActor[]) => {}); +Model.find({ name: /john/i }, null, { skip: 10 }).exec((err: any, docs: IActor[]) => {}); +var query = Model.find({ name: /john/i }, null, { skip: 10 }); +var promise1 = query.exec(); +promise1.addBack((err: any, docs: IActor[]) => {}); + +Model.findById('id', (err: any, res: IActor) => {}); +Model.findById('id').exec((err: any, res: IActor) => {}); +Model.findById('id', 'name length', (err: any, res: IActor) => {}); +Model.findById('id', '-length').exec((err: any, res: IActor) => {}); +Model.findById('id', 'name', { lean: true }, (err: any, res: IActor) => {}); +Model.findById('id', 'name').lean().exec((err: any, res: IActor) => {}); +Model.findByIdAndRemove('id1', { select: 'name' }, (err: any, res: IActor) => {}); +Model.findByIdAndRemove('id1', { select: 'name' }).exec((err: any, res: IActor) => {}); +Model.findByIdAndRemove('id1', (err: any, res: IActor) => {}); +Model.findByIdAndRemove('id1').exec((err: any, res: IActor) => {}); +Model.findByIdAndUpdate('id2', { $set: { name: 'jason borne' }}, { upsert: true }, (err: any, res: IActor) => {}); + +Model.findOne({ type: 'iphone' }, (err: any, res: IActor) => {}); +Model.findOne({ type: 'iphone' }).exec((err: any, res: IActor) => {}); +Model.findOne({ type: 'iphone' }, 'name', (err: any, res: IActor) => {}); +Model.findOne({ type: 'iphone' }, 'name').exec((err: any, res: IActor) => {}); +Model.findOne({ type: 'iphone' }, 'name', { lean: true }, (err: any, res: IActor) => {}); +Model.findOne({ type: 'iphone' }, 'name', { lean: true }).exec((err: any, res: IActor) => {}); +Model.findOne({ type: 'iphone' }).select('name').lean().exec((err: any, res: IActor) => {}); +Model.findOneAndRemove({ type: 'iphone' }, { select: 'name' }, (err: any, res: IActor) => {}); +Model.findOneAndRemove({ type: 'iphone' }, { select: 'name' }).exec((err: any, res: IActor) => {}); +Model.findOneAndUpdate({ type: 'iphone' }, { $set: { name: 'jason borne' }}, { upsert: true }, (err: any, res: IActor) => {}); + +Model.geoNear([1, 3], { maxDistance : 5, spherical : true }, (err: any, res: IActor[]) => {}); +Model.geoNear({ type : "Point", coordinates : [9,9] }, { maxDistance : 5, spherical : true }, (err: any, res: IActor[]) => {}); +Model.geoSearch({ type : "house" }, { near: [10, 10], maxDistance: 5 }, (err: any, res: IActor[]) => {}); + +var o = { + map: function () { this.emit(this.name, 1) }, + reduce: function (k: string, vals: IActor[]) { return vals.length }, +}; +Model.mapReduce(o, (err: any, res: any[]) => {}); + +Model.findById('id', (err: any, res: IActor) => { + var opts = [ + { path: 'company', match: { x: 1 }, select: 'name' }, + { path: 'notes', options: { limit: 10 }, model: 'override' } + ]; + Model.populate(res, opts, (err: any, res: IActor) => {}); +}); +Model.find({ type: 'iphone' }, (err: any, res: IActor[]) => { + var opts = [{ path: 'company', match: { x: 1 }, select: 'name' }]; + var promise = Model.populate(res, opts); + promise.then(console.log).end(); +}); +Model.populate({ name: 'Test A' }, { path: 'weapon', model: 'Weapon' }, (err: any, user: IActor) => {}); +Model.populate([ + { name: 'User hoge' }, + { name: 'User fuga' }, +], { path: 'weapon' }, (err: any, users: IActor[]) => {}); + +Model.remove({ title: 'baby born from alien father' }, (err: any) => {}); +var query2 = Model.remove({ _id: 'id' }); +query2.exec(); +Model.update({ age: { $gt: 18 } }, { oldEnough: true }, (err: any, numberAffected: number, raw: any) => {}); +Model.update({ name: 'Tobi' }, { ferret: true }, { multi: true }, (err: any, numberAffected: number, raw: any) => {}); +Model.update({ _id: 'id' }, { $set: { text: 'changed' }}).exec(); + +Model.where('age').gte(21).lte(65).exec((err: any, res: IActor[]) => {}); +var query3 =Model + .where('age').gt(21).lt(65) + .where('name', /^b/i).all('type', 1); +query3.all(25); +query3.and([{ color: 'green' }, { status: 'ok' }]); +query3.batchSize(100); +query3.where('loc').within().box([40.73083, -73.99756], [40.741404, -73.988135]); +query3.where('loc').within().circle({ center: [50, 50], radius: 10, unique: true }); +query3.circle('loc', { center: [50, 50], radius: 10, unique: true }); +query3.comment('login query'); +query3.where({ 'color': 'black' }).count(); +query3.count({ color: 'black' }).count((err: any, count: number) => {}); +query3.count({ color: 'black' }, (err: any, count: number) => {}); +query3.where({ color: 'black' }).count((err: any, count: number) => {}); +query3.elemMatch('comment', { author: 'autobot', votes: {$gte: 5}}); +query3.where('comment').elemMatch({ author: 'autobot', votes: {$gte: 5}}); +query.elemMatch('comment', (elem: mongoose.Query) => { + elem.where('author').equals('autobot'); + elem.where('votes').gte(5); +}); +query3.where('age').equals(49); +query3.where('age', 49); +query3.exec(); +query3.exec('update'); +query3.where('name').exists(); +query3.where('name').exists(true); +query3.find().exists('name'); +query3.where('name').exists(false); +query3.find().exists('name', false); +query3.find({ name: 'Los Pollos Hermanos' }).find((err: any, res: IActor[]) => {}); +query3.where('loc').within().geometry({ type: 'Polygon', coordinates: [[[ 10, 20 ], [ 10, 40 ], [ 30, 40 ], [ 30, 20 ]]] }); +query3.find().where('age').gt(21); +query3.find().gt('age', 21); +query3.hint({ indexA: 1, indexB: -1}); +query3.where('path').intersects().geometry({ type: 'LineString', coordinates: [[180.0, 11.0], [180, 9.0]] }); +query3.where('path').intersects({ type: 'LineString', coordinates: [[180.0, 11.0], [180, 9.0]] }); +query3.maxScan(100); +query3.where('loc').near({ center: [10, 10] }); +query3.where('loc').near({ center: [10, 10], maxDistance: 5 }); +query3.where('loc').near({ center: [10, 10], maxDistance: 5, spherical: true }); +query3.near('loc', { center: [10, 10], maxDistance: 5 }); +query3.where('loc').nearSphere({ center: [10, 10], maxDistance: 5 }); +query3.nor([{ color: 'green' }, { status: 'ok' }]); +query3.or([{ color: 'red' }, { status: 'emergency' }]); +query3.where('loc').within().polygon([10,20], [13, 25], [7,15]); +query3.polygon('loc', [10,20], [13, 25], [7,15]); + +query3.findOne().populate('owner').exec((err: any, res: IActor[]) => {}); +query3.find().populate({ + path: 'owner', + select: 'name', + match: { color: 'black' }, + options: { sort: { name: -1 }} +}).exec((err: any, res: IActor[]) => {}); +query3.find().populate('owner', 'name', null, {sort: { name: -1 }}).exec((err: any, res: IActor[]) => {}); + +query3.read('primary'); +query3.read('p'); +query3.read('primaryPreferred'); +query3.read('pp'); +query3.read('secondary'); +query3.read('s'); +query3.read('secondaryPreferred'); +query3.read('sp'); +query3.read('nearest'); +query3.read('n'); +query3.read('s', [{ dc:'sf', s: 1 },{ dc:'ma', s: 2 }]); +query3.remove({ artist: 'Anne Murray' }, (err: any, res: IActor[]) => {}); +query3.select('a b -c'); +query3.select({a: 1, b: 1, c: 0}); +query3.select('+path'); +query3.where('tags').size(0); +query3.skip(100).limit(20); +query3.slaveOk(); +query3.slaveOk(true); +query3.slaveOk(false); +query3.slice('comments', -5); +query3.slice('comments', [10, 5]) +query3.where('comments').slice(5); +query3.where('comments').slice([-10, 5]); +query3.snapshot(); +query3.snapshot(true); +query3.snapshot(false); +query3.sort({ field: 'asc', test: -1 }); +query3.sort('field -test'); +Model.find({ name: /^hello/ }).stream({ transform: JSON.stringify }).pipe(fs.createWriteStream('./test.json')); +var stream = Model.find({ name: /^hello/ }).stream(); +stream + .on('data', (doc: IActor) => {}) + .on('error', (err: any) => {}) + .on('close', () => {}); + +query3.tailable(); +query3.tailable(false); +var AdvQuery = query3.toConstructor(); +query3.update({ title: 'words' }); +query3.update({ $set: { title: 'words' }}); +query3.update({ name: /^match/ }, { $set: { arr: [] }}, { multi: true }, (err: any, row: number, raw: any) => {}); + +query3.where('loc').within({ center: [50,50], radius: 10, unique: true, spherical: true }); +query3.where('loc').within({ box: [[40.73, -73.9], [40.7, -73.988]] }); +query3.where('loc').within({ polygon: [[],[],[],[]] }); +query3.where('loc').within([], [], []); // polygon +query3.where('loc').within([], []); // box +query3.where('loc').within({ type: 'LineString', coordinates: [] }); // geometry + +mongoose.Query.use$geoWithin = false; + + +var ToySchema = new Schema({}); +ToySchema.add({ name: 'string', color: 'string', price: 'number' }); +schema.eachPath(function(path: string, value: any) {}); +schema.index({ first: 1, last: -1 }); +schema.indexes(); +schema.method('meow', function() { + console.log('meeeeeoooooooooooow'); +}); +var Kitty = mongoose.model('Kitty', schema); +var fizz: any = new Kitty({ name: 'kitty' }); +fizz.meow(); +schema.method({ + purr: function() {}, + scratch: function() {}, +}); +schema.path('name'); +schema.path('name', Number); +schema.pathType('name'); +schema.plugin(function() {}); +schema.post('save', function(doc: IActor) {}); +schema.pre('save', function(next: () => void) {}); +schema.requiredPaths(); +schema.static('findByName', function(name: string, callback: () => void) {}); +schema.virtual('display_name') + .get(function(): string { return this.name; }) + .set((value: string): void => {}); + diff --git a/mongoose/mongoose.d.ts b/mongoose/mongoose.d.ts new file mode 100644 index 0000000000..e9057abc7a --- /dev/null +++ b/mongoose/mongoose.d.ts @@ -0,0 +1,453 @@ +// Type definitions for Mongoose 3.8.5 +// Project: http://mongoosejs.com/ +// Definitions by: horiuchi +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "mongoose" { + function connect(uri: string, options?: ConnectionOption, callback?: (err: any) => void): Mongoose; + function createConnection(): Connection; + function createConnection(uri: string, options?: ConnectionOption): Connection; + function createConnection(host: string, database_name: string, port?: number, options?: ConnectionOption): Connection; + function disconnect(callback?: (err?: any) => void): Mongoose; + + function model(name: string, schema: Schema, collection?: string, skipInit?: boolean): Model; + function modelNames(): string[]; + function plugin(plugin: (schema: Schema, options?: Object) => void, options?: Object): Mongoose; + + function get(key: string): any; + function set(key: string, value: any): void; + + var mongo: any; + var mquery: any; + var version: string; + var connection: Connection; + + export class Mongoose { + connect(uri: string, options?: ConnectionOption, callback?: (err: any) => void): Mongoose; + createConnection(): Connection; + createConnection(uri: string, options?: Object): Connection; + createConnection(host: string, database_name: string, port?: number, options?: ConnectionOption): Connection; + disconnect(callback?: (err?: any) => void): Mongoose; + get(key: string): any; + model(name: string, schema: Schema, collection?: string, skipInit?: boolean): Model; + modelNames(): string[]; + plugin(plugin: (schema: Schema, options?: Object) => void, options?: Object): Mongoose; + set(key: string, value: any): void; + + mongo: any; + mquery: any; + version: string; + connection: Connection; + } + + export interface Connection extends NodeJS.EventEmitter { + constructor(base: Mongoose): Connection; + + close(callback?: (err: any) => void): Connection; + collection(name: string, options?: Object): Collection; + model(name: string, schema: Schema, collection?: string): Model; + modelNames(): string[]; + open(host: string, database?: string, port?: number, options?: ConnectionOption, callback?: (err: any) => void): Connection; + openSet(uris: string, database?: string, options?: ConnectionSetOption, callback?: (err: any) => void): Connection; + + db: any; + collections: {[index: string]: Collection}; + readyState: number; + } + export interface ConnectionOption { + db?: any; + server?: any; + replset?: any; + user?: string; + pass?: string; + auth?: any; + } + export interface ConnectionSetOption extends ConnectionOption { + mongos?: boolean; + } + + export interface Collection { + } + + + export class SchemaType { } + export class VirtualType { + get(fn: Function): VirtualType; + set(fn: Function): VirtualType; + } + export module Types { + export class ObjectId {} + } + + export class Schema { + static Types: { + String: String; + ObjectId: Types.ObjectId; + OId: Types.ObjectId; + Mixed: any; + }; + constructor(schema?: Object, options?: Object); + + add(obj: Object, prefix?: string): void; + eachPath(fn: (path: string, type: any) => void): Schema; + get(key: string): any; + index(fields: Object, options?: Object): Schema; + indexes(): void; + method(name: string, fn: Function): Schema; + method(method: Object): Schema; + path(path: string): any; + path(path: string, constructor: any): Schema; + pathType(path: string): string; + plugin(plugin: (schema: Schema, options?: Object) => void, options?: Object): Schema; + post(method: string, fn: Function): Schema; + pre(method: string, callback: Function): Schema; + requiredPaths(): string[]; + set(key: string, value: any): void; + static(name: string, fn: Function): Schema; + virtual(name: string, options?: Object): VirtualType; + virtualpath(name: string): VirtualType; + } + export interface SchemaOption { + autoIndex?: boolean; + bufferCommands?: boolean; + capped?: boolean; + collection?: string; + id?: boolean; + _id?: boolean; + minimize?: boolean; + read?: string; + safe?: boolean; + shardKey?: boolean; + strict?: boolean; + toJSON?: Object; + toObject?: Object; + versionKey?: boolean; + } + + export interface Model { + new(doc: Object): T; + + aggregate(...aggregations: Object[]): Aggregate; + aggregate(aggregation: Object, callback: (err: any, res: T[]) => void): Promise; + aggregate(aggregation1: Object, aggregation2: Object, callback: (err: any, res: T[]) => void): Promise; + aggregate(aggregation1: Object, aggregation2: Object, aggregation3: Object, callback: (err: any, res: T[]) => void): Promise; + count(conditions: Object, callback?: (err: any, count: number) => void): Query; + + create(doc: Object, fn?: (err: any, res: T) => void): Promise; + create(doc1: Object, doc2: Object, fn?: (err: any, res1: T, res2: T) => void): Promise; + create(doc1: Object, doc2: Object, doc3: Object, fn?: (err: any, res1: T, res2: T, res3: T) => void): Promise; + discriminator(name: string, schema: Schema): Model; + distinct(field: string, callback?: (err: any, res: T[]) => void): Query; + distinct(field: string, conditions: Object, callback?: (err: any, res: T[]) => void): Query; + ensureIndexes(callback: (err: any) => void): Promise; + + find(cond: Object, callback?: (err: any, res: T[]) => void): Query; + find(cond: Object, fields: Object, callback?: (err: any, res: T[]) => void): Query; + find(cond: Object, fields: Object, options: Object, callback?: (err: any, res: T[]) => void): Query; + findById(id: string, callback?: (err: any, res: T) => void): Query; + findById(id: string, fields: Object, callback?: (err: any, res: T) => void): Query; + findById(id: string, fields: Object, options: Object, callback?: (err: any, res: T) => void): Query; + findByIdAndRemove(id: string, callback?: (err: any, res: T) => void): Query; + findByIdAndRemove(id: string, options: Object, callback?: (err: any, res: T) => void): Query; + findByIdAndUpdate(id: string, update: Object, callback?: (err: any, res: T) => void): Query; + findByIdAndUpdate(id: string, update: Object, options: FindAndUpdateOption, callback?: (err: any, res: T) => void): Query; + findOne(cond: Object, callback?: (err: any, res: T) => void): Query; + findOne(cond: Object, fields: Object, callback?: (err: any, res: T) => void): Query; + findOne(cond: Object, fields: Object, options: Object, callback?: (err: any, res: T) => void): Query; + findOneAndRemove(cond: Object, callback?: (err: any, res: T) => void): Query; + findOneAndRemove(cond: Object, options: Object, callback?: (err: any, res: T) => void): Query; + findOneAndUpdate(cond: Object, update: Object, callback?: (err: any, res: T) => void): Query; + findOneAndUpdate(cond: Object, update: Object, options: FindAndUpdateOption, callback?: (err: any, res: T) => void): Query; + + geoNear(point: { type: string; coordinates: number[] }, options: Object, callback?: (err: any, res: T[]) => void): Query; + geoNear(point: number[], options: Object, callback?: (err: any, res: T[]) => void): Query; + geoSearch(cond: Object, options: GeoSearchOption, callback?: (err: any, res: T[]) => void): Query; + increment(): T; + mapReduce(options: MapReduceOption, callback?: (err: any, res: MapReduceResult[]) => void): Promise[]>; + mapReduce(options: MapReduceOption2, callback?: (err: any, res: MapReduceResult[]) => void): Promise[]>; + model(name: string): Model; + + populate(doc: U, options: Object, callback?: (err: any, res: U) => void): Promise; + populate(doc: U[], options: Object, callback?: (err: any, res: U[]) => void): Promise; + update(cond: Object, update: Object, callback?: (err: any, affectedRows: number, raw: any) => void): Query; + update(cond: Object, update: Object, options: Object, callback?: (err: any, affectedRows: number, raw: any) => void): Query; + remove(cond: Object, callback?: (err: any) => void): Query<{}>; + save(callback?: (err: any, result: T, numberAffected: number) => void): Query; + where(path: string, val?: Object): Query; + + $where(argument: string): Query; + $where(argument: Function): Query; + + base: Mongoose; + collection: Collection; + db: any; + discriminators: any; + modelName: string; + schema: Schema; + } + export interface FindAndUpdateOption { + new?: boolean; + upsert?: boolean; + sort?: Object; + select?: Object; + } + export interface GeoSearchOption { + near: number[]; + maxDistance: number; + limit?: number; + lean?: boolean; + } + export interface MapReduceOption { + map: () => void; + reduce: (key: Key, vals: T[]) => Val; + query?: Object; + limit?: number; + keeptemp?: boolean; + finalize?: (key: Key, val: Val) => Val; + scope?: Object; + jsMode?: boolean; + verbose?: boolean; + out?: { + inline?: number; + replace?: string; + reduce?: string; + merge?: string; + }; + } + export interface MapReduceOption2 { + map: string; + reduce: (key: Key, vals: T[]) => Val; + query?: Object; + limit?: number; + keeptemp?: boolean; + finalize?: (key: Key, val: Val) => Val; + scope?: Object; + jsMode?: boolean; + verbose?: boolean; + out?: { + inline?: number; + replace?: string; + reduce?: string; + merge?: string; + }; + } + export interface MapReduceResult { + _id: Key; + value: Val; + } + + export class Query { + exec(callback?: (err: any, res: T) => void): Promise; + exec(operation: string, callback?: (err: any, res: T) => void): Promise; + exec(operation: Function, callback?: (err: any, res: T) => void): Promise; + + all(val: number): Query; + all(path: string, val: number): Query; + and(array: Object[]): Query; + box(val: Object): Query; + box(a: number[], b: number[]): Query; + batchSize(val: number): Query; + cast(model: Model, obj: Object): U; + //center(): Query; + //centerSphere(path: string, val: Object): Query; + circle(area: Object): Query; + circle(path: string, area: Object): Query; + comment(val: any): Query; + count(callback?: (err: any, count: number) => void): Query; + count(criteria: Object, callback?: (err: any, count: number) => void): Query; + distinct(callback?: (err: any, res: T) => void): Query; + distinct(field: string, callback?: (err: any, res: T) => void): Query; + distinct(criteria: Object, field: string, callback?: (err: any, res: T) => void): Query; + distinct(criteria: Query, field: string, callback?: (err: any, res: T) => void): Query; + elemMatch(criteria: Object): Query; + elemMatch(criteria: (elem: Query) => void): Query; + elemMatch(path: string, criteria: Object): Query; + elemMatch(path: string, criteria: (elem: Query) => void): Query; + equals(val: Object): Query; + exists(val?: boolean): Query; + exists(path: string, val?: boolean): Query; + find(callback?: (err: any, res: T) => void): Query; + find(criteria: Object, callback?: (err: any, res: T) => void): Query; + findOne(callback?: (err: any, res: T) => void): Query; + findOne(criteria: Object, callback?: (err: any, res: T) => void): Query; + findOneAndRemove(callback?: (err: any, res: T) => void): Query; + findOneAndRemove(cond: Object, callback?: (err: any, res: T) => void): Query; + findOneAndRemove(cond: Object, options: Object, callback?: (err: any, res: T) => void): Query; + findOneAndUpdate(callback?: (err: any, res: T) => void): Query; + findOneAndUpdate(update: Object, callback?: (err: any, res: T) => void): Query; + findOneAndUpdate(cond: Object, update: Object, callback?: (err: any, res: T) => void): Query; + findOneAndUpdate(cond: Object, update: Object, options: FindAndUpdateOption, callback?: (err: any, res: T) => void): Query; + geometry(object: Object): Query; + gt(val: number): Query; + gt(path: string, val: number): Query; + gte(val: number): Query; + gte(path: string, val: number): Query; + hint(val: Object): Query; + in(val: any[]): Query; + in(path: string, val: any[]): Query; + intersects(arg?: Object): Query; + lean(bool?: boolean): Query; + limit(val: number): Query; + lt(val: number): Query; + lt(path: string, val: number): Query; + lte(val: number): Query; + lte(path: string, val: number): Query; + maxDistance(val: number): Query; + maxDistance(path: string, val: number): Query; + maxScan(val: number): Query; + merge(source: Query): Query; + merge(source: Object): Query; + mod(val: number[]): Query; + mod(path: string, val: number[]): Query; + ne(val: any): Query; + ne(path: string, val: any): Query; + near(val: Object): Query; + near(path: string, val: Object): Query; + nearSphere(val: Object): Query; + nearSphere(path: string, val: Object): Query; + nin(val: any[]): Query; + nin(path: string, val: any[]): Query; + nor(array: Object[]): Query; + or(array: Object[]): Query; + polygon(...coordinatePairs: number[][]): Query; + polygon(path: string, ...coordinatePairs: number[][]): Query; + populate(path: string, select?: string, match?: Object, options?: Object): Query; + populate(path: string, select: string, model: string, match?: Object, options?: Object): Query; + populate(opt: PopulateOption): Query; + read(pref: string, tags?: Object[]): Query; + regex(val: RegExp): Query; + regex(path: string, val: RegExp): Query; + remove(callback?: (err: any, res: T) => void): Query; + remove(criteria: Object, callback?: (err: any, res: T) => void): Query; + select(arg: string): Query; + select(arg: Object): Query; + setOptions(options: Object): Query; + size(val: number): Query; + size(path: string, val: number): Query; + skip(val: number): Query; + slaveOk(v?: boolean): Query; + slice(val: number): Query; + slice(val: number[]): Query; + slice(path: string, val: number): Query; + slice(path: string, val: number[]): Query; + snapshot(v?: boolean): Query; + sort(arg: Object): Query; + sort(arg: string): Query; + stream(options?: { transform?: Function; }): QueryStream; + tailable(v?: boolean): Query; + toConstructor(): Query; + update(callback?: (err: any, affectedRows: number, doc: T) => void): Query; + update(doc: Object, callback?: (err: any, affectedRows: number, doc: T) => void): Query; + update(criteria: Object, doc: Object, callback?: (err: any, affectedRows: number, doc: T) => void): Query; + update(criteria: Object, doc: Object, options: Object, callback?: (err: any, affectedRows: number, doc: T) => void): Query; + where(path?: string, val?: any): Query; + where(path?: Object, val?: any): Query; + within(val?: Object): Query; + within(coordinate: number[], ...coordinatePairs: number[][]): Query; + + $where(argument: string): Query; + $where(argument: Function): Query; + + static use$geoWithin: boolean; + } + + export interface PopulateOption { + path: string; + select?: string; + model?: string; + match?: Object; + options?: Object; + } + + export interface QueryStream extends NodeJS.EventEmitter { + destory(err?: any): void; + pause(): void; + resume(): void; + pipe(destination: T, options?: { end?: boolean; }): T; + paused: number; + readable: boolean; + } + + export interface Document { + id?: string; + _id: string; + + equals(doc: Document): boolean; + get(path: string, type?: new(...args: any[]) => any): any; + inspect(options?: Object): string; + invalidate(path: string, errorMsg: string, value: any): void; + invalidate(path: string, error: Error, value: any): void; + isDirectModified(path: string): boolean; + isInit(path: string): boolean; + isModified(path?: string): boolean; + isSelected(path: string): boolean; + markModified(path: string): void; + modifiedPaths(): string[]; + populate(callback?: (err: any, res: T) => void): Document; + populate(path?: string, callback?: (err: any, res: T) => void): Document; + populate(opt: PopulateOption, callback?: (err: any, res: T) => void): Document; + populated(path: string): any; + remove(callback?: (err: any) => void): Query; + save(callback?: (err: any, res: T) => void): void; + set(path: string, val: any, type?: new(...args: any[]) => any, options?: Object): void; + set(path: string, val: any, options?: Object): void; + set(value: Object): void; + toJSON(options?: Object): Object; + toObject(options?: Object): Object; + toString(): string; + update(doc: Object, options: Object, callback: (err: any, affectedRows: number, raw: any) => void): Query; + validate(cb: (err: any) => void): void; + + isNew: boolean; + errors: Object; + schema: Object; + } + + + export class Aggregate { + constructor(...options: Object[]); + + append(...options: Object[]): Aggregate; + group(arg: Object): Aggregate; + limit(num: number): Aggregate; + match(arg: Object): Aggregate; + near(parameters: Object): Aggregate; + project(arg: string): Aggregate; + project(arg: Object): Aggregate; + select(filter: string): Aggregate; + skip(num: number): Aggregate; + sort(arg: string): Aggregate; + sort(arg: Object): Aggregate; + unwind(fiels: string, ...rest: string[]): Aggregate; + + exec(callback?: (err: any, result: T) => void): Promise; + read(pref: string, ...tags: Object[]): Aggregate; + } + + export class Promise { + constructor(fn?: (err: any, result: T) => void); + + then(onFulFill: (result: T) => void, onReject?: (err: any) => void): Promise; + end(): void; + + fulfill(result: T): Promise; + reject(err: any): Promise; + resolve(err: any, result: T): Promise; + + onFulfill(listener: (result: T) => void): Promise; + onReject(listener: (err: any) => void): Promise; + onResolve(listener: (err: any, result: T) => void): Promise; + on(event: string, listener: Function): Promise; + + // Deprecated methods. + addBack(listener: (err: any, result: T) => void): Promise; + addCallback(listener: (result: T) => void): Promise; + addErrback(listener: (err: any) => void): Promise; + complete(result: T): Promise; + error(err: any): Promise; + } + +} + From 3d92fa2caf870c60d50956762845e3a6abe79826 Mon Sep 17 00:00:00 2001 From: Horiuchi_H Date: Thu, 1 May 2014 19:42:33 +0900 Subject: [PATCH 156/225] add mongoose in CONTRIBUTORS.md --- CONTRIBUTORS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 01b5025d20..c8368f022b 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -205,6 +205,7 @@ All definitions files include a header with the author and editors, so at some p * [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/)) * [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield)) * [MongoDB](http://mongodb.github.io/node-mongodb-native/) (from TypeScript samples, updated by [Niklas Mollenhauer](https://github.com/nikeee)) +* [mongoose](http://mongoosejs.com/) (by [Hiroki Horiuchi](https://github.com/horiuchi/)) * [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)) From 648511f6c4ba6036fd8ec0462291bc6fd2c7446b Mon Sep 17 00:00:00 2001 From: teppeis Date: Thu, 1 May 2014 22:19:36 +0900 Subject: [PATCH 157/225] Add Esprima --- CONTRIBUTORS.md | 1 + esprima/esprima-tests.ts | 163 +++++++++++++++++++++++ esprima/esprima.d.ts | 274 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 438 insertions(+) create mode 100644 esprima/esprima-tests.ts create mode 100644 esprima/esprima.d.ts diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 01b5025d20..f3fcff1ea1 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -63,6 +63,7 @@ All definitions files include a header with the author and editors, so at some p * [emissary](https://github.com/atom/emissary) (by [vvakame](https://github.com/vvakame)) * [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov)) * [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/)) +* [Esprima](http://esprima.org/) (by [Teppei Sato](https://github.com/teppeis)) * [expect.js](https://github.com/LearnBoost/expect.js) (by [Teppei Sato](https://github.com/teppeis)) * [expectations](https://github.com/spmason/expectations) (by [vvakame](https://github.com/vvakame)) * [Express](http://expressjs.com/) (by [Boris Yankov](https://github.com/borisyankov)) diff --git a/esprima/esprima-tests.ts b/esprima/esprima-tests.ts new file mode 100644 index 0000000000..9451e077d2 --- /dev/null +++ b/esprima/esprima-tests.ts @@ -0,0 +1,163 @@ +/// + +import esprima = require('esprima'); +import Syntax = esprima.Syntax; + +var token: esprima.Token; +var options: esprima.Options; +var comment: Syntax.Comment; +var program: Syntax.Program; +var statement: Syntax.SomeStatement; +var blockStatement: Syntax.BlockStatement; +var expression: Syntax.SomeExpression; +var property: Syntax.Property; +var identifier: Syntax.Identifier; +var literal: Syntax.Literal; +var switchCase: Syntax.SwitchCase; +var catchClause: Syntax.CatchClause; +var variableDeclaratorOrExpression: Syntax.VariableDeclaratorOrExpression; +var literalOrIdentifier: Syntax.LiteralOrIdentifier; +var blockStatementOrExpression: Syntax.BlockStatementOrExpression; +var identifierOrExpression: Syntax.IdentifierOrExpression; +var any: any; +var string: string; +var boolean: boolean; +var number: number; + +// esprima +string = esprima.version; +program = esprima.parse('code'); +program = esprima.parse('code', {range: true}); +token = esprima.tokenize('code')[0]; +token = esprima.tokenize('code', {range: true})[0]; + +// Token +string = token.type; +string = token.value; + +// Program +string = program.type; +statement = program.body[0]; +comment = program.comments[0] + +// Location +number = program.loc.start.line; +number = program.loc.start.column; +number = program.loc.end.line; +number = program.loc.end.column; +number = program.range[0]; + +// Comment +string = comment.value; + +// Statement +// BlockStatement +string = statement.type; +statement = statement.body[0]; +comment = statement.leadingComments[0] +comment = statement.trailingComments[0] + +// ExpressionStatement +expression = statement.expression; + +// IfStatement +expression = statement.test; +statement = statement.consequent; +statement = statement.alternate; + +// LabeledStatement +identifier = statement.label; +statement = statement.body; + +// WithStatement +expression = statement.object; + +// SwitchStatement +expression = statement.discriminant; +switchCase = statement.cases[0]; +boolean = statement.lexical; + +// ReturnStatement +expression = statement.argument; + +// TryStatement +blockStatement = statement.block; +catchClause = statement.handler; +catchClause = statement.guardedHandlers[0]; +blockStatement = statement.finalizer; + +// ForStatement +variableDeclaratorOrExpression = statement.init; +expression = statement.update; + +// ForInStatement +variableDeclaratorOrExpression = statement.left; +expression = statement.right; +boolean = statement.each; + +// Expression +// ArrayExpression +string = expression.type; +expression = expression.elements[0]; + +// ObjectExpression +property = expression.properties[0]; +string = property.type; +literalOrIdentifier = property.key; +expression = property.value; +string = property.kind; + +// FunctionExpression +identifier = expression.id; +identifier = expression.params[0]; +expression = expression.defaults[0]; +identifier = expression.rest; +blockStatementOrExpression = expression.body; +boolean = expression.generator; +boolean = expression.expression; + +// SequenceExpression +expression = expression.expressions[0] + +// UnaryExpression +string = expression.operator; +boolean = expression.prefix; + +// BinaryExpression +expression = expression.left; +expression = expression.right; + +// ConditionalExpression +expression = expression.test; +expression = expression.alternate; +expression = expression.consequent; + +// ConditionalExpression +expression = expression.callee; +expression = expression.arguments[0]; + +// MemberExpression +expression = expression.object; +identifierOrExpression = expression.property; +boolean = expression.computed; + +// Clauses +// SwitchCase +string = switchCase.type; +expression = switchCase.test; +statement = switchCase.consequent[0]; + +// CatchClause +string = catchClause.type; +identifier = catchClause.param; +expression = catchClause.guard; +blockStatement = catchClause.body; + +// Misc +// Identifier +string = identifier.type; +string = identifier.name; + +// Literal +string = literal.type; +any = literal.value; diff --git a/esprima/esprima.d.ts b/esprima/esprima.d.ts new file mode 100644 index 0000000000..2b09e895ce --- /dev/null +++ b/esprima/esprima.d.ts @@ -0,0 +1,274 @@ +// Type definitions for Esprima v1.2.0 +// Project: http://esprima.org +// Definitions by: teppeis +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module esprima { + var version: string; + function parse(code: string, options?: Options): Syntax.Program; + function tokenize(code: string, options?: Options): Array; + + interface Token { + type: string + value: string + } + + interface Options { + loc?: boolean + range?: boolean + raw?: boolean + tokens?: boolean + comment?: boolean + attachComment?: boolean + tolerant?: boolean + source?: boolean + } + + module Syntax { + // Node + interface Node { + type: string + loc?: LineLocation + range?: number[] + leadingComments?: Comment[] + trailingComments?: Comment[] + } + interface LineLocation { + start: Position + end: Position + } + interface Position { + line: number + column: number + } + + // Comment + interface Comment extends Node { + value: string + } + + // Program + interface Program extends Node { + body: SomeStatement[] + comments?: Comment[] + } + + // Function + interface Function extends Node { + id: Identifier // | null + params: Identifier[] + defaults: SomeExpression[] + rest: Identifier // | null + body: BlockStatementOrExpression + generator: boolean + expression: boolean + } + interface BlockStatementOrExpression extends Array, BlockStatement, SomeExpression { + body: BlockStatementOrExpression + } + + // Statement + interface Statement extends Node { + } + interface EmptyStatement extends Statement { + } + interface BlockStatement extends Statement { + body: SomeStatement[] + } + interface ExpressionStatement extends Statement { + expression: SomeExpression + } + interface IfStatement extends Statement { + test: SomeExpression + consequent: SomeStatement + alternate: SomeStatement + } + interface LabeledStatement extends Statement { + label: Identifier + body: SomeStatement + } + interface BreakStatement extends Statement { + label: Identifier // | null + } + interface ContinueStatement extends Statement { + label: Identifier // | null + } + interface WithStatement extends Statement { + object: SomeExpression + body: SomeStatement + } + interface SwitchStatement extends Statement { + discriminant: SomeExpression + cases: SwitchCase[] + lexical: boolean + } + interface ReturnStatement extends Statement { + argument: SomeExpression // | null + } + interface ThrowStatement extends Statement { + argument: SomeExpression + } + interface TryStatement extends Statement { + block: BlockStatement + handler: CatchClause // | null + guardedHandlers: CatchClause[] + finalizer: BlockStatement // | null + } + interface WhileStatement extends Statement { + test: SomeExpression + body: SomeStatement + } + interface DoWhileStatement extends Statement { + body: SomeStatement + test: SomeExpression + } + interface ForStatement extends Statement { + init: VariableDeclaratorOrExpression // | null + test: SomeExpression // | null + update: SomeExpression // | null + body: SomeStatement + } + interface ForInStatement extends Statement { + left: VariableDeclaratorOrExpression + right: SomeExpression + body: SomeStatement + each: boolean + } + interface VariableDeclaratorOrExpression extends VariableDeclarator, SomeExpression { + } + interface DebuggerStatement extends Statement { + } + interface SomeStatement extends + EmptyStatement, ExpressionStatement, BlockStatement, IfStatement, + LabeledStatement, BreakStatement, ContinueStatement, WithStatement, + SwitchStatement, ReturnStatement, ThrowStatement, TryStatement, + WhileStatement, DoWhileStatement, ForStatement, ForInStatement, DebuggerStatement { + body: SomeStatementOrList + } + interface SomeStatementOrList extends Array, SomeStatement { + } + + // Declration + interface Declration extends Statement { + } + interface FunctionDeclration extends Declration { + id: Identifier + params: Identifier[] // Pattern + defaults: SomeExpression[] + rest: Identifier + body: BlockStatementOrExpression + generator: boolean + expression: boolean + } + interface VariableDeclaration extends Declration { + declarations: VariableDeclarator[] + kind: string // "var" | "let" | "const" + } + interface VariableDeclarator extends Node { + id: Identifier // Pattern + init: SomeExpression + } + + // Expression + interface Expression extends Node { // | Pattern + } + interface SomeExpression extends + ThisExpression, ArrayExpression, ObjectExpression, FunctionExpression, + ArrowFunctionExpression, SequenceExpression, UnaryExpression, BinaryExpression, + AssignmentExpression, UpdateExpression, LogicalExpression, ConditionalExpression, + NewExpression, CallExpression, MemberExpression { + } + interface ThisExpression extends Expression { + } + interface ArrayExpression extends Expression { + elements: SomeExpression[] // [ Expression | null ] + } + interface ObjectExpression extends Expression { + properties: Property[] + } + interface Property extends Node { + key: LiteralOrIdentifier // Literal | Identifier + value: SomeExpression + kind: string // "init" | "get" | "set" + } + interface LiteralOrIdentifier extends Literal, Identifier { + } + interface FunctionExpression extends Function, Expression { + } + interface ArrowFunctionExpression extends Function, Expression { + } + interface SequenceExpression extends Expression { + expressions: SomeExpression[] + } + interface UnaryExpression extends Expression { + operator: string // UnaryOperator + prefix: boolean + argument: SomeExpression + } + interface BinaryExpression extends Expression { + operator: string // BinaryOperator + left: SomeExpression + right: SomeExpression + } + interface AssignmentExpression extends Expression { + operator: string // AssignmentOperator + left: SomeExpression + right: SomeExpression + } + interface UpdateExpression extends Expression { + operator: string // UpdateOperator + argument: SomeExpression + prefix: boolean + } + interface LogicalExpression extends Expression { + operator: string // LogicalOperator + left: SomeExpression + right: SomeExpression + } + interface ConditionalExpression extends Expression { + test: SomeExpression + alternate: SomeExpression + consequent: SomeExpression + } + interface NewExpression extends Expression { + callee: SomeExpression + arguments: SomeExpression[] + } + interface CallExpression extends Expression { + callee: SomeExpression + arguments: SomeExpression[] + } + interface MemberExpression extends Expression { + object: SomeExpression + property: IdentifierOrExpression // Identifier | Expression + computed: boolean + } + interface IdentifierOrExpression extends Identifier, SomeExpression { + } + + // Pattern + // interface Pattern extends Node { + // } + + // Clauses + interface SwitchCase extends Node { + test: SomeExpression + consequent: SomeStatement[] + } + interface CatchClause extends Node { + param: Identifier // Pattern + guard: SomeExpression + body: BlockStatement + } + + // Misc + interface Identifier extends Node, Expression { // | Pattern + name: string + } + interface Literal extends Node, Expression { + value: any // string | boolean | null | number | RegExp + } + } +} + +export = esprima From 7fc10a1c7c2010899b5812e520abfbd5e0a20f9c Mon Sep 17 00:00:00 2001 From: teppeis Date: Fri, 2 May 2014 20:28:45 +0900 Subject: [PATCH 158/225] Wrap "export = esprima" up in an external module --- esprima/esprima.d.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esprima/esprima.d.ts b/esprima/esprima.d.ts index 2b09e895ce..1e603ee255 100644 --- a/esprima/esprima.d.ts +++ b/esprima/esprima.d.ts @@ -271,4 +271,6 @@ declare module esprima { } } -export = esprima +declare module "esprima" { + export = esprima +} From edd089a240ebb16958587940b47880de73276d3d Mon Sep 17 00:00:00 2001 From: Basarat Ali Syed Date: Fri, 2 May 2014 23:00:30 +1000 Subject: [PATCH 159/225] Update chai-datetime.d.ts --- chai-datetime/chai-datetime.d.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/chai-datetime/chai-datetime.d.ts b/chai-datetime/chai-datetime.d.ts index 432f6bb247..263034361f 100644 --- a/chai-datetime/chai-datetime.d.ts +++ b/chai-datetime/chai-datetime.d.ts @@ -18,13 +18,19 @@ declare module chai { } interface Assert { - afterDate(leftDate: Date, rightDate: Date): boolean; - beforeDate(leftDate: Date, rightDate: Date): boolean; - equalDate(leftDate: Date, rightDate: Date): boolean; - - afterTime(leftDate: Date, rightDate: Date): boolean; - beforeTime(leftDate: Date, rightDate: Date): boolean; - equalTime(leftDate: Date, rightDate: Date): boolean; + equalTime(val: Date, exp: Date, msg?: string): boolean; + notEqualTime(val: Date, exp: Date, msg?: string): boolean; + beforeTime(val: Date, exp: Date, msg?: string): boolean; + notBeforeTime(val: Date, exp: Date, msg?: string): boolean; + afterTime(val: Date, exp: Date, msg?: string): boolean; + notAfterTime(val: Date, exp: Date, msg?: string): boolean; + + equalDate(val: Date, exp: Date, msg?: string): boolean; + notEqualDate(val: Date, exp: Date, msg?: string): boolean; + beforeDate(val: Date, exp: Date, msg?: string): boolean; + notBeforeDate(val: Date, exp: Date, msg?: string): boolean; + afterDate(val: Date, exp: Date, msg?: string): boolean; + notAfterDate(val: Date, exp: Date, msg?: string): boolean; } } From 3ceb61d01e4c39d7de1df4241b0c0b7c5939996f Mon Sep 17 00:00:00 2001 From: Seon-Wook Park Date: Fri, 2 May 2014 16:45:24 +0200 Subject: [PATCH 160/225] node-uuid: Let require("node-uuid") work in nodejs --- node-uuid/node-uuid.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node-uuid/node-uuid.d.ts b/node-uuid/node-uuid.d.ts index 48a3422049..d4857cf310 100644 --- a/node-uuid/node-uuid.d.ts +++ b/node-uuid/node-uuid.d.ts @@ -46,7 +46,7 @@ interface UUID { v4(options?: UUIDOptions, buffer?: Buffer, offset?: number): string } -declare module 'uuid' { +declare module "node-uuid" { var uuid: UUID; export = uuid; } From fe6c5d8ef7fb818b6102f3f70925614bb154b272 Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 4 May 2014 01:47:48 +0900 Subject: [PATCH 161/225] added EditorView declaration to atom/atom.d.ts --- atom/atom.d.ts | 644 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 478 insertions(+), 166 deletions(-) diff --git a/atom/atom.d.ts b/atom/atom.d.ts index 14a8dbebae..3791a11cf8 100644 --- a/atom/atom.d.ts +++ b/atom/atom.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/borisyankov/DefinitelyTyped /// +/// /// /// @@ -108,214 +109,214 @@ declare module AtomCore { getLongTitle():string; setVisible(visible:boolean):void; setScrollTop(scrollTop:any):void; - getScrollTop():any; + getScrollTop():number; setScrollLeft(scrollLeft:any):void; - getScrollLeft():any; + getScrollLeft():number; setEditorWidthInChars(editorWidthInChars:any):void; - getSoftWrapColumn():any; + getSoftWrapColumn():number; getSoftTabs():boolean; setSoftTabs(softTabs:boolean):void; - getSoftWrap():any; + getSoftWrap():boolean; setSoftWrap(softWrap:any):void; - getTabText():any; - getTabLength():any; + getTabText():string; + getTabLength():number; setTabLength(tabLength:any):void; clipBufferPosition(bufferPosition:any):void; clipBufferRange(range:any):void; indentationForBufferRow(bufferRow:any):void; setIndentationForBufferRow(bufferRow:any, newLevel:any, _arg:any):void; indentLevelForLine(line:any):number; - buildIndentString(number:any):any; + buildIndentString(number:any):string; save():void; saveAs(filePath:any):void; - getPath():any; - getText():any; + getPath():string; + getText():string; setText(text:any):void; getTextInRange(range:any):any; - getLineCount():any; - getBuffer():any; - getUri():any; - isBufferRowBlank(bufferRow:any):void; + getLineCount():number; + getBuffer():ITextBuffer; + getUri():string; + isBufferRowBlank(bufferRow:any):boolean; isBufferRowCommented(bufferRow:any):void; nextNonBlankBufferRow(bufferRow:any):void; - getEofBufferPosition():any; - getLastBufferRow():any; - bufferRangeForBufferRow(row:any, options:any):any; - lineForBufferRow(row:any):any; - lineLengthForBufferRow(row:any):any; + getEofBufferPosition():IPoint; + getLastBufferRow():number; + bufferRangeForBufferRow(row:any, options:any):IRange; + lineForBufferRow(row:number):string; + lineLengthForBufferRow(row:number):number; scan():any; scanInBufferRange():any; backwardsScanInBufferRange():any; - isModified():any; - shouldPromptToSave():any; - screenPositionForBufferPosition(bufferPosition:any, options:any):any; - bufferPositionForScreenPosition(screenPosition:any, options:any):any; - screenRangeForBufferRange(bufferRange:any):any; - bufferRangeForScreenRange(screenRange:any):any; - clipScreenPosition(screenPosition:any, options:any):any; - lineForScreenRow(row:any):any; - linesForScreenRows(start:any, end:any):any; - getScreenLineCount():any; - getMaxScreenLineLength():any; - getLastScreenRow():any; - bufferRowsForScreenRows(startRow:any, endRow:any):any; - bufferRowForScreenRow(row:any):any; - scopesForBufferPosition(bufferPosition:any):any; - bufferRangeForScopeAtCursor(selector:any):any; - tokenForBufferPosition(bufferPosition:any):any; - getCursorScopes():any; - insertText(text:any, options:any):any; - insertNewline():any; - insertNewlineBelow():any; + isModified():boolean; + shouldPromptToSave():boolean; + screenPositionForBufferPosition(bufferPosition:any, options?:any):IPoint; + bufferPositionForScreenPosition(screenPosition:any, options?:any):IPoint; + screenRangeForBufferRange(bufferRange:any):IRange; + bufferRangeForScreenRange(screenRange:any):IRange; + clipScreenPosition(screenPosition:any, options:any):IRange; + lineForScreenRow(row:any):ITokenizedLine; + linesForScreenRows(start?:any, end?:any):ITokenizedLine[]; + getScreenLineCount():number; + getMaxScreenLineLength():number; + getLastScreenRow():number; + bufferRowsForScreenRows(startRow:any, endRow:any):any[]; + bufferRowForScreenRow(row:any):number; + scopesForBufferPosition(bufferPosition:any):string[]; + bufferRangeForScopeAtCursor(selector:string):any; + tokenForBufferPosition(bufferPosition:any):IToken; + getCursorScopes():string[]; + insertText(text:string, options?:any):IRange[]; + insertNewline():IRange[]; + insertNewlineBelow():IRange[]; insertNewlineAbove():any; indent(options?:any):any; - backspace():any; - backspaceToBeginningOfWord():any; - backspaceToBeginningOfLine():any; - delete():any; - deleteToEndOfWord():any; - deleteLine():any; - indentSelectedRows():any; - outdentSelectedRows():any; - toggleLineCommentsInSelection():any; - autoIndentSelectedRows():any; + backspace():any[]; + backspaceToBeginningOfWord():any[]; + backspaceToBeginningOfLine():any[]; + delete():any[]; + deleteToEndOfWord():any[]; + deleteLine():IRange[]; + indentSelectedRows():IRange[][]; + outdentSelectedRows():IRange[][]; + toggleLineCommentsInSelection():IRange[]; + autoIndentSelectedRows():IRange[][]; normalizeTabsInBufferRange(bufferRange:any):any; - cutToEndOfLine():any; - cutSelectedText():any; - copySelectedText():any; - pasteText(options?:any):any; - undo():any; - redo():any; + cutToEndOfLine():boolean[]; + cutSelectedText():boolean[]; + copySelectedText():boolean[]; + pasteText(options?:any):IRange[]; + undo():any[]; + redo():any[]; foldCurrentRow():any; - unfoldCurrentRow():any; - foldSelectedLines():any; - foldAll():any; - unfoldAll():any; + unfoldCurrentRow():any[]; + foldSelectedLines():any[]; + foldAll():any[]; + unfoldAll():any[]; foldAllAtIndentLevel(level:any):any; foldBufferRow(bufferRow:any):any; unfoldBufferRow(bufferRow:any):any; - isFoldableAtBufferRow(bufferRow:any):any; - createFold(startRow:any, endRow:any):any; + isFoldableAtBufferRow(bufferRow:any):boolean; + createFold(startRow:any, endRow:any):IFold; destroyFoldWithId(id:any):any; destroyFoldsIntersectingBufferRange(bufferRange:any):any; toggleFoldAtBufferRow(bufferRow:any):any; - isFoldedAtCursorRow():any; - isFoldedAtBufferRow(bufferRow:any):any; - isFoldedAtScreenRow(screenRow:any):any; - largestFoldContainingBufferRow(bufferRow:any):any; + isFoldedAtCursorRow():boolean; + isFoldedAtBufferRow(bufferRow:any):boolean; + isFoldedAtScreenRow(screenRow:any):boolean; + largestFoldContainingBufferRow(bufferRow:any):boolean; largestFoldStartingAtScreenRow(screenRow:any):any; - outermostFoldsInBufferRowRange(startRow:any, endRow:any):any; - moveLineUp():any; - moveLineDown():any; - duplicateLines():any; - duplicateLine():any; - mutateSelectedText(fn:Function):any; - replaceSelectedText(options:any, fn:Function):any; - getMarker(id:any):any; - getMarkers():any; - findMarkers(properties:any):any; - markScreenRange():any; - markBufferRange():any; - markScreenPosition():any; - markBufferPosition():any; - destroyMarker():any; - getMarkerCount():any; - hasMultipleCursors():any; - getCursors():any; - getCursor():any; - addCursorAtScreenPosition(screenPosition:any):any; - addCursorAtBufferPosition(bufferPosition:any):any; - addCursor(marker:any):any; - removeCursor(cursor:any):any; - addSelection(marker:any, options:any):any; - addSelectionForBufferRange(bufferRange:any, options:any):any; + outermostFoldsInBufferRowRange(startRow:any, endRow:any):any[]; + moveLineUp():ISelection[]; + moveLineDown():ISelection[]; + duplicateLines():any[][]; + duplicateLine():any[][]; + mutateSelectedText(fn:(selection:ISelection)=>any):any; + replaceSelectedText(options:any, fn:(selection:string)=>any):any; + getMarker(id:number):IDisplayBufferMarker; + getMarkers():IDisplayBufferMarker[]; + findMarkers(properties:any):IDisplayBufferMarker[]; + markScreenRange(value:number):IDisplayBufferMarker; + markBufferRange(value:number):IDisplayBufferMarker; + markScreenPosition(value:number):IDisplayBufferMarker; + markBufferPosition():IDisplayBufferMarker; + destroyMarker():boolean; + getMarkerCount():number; + hasMultipleCursors():boolean; + getCursors():ICursor[]; + getCursor():ICursor; + addCursorAtScreenPosition(screenPosition:any):ICursor; + addCursorAtBufferPosition(bufferPosition:any):ICursor; + addCursor(marker:any):ICursor; + removeCursor(cursor:any):ICursor[]; + addSelection(marker:any, options:any):ISelection; + addSelectionForBufferRange(bufferRange:any, options:any):ISelection; setSelectedBufferRange(bufferRange:any, options:any):any; setSelectedBufferRanges(bufferRanges:any, options:any):any; - removeSelection(selection:any):any; - clearSelections():any; - consolidateSelections():any; - getSelections():any; - getSelection(index:any):any; - getLastSelection():any; - getSelectionsOrderedByBufferPosition():any; - getLastSelectionInBuffer():any; + removeSelection(selection:ISelection):any; + clearSelections():boolean; + consolidateSelections():boolean; + getSelections():ISelection[]; + getSelection(index?:number):ISelection; + getLastSelection():ISelection; + getSelectionsOrderedByBufferPosition():ISelection[]; + getLastSelectionInBuffer():ISelection; selectionIntersectsBufferRange(bufferRange:any):any; setCursorScreenPosition(position:any, options:any):any; - getCursorScreenPosition():any; - getCursorScreenRow():any; + getCursorScreenPosition():IPoint; + getCursorScreenRow():number; setCursorBufferPosition(position:any, options:any):any; - getCursorBufferPosition():any; - getSelectedScreenRange():any; - getSelectedBufferRange():any; - getSelectedBufferRanges():any; - getSelectedText():any; - getTextInBufferRange(range:any):any; - setTextInBufferRange(range:any, text:any):any; - getCurrentParagraphBufferRange():any; - getWordUnderCursor(options:any):any; - moveCursorUp(lineCount:any):any; - moveCursorDown(lineCount:any):any; - moveCursorLeft():any; - moveCursorRight():any; - moveCursorToTop():any; - moveCursorToBottom():any; - moveCursorToBeginningOfScreenLine():any; - moveCursorToBeginningOfLine():any; - moveCursorToFirstCharacterOfLine():any; - moveCursorToEndOfScreenLine():any; - moveCursorToEndOfLine():any; - moveCursorToBeginningOfWord():any; - moveCursorToEndOfWord():any; - moveCursorToBeginningOfNextWord():any; - moveCursorToPreviousWordBoundary():any; - moveCursorToNextWordBoundary():any; - moveCursors(fn:Function):any; - selectToScreenPosition(position:any):any; - selectRight():any; - selectLeft():any; - selectUp(rowCount:any):any; - selectDown(rowCount:any):any; - selectToTop():any; - selectAll():any; - selectToBottom():any; - selectToBeginningOfLine():any; - selectToFirstCharacterOfLine():any; - selectToEndOfLine():any; - selectToPreviousWordBoundary():any; - selectToNextWordBoundary():any; - selectLine():any; - addSelectionBelow():any; - addSelectionAbove():any; - splitSelectionsIntoLines():any; - transpose():any; - upperCase():any; - lowerCase():any; - joinLines():any; - selectToBeginningOfWord():any; - selectToEndOfWord():any; - selectToBeginningOfNextWord():any; - selectWord():any; + getCursorBufferPosition():IPoint; + getSelectedScreenRange():IRange; + getSelectedBufferRange():IRange; + getSelectedBufferRanges():IRange[]; + getSelectedText():string; + getTextInBufferRange(range:IRange):string; + setTextInBufferRange(range:IRange, text:string):any; + getCurrentParagraphBufferRange():IRange; + getWordUnderCursor(options?:any):string; + moveCursorUp(lineCount?:number):void; + moveCursorDown(lineCount?:number):void; + moveCursorLeft():void; + moveCursorRight():void; + moveCursorToTop():void; + moveCursorToBottom():void; + moveCursorToBeginningOfScreenLine():void; + moveCursorToBeginningOfLine():void; + moveCursorToFirstCharacterOfLine():void; + moveCursorToEndOfScreenLine():void; + moveCursorToEndOfLine():void; + moveCursorToBeginningOfWord():void; + moveCursorToEndOfWord():void; + moveCursorToBeginningOfNextWord():void; + moveCursorToPreviousWordBoundary():void; + moveCursorToNextWordBoundary():void; + moveCursors(fn:(cursor:ICursor)=>any):any; + selectToScreenPosition(position:IPoint):any; + selectRight():ISelection[]; + selectLeft():ISelection[]; + selectUp(rowCount?:number):ISelection[]; + selectDown(rowCount?:number):ISelection[]; + selectToTop():ISelection[]; + selectAll():ISelection[]; + selectToBottom():ISelection[]; + selectToBeginningOfLine():ISelection[]; + selectToFirstCharacterOfLine():ISelection[]; + selectToEndOfLine():ISelection[]; + selectToPreviousWordBoundary():ISelection[]; + selectToNextWordBoundary():ISelection[]; + selectLine():ISelection[]; + addSelectionBelow():ISelection[]; + addSelectionAbove():ISelection[]; + splitSelectionsIntoLines():any[]; + transpose():IRange[]; + upperCase():boolean[]; + lowerCase():boolean[]; + joinLines():any[]; + selectToBeginningOfWord():ISelection[]; + selectToEndOfWord():ISelection[]; + selectToBeginningOfNextWord():ISelection[]; + selectWord():ISelection[]; selectMarker(marker:any):any; - mergeCursors():any; + mergeCursors():number[]; expandSelectionsForward():any; - expandSelectionsBackward(fn:Function):any; - finalizeSelections():any; + expandSelectionsBackward(fn:(selection:ISelection)=>any):ISelection[]; + finalizeSelections():boolean[]; mergeIntersectingSelections():any; - preserveCursorPositionOnBufferReload():any; + preserveCursorPositionOnBufferReload():ISubscription; getGrammar(): IGrammar; setGrammar(grammer:IGrammar):void; reloadGrammar():any; - shouldAutoIndent():any; + shouldAutoIndent():boolean; transact(fn:Function):any; - beginTransaction():any; + beginTransaction():ITransaction; commitTransaction():any; - abortTransaction():any; - inspect():any; - logScreenLines(start:any, end:any):any; - handleGrammarChange():any; + abortTransaction():any[]; + inspect():string; + logScreenLines(start:number, end:number):any[]; + handleGrammarChange():void; handleMarkerCreated(marker:any):any; - getSelectionMarkerAttributes():any; - joinLine():any; + getSelectionMarkerAttributes():{type: string; editorId: number; invalidate: string; }; + // joinLine():any; // deprecated } interface IGrammar { @@ -686,6 +687,26 @@ declare module AtomCore { // TBD } + interface ITokenizedLine { + // TBD + } + + interface IToken { + // TBD + } + + interface IFold { + // TBD + } + + interface IDisplayBufferMarker { + // TBD + } + + interface ITransaction { + // TBD + } + interface ITaskStatic { new(taskPath:any):ITask; } @@ -705,7 +726,6 @@ declare module "atom" { var BufferedNodeProcess:AtomCore.IBufferedNodeProcessStatic; var BufferedProcess:AtomCore.IBufferedProcessStatic; - var EditorView:any; var Git:AtomCore.IGitStatic; var Point:AtomCore.IPointStatic; var Range:AtomCore.IRangeStatic; @@ -725,12 +745,304 @@ declare module "atom" { unsubscribe(object?:any):any; } + class EditorView extends View { + static characterWidthCache:any; + static configDefaults:any; + static nextEditorId:number; + + static content(params:any):void; + + static classes(_arg?:{mini?:any}):string; + + vScrollMargin:number; + hScrollMargin:number; + lineHeight:any; + charWidth:any; + charHeight:any; + cursorViews:any[]; + selectionViews:any[]; + lineCache:any[]; + isFocused:any; + editor:AtomCore.IEditor; + attached:any; + lineOverdraw:number; + pendingChanges:any[]; + newCursors:any[]; + newSelections:any[]; + redrawOnReattach:any; + bottomPaddingInLines:number; + + id:number; + + + initialize(editorOrOptions:AtomCore.IEditor):void; // return type are same as editor method. + initialize(editorOrOptions?:{editor: AtomCore.IEditor; mini:any; placeholderText:any}):void; + + initialize(editorOrOptions:{}):void; // compatible for spacePen.View + + bindKeys():void; + + getEditor():AtomCore.IEditor; + + getText():string; + + setText(text:string):void; + + insertText(text:string, options?:any):AtomCore.IRange[]; + + setHeightInLines(heightInLines:number):number; + + setWidthInChars(widthInChars:number):number; + + pageDown():void; + + pageUp():void; + + getPageRows():number; + + setShowInvisibles(showInvisibles:boolean):void; + + setInvisibles(invisibles:{ eol:string; space: string; tab: string; cr: string; }):void; + + setShowIndentGuide(showIndentGuide:boolean):void; + + setPlaceholderText(placeholderText:string):void; + + getPlaceholderText():string; + + checkoutHead():boolean; + + configure():AtomCore.ISubscription; + + handleEvents():void; + + handleInputEvents():void; + + bringHiddenInputIntoView():JQuery; + + selectOnMousemoveUntilMouseup():any; + + afterAttach(onDom:any):any; + + edit(editor:AtomCore.IEditor):any; + + getModel():AtomCore.IEditor; + + setModel(editor:AtomCore.IEditor):any; + + showBufferConflictAlert(editor:AtomCore.IEditor):any; + + scrollTop(scrollTop:number, options?:any):any; + + scrollBottom(scrollBottom?:number):any; + + scrollLeft(scrollLeft?:number):number; + + scrollRight(scrollRight?:number):any; + + scrollToBottom():any; + + scrollToCursorPosition():any; + + scrollToBufferPosition(bufferPosition:any, options:any):any; + + scrollToScreenPosition(screenPosition:any, options:any):any; + + scrollToPixelPosition(pixelPosition:any, options:any):any; + + highlightFoldsContainingBufferRange(bufferRange:any):any; + + saveScrollPositionForEditor():any; + + toggleSoftTabs():any; + + toggleSoftWrap():any; + + calculateWidthInChars():number; + + calculateHeightInLines():number; + + getScrollbarWidth():number; + + setSoftWrap(softWrap:boolean):any; + + setFontSize(fontSize:number):any; + + getFontSize():number; + + setFontFamily(fontFamily?:string):any; + + getFontFamily():string; + + setLineHeight(lineHeight:number):any; + + redraw():any; + + splitLeft():any; + + splitRight():any; + + splitUp():any; + + splitDown():any; + + getPane():any; // return type are PaneView + + remove(selector:any, keepData:any):any; + + beforeRemove():any; + + getCursorView(index?:number):any; // return type are CursorView + + getCursorViews():any[]; // return type are CursorView[] + + addCursorView(cursor:any, options:any):any; // return type are CursorView + + removeCursorView(cursorView:any):any; + + getSelectionView(index?:number):any; // return type are SelectionView + + getSelectionViews():any[]; // return type are SelectionView[] + + addSelectionView(selection:any):any; + + removeSelectionView(selectionView:any):any; + + removeAllCursorAndSelectionViews():any[]; + + appendToLinesView(view:any):any; + + scrollVertically(pixelPosition:any, _arg:any):any; + + scrollHorizontally(pixelPosition:any):any; + + calculateDimensions():number; + + recalculateDimensions():any; + + updateLayerDimensions():any; + + isHidden():boolean; + + clearRenderedLines():void; + + resetDisplay():any; + + requestDisplayUpdate():any; + + updateDisplay(options?:any):any; + + updateCursorViews():any; + + shouldUpdateCursor(cursorView:any):any; + + updateSelectionViews():any[]; + + shouldUpdateSelection(selectionView:any):any; + + syncCursorAnimations():any[]; + + autoscroll(suppressAutoscroll?:any):any[]; + + updatePlaceholderText():any; + + updateRenderedLines(scrollViewWidth:any):any; + + computeSurroundingEmptyLineChanges(change:any):any; + + computeIntactRanges(renderFrom:any, renderTo:any):any; + + truncateIntactRanges(intactRanges:any, renderFrom:any, renderTo:any):any; + + clearDirtyRanges(intactRanges:any):any; + + clearLine(lineElement:any):any; + + fillDirtyRanges(intactRanges:any, renderFrom:any, renderTo:any):any; + + updatePaddingOfRenderedLines():any; + + getFirstVisibleScreenRow():number; + + getLastVisibleScreenRow():number; + + isScreenRowVisible():boolean; + + handleScreenLinesChange(change:any):any; + + buildLineElementForScreenRow(screenRow:any):any; + + buildLineElementsForScreenRows(startRow:any, endRow:any):any; + + htmlForScreenRows(startRow:any, endRow:any):any; + + htmlForScreenLine(screenLine:any, screenRow:any):any; + + buildIndentation(screenRow:any, editor:any):any; + + buildHtmlEndOfLineInvisibles(screenLine:any):any; + + getEndOfLineInvisibles(screenLine:any):any; + + lineElementForScreenRow(screenRow:any):any; + + toggleLineCommentsInSelection():any; + + pixelPositionForBufferPosition(position:any):any; + + pixelPositionForScreenPosition(position:any):any; + + positionLeftForLineAndColumn(lineElement:any, screenRow:any, screenColumn:any):any; + + measureToColumn(lineElement:any, tokenizedLine:any, screenColumn:any):any; + + getCharacterWidthCache(scopes:any, char:any):any; + + setCharacterWidthCache(scopes:any, char:any, val:any):any; + + clearCharacterWidthCache():any; + + pixelOffsetForScreenPosition(position:any):any; + + screenPositionFromMouseEvent(e:any):any; + + highlightCursorLine():any; + + copyPathToClipboard():any; + + buildLineHtml(_arg:any):any; + + updateScopeStack(line:any, scopeStack:any, desiredScopes:any):any; + + pushScope(line:any, scopeStack:any, scope:any):any; + + popScope(line:any, scopeStack:any):any; + + buildEmptyLineHtml(showIndentGuide:any, eolInvisibles:any, htmlEolInvisibles:any, indentation:any, editor:any, mini:any):any; + + replaceSelectedText(replaceFn:(str:string)=>string):any; + + consolidateSelections(e:any):any; + + logCursorScope():any; + + logScreenLines(start:any, end:any):any; + + logRenderedLines():any; + } + class ScrollView extends View { // TBD } - var SelectListView:any; + class SelectListView extends View { + // TBD + } + + class WorkspaceView extends View { + // TBD + } + var Task:AtomCore.ITaskStatic; var Workspace:AtomCore.IWorkspaceStatic; - var WorkspaceView:any; // WorkspaceView extends View } From 9a8241a51e391b789e8949a26e1388aaf15e9597 Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 4 May 2014 02:11:16 +0900 Subject: [PATCH 162/225] improve AtomCore.ISelection definition in atom/atom.d.ts --- atom/atom.d.ts | 80 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 3 deletions(-) diff --git a/atom/atom.d.ts b/atom/atom.d.ts index 3791a11cf8..e976116d1a 100644 --- a/atom/atom.d.ts +++ b/atom/atom.d.ts @@ -40,7 +40,7 @@ declare module AtomCore { // TBD } - interface TreeView { + interface ITreeView { // TBD } @@ -65,8 +65,82 @@ declare module AtomCore { // TBD } - interface ISelection { - // TBD + interface ISelection /* extends Theorist.Model */ { + cursor:ICursor; + marker:IDisplayBufferMarker; + editor:IEditor; + initialScreenRange:any; + wordwise:boolean; + needsAutoscroll:boolean; + retainSelection:boolean; + subscriptionCounts:any; + + destroy():any; + finalize():any; + clearAutoscroll():any; + isEmpty():boolean; + isReversed():boolean; + isSingleScreenLine():boolean; + getScreenRange():IRange; + setScreenRange(screenRange:any, options:any):any; + getBufferRange():IRange; + setBufferRange(bufferRange:any, options:any):any; + getBufferRowRange():number[]; + autoscroll():void; + getText():string; + clear():boolean; + selectWord():IRange; + expandOverWord():any; + selectLine(row?:any):IRange; + expandOverLine():boolean; + selectToScreenPosition(position:any):any; + selectToBufferPosition(position:any):any; + selectRight():boolean; + selectLeft():boolean; + selectUp(rowCount?:any):boolean; + selectDown(rowCount?:any):boolean; + selectToTop():any; + selectToBottom():any; + selectAll():any; + selectToBeginningOfLine():any; + selectToFirstCharacterOfLine():any; + selectToEndOfLine():any; + selectToBeginningOfWord():any; + selectToEndOfWord():any; + selectToBeginningOfNextWord():any; + selectToPreviousWordBoundary():any; + selectToNextWordBoundary():any; + addSelectionBelow():any; + getGoalBufferRange():any; + addSelectionAbove():any[]; + insertText(text:string, options?:any):any; + normalizeIndents(text:string, indentBasis:number):any; + indent(_arg?:any):any; + indentSelectedRows():IRange[]; + setIndentationForLine(line:string, indentLevel:number):any; + backspace():any; + backspaceToBeginningOfWord():any; + backspaceToBeginningOfLine():any; + delete():any; + deleteToEndOfWord():any; + deleteSelectedText():any; + deleteLine():any; + joinLines():any; + outdentSelectedRows():any[]; + autoIndentSelectedRows():any; + toggleLineComments():any; + cutToEndOfLine(maintainClipboard:any):any; + cut(maintainClipboard:any):any; + copy(maintainClipboard:any):any; + fold():any; + modifySelection(fn:()=>any):any; + plantTail():any; + intersectsBufferRange(bufferRange:any):any; + intersectsWith(otherSelection:any):any; + merge(otherSelection:any, options:any):any; + compare(otherSelection:any):any; + getRegionRects():any[]; + screenRangeChanged():any; } interface ISubscription { From 3cdedd857ab258793f81d8715c062d387dc1991d Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 4 May 2014 02:23:32 +0900 Subject: [PATCH 163/225] improve AtomCore.IPointStatic and AtomCore.IPoint definition in atom/atom.d.ts --- atom/atom.d.ts | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/atom/atom.d.ts b/atom/atom.d.ts index e976116d1a..42f1860063 100644 --- a/atom/atom.d.ts +++ b/atom/atom.d.ts @@ -746,11 +746,49 @@ declare module AtomCore { } interface IPointStatic { - new(row:any, column:any):IPoint; + new (row?:number, column?:number):IPoint; + + fromObject(point:IPoint, copy?:boolean):IPoint; + fromObject(object:number[]):IPoint; + fromObject(object:{row:number; col:number;}):IPoint; + + min(point1:IPoint, point2:IPoint):IPoint; + min(point1:number[], point2:IPoint):IPoint; + min(point1:{row:number; col:number;}, point2:IPoint):IPoint; + + min(point1:IPoint, point2:number[]):IPoint; + min(point1:number[], point2:number[]):IPoint; + min(point1:{row:number; col:number;}, point2:number[]):IPoint; + + min(point1:IPoint, point2:{row:number; col:number;}):IPoint; + min(point1:number[], point2:{row:number; col:number;}):IPoint; + min(point1:{row:number; col:number;}, point2:{row:number; col:number;}):IPoint; } interface IPoint { - // TBD + row:number; + column:number; + + copy():IPoint; + freeze():IPoint; + + translate(delta:IPoint):IPoint; + translate(delta:number[]):IPoint; + translate(delta:{row:number; col:number;}):IPoint; + + add(other:IPoint):IPoint; + add(other:number[]):IPoint; + add(other:{row:number; col:number;}):IPoint; + + splitAt(column:number):IPoint[]; + compare(other:IPoint):number; + isEqual(other:IPoint):boolean; + isLessThan(other:IPoint):boolean; + isLessThanOrEqual(other:IPoint):boolean; + isGreaterThan(other:IPoint):boolean; + isGreaterThanOrEqual(other:IPoint):boolean; + toArray():number[]; + serialize():number[]; } interface IRangeStatic { From 5801fa46c24fcb37036c83d639189dfd769f55fb Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 4 May 2014 02:47:59 +0900 Subject: [PATCH 164/225] improve AtomCore.IRangeStatic and AtomCore.IRange in atom/atom.d.ts --- atom/atom.d.ts | 101 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/atom/atom.d.ts b/atom/atom.d.ts index 42f1860063..106c6f318e 100644 --- a/atom/atom.d.ts +++ b/atom/atom.d.ts @@ -766,6 +766,8 @@ declare module AtomCore { } interface IPoint { + constructor: IPointStatic; + row:number; column:number; @@ -792,11 +794,106 @@ declare module AtomCore { } interface IRangeStatic { - new(pointA:IPoint, pointB:IPoint):IRange; + deserialize(array:IPoint[]):IRange; + + fromObject(object:IPoint[]):IRange; + + fromObject(object:IRange, copy?:boolean):IRange; + + fromObject(object:{start: IPoint; end: IPoint}):IRange; + fromObject(object:{start: number[]; end: IPoint}):IRange; + fromObject(object:{start: {row:number; col:number;}; end: IPoint}):IRange; + + fromObject(object:{start: IPoint; end: number[]}):IRange; + fromObject(object:{start: number[]; end: number[]}):IRange; + fromObject(object:{start: {row:number; col:number;}; end: number[]}):IRange; + + fromObject(object:{start: IPoint; end: {row:number; col:number;}}):IRange; + fromObject(object:{start: number[]; end: {row:number; col:number;}}):IRange; + fromObject(object:{start: {row:number; col:number;}; end: {row:number; col:number;}}):IRange; + + fromText(point:IPoint, text:string):IRange; + fromText(point:number[], text:string):IRange; + fromText(point:{row:number; col:number;}, text:string):IRange; + fromText(text:string):IRange; + + fromPointWithDelta(startPoint:IPoint, rowDelta:number, columnDelta:number):IRange; + fromPointWithDelta(startPoint:number[], rowDelta:number, columnDelta:number):IRange; + fromPointWithDelta(startPoint:{row:number; col:number;}, rowDelta:number, columnDelta:number):IRange; + + new(point1:IPoint, point2:IPoint):IRange; + new(point1:number[], point2:IPoint):IRange; + new(point1:{row:number; col:number;}, point2:IPoint):IRange; + + new(point1:IPoint, point2:number[]):IRange; + new(point1:number[], point2:number[]):IRange; + new(point1:{row:number; col:number;}, point2:number[]):IRange; + + new(point1:IPoint, point2:{row:number; col:number;}):IRange; + new(point1:number[], point2:{row:number; col:number;}):IRange; + new(point1:{row:number; col:number;}, point2:{row:number; col:number;}):IRange; } interface IRange { - // TBD + constructor:IRangeStatic; + + start: IPoint; + end: IPoint; + + serialize():number[][]; + copy():IRange; + freeze():IRange; + isEqual(other:IRange):boolean; + isEqual(other:IPoint[]):boolean; + + compare(object:IPoint[]):number; + + compare(object:{start: IPoint; end: IPoint}):number; + compare(object:{start: number[]; end: IPoint}):number; + compare(object:{start: {row:number; col:number;}; end: IPoint}):number; + + compare(object:{start: IPoint; end: number[]}):number; + compare(object:{start: number[]; end: number[]}):number; + compare(object:{start: {row:number; col:number;}; end: number[]}):number; + + compare(object:{start: IPoint; end: {row:number; col:number;}}):number; + compare(object:{start: number[]; end: {row:number; col:number;}}):number; + compare(object:{start: {row:number; col:number;}; end: {row:number; col:number;}}):number; + + isSingleLine():boolean; + coversSameRows(other:IRange):boolean; + + add(object:IPoint[]):IRange; + + add(object:{start: IPoint; end: IPoint}):IRange; + add(object:{start: number[]; end: IPoint}):IRange; + add(object:{start: {row:number; col:number;}; end: IPoint}):IRange; + + add(object:{start: IPoint; end: number[]}):IRange; + add(object:{start: number[]; end: number[]}):IRange; + add(object:{start: {row:number; col:number;}; end: number[]}):IRange; + + add(object:{start: IPoint; end: {row:number; col:number;}}):IRange; + add(object:{start: number[]; end: {row:number; col:number;}}):IRange; + add(object:{start: {row:number; col:number;}; end: {row:number; col:number;}}):IRange; + + translate(startPoint:IPoint, endPoint:IPoint):IRange; + translate(startPoint:IPoint):IRange; + + intersectsWith(otherRange:IRange):boolean; + containsRange(otherRange:IRange, exclusive:boolean):boolean; + + containsPoint(point:IPoint, exclusive:boolean):boolean; + containsPoint(point:number[], exclusive:boolean):boolean; + containsPoint(point:{row:number; col:number;}, exclusive:boolean):boolean; + + intersectsRow(row:number):boolean; + intersectsRowRange(startRow:number, endRow:number):boolean; + union(otherRange:IRange):IRange; + isEmpty():boolean; + toDelta():IPoint; + getRowCount():number; + getRows():number[]; } interface ITokenizedLine { From f8b43ffd5c92a1e269f4ffa322eec247dc11608c Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 4 May 2014 03:03:27 +0900 Subject: [PATCH 165/225] improve AtomCore.IDisplayBufferMarkerStatic and AtomCore.IDisplayBufferMarker in atom/atom.d.ts --- atom/atom.d.ts | 59 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/atom/atom.d.ts b/atom/atom.d.ts index 106c6f318e..cef13f81c6 100644 --- a/atom/atom.d.ts +++ b/atom/atom.d.ts @@ -908,14 +908,69 @@ declare module AtomCore { // TBD } - interface IDisplayBufferMarker { - // TBD + interface IDisplayBufferMarkerStatic { + new (_arg:{bufferMarker:IMarker; displayBuffer: IDisplayBuffer}):IDisplayBufferMarker; + } + + interface IDisplayBufferMarker extends Emissary.IEmitter, Emissary.ISubscriber { + constructor:IDisplayBufferMarkerStatic; + + id: number; + + bufferMarkerSubscription:any; + oldHeadBufferPosition:IPoint; + oldHeadScreenPosition:IPoint; + oldTailBufferPosition:IPoint; + oldTailScreenPosition:IPoint; + wasValid:boolean; + + bufferMarker: IMarker; + displayBuffer: IDisplayBuffer; + globalPauseCount:number; + globalQueuedEvents:any; + + subscriptions:ISubscription[]; + subscriptionsByObject:any; // WeakMap + + copy(attributes?:any /* maybe IMarker */):IDisplayBufferMarker; + getScreenRange():IRange; + setScreenRange(screenRange:any, options:any):any; + getBufferRange():IRange; + setBufferRange(bufferRange:any, options:any):any; + getPixelRange():any; + getHeadScreenPosition():IPoint; + setHeadScreenPosition(screenPosition:any, options:any):any; + getHeadBufferPosition():IPoint; + setHeadBufferPosition(bufferPosition:any):any; + getTailScreenPosition():IPoint; + setTailScreenPosition(screenPosition:any, options:any):any; + getTailBufferPosition():IPoint; + setTailBufferPosition(bufferPosition:any):any; + plantTail():boolean; + clearTail():boolean; + hasTail():boolean; + isReversed():boolean; + isValid():boolean; + isDestroyed():boolean; + getAttributes():any; + setAttributes(attributes:any):any; + matchesAttributes(attributes:any):any; + destroy():any; + isEqual(other:IDisplayBufferMarker):boolean; + compare(other:IDisplayBufferMarker):boolean; + inspect():string; + destroyed():any; + notifyObservers(_arg:any):any; } interface ITransaction { // TBD } + interface IMarker { + // TBD + } + interface ITaskStatic { new(taskPath:any):ITask; } From 8433ce18732b6627a85145592612433d81ab3d54 Mon Sep 17 00:00:00 2001 From: vvakame Date: Sun, 4 May 2014 04:11:02 +0900 Subject: [PATCH 166/225] improve AtomCore.IDisplayBufferStatic and AtomCore.IDisplayBuffer in atom/atom.d.ts --- atom/atom.d.ts | 214 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 211 insertions(+), 3 deletions(-) diff --git a/atom/atom.d.ts b/atom/atom.d.ts index cef13f81c6..1dd2694df3 100644 --- a/atom/atom.d.ts +++ b/atom/atom.d.ts @@ -52,9 +52,201 @@ declare module AtomCore { // TBD } - interface IDisplayBuffer { + interface IDisplayBufferStatic { + new(_arg?:any):IDisplayBuffer; + } + + interface IDisplayBuffer /* extends Theorist.Model */ { + // Serializable.includeInto(Editor); + + constructor:IDisplayBufferStatic; + + verticalScrollMargin:number; + horizontalScrollMargin:number; + + declaredPropertyValues:any; + tokenizedBuffer: ITokenizedBuffer; buffer: ITextBuffer; - // TBD + charWidthsByScope:any; + markers:{ [index:number]:IDisplayBufferMarker; }; + foldsByMarkerId:any; + maxLineLength:number; + screenLines:ITokenizedLine[]; + rowMap:any; // return type are RowMap + longestScreenRow:number; + subscriptions:ISubscription[]; + subscriptionsByObject:any; // return type are WeakMap + behaviors:any; + subscriptionCounts:any; + eventHandlersByEventName:any; + pendingChangeEvent:any; + + softWrap:boolean; + + serializeParams():{id:number; softWrap:boolean; editorWidthInChars: number; scrollTop: number; scrollLeft: number; tokenizedBuffer: any; }; + deserializeParams(params:any):any; + copy():IDisplayBuffer; + updateAllScreenLines():any; + emitChanged(eventProperties:any, refreshMarkers?:boolean):any; + updateWrappedScreenLines():any; + setVisible(visible:any):any; + getVerticalScrollMargin():number; + setVerticalScrollMargin(verticalScrollMargin:number):number; + getHorizontalScrollMargin():number; + setHorizontalScrollMargin(horizontalScrollMargin:number):number; + getHeight():any; + setHeight(height:any):any; + getWidth():any; + setWidth(newWidth:any):any; + getScrollTop():number; + setScrollTop(scrollTop:number):number; + getScrollBottom():number; + setScrollBottom(scrollBottom:number):number; + getScrollLeft():number; + setScrollLeft(scrollLeft:number):number; + getScrollRight():number; + setScrollRight(scrollRight:number):number; + getLineHeight():any; + setLineHeight(lineHeight:any):any; + getDefaultCharWidth():any; + setDefaultCharWidth(defaultCharWidth:any):any; + getScopedCharWidth(scopeNames:any, char:any):any; + getScopedCharWidths(scopeNames:any):any; + setScopedCharWidth(scopeNames:any, char:any, width:any):any; + setScopedCharWidths(scopeNames:any, charWidths:any):any; + clearScopedCharWidths():any; + getScrollHeight():number; + getScrollWidth():number; + getVisibleRowRange():number[]; + intersectsVisibleRowRange(startRow:any, endRow:any):any; + selectionIntersectsVisibleRowRange(selection:any):any; + scrollToScreenRange(screenRange:any):any; + scrollToScreenPosition(screenPosition:any):any; + scrollToBufferPosition(bufferPosition:any):any; + pixelRectForScreenRange(screenRange:IRange):any; + getTabLength():number; + setTabLength(tabLength:number):any; + setSoftWrap(softWrap:boolean):boolean; + getSoftWrap():boolean; + setEditorWidthInChars(editorWidthInChars:number):any; + getEditorWidthInChars():number; + getSoftWrapColumn():number; + lineForRow(row:number):any; + linesForRows(startRow:number, endRow:number):any; + getLines():any[]; + indentLevelForLine(line:any):any; + bufferRowsForScreenRows(startScreenRow:any, endScreenRow:any):any; + createFold(startRow:number, endRow:number):IFold; + isFoldedAtBufferRow(bufferRow:number):boolean; + isFoldedAtScreenRow(screenRow:number):boolean; + destroyFoldWithId(id:number):any; + unfoldBufferRow(bufferRow:number):any[]; + largestFoldStartingAtBufferRow(bufferRow:number):any; + foldsStartingAtBufferRow(bufferRow:number):any; + largestFoldStartingAtScreenRow(screenRow:any):any; + largestFoldContainingBufferRow(bufferRow:any):any; + outermostFoldsInBufferRowRange(startRow:any, endRow:any):any[]; + foldsContainingBufferRow(bufferRow:any):any[]; + screenRowForBufferRow(bufferRow:number):number; + lastScreenRowForBufferRow(bufferRow:number):number; + bufferRowForScreenRow(screenRow:number):number; + + screenRangeForBufferRange(bufferRange:IPoint[]):IRange; + + screenRangeForBufferRange(bufferRange:IRange):IRange; + + screenRangeForBufferRange(bufferRange:{start: IPoint; end: IPoint}):IRange; + screenRangeForBufferRange(bufferRange:{start: number[]; end: IPoint}):IRange; + screenRangeForBufferRange(bufferRange:{start: {row:number; col:number;}; end: IPoint}):IRange; + + screenRangeForBufferRange(bufferRange:{start: IPoint; end: number[]}):IRange; + screenRangeForBufferRange(bufferRange:{start: number[]; end: number[]}):IRange; + screenRangeForBufferRange(bufferRange:{start: {row:number; col:number;}; end: number[]}):IRange; + + screenRangeForBufferRange(bufferRange:{start: IPoint; end: {row:number; col:number;}}):IRange; + screenRangeForBufferRange(bufferRange:{start: number[]; end: {row:number; col:number;}}):IRange; + screenRangeForBufferRange(bufferRange:{start: {row:number; col:number;}; end: {row:number; col:number;}}):IRange; + + bufferRangeForScreenRange(screenRange:IPoint[]):IRange; + + bufferRangeForScreenRange(screenRange:IRange):IRange; + + bufferRangeForScreenRange(screenRange:{start: IPoint; end: IPoint}):IRange; + bufferRangeForScreenRange(screenRange:{start: number[]; end: IPoint}):IRange; + bufferRangeForScreenRange(screenRange:{start: {row:number; col:number;}; end: IPoint}):IRange; + + bufferRangeForScreenRange(screenRange:{start: IPoint; end: number[]}):IRange; + bufferRangeForScreenRange(screenRange:{start: number[]; end: number[]}):IRange; + bufferRangeForScreenRange(screenRange:{start: {row:number; col:number;}; end: number[]}):IRange; + + bufferRangeForScreenRange(screenRange:{start: IPoint; end: {row:number; col:number;}}):IRange; + bufferRangeForScreenRange(screenRange:{start: number[]; end: {row:number; col:number;}}):IRange; + bufferRangeForScreenRange(screenRange:{start: {row:number; col:number;}; end: {row:number; col:number;}}):IRange; + + pixelRangeForScreenRange(screenRange:IPoint[], clip?:boolean):IRange; + + pixelRangeForScreenRange(screenRange:IRange, clip?:boolean):IRange; + + pixelRangeForScreenRange(screenRange:{start: IPoint; end: IPoint}, clip?:boolean):IRange; + pixelRangeForScreenRange(screenRange:{start: number[]; end: IPoint}, clip?:boolean):IRange; + pixelRangeForScreenRange(screenRange:{start: {row:number; col:number;}; end: IPoint}, clip?:boolean):IRange; + + pixelRangeForScreenRange(screenRange:{start: IPoint; end: number[]}, clip?:boolean):IRange; + pixelRangeForScreenRange(screenRange:{start: number[]; end: number[]}, clip?:boolean):IRange; + pixelRangeForScreenRange(screenRange:{start: {row:number; col:number;}; end: number[]}, clip?:boolean):IRange; + + pixelRangeForScreenRange(screenRange:{start: IPoint; end: {row:number; col:number;}}, clip?:boolean):IRange; + pixelRangeForScreenRange(screenRange:{start: number[]; end: {row:number; col:number;}}, clip?:boolean):IRange; + pixelRangeForScreenRange(screenRange:{start: {row:number; col:number;}; end: {row:number; col:number;}}, clip?:boolean):IRange; + + pixelPositionForScreenPosition(screenPosition:IPoint, clip?:boolean):IPoint; + pixelPositionForScreenPosition(screenPosition:number[], clip?:boolean):IPoint; + pixelPositionForScreenPosition(screenPosition:{row:number; col:number;}, clip?:boolean):IPoint; + + screenPositionForPixelPosition(pixelPosition:any):IPoint; + + pixelPositionForBufferPosition(bufferPosition:any):any; + getLineCount():number; + getLastRow():number; + getMaxLineLength():number; + screenPositionForBufferPosition(bufferPosition:any, options:any):any; + bufferPositionForScreenPosition(bufferPosition:any, options:any):any; + scopesForBufferPosition(bufferPosition:any):any; + bufferRangeForScopeAtPosition(selector:any, position:any):any; + tokenForBufferPosition(bufferPosition:any):any; + getGrammar():IGrammar; + setGrammar(grammar:IGrammar):any; + reloadGrammar():any; + clipScreenPosition(screenPosition:any, options:any):any; + findWrapColumn(line:any, softWrapColumn:any):any; + rangeForAllLines():IRange; + getMarker(id:number):IDisplayBufferMarker; + getMarkers():IDisplayBufferMarker[]; + getMarkerCount():number; + markScreenRange(range:IRange, ...args:any[]):IDisplayBufferMarker; + markBufferRange(range:IRange, options?:any):IDisplayBufferMarker; + markScreenPosition(screenPosition:IPoint, options?:any):IDisplayBufferMarker; + markBufferPosition(bufferPosition:IPoint, options?:any):IDisplayBufferMarker; + destroyMarker(id:number):any; + findMarker(params?:any):IDisplayBufferMarker; + findMarkers(params?:any):IDisplayBufferMarker[]; + translateToBufferMarkerParams(params?:any):any; + findFoldMarker(attributes:any):IMarker; + findFoldMarkers(attributes:any):IMarker[]; + getFoldMarkerAttributes(attributes?:any):any; + pauseMarkerObservers():any; + resumeMarkerObservers():any; + refreshMarkerScreenPositions():any; + destroy():any; + logLines(start:number, end:number):any[]; + handleTokenizedBufferChange(tokenizedBufferChange:any):any; + updateScreenLines(startBufferRow:any, endBufferRow:any, bufferDelta?:number, options?:any):any; + buildScreenLines(startBufferRow:any, endBufferRow:any):any; + findMaxLineLength(startScreenRow:any, endScreenRow:any, newScreenLines:any):any; + handleBufferMarkersUpdated():any; + handleBufferMarkerCreated(marker:any):any; + createFoldForMarker(maker:any):IFold; + foldForMarker(marker:any):any; } interface ICursor { @@ -896,6 +1088,10 @@ declare module AtomCore { getRows():number[]; } + interface ITokenizedBuffer { + // TBD + } + interface ITokenizedLine { // TBD } @@ -904,7 +1100,16 @@ declare module AtomCore { // TBD } + interface IFoldStatic { + new (displayBuffer:IDisplayBuffer, marker:IMarker):IFold; + // TBD + } + interface IFold { + id:number; + displayBuffer:IDisplayBuffer; + marker:IMarker; + // TBD } @@ -967,7 +1172,10 @@ declare module AtomCore { // TBD } - interface IMarker { + interface IMarker extends Emissary.IEmitter { + // Serializable.includeInto(Editor); + // Delegator.includeInto(Editor); + // TBD } From 657277a43c05d721641f880b646354eb452394c5 Mon Sep 17 00:00:00 2001 From: David Driscoll Date: Sun, 4 May 2014 20:16:10 -0400 Subject: [PATCH 167/225] Renamed tests file. Fixed remaining tests. --- ...dash-tests.disabled.ts => lodash-tests.ts} | 1963 ++- lodash/lodash.d.ts | 11432 ++++++++-------- 2 files changed, 6697 insertions(+), 6698 deletions(-) rename lodash/{lodash-tests.disabled.ts => lodash-tests.ts} (56%) diff --git a/lodash/lodash-tests.disabled.ts b/lodash/lodash-tests.ts similarity index 56% rename from lodash/lodash-tests.disabled.ts rename to lodash/lodash-tests.ts index de96b3d978..953d32d379 100644 --- a/lodash/lodash-tests.disabled.ts +++ b/lodash/lodash-tests.ts @@ -1,982 +1,981 @@ -/// - -declare var $: any, jQuery: any; - -interface IFoodOrganic { - name: string; - organic: boolean; -} - -interface IFoodType { - name: string; - type: string; -} - -interface IFoodCombined { - name: string; - organic: boolean; - type: string; -} - -interface IStoogesQuote { - name: string; - quotes: string[]; -} - -interface IStoogesAge { - name: string; - age: number; -} - -interface IStoogesCombined { - name: string; - age: number; - quotes: string[]; -} - -interface IKey { - dir: string; - code: number; -} - -var foodsOrganic: IFoodOrganic[] = [ - { name: 'banana', organic: true }, - { name: 'beet', organic: false }, -]; -var foodsType: IFoodType[] = [ - { name: 'apple', type: 'fruit' }, - { name: 'banana', type: 'fruit' }, - { name: 'beet', type: 'vegetable' } -]; -var foodsCombined: IFoodCombined[] = [ - { 'name': 'apple', 'organic': false, 'type': 'fruit' }, - { 'name': 'carrot', 'organic': true, 'type': 'vegetable' } -]; - -var stoogesQuotes: IStoogesQuote[] = [ - { 'name': 'curly', 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'quotes': ['Spread out!', 'You knucklehead!'] } -]; -var stoogesAges: IStoogesAge[] = [ - { 'name': 'moe', 'age': 40 }, - { 'name': 'larry', 'age': 50 } -]; - -var stoogesCombined: IStoogesCombined[] = [ - { 'name': 'curly', 'age': 30, 'quotes': ['Oh, a wise guy, eh?', 'Poifect!'] }, - { 'name': 'moe', 'age': 40, 'quotes': ['Spread out!', 'You knucklehead!'] } -]; - -var keys: IKey[] = [ - { 'dir': 'left', 'code': 97 }, - { 'dir': 'right', 'code': 100 } -]; - -class Dog { - constructor(public name: string) {} - - public bark() { - console.log('Woof, woof!'); - } -} - -var result : any; - -/************* - * Chaining * - *************/ -result = <_.LoDashWrapper>_('test'); -result = <_.LoDashWrapper>_(1); -result = <_.LoDashWrapper>_(true); -result = <_.LoDashArrayWrapper>_(['test1', 'test2']); -// Appears to be a change in the compiler, if the type explicity implements the object indexer. -// Looking at: https://typescript.codeplex.com/wikipage?title=Known%20breaking%20changes%20between%200.8%20and%200.9&referringTitle=Documentation -// "The ‘noimplicitany’ option now warns on the use of the hidden default indexer" -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }); - -result = <_.LoDashWrapper>_.chain('test'); -result = <_.LoDashWrapper>_('test').chain(); -result = <_.LoDashWrapper>_.chain(1); -result = <_.LoDashWrapper>_(1).chain(); -result = <_.LoDashWrapper>_.chain(true); -result = <_.LoDashWrapper>_(true).chain(); -result = <_.LoDashArrayWrapper>_.chain(['test1', 'test2']); -result = <_.LoDashArrayWrapper>_(['test1', 'test2']).chain(); -result = <_.LoDashObjectWrapper<_.Dictionary>>_.chain(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).chain(); - -//Wrapped array shortcut methods -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).concat(5, 6); -result = <_.LoDashWrapper>_([1, 2, 3, 4]).join(','); -result = <_.LoDashWrapper>_([1, 2, 3, 4]).pop(); -_([1, 2, 3, 4]).push(5, 6, 7); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).reverse(); -result = <_.LoDashWrapper>_([1, 2, 3, 4]).shift(); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).slice(1, 2); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).slice(2); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).sort((a, b) => 1); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).splice(1, 2, 5, 6); -result = <_.LoDashWrapper>_([1, 2, 3, 4]).unshift(5, 6); - -result = _.tap([1, 2, 3, 4], function(array) { console.log(array); }); -result = <_.LoDashWrapper>_('test').tap(function(value) { console.log(value); }); -result = <_.LoDashArrayWrapper>_([1, 2, 3, 4]).tap(function(array) { console.log(array); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).tap(function (array) { console.log(array); }); - -result = _('test').toString(); -result = _([1, 2, 3]).toString(); -result = _({'key1': 'test1', 'key2': 'test2'}).toString(); - -result = _('test').valueOf(); -result = _([1, 2, 3]).valueOf(); -result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).valueOf(); - -result = _('test').value(); -result = _([1, 2, 3]).value(); -result = <_.Dictionary>_(<{ [index: string]: string; }>{ 'key1': 'test1', 'key2': 'test2' }).value(); - -// /************* -// * Arrays * -// *************/ -result = _.compact([0, 1, false, 2, '', 3]); - result = <_.LoDashArrayWrapper>_([0, 1, false, 2, '', 3]).compact(); - -result = _.difference([1, 2, 3, 4, 5], [5, 2, 10]); - result = <_.LoDashArrayWrapper>_([1, 2, 3, 4, 5]).difference([5, 2, 10]); - -result = _.rest([1, 2, 3]); -result = _.rest([1, 2, 3], 2); -result = _.rest([1, 2, 3], (num) => num < 3) -result = _.rest(foodsOrganic, 'test'); -result = _.rest(foodsType, { 'type': 'value' }); - -result = _.drop([1, 2, 3]); -result = _.drop([1, 2, 3], 2); -result = _.drop([1, 2, 3], (num) => num < 3) -result = _.drop(foodsOrganic, 'test'); -result = _.drop(foodsType, { 'type': 'value' }); - -result = _.tail([1, 2, 3]) -result = _.tail([1, 2, 3], 2) -result = _.tail([1, 2, 3], (num) => num < 3) -result = _.tail(foodsOrganic, 'test') -result = _.tail(foodsType, { 'type': 'value' }) - -result = _.findIndex(['apple', 'banana', 'beet'], function(f) { - return /^b/.test(f); -}); -result = _.findIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); - -result = _.findLastIndex(['apple', 'banana', 'beet'], function(f: string) { - return /^b/.test(f); -}); -result = _.findLastIndex(['apple', 'banana', 'beet'], 'apple'); -result = _.findLastIndex([{ food: 'apple' }, { food: 'banana' }, { food: 'beet' }], { food: 'apple'}); - -result = _.first([1, 2, 3]); -result = _.first([1, 2, 3], 2); -result = _.first([1, 2, 3], function(num) { - return num < 3; -}); -result = _.first(foodsOrganic, 'organic'); -result = _.first(foodsType, { 'type': 'fruit' }); - - result = _.head([1, 2, 3]); - result = _.head([1, 2, 3], 2); - result = _.head([1, 2, 3], function(num) { - return num < 3; - }); - result = _.head(foodsOrganic, 'organic'); - result = _.head(foodsType, { 'type': 'fruit' }); - - result = _.take([1, 2, 3]); - result = _.take([1, 2, 3], 2); - result = _.take([1, 2, 3], (num) => num < 3); - result = _.take(foodsOrganic, 'organic'); - result = _.take(foodsType, { 'type': 'fruit' }); - -result = _.flatten([1, [2], [3, [[4]]]]); -result = _.flatten([1, [2], [3, [[4]]]], true); -var result: any -result = _.flatten(stoogesQuotes, 'quotes'); - - result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(); - result = <_.LoDashArrayWrapper>_([1, [2], [3, [[4]]]]).flatten(true); - result = <_.LoDashArrayWrapper>_(stoogesQuotes).flatten('quotes'); - -result = _.indexOf([1, 2, 3, 1, 2, 3], 2); -result = _.indexOf([1, 2, 3, 1, 2, 3], 2, 3); -result = _.indexOf([1, 1, 2, 2, 3, 3], 2, true); - -result = _.initial([1, 2, 3]); -result = _.initial([1, 2, 3], 2); -result = _.initial([1, 2, 3], function(num) { - return num > 1; -}); -result = _.initial(foodsOrganic, 'organic'); -result = _.initial(foodsType, { 'type': 'vegetable' }); - -result = _.intersection([1, 2, 3], [101, 2, 1, 10], [2, 1]); - -result = _.last([1, 2, 3]); -result = _.last([1, 2, 3], 2); -result = _.last([1, 2, 3], function(num) { - return num > 1; -}); -result = _.last(foodsOrganic, 'organic'); -result = _.last(foodsType, { 'type': 'vegetable' }); - -result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2); -result = _.lastIndexOf([1, 2, 3, 1, 2, 3], 2, 3); - -result = <{[key: string]: any}>_.zipObject(['moe', 'larry'], [30, 40]); -result = <{[key: string]: any}>_.object(['moe', 'larry'], [30, 40]); - -result = _.pull([1, 2, 3, 1, 2, 3], 2, 3); - -result = _.range(10); -result = _.range(1, 11); -result = _.range(0, 30, 5); -result = _.range(0, -10, -1); -result = _.range(1, 4, 0); -result = _.range(0); - -result = _.remove([1, 2, 3, 4, 5, 6], function(num: number) { return num % 2 == 0; }); -result = _.remove(foodsOrganic, 'organic'); -result = _.remove(foodsType, { 'type': 'vegetable'}); - -result = _.sortedIndex([20, 30, 50], 40); -result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); -var sortedIndexDict = { - 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } -}; -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return sortedIndexDict.wordToNumber[word]; -}); -result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function(word) { - return this.wordToNumber[word]; -}, sortedIndexDict); - -result = _.union([1, 2, 3], [101, 2, 1, 10], [2, 1]); - -result = _.uniq([1, 2, 1, 3, 1]); -result = _.uniq([1, 1, 2, 2, 3], true); -result = _.uniq(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { - return letter.toLowerCase(); -}); -result = _.uniq([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); -result = <{x: number;}[]>_.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - - result = _.unique([1, 2, 1, 3, 1]); - result = _.unique([1, 1, 2, 2, 3], true); - result = _.unique(['A', 'b', 'C', 'a', 'B', 'c'], function(letter) { - return letter.toLowerCase(); - }); - result = _.unique([1, 2.5, 3, 1.5, 2, 3.5], function(num) { return this.floor(num); }, Math); - result = <{x: number;}[]>_.unique([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x'); - -result = _.without([1, 2, 1, 0, 3, 1, 4], 0, 1); - -result = _.zip(['moe', 'larry'], [30, 40], [true, false]); -result = _.unzip(['moe', 'larry'], [30, 40], [true, false]); - -// /* ************* -// * Collections * -// ************* */ - -result = _.at(['a', 'b', 'c', 'd', 'e'], [0, 2, 4]); -result = _.at(['moe', 'larry', 'curly'], 0, 2); - -result = _.contains([1, 2, 3], 1); -result = _.contains([1, 2, 3], 1, 2); -result = _.contains({ 'name': 'moe', 'age': 40 }, 'moe'); -result = _.contains('curly', 'ur'); - - result = _.include([1, 2, 3], 1); - result = _.include([1, 2, 3], 1, 2); - result = _.include({ 'name': 'moe', 'age': 40 }, 'moe'); - result = _.include('curly', 'ur'); - -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = <_.Dictionary>_.countBy([4.3, 6.1, 6.4], function(num) { return this.floor(num); }, Math); -result = <_.Dictionary>_.countBy(['one', 'two', 'three'], 'length'); - -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return Math.floor(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.3, 6.1, 6.4]).countBy(function (num) { return this.floor(num); }, Math); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).countBy('length'); - -result = _.every([true, 1, null, 'yes'], Boolean); -result = _.every(stoogesAges, 'age'); -result = _.every(stoogesAges, { 'age': 50 }); - - result = _.all([true, 1, null, 'yes'], Boolean); - result = _.all(stoogesAges, 'age'); - result = _.all(stoogesAges, { 'age': 50 }); - -result = _.filter([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); -result = _.filter(foodsCombined, 'organic'); -result = _.filter(foodsCombined, { 'type': 'fruit' }); - - result = _([1, 2, 3, 4, 5, 6]).filter(function(num) { return num % 2 == 0; }).value(); - result = _(foodsCombined).filter('organic').value(); - result = _(foodsCombined).filter({ 'type': 'fruit' }).value(); - - result = _.select([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); - result = _.select(foodsCombined, 'organic'); - result = _.select(foodsCombined, { 'type': 'fruit' }); - - result = _([1, 2, 3, 4, 5, 6]).select(function(num) { return num % 2 == 0; }).value(); - result = _(foodsCombined).select('organic').value(); - result = _(foodsCombined).select({ 'type': 'fruit' }).value(); - -result = _.find([1, 2, 3, 4], function(num) { - return num % 2 == 0; -}); -result = _.find(foodsCombined, { 'type': 'vegetable' }); -result = _.find(foodsCombined, 'organic'); - - result = _.detect([1, 2, 3, 4], function(num) { - return num % 2 == 0; - }); - result = _.detect(foodsCombined, { 'type': 'vegetable' }); - result = _.detect(foodsCombined, 'organic'); - - result = _.findWhere([1, 2, 3, 4], function(num) { - return num % 2 == 0; - }); - result = _.findWhere(foodsCombined, { 'type': 'vegetable' }); - result = _.findWhere(foodsCombined, 'organic'); - -result = _.findLast([1, 2, 3, 4], function(num) { - return num % 2 == 0; -}); -result = _.findLast(foodsCombined, { 'type': 'vegetable' }); -result = _.findLast(foodsCombined, 'organic'); - -result = _.forEach([1, 2, 3], function(num) { console.log(num); }); -result = <_.Dictionary>_.forEach({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - - result = _.each([1, 2, 3], function(num) { console.log(num); }); - result = <_.Dictionary>_.each({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - -result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEach(function (num) { console.log(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEach(function (num) { console.log(num); }); - -result = <_.LoDashArrayWrapper>_([1, 2, 3]).each(function (num) { console.log(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).each(function (num) { console.log(num); }); - -result = _.forEachRight([1, 2, 3], function(num) { console.log(num); }); -result = <_.Dictionary>_.forEachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - - result = _.eachRight([1, 2, 3], function(num) { console.log(num); }); - result = <_.Dictionary>_.eachRight({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { console.log(num); }); - -result = <_.LoDashArrayWrapper>_([1, 2, 3]).forEachRight(function (num) { console.log(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).forEachRight(function (num) { console.log(num); }); - -result = <_.LoDashArrayWrapper>_([1, 2, 3]).eachRight(function (num) { console.log(num); }); -result = <_.LoDashObjectWrapper<_.Dictionary>>_(<{ [index: string]: number; }>{ 'one': 1, 'two': 2, 'three': 3 }).eachRight(function (num) { console.log(num); }); - -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return Math.floor(num); }); -result = <_.Dictionary>_.groupBy([4.2, 6.1, 6.4], function(num) { return this.floor(num); }, Math); -result = <_.Dictionary>_.groupBy(['one', 'two', 'three'], 'length'); - - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return Math.floor(num); }); - result = <_.LoDashObjectWrapper<_.Dictionary>>_([4.2, 6.1, 6.4]).groupBy(function(num) { return this.floor(num); }, Math); - result = <_.LoDashObjectWrapper<_.Dictionary>>_(['one', 'two', 'three']).groupBy('length'); - -result = <_.Dictionary>_.indexBy(keys, 'dir'); -result = <_.Dictionary>_.indexBy(keys, function(key) { return String.fromCharCode(key.code); }); -result = <_.Dictionary>_.indexBy(keys, function(key) { this.fromCharCode(key.code); }, String); - -result = _.invoke([[5, 1, 7], [3, 2, 1]], 'sort'); -result = _.invoke([123, 456], String.prototype.split, ''); - -result = _.map([1, 2, 3], function(num) { return num * 3; }); -result = _.map({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); -result = _.map(stoogesAges, 'name'); - - result = _([1, 2, 3]).map(function(num) { return num * 3; }).value(); - result = _({ 'one': 1, 'two': 2, 'three': 3 }).map(function(num) { return num * 3; }).value(); - result = _(stoogesAges).map('name').value(); - -result = _.collect([1, 2, 3], function(num) { return num * 3; }); -result = _.collect({ 'one': 1, 'two': 2, 'three': 3 }, function(num) { return num * 3; }); -result = _.collect(stoogesAges, 'name'); - - result = _([1, 2, 3]).collect(function(num) { return num * 3; }).value(); - result = _({ 'one': 1, 'two': 2, 'three': 3 }).collect(function(num) { return num * 3; }).value(); - result = _(stoogesAges).collect('name').value(); - -result = _.max([4, 2, 8, 6]); -result = _.max(stoogesAges, function(stooge) { return stooge.age; }); -result = _.max(stoogesAges, 'age'); - -result = _.min([4, 2, 8, 6]); -result = _.min(stoogesAges, function(stooge) { return stooge.age; }); -result = _.min(stoogesAges, 'age'); - -result = _.pluck(stoogesAges, 'name'); - -result = _.reduce([1, 2, 3], function(sum: number, num: number) { - return sum + num; -}); -interface ABC { - a: number; - b: number; - c: number; -} -result = _.reduce({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; -}, {}); - -result = _.foldl([1, 2, 3], function(sum, num) { - return sum + num; -}); -result = _.foldl({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; -}, {}); - -result = _.inject([1, 2, 3], function(sum, num) { - return sum + num; -}); -result = _.inject({ 'a': 1, 'b': 2, 'c': 3 }, function(r: ABC, num, key) { - r[key] = num * 3; - return r; -}, {}); - -result = _.reduceRight([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); -result = _.foldr([[0, 1], [2, 3], [4, 5]], function(a: number[], b: number[]) { return a.concat(b); }, []); - -result = _.reject([1, 2, 3, 4, 5, 6], function(num) { return num % 2 == 0; }); -result = _.reject(foodsCombined, 'organic'); -result = _.reject(foodsCombined, { 'type': 'fruit' }); - -result = _.sample([1, 2, 3, 4]); -result = _.sample([1, 2, 3, 4], 2); - -result = _.shuffle([1, 2, 3, 4, 5, 6]); - -result = _.size([1, 2]); -result = _.size({ 'one': 1, 'two': 2, 'three': 3 }); -result = _.size('curly'); - -result = _.some([null, 0, 'yes', false], Boolean); -result = _.some(foodsCombined, 'organic'); -result = _.some(foodsCombined, { 'type': 'meat' }); - -result = _.any([null, 0, 'yes', false], Boolean); -result = _.any(foodsCombined, 'organic'); -result = _.any(foodsCombined, { 'type': 'meat' }); - -result = _.sortBy([1, 2, 3], function(num) { return Math.sin(num); }); -result = _.sortBy([1, 2, 3], function(num) { return this.sin(num); }, Math); -result = _.sortBy(['banana', 'strawberry', 'apple'], 'length'); - -(function(a: number, b: number, c: number, d: number){ return _.toArray(arguments).slice(1); })(1, 2, 3, 4); - -result = _.where(stoogesCombined, { 'age': 40 }); -result = _.where(stoogesCombined, { 'quotes': ['Poifect!'] }); - -/************* - * Functions * - *************/ -var saves = ['profile', 'settings']; -var asyncSave = (obj: any) => obj.done(); -var done: Function; - -done = _.after(saves.length, function() { - console.log('Done saving!'); -}); - -_.forEach(saves, function(type) { - asyncSave({ 'type': type, 'complete': done }); -}); - -done = _(saves.length).after(function() { - console.log('Done saving!'); -}).value(); - -_.forEach(saves, function(type) { - asyncSave({ 'type': type, 'complete': done }); -}); - -var funcBind = function (greeting: string) { return greeting + ' ' + this.name }; -var funcBind2: () => any = _.bind(funcBind, { 'name': 'moe' }, 'hi'); -funcBind2(); - -var funcBind3: () => any = _(funcBind).bind({ 'name': 'moe' }, 'hi').value(); -funcBind3(); - -var view = { - 'label': 'docs', - 'onClick': function() { console.log('clicked ' + this.label); } -}; - -view = _.bindAll(view); -jQuery('#docs').on('click', view.onClick); - -view = _(view).bindAll().value(); -jQuery('#docs').on('click', view.onClick); - -var objectBindKey = { - 'name': 'moe', - 'greet': function(greeting: string) { - return greeting + ' ' + this.name; - } -}; - -var funcBindKey: Function = _.bindKey(objectBindKey, 'greet', 'hi'); -funcBindKey(); - -objectBindKey.greet = function(greeting) { - return greeting + ', ' + this.name + '!'; -}; - -funcBindKey(); - -funcBindKey = _(objectBindKey).bindKey('greet', 'hi').value(); -funcBindKey(); - -var realNameMap = { - 'curly': 'jerome' -}; - -var format = function(name: string) { - name = realNameMap[name.toLowerCase()] || name; - return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase(); -}; - -var greet = function(formatted: string) { - return 'Hiya ' + formatted + '!'; -}; - -result = _.compose(greet, format); -result = <_.LoDashObjectWrapper>_(greet).compose(format); - -var createCallbackObj: { [index: string]: string; } = { name: 'Joe' }; -result = <() => any>_.createCallback('name'); -result = <() => boolean>_.createCallback(createCallbackObj); -result = <_.LoDashObjectWrapper<() => any>>_('name').createCallback(); -result = <_.LoDashObjectWrapper<() => boolean>>_(createCallbackObj).createCallback(); - -result = _.curry(function(a, b, c) { - console.log(a + b + c); -}); - -result = <_.LoDashObjectWrapper>_(function(a, b, c) { - console.log(a + b + c); -}).curry(); - -declare var source: any; -result = _.debounce(function() {}, 150); - -jQuery('#postbox').on('click', _.debounce(function() {}, 300, { - 'leading': true, - 'trailing': false -})); - -source.addEventListener('message', _.debounce(function() {}, 250, { - 'maxWait': 1000 -}), false); - -result = <_.LoDashObjectWrapper>_(function() {}).debounce(150); - -jQuery('#postbox').on('click', <_.LoDashObjectWrapper>_(function() {}).debounce(300, { - 'leading': true, - 'trailing': false -})); - -source.addEventListener('message', <_.LoDashObjectWrapper>_(function() {}).debounce(250, { - 'maxWait': 1000 -}), false); - -var returnedDebounce = _.throttle(function (a) { return a * 5; }, 5); -returnedThrottled(4); - -result = _.defer(function() { console.log('deferred'); }); -result = <_.LoDashWrapper>_(function() { console.log('deferred'); }).defer(); - -var log = _.bind(console.log, console); -result = _.delay(log, 1000, 'logged later'); -result = <_.LoDashWrapper>_(log).delay(1000, 'logged later'); - -var fibonacci = _.memoize(function(n) { - return n < 2 ? n : fibonacci(n - 1) + fibonacci(n - 2); -}); - -var data = { - 'moe': { 'name': 'moe', 'age': 40 }, - 'curly': { 'name': 'curly', 'age': 60 } -}; - -var stooge = _.memoize(function(name: string) { return data[name]; }, _.identity); -stooge('curly'); - -stooge['cache']['curly'].name = 'jerome'; -stooge('curly'); - -var returnedMemoize = _.throttle(function (a) { return a * 5; }, 5); -returnedMemoize(4); - -var initialize = _.once(function(){ }); -initialize(); -initialize();'' -var returnedOnce = _.throttle(function (a) { return a * 5; }, 5); -returnedOnce(4); - -var greetPartial = function(greeting: string, name: string) { return greeting + ' ' + name; }; -var hi = _.partial(greetPartial, 'hi'); -hi('moe'); - -var defaultsDeep = _.partialRight(_.merge, _.defaults); - -var optionsPartialRight = { - 'variable': 'data', - 'imports': { 'jq': $ } -}; - -defaultsDeep(optionsPartialRight, _.templateSettings); - -var throttled = _.throttle(function () { }, 100); -jQuery(window).on('scroll', throttled); - -jQuery('.interactive').on('click', _.throttle(function() { }, 300000, { - 'trailing': false -})); - -var returnedThrottled = _.throttle(function (a) { return a*5; }, 5); -returnedThrottled(4); - -var helloWrap = function(name: string) { return 'hello ' + name; }; -var helloWrap2 = _.wrap(helloWrap, function(func) { - return 'before, ' + func('moe') + ', after'; -}); -helloWrap2(); - -/********** -* Objects * -***********/ -interface NameAge { - name: string; - age: number; -} -result = _.assign({ 'name': 'moe' }, { 'age': 40 }); -result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; -}); - -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).assign({ 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; -}); - -result = _.extend({ 'name': 'moe' }, { 'age': 40 }); -result = _.extend({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; -}); - -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }); -result = <_.LoDashObjectWrapper>_({ 'name': 'moe' }).extend({ 'age': 40 }, function(a, b) { - return typeof a == 'undefined' ? b : a; -}); - -result = _.clone(stoogesAges); -result = _.clone(stoogesAges, true); -result = _.clone(stoogesAges, true, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; -}); - -result = _.cloneDeep(stoogesAges); -result = _.cloneDeep(stoogesAges, function(value) { - return _.isElement(value) ? value.cloneNode(false) : undefined; -}); - -interface Food { - name: string; - type: string; -} -var foodDefaults = { 'name': 'apple' }; -result = _.defaults(foodDefaults, { 'name': 'banana', 'type': 'fruit' }); - result = <_.LoDashObjectWrapper>_(foodDefaults).defaults({ 'name': 'banana', 'type': 'fruit' }); - -result = _.findKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { - return num % 2 == 0; -}); - -result = _.findLastKey({ 'a': 1, 'b': 2, 'c': 3, 'd': 4 }, function(num) { - return num % 2 == 1; -}); - -result = _.forIn(new Dog('Dagny'), function(value, key) { - console.log(key); -}); - -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forIn(function(value, key) { - console.log(key); -}); - -result = _.forInRight(new Dog('Dagny'), function(value, key) { - console.log(key); -}); - -result = <_.LoDashObjectWrapper>_(new Dog('Dagny')).forInRight(function(value, key) { - console.log(key); -}); - -interface ZeroOne { - 0: string; - 1: string; - one: string; -} - -result = _.forOwn({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - console.log(key); -}); - - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwn(function(num, key) { - console.log(key); - }); - -result = _.forOwnRight({ '0': 'zero', '1': 'one', 'length': 2 }, function(num, key) { - console.log(key); -}); - - result = <_.LoDashObjectWrapper>_({ '0': 'zero', '1': 'one', 'length': 2 }).forOwnRight(function(num, key) { - console.log(key); - }); - -result = _.functions(_); -result = _.methods(_); - -result = <_.LoDashArrayWrapper>_(_).functions(); -result = <_.LoDashArrayWrapper>_(_).methods(); - -result = _.has({ 'a': 1, 'b': 2, 'c': 3 }, 'b'); - -interface FirstSecond { - first: string; - second: string; -} -result = _.invert({ 'first': 'moe', 'second': 'larry' }); - -(function(...args: any[]) { return _.isArguments(arguments); })(1, 2, 3); - -(function () { return _.isArray(arguments); })(); -result = _.isArray([1, 2, 3]); - -result = _.isBoolean(null); - -result = _.isDate(new Date()); - -result = _.isElement(document.body); - -result = _.isEmpty([1, 2, 3]); -result = _.isEmpty({}); -result = _.isEmpty(''); - -var moe = { 'name': 'moe', 'age': 40 }; -var copy = { 'name': 'moe', 'age': 40 }; - -result = _.isEqual(moe, copy); - -var words = ['hello', 'goodbye']; -var otherWords = ['hi', 'goodbye']; - -result = _.isEqual(words, otherWords, function(a, b) { - var reGreet = /^(?:hello|hi)$/i, - aGreet = _.isString(a) && reGreet.test(a), - bGreet = _.isString(b) && reGreet.test(b); - - return (aGreet || bGreet) ? (aGreet == bGreet) : undefined; -}); - -result = _.isFinite(-101); -result = _.isFinite('10'); -result = _.isFinite(true); -result = _.isFinite(''); -result = _.isFinite(Infinity); - -result = _.isFunction(_); - -result = _.isNaN(NaN); -result = _.isNaN(new Number(NaN)); -result = _.isNaN(undefined); - -result = _.isNull(null); -result = _.isNull(undefined); - -result = _.isNumber(8.4 * 5); - -result = _.isObject({}); -result = _.isObject([1, 2, 3]); -result = _.isObject(1); - -class Stooge { - constructor( - public name: string, - public age: number - ) {} -} - -result = _.isPlainObject(new Stooge('moe', 40)); -result = _.isPlainObject([1, 2, 3]); -result = _.isPlainObject({ 'name': 'moe', 'age': 40 }); - -result = _.isRegExp(/moe/); - -result = _.isString('moe'); - -result = _.isUndefined(void 0); - -result = _.keys({ 'one': 1, 'two': 2, 'three': 3 }); - -var mergeNames = { - 'stooges': [ - { 'name': 'moe' }, - { 'name': 'larry' } - ] -}; - -var mergeAges = { - 'stooges': [ - { 'age': 40 }, - { 'age': 50 } - ] -}; - -result = _.merge(mergeNames, mergeAges); - -var mergeFood = { - 'fruits': ['apple'], - 'vegetables': ['beet'] -}; - -var mergeOtherFood = { - 'fruits': ['banana'], - 'vegetables': ['carrot'] -}; - -interface FruitVeg { - fruits: string[]; - vegetables: string[] -}; - -result = _.merge(mergeFood, mergeOtherFood, function(a, b) { - return _.isArray(a) ? a.concat(b) : undefined; -}); - -interface HasName { - name: string; -} -result = _.omit({ 'name': 'moe', 'age': 40 }, 'age'); -result = _.omit({ 'name': 'moe', 'age': 40 }, ['age']); -result = _.omit({ 'name': 'moe', 'age': 40 }, function(value) { - return typeof value == 'number'; -}); - -result = _.pairs({ 'moe': 30, 'larry': 40 }); - -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, 'name'); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, ['name']); -result = _.pick({ 'name': 'moe', '_userid': 'moe1' }, function(value, key) { - return key.charAt(0) != '_'; -}); - -result = _.transform([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], function(r, num) { - num *= num; - if (num % 2) { - return r.push(num) < 3; - } -}); -// → [1, 9, 25] - -result = <{a:number;b:number;c:number;}>_.transform({ 'a': 1, 'b': 2, 'c': 3 }, function(r, num, key) { - r[key] = num * 3; -}); - -result = _.values({ 'one': 1, 'two': 2, 'three': 3 }); - -/********** -* Utilities * -***********/ - -result = _.escape('Moe, Larry & Curly'); - -result = <{ name: string }>_.identity({ 'name': 'moe' }); - -_.mixin({ - 'capitalize': function(string) { - return string.charAt(0).toUpperCase() + string.slice(1).toLowerCase(); - } -}); - -var lodash = _.noConflict(); - -result = _.parseInt('08'); - -result = _.random(0, 5); -result = _.random(5); -result = _.random(5, true); -result = _.random(1.2, 5.2); -result = _.random(0, 5, true); - -var object = { - 'cheese': 'crumpets', - 'stuff': function() { - return 'nonsense'; - } -}; - -result = _.result(object, 'cheese'); -result = _.result(object, 'stuff'); - -var tempObject = {}; -result = _.runInContext(tempObject); - -result = <_.TemplateExecutor>_.template('hello <%= name %>'); -result = _.template('<%- value %>', { 'value': '