diff --git a/.gitignore b/.gitignore index 2ea470b9ec..2a52c95e0c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ *.map *.swp .DS_Store +npm-debug.log _Resharper.DefinitelyTyped bin diff --git a/.travis.yml b/.travis.yml index f996631624..48704282ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: node_js node_js: - - "iojs-v2" + - 4 sudo: false diff --git a/adm-zip/adm-zip-tests.ts b/adm-zip/adm-zip-tests.ts index f8583ae617..93f8f2f2d7 100644 --- a/adm-zip/adm-zip-tests.ts +++ b/adm-zip/adm-zip-tests.ts @@ -1,10 +1,9 @@ /// import AdmZip = require("adm-zip"); - // reading archives var zip = new AdmZip("./my_file.zip"); -var zipEntries = zip.getEntries(); // an array of ZipEntry records +var zipEntries: AdmZip.IZipEntry[] = zip.getEntries(); // an array of ZipEntry records zipEntries.forEach(function (zipEntry) { console.log(zipEntry.toString()); // outputs zip entries information @@ -31,3 +30,32 @@ zip.addLocalFile("/home/me/some_picture.png"); var willSendthis = zip.toBuffer(); // or write everything to disk zip.writeZip(/*target file name*/"/home/me/files.zip"); + +function processZipEntry(zipEntry: AdmZip.IZipEntry) { + console.log('comment', zipEntry.comment); +} + +//tests taken from examples at https://github.com/cthackers/adm-zip/wiki/ADM-ZIP +import Zip = require("adm-zip"); +// loads and parses existing zip file local_file.zip +var zip = new Zip("local_file.zip"); +// creates new in memory zip +zip = new Zip(); +// loads and parses existing zip file local_file.zip +zip = new Zip("local_file.zip"); +// get all entries and iterate them +zip.getEntries().forEach((entry) => { + var entryName = entry.entryName; + var decompressedData = zip.readFile(entry); // decompressed buffer of the entry + console.log(zip.readAsText(entry)); // outputs the decompressed content of the entry +}); + +// will extract the file myfile.txt from the archive to /home/user/folder/subfolder/myfile.txt +zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", true, true); + +// will extract the file myfile.txt from the archive to /home/user/myfile.txt +zip.extractEntryTo("folder/subfolder/myfile.txt", "/home/user/", false, true); + +function isAdmZipEntry(obj: any): obj is AdmZip.IZipEntry { + return obj !== null && typeof obj === "object" && typeof obj['entryName'] === 'string'; +} \ No newline at end of file diff --git a/adm-zip/adm-zip.d.ts b/adm-zip/adm-zip.d.ts index 9f2eb7dfdb..208c13b27b 100644 --- a/adm-zip/adm-zip.d.ts +++ b/adm-zip/adm-zip.d.ts @@ -5,8 +5,8 @@ /// -declare module AdmZip { - class ZipFile { +declare module "adm-zip" { + class AdmZip { /** * Create a new, empty archive. */ @@ -28,7 +28,7 @@ declare module AdmZip { * @param entry ZipEntry object * @return Buffer or Null in case of error */ - readFile(entry: IZipEntry): Buffer; + readFile(entry: AdmZip.IZipEntry): Buffer; /** * Asynchronous readFile * @param entry String with the full path of the entry @@ -41,7 +41,7 @@ declare module AdmZip { * @param callback Called with a Buffer or Null in case of error * @return Buffer or Null in case of error */ - readFileAsync(entry: IZipEntry, callback: (data: Buffer, err: string) => any): void; + readFileAsync(entry: AdmZip.IZipEntry, callback: (data: Buffer, err: string) => any): void; /** * Extracts the given entry from the archive and returns the content as * plain text in the given encoding @@ -57,7 +57,7 @@ declare module AdmZip { * @param encoding Optional. If no encoding is specified utf8 is used * @return String */ - readAsText(fileName: IZipEntry, encoding?: string): string; + readAsText(fileName: AdmZip.IZipEntry, encoding?: string): string; /** * Asynchronous readAsText * @param entry String with the full path of the entry @@ -71,7 +71,7 @@ declare module AdmZip { * @param callback Called with the resulting string. * @param encoding Optional. If no encoding is specified utf8 is used */ - readAsTextAsync(fileName: IZipEntry, callback: (data: string) => any, encoding?: string): void; + readAsTextAsync(fileName: AdmZip.IZipEntry, callback: (data: string) => any, encoding?: string): void; /** * Remove the entry from the file or the entry and all its nested directories * and files if the given entry is a directory @@ -83,7 +83,7 @@ declare module AdmZip { * and files if the given entry is a directory * @param entry A ZipEntry object. */ - deleteFile(entry: IZipEntry): void; + deleteFile(entry: AdmZip.IZipEntry): void; /** * Adds a comment to the zip. The zip must be rewritten after * adding the comment. @@ -110,7 +110,7 @@ declare module AdmZip { * @param entry ZipEntry object. * @param comment The comment to add to the entry. */ - addZipEntryComment(entry: IZipEntry, comment: string): void; + addZipEntryComment(entry: AdmZip.IZipEntry, comment: string): void; /** * Returns the comment of the specified entry. * @param entry String with the full path of the entry. @@ -122,7 +122,7 @@ declare module AdmZip { * @param entry ZipEntry object. * @return String The comment of the specified entry. */ - getZipEntryComment(entry: IZipEntry): string; + getZipEntryComment(entry: AdmZip.IZipEntry): string; /** * Updates the content of an existing entry inside the archive. The zip * must be rewritten after updating the content @@ -136,7 +136,7 @@ declare module AdmZip { * @param entry ZipEntry object. * @param content The entry's new contents. */ - updateFile(entry: IZipEntry, content: Buffer): void; + updateFile(entry: AdmZip.IZipEntry, content: Buffer): void; /** * Adds a file from the disk to the archive. * @param localPath Path to a file on disk. @@ -167,14 +167,14 @@ declare module AdmZip { * Returns an array of ZipEntry objects representing the files and folders * inside the archive */ - getEntries(): IZipEntry[]; + getEntries(): AdmZip.IZipEntry[]; /** * Returns a ZipEntry object representing the file or folder specified by * ``name``. * @param name Name of the file or folder to retrieve. * @return ZipEntry The entry corresponding to the name. */ - getEntry(name: string): IZipEntry; + getEntry(name: string): AdmZip.IZipEntry; /** * Extracts the given entry to the given targetPath. * If the entry is a directory inside the archive, the entire directory and @@ -203,7 +203,7 @@ declare module AdmZip { * will be overwriten if this is true. Default is FALSE * @return Boolean */ - extractEntryTo(entryPath: IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean; + extractEntryTo(entryPath: AdmZip.IZipEntry, targetPath: string, maintainEntryPath?: boolean, overwrite?: boolean): boolean; /** * Extracts the entire archive to the given location * @param targetPath Target location @@ -225,76 +225,75 @@ declare module AdmZip { toBuffer(): Buffer; } - /** - * The ZipEntry is more than a structure representing the entry inside the - * zip file. Beside the normal attributes and headers a entry can have, the - * class contains a reference to the part of the file where the compressed - * data resides and decompresses it when requested. It also compresses the - * data and creates the headers required to write in the zip file. - */ - interface IZipEntry { + module AdmZip { /** - * Represents the full name and path of the file + * The ZipEntry is more than a structure representing the entry inside the + * zip file. Beside the normal attributes and headers a entry can have, the + * class contains a reference to the part of the file where the compressed + * data resides and decompresses it when requested. It also compresses the + * data and creates the headers required to write in the zip file. */ - entryName: string; - rawEntryName: Buffer; - /** - * Extra data associated with this entry. - */ - extra: Buffer; - /** - * Entry comment. - */ - comment: string; - name: string; - /** - * Read-Only property that indicates the type of the entry. - */ - isDirectory: boolean; - /** - * Get the header associated with this ZipEntry. - */ - header: Buffer; - /** - * Retrieve the compressed data for this entry. Note that this may trigger - * compression if any properties were modified. - */ - getCompressedData(): Buffer; - /** - * Asynchronously retrieve the compressed data for this entry. Note that - * this may trigger compression if any properties were modified. - */ - getCompressedDataAsync(callback: (data: Buffer) => void): void; - /** - * Set the (uncompressed) data to be associated with this entry. - */ - setData(value: string): void; - /** - * Set the (uncompressed) data to be associated with this entry. - */ - setData(value: Buffer): void; - /** - * Get the decompressed data associated with this entry. - */ - getData(): Buffer; - /** - * Asynchronously get the decompressed data associated with this entry. - */ - getDataAsync(callback: (data: Buffer) => void): void; - /** - * Returns the CEN Entry Header to be written to the output zip file, plus - * the extra data and the entry comment. - */ - packHeader(): Buffer; - /** - * Returns a nicely formatted string with the most important properties of - * the ZipEntry. - */ - toString(): string; + interface IZipEntry { + /** + * Represents the full name and path of the file + */ + entryName: string; + rawEntryName: Buffer; + /** + * Extra data associated with this entry. + */ + extra: Buffer; + /** + * Entry comment. + */ + comment: string; + name: string; + /** + * Read-Only property that indicates the type of the entry. + */ + isDirectory: boolean; + /** + * Get the header associated with this ZipEntry. + */ + header: Buffer; + /** + * Retrieve the compressed data for this entry. Note that this may trigger + * compression if any properties were modified. + */ + getCompressedData(): Buffer; + /** + * Asynchronously retrieve the compressed data for this entry. Note that + * this may trigger compression if any properties were modified. + */ + getCompressedDataAsync(callback: (data: Buffer) => void): void; + /** + * Set the (uncompressed) data to be associated with this entry. + */ + setData(value: string): void; + /** + * Set the (uncompressed) data to be associated with this entry. + */ + setData(value: Buffer): void; + /** + * Get the decompressed data associated with this entry. + */ + getData(): Buffer; + /** + * Asynchronously get the decompressed data associated with this entry. + */ + getDataAsync(callback: (data: Buffer) => void): void; + /** + * Returns the CEN Entry Header to be written to the output zip file, plus + * the extra data and the entry comment. + */ + packHeader(): Buffer; + /** + * Returns a nicely formatted string with the most important properties of + * the ZipEntry. + */ + toString(): string; + } } -} -declare module "adm-zip" { - import zipFile = AdmZip.ZipFile; - export = zipFile; + export = AdmZip; } diff --git a/angular-jwt/angular-jwt.d.ts b/angular-jwt/angular-jwt.d.ts index 55bb3e4f6a..620fcc8e4c 100644 --- a/angular-jwt/angular-jwt.d.ts +++ b/angular-jwt/angular-jwt.d.ts @@ -25,6 +25,6 @@ declare module angular.jwt { } interface IJwtInterceptor { - tokenGetter(): string; + tokenGetter(...params : any[]): string; } } diff --git a/angular-material/angular-material-tests.ts b/angular-material/angular-material-tests.ts index a9cd52437a..3c70dd27e8 100644 --- a/angular-material/angular-material-tests.ts +++ b/angular-material/angular-material-tests.ts @@ -96,5 +96,5 @@ myApp.controller('SidenavController', ($scope: ng.IScope, $mdSidenav: ng.materia }); myApp.controller('ToastController', ($scope: ng.IScope, $mdToast: ng.material.IToastService) => { - $scope['openToast'] = () => $mdToast.show($mdToast.simple().content('Hello!')); -}); \ No newline at end of file + $scope['openToast'] = () => $mdToast.show($mdToast.simple().textContent('Hello!')); +}); diff --git a/angular-material/angular-material.d.ts b/angular-material/angular-material.d.ts index 54ef2507b3..43e0b9f53b 100644 --- a/angular-material/angular-material.d.ts +++ b/angular-material/angular-material.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Angular Material 0.10.1-rc1+ (angular.material module) +// Type definitions for Angular Material 1.0.0-rc5+ (angular.material module) // Project: https://github.com/angular/material // Definitions by: Matt Traynham // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -116,7 +116,7 @@ declare module angular.material { } interface IToastPreset { - content(content: string): T; + textContent(content: string): T; action(action: string): T; highlightAction(highlightAction: boolean): T; capsule(capsule: boolean): T; diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts index 048b9cd4a1..a489141d54 100644 --- a/angularjs/angular.d.ts +++ b/angularjs/angular.d.ts @@ -165,6 +165,12 @@ declare module angular { dot: number; codeName: string; }; + + /** + * If window.name contains prefix NG_DEFER_BOOTSTRAP! when angular.bootstrap is called, the bootstrap process will be paused until angular.resumeBootstrap() is called. + * @param extraModules An optional array of modules that should be added to the original list of modules that the app was about to be bootstrapped with. + */ + resumeBootstrap?(extraModules?: string[]): ng.auto.IInjectorService; } /////////////////////////////////////////////////////////////////////////// diff --git a/browserify/browserify-tests.ts b/browserify/browserify-tests.ts index 5249015661..b4096a7f98 100644 --- a/browserify/browserify-tests.ts +++ b/browserify/browserify-tests.ts @@ -2,11 +2,51 @@ import browserify = require("browserify"); import fs = require("fs"); +import stream = require('stream'); -var b: BrowserifyObject = browserify(); +var bNoArg = browserify(); + +var b = browserify({ + baseDir: 'somewhere' +}); b.add('./browser/main.js'); -b.transform('deamdify'); -b.bundle().pipe(fs.createWriteStream('bundle.js')); +b.transform('deamdify') + .transform(function (file) { + return new stream.Transform(); + }).plugin((b, opts) => { return opts.l; }, {l: 3}) + .require('foo', { expose: 'bar' }) + .exclude('baz') + .ignore('bat') + .reset({ basedir: 'elsewhere' }); -var customBrowsify: Browserify = require("browserify"); +b.on('file', (file) => { + file += ""; +}); + +b.external(bNoArg); + +var b2 = new browserify(['/some/File', {file: '/some/file' }, fs.createReadStream('/somewhere')], { builtins: ['buffer']}) + .reset({ + builtins: { + 'buffer': './customBuffer' + } + }); + +var customBrowsify = require("browserify"); customBrowsify({entries: []}); + +var b = browserify('./browser/main.js', { + noParse: ['jquery'], + debug: true, + foo: 'bar' +}); +b.add('./browser/other.js'); +b.transform(function(file: string): NodeJS.ReadWriteStream { + return new stream.PassThrough(); +}); + +var record_pipeline = b.pipeline.get('record'); + +b.bundle().pipe(process.stdout); + + diff --git a/browserify/browserify.d.ts b/browserify/browserify.d.ts index c301df51eb..1ce6b653d3 100644 --- a/browserify/browserify.d.ts +++ b/browserify/browserify.d.ts @@ -1,41 +1,182 @@ -// Type definitions for Browserify +// Type definitions for Browserify v12.0.1 // Project: http://browserify.org/ -// Definitions by: Andrew Gaspar +// Definitions by: Andrew Gaspar , John Vilk // Definitions: https://github.com/borisyankov/DefinitelyTyped /// -interface BrowserifyObject extends NodeJS.EventEmitter { - add(file:string, opts?:any): BrowserifyObject; - require(file:string, opts?:{ - expose: string; - }): BrowserifyObject; - bundle(opts?:{ - insertGlobals?: boolean; - detectGlobals?: boolean; - debug?: boolean; - standalone?: string; - insertGlobalVars?: any; - }, cb?:(err:any, src:any) => void): NodeJS.ReadableStream; +declare module Browserify { + /** + * Options pertaining to an individual file. + */ + interface FileOptions { + // If true, this is considered an entry point to your app. + entry?: boolean; + // Expose this file under a custom dependency name. + // require('./vendor/angular/angular.js', {expose: 'angular'}) enables require('angular') + expose?: string; + // Basedir to use to resolve this file's path. + basedir?: string; + // The name/path to the file. + file?: string; + // Forward file to external() to be externalized. + external?: boolean; + // Disable transforms on file if set to false. + transform?: boolean; + // The ID to use for require() statements. + id?: string; + } - external(file:string, opts?:any): BrowserifyObject; - ignore(file:string, opts?:any): BrowserifyObject; - transform(tr:string, opts?:any): BrowserifyObject; - transform(tr:Function, opts?:any): BrowserifyObject; - plugin(plugin:string, opts?:any): BrowserifyObject; - plugin(plugin:Function, opts?:any): BrowserifyObject; -} -interface Browserify { - (): BrowserifyObject; - (files:string[]): BrowserifyObject; - (opts:{ - entries?: string[]; + // Browserify accepts a filename, an input stream for file inputs, or a FileOptions configuration + // for each file in a bundle. + type InputFile = string | NodeJS.ReadableStream | FileOptions; + + /** + * Options pertaining to a Browserify instance. + */ + interface Options { + // Custom properties can be defined on Options. + // These options are forwarded along to module-deps and browser-pack directly. + [propName: string]: any; + // String, file object, or array of those types (they may be mixed) specifying entry file(s). + entries?: InputFile | InputFile[]; + // an array which will skip all require() and global parsing for each file in the array. + // Use this for giant libs like jquery or threejs that don't have any requires or node-style globals but take forever to parse. noParse?: string[]; - }): BrowserifyObject; + // an array of optional extra extensions for the module lookup machinery to use when the extension has not been specified. + // By default Browserify considers only .js and .json files in such cases. + extensions?: string[]; + // the directory that Browserify starts bundling from for filenames that start with .. + basedir?: string; + // an array of directories that Browserify searches when looking for modules which are not referenced using relative path. + // Can be absolute or relative to basedir. Equivalent of setting NODE_PATH environmental variable when calling Browserify command. + paths?: string[]; + // sets the algorithm used to parse out the common paths. Use false to turn this off, otherwise it uses the commondir module. + commondir?: boolean; + // disables converting module ids into numerical indexes. This is useful for preserving the original paths that a bundle was generated with. + fullPaths?: boolean; + // sets the list of built-ins to use, which by default is set in lib/builtins.js in this distribution. + builtins?: string[] | {[builtinName: string]: string} | boolean; + // set if external modules should be bundled. Defaults to true. + bundleExternal?: boolean; + // When true, always insert process, global, __filename, and __dirname without analyzing the AST for faster builds but larger output bundles. Default false. + insertGlobals?: boolean; + // When true, scan all files for process, global, __filename, and __dirname, defining as necessary. + // With this option npm modules are more likely to work but bundling takes longer. Default true. + detectGlobals?: boolean; + // When true, add a source map inline to the end of the bundle. This makes debugging easier because you can see all the original files if you are in a modern enough browser. + debug?: boolean; + // When a non-empty string, a standalone module is created with that name and a umd wrapper. + // You can use namespaces in the standalone global export using a . in the string name as a separator, for example 'A.B.C'. + // The global export will be sanitized and camel cased. + standalone?: string; + // will be passed to insert-module-globals as the opts.vars parameter. + insertGlobalVars?: {[globalName: string]: (file: string, basedir: string) => any}; + // defaults to 'require' in expose mode but you can use another name. + externalRequireName?: string; + } + + interface BrowserifyConstructor { + (files: InputFile[], opts?: Options): BrowserifyObject; + (file: InputFile, opts?: Options): BrowserifyObject; + (opts: Options): BrowserifyObject; + (): BrowserifyObject + new(files: InputFile[], opts?: Options): BrowserifyObject; + new(file: InputFile, opts?: Options): BrowserifyObject; + new(opts: Options): BrowserifyObject; + new(): BrowserifyObject + } + + interface BrowserifyObject extends NodeJS.EventEmitter { + /** + * Add an entry file from file that will be executed when the bundle loads. + * If file is an array, each item in file will be added as an entry file. + */ + add(file: InputFile[], opts?: FileOptions): BrowserifyObject; + add(file: InputFile, opts?: FileOptions): BrowserifyObject; + /** + * Make file available from outside the bundle with require(file). + * The file param is anything that can be resolved by require.resolve(). + * file can also be a stream, but you should also use opts.basedir so that relative requires will be resolvable. + * If file is an array, each item in file will be required. In file array form, you can use a string or object for each item. Object items should have a file property and the rest of the parameters will be used for the opts. + * Use the expose property of opts to specify a custom dependency name. require('./vendor/angular/angular.js', {expose: 'angular'}) enables require('angular') + */ + require(file: InputFile, opts?: FileOptions): BrowserifyObject; + /** + * Bundle the files and their dependencies into a single javascript file. + * Return a readable stream with the javascript file contents or optionally specify a cb(err, buf) to get the buffered results. + */ + bundle(cb?: (err: any, src: Buffer) => any): NodeJS.ReadableStream; + /** + * Prevent file from being loaded into the current bundle, instead referencing from another bundle. + * If file is an array, each item in file will be externalized. + * If file is another bundle, that bundle's contents will be read and excluded from the current bundle as the bundle in file gets bundled. + */ + external(file: string[], opts?: { basedir?: string }): BrowserifyObject; + external(file: string, opts?: { basedir?: string }): BrowserifyObject; + external(file: BrowserifyObject): BrowserifyObject; + /** + * Prevent the module name or file at file from showing up in the output bundle. + * Instead you will get a file with module.exports = {}. + */ + ignore(file: string, opts?: { basedir?: string }): BrowserifyObject; + /** + * Prevent the module name or file at file from showing up in the output bundle. + * If your code tries to require() that file it will throw unless you've provided another mechanism for loading it. + */ + exclude(file: string, opts?: { basedir?: string }): BrowserifyObject; + /** + * Transform source code before parsing it for require() calls with the transform function or module name tr. + * If tr is a function, it will be called with tr(file) and it should return a through-stream that takes the raw file contents and produces the transformed source. + * If tr is a string, it should be a module name or file path of a transform module + */ + transform(tr: string, opts?: T): BrowserifyObject; + transform(tr: (file: string, opts: T) => NodeJS.ReadWriteStream, opts?: T): BrowserifyObject; + /** + * Register a plugin with opts. Plugins can be a string module name or a function the same as transforms. + * plugin(b, opts) is called with the Browserify instance b. + */ + plugin(plugin: string, opts?: T): BrowserifyObject; + plugin(plugin: (b: BrowserifyObject, opts: T) => any, opts?: T): BrowserifyObject; + /** + * Reset the pipeline back to a normal state. This function is called automatically when bundle() is called multiple times. + * This function triggers a 'reset' event. + */ + reset(opts?: Options): void; + + /** + * When a file is resolved for the bundle, the bundle emits a 'file' event with the full file path, the id string passed to require(), and the parent object used by browser-resolve. + * You could use the file event to implement a file watcher to regenerate bundles when files change. + */ + on(event: 'file', listener: (file: string, id: string, parent: any) => any): BrowserifyObject; + /** + * When a package.json file is read, this event fires with the contents. + * The package directory is available at pkg.__dirname. + */ + on(event: 'package', listener: (pkg: any) => any): BrowserifyObject; + /** + * When .bundle() is called, this event fires with the bundle output stream. + */ + on(event: 'bundle', listener: (bundle: NodeJS.ReadableStream) => any): BrowserifyObject; + /** + * When the .reset() method is called or implicitly called by another call to .bundle(), this event fires. + */ + on(event: 'reset', listener: () => any): BrowserifyObject; + /** + * When a transform is applied to a file, the 'transform' event fires on the bundle stream with the transform stream tr and the file that the transform is being applied to. + */ + on(event: 'transform', listener: (tr: NodeJS.ReadWriteStream, file: string) => any): BrowserifyObject; + on(event: string, listener: Function): BrowserifyObject; + + /** + * Set to any until substack/labeled-stream-splicer is defined + */ + pipeline: any; + } } declare module "browserify" { - var browserify: Browserify; + var browserify: Browserify.BrowserifyConstructor; export = browserify; } diff --git a/buffer-compare/buffer-compare-tests.ts b/buffer-compare/buffer-compare-tests.ts new file mode 100644 index 0000000000..88e6dddb94 --- /dev/null +++ b/buffer-compare/buffer-compare-tests.ts @@ -0,0 +1,27 @@ +/// +/// + +import compare = require('buffer-compare'); + +let result: number; + +result = compare(new Buffer(''), new Buffer('')); +result = compare([], []); +result = compare('', ''); +result = compare(new Buffer(''), []); +result = compare([], ''); +result = compare('', new Buffer('')); + +result = compare(new Buffer(''), new Buffer('')); +result = compare([], []); +result = compare('', ''); +result = compare(new Buffer(''), []); +result = compare([], ''); +result = compare('', new Buffer('')); + +result = compare(new Buffer(''), new Buffer('')); +result = compare([], []); +result = compare('', ''); +result = compare(new Buffer(''), []); +result = compare([], ''); +result = compare('', new Buffer('')); diff --git a/buffer-compare/buffer-compare.d.ts b/buffer-compare/buffer-compare.d.ts new file mode 100644 index 0000000000..58e4004dcb --- /dev/null +++ b/buffer-compare/buffer-compare.d.ts @@ -0,0 +1,17 @@ +// Type definitions for buffer-compare +// Project: https://github.com/soldair/node-buffer-compare +// Definitions by: Ilya Mochalov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "buffer-compare" { + interface List { + [index: number]: any; + length: number + } + + function compare(cmp: List, to: List): number; + function compare(cmp: T, to: T): number; + function compare(cmp: C, to: T): number; + + export = compare; +} diff --git a/bytebuffer/bytebuffer-tests.ts b/bytebuffer/bytebuffer-tests.ts new file mode 100644 index 0000000000..34db7368d5 --- /dev/null +++ b/bytebuffer/bytebuffer-tests.ts @@ -0,0 +1,8 @@ +/// + +import ByteBuffer = require("bytebuffer"); + +var bb = new ByteBuffer() + .writeIString("Hello world!") + .flip(); +console.log(bb.readIString()+" from bytebuffer.js"); \ No newline at end of file diff --git a/bytebuffer/bytebuffer.d.ts b/bytebuffer/bytebuffer.d.ts new file mode 100644 index 0000000000..8f1a800eae --- /dev/null +++ b/bytebuffer/bytebuffer.d.ts @@ -0,0 +1,615 @@ +// Type definitions for bytebuffer.js 5.0.0 +// Project: https://github.com/dcodeIO/bytebuffer.js +// Definitions by: Denis Cappellin +// Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions by: SINTEF-9012 + +/// + +declare class ByteBuffer +{ + /** + * Constructs a new ByteBuffer. + */ + constructor( capacity?: number, littleEndian?: boolean, noAssert?: boolean ); + + /** + * Big endian constant that can be used instead of its boolean value. Evaluates to false. + */ + static BIG_ENDIAN: boolean; + + /** + * Default initial capacity of 16. + */ + static DEFAULT_CAPACITY: number; + + /** + * Default no assertions flag of false. + */ + static DEFAULT_NOASSERT: boolean; + + /** + * Little endian constant that can be used instead of its boolean value. Evaluates to true. + */ + static LITTLE_ENDIAN: boolean; + + /** + * Maximum number of bytes required to store a 32bit base 128 variable-length integer. + */ + static MAX_VARINT32_BYTES: number; + + /** + * Maximum number of bytes required to store a 64bit base 128 variable-length integer. + */ + static MAX_VARINT64_BYTES: number; + + /** + * Metrics representing number of bytes.Evaluates to 2. + */ + static METRICS_BYTES: number; + + /** + * Metrics representing number of UTF8 characters.Evaluates to 1. + */ + static METRICS_CHARS: number; + + /** + * ByteBuffer version. + */ + static VERSION: string; + + /** + * Backing buffer. + */ + buffer: ArrayBuffer; + + /** + * Absolute limit of the contained data. Set to the backing buffer's capacity upon allocation. + */ + limit: number; + + /** + * Whether to use little endian byte order, defaults to false for big endian. + */ + littleEndian: boolean; + + /** + * Marked offset. + */ + markedOffset: number; + + /** + * Whether to skip assertions of offsets and values, defaults to false. + */ + noAssert: boolean; + + /** + * Absolute read/write offset. + */ + offset: number; + + /** + * Data view to manipulate the backing buffer. Becomes null if the backing buffer has a capacity of 0. + */ + view: DataView; + + /** + * Allocates a new ByteBuffer backed by a buffer of the specified capacity. + */ + static allocate( capacity?: number, littleEndian?: number, noAssert?: boolean ): ByteBuffer; + + /** + * Decodes a base64 encoded string to binary like window.atob does. + */ + static atob( b64: string ): string; + + /** + * Encodes a binary string to base64 like window.btoa does. + */ + static btoa( str: string ): string; + + /** + * Calculates the number of UTF8 bytes of a string. + */ + static calculateUTF8Byte( str: string ): number; + + /** + * Calculates the number of UTF8 characters of a string.JavaScript itself uses UTF- 16, so that a string's length property does not reflect its actual UTF8 size if it contains code points larger than 0xFFFF. + */ + static calculateUTF8Char( str: string ): number; + + /** + * Calculates the actual number of bytes required to store a 32bit base 128 variable-length integer. + */ + static calculateVariant32( value: number ): number; + + /** + * Calculates the actual number of bytes required to store a 64bit base 128 variable-length integer. + */ + static calculateVariant64( value: number | Long ): number; + + /** + * Concatenates multiple ByteBuffers into one. + */ + static concat( buffers: Array, encoding?: string | boolean, litteEndian?: boolean, noAssert?: boolean ): ByteBuffer; + + /** + * Decodes a base64 encoded string to a ByteBuffer. + */ + static fromBase64( str: string, littleEndian?: boolean, noAssert?: boolean ): ByteBuffer; + + /** + * Decodes a binary encoded string, that is using only characters 0x00-0xFF as bytes, to a ByteBuffer. + */ + static fromBinary( str: string, littleEndian?: boolean, noAssert?: boolean ): ByteBuffer; + + /** + * Decodes a hex encoded string with marked offsets to a ByteBuffer. + */ + static fromDebug( str: string, littleEndian?: boolean, noAssert?: boolean ): ByteBuffer; + + /** + * Decodes a hex encoded string to a ByteBuffer. + */ + static fromHex( str: string, littleEndian?: boolean, noAssert?: boolean ): ByteBuffer; + + /** + * Decodes an UTF8 encoded string to a ByteBuffer. + */ + static fromUTF8( str: string, littleEndian?: boolean, noAssert?: boolean ): ByteBuffer; + + /** + * Gets the backing buffer type. + */ + static isByteBuffer( bb: any ): boolean; + + /** + * Wraps a buffer or a string. Sets the allocated ByteBuffer's ByteBuffer#offset to 0 and its ByteBuffer#limit to the length of the wrapped data. + * @param buffer Anything that can be wrapped + * @param encoding String encoding if buffer is a string ("base64", "hex", "binary", defaults to "utf8") + * @param littleEndian Whether to use little or big endian byte order. Defaults to ByteBuffer.DEFAULT_ENDIAN. + * @param noAssert Whether to skip assertions of offsets and values. Defaults to ByteBuffer.DEFAULT_NOASSERT. + */ + static wrap( buffer: ByteBuffer | ArrayBuffer | Uint8Array | string, enc?: string | boolean, littleEndian?: boolean, noAssert?: boolean ): ByteBuffer; + + /** + * Decodes a zigzag encoded signed 32bit integer. + */ + static zigZagDecode32( n: number ): number; + + /** + * Decodes a zigzag encoded signed 64bit integer. + */ + static zigZagDecode64( n: number | Long ): Long; + + /** + * Zigzag encodes a signed 32bit integer so that it can be effectively used with varint encoding. + */ + static zigZagEncode32( n: number ): number; + + /** + * Zigzag encodes a signed 64bit integer so that it can be effectively used with varint encoding. + */ + static zigZagEncode64( n: number | Long ): Long; + + /** + * Switches (to) big endian byte order. + */ + BE( bigEndian?: boolean ): ByteBuffer; + + /** + * Switches (to) little endian byte order. + */ + LE( bigEndian?: boolean ): ByteBuffer; + + /** + * Appends some data to this ByteBuffer. This will overwrite any contents behind the specified offset up to the appended data's length. + */ + append( source: ByteBuffer | ArrayBuffer | Uint8Array | string, encoding?: string | number, offset?: number ): ByteBuffer; + + /** + * Appends this ByteBuffer's contents to another ByteBuffer. This will overwrite any contents behind the specified offset up to the length of this ByteBuffer's data. + */ + appendTo( target: ByteBuffer, offset?: number ): ByteBuffer; + + /** + * Enables or disables assertions of argument types and offsets. Assertions are enabled by default but you can opt to disable them if your code already makes sure that everything is valid. + */ + assert( assert: boolean ): ByteBuffer; + + /** + * Gets the capacity of this ByteBuffer's backing buffer. + */ + capacity(): number; + + /** + * Clears this ByteBuffer's offsets by setting ByteBuffer#offset to 0 and + * ByteBuffer#limit to the backing buffer's capacity. Discards ByteBuffer#markedOffset. + */ + clear(): ByteBuffer; + + /** + * Creates a cloned instance of this ByteBuffer, preset with this ByteBuffer's values for ByteBuffer#offset, ByteBuffer#markedOffset and ByteBuffer#limit. + */ + clone( copy?: boolean ): ByteBuffer; + + /** + * Compacts this ByteBuffer to be backed by a ByteBuffer#buffer of its contents' length. Contents are the bytes between ByteBuffer#offset and ByteBuffer#limit. Will set offset = 0 and limit = capacity and adapt ByteBuffer#markedOffset to the same relative position if set. + */ + compact( begin?: number, end?: number ): ByteBuffer; + + /** + * Creates a copy of this ByteBuffer's contents. Contents are the bytes between ByteBuffer#offset and ByteBuffer#limit. + */ + copy( begin?: number, end?: number ): ByteBuffer; + + /** + * Copies this ByteBuffer's contents to another ByteBuffer. Contents are the bytes between ByteBuffer#offset and ByteBuffer#limit. + */ + copyTo( target: ByteBuffer, targetOffset?: number, sourceOffset?: number, sourceLimit?: number ): ByteBuffer; + + /** + * Makes sure that this ByteBuffer is backed by a ByteBuffer#buffer of at least the specified capacity. If the current capacity is exceeded, it will be doubled. If double the current capacity is less than the required capacity, the required capacity will be used instead. + */ + ensureCapacity( capacity: number ): ByteBuffer; + + /** + * Overwrites this ByteBuffer's contents with the specified value. Contents are the bytes between ByteBuffer#offset and ByteBuffer#limit. + */ + fill( value: number | string, begin?: number, end?: number ): ByteBuffer; + + /** + * Makes this ByteBuffer ready for a new sequence of write or relative read operations. Sets limit = offset and offset = 0. Make sure always to flip a ByteBuffer when all relative read or write operations are complete. + */ + flip(): ByteBuffer; + + /** + * Marks an offset on this ByteBuffer to be used later. + */ + mark( offset?: number ): ByteBuffer; + + /** + * Sets the byte order. + */ + order( littleEndian: boolean ): ByteBuffer; + + /** + * Prepends some data to this ByteBuffer. This will overwrite any contents before the specified offset up to the prepended data's length. If there is not enough space available before the specified offset, the backing buffer will be resized and its contents moved accordingly. + */ + prepend( source: ByteBuffer | string | ArrayBuffer, encoding?: string | number, offset?: number ): ByteBuffer; + + /** + * Prepends this ByteBuffer to another ByteBuffer. This will overwrite any contents before the specified offset up to the prepended data's length. If there is not enough space available before the specified offset, the backing buffer will be resized and its contents moved accordingly. + */ + prependTo( target: ByteBuffer, offset?: number ): ByteBuffer; + + /** + * Prints debug information about this ByteBuffer's contents. + */ + printDebug( out?: ( text: string ) => void ): void; + + /** + * Reads an 8bit signed integer. This is an alias of ByteBuffer#readInt8. + */ + readByte( offset?: number ): number; + + /** + * Reads a NULL-terminated UTF8 encoded string. For this to work the string read must not contain any NULL characters itself. + */ + readCString( offset?: number ): string; + + /** + * Reads a 64bit float. This is an alias of ByteBuffer#readFloat64. + */ + readDouble( offset?: number ): number; + + /** + * Reads a 32bit float. This is an alias of ByteBuffer#readFloat32. + */ + readFloat( offset?: number ): number; + + /** + * Reads a 32bit float. + */ + readFloat32( offset?: number ): number; + + /** + * Reads a 64bit float. + */ + readFloat64( offset?: number ): number; + + /** + * Reads a length as uint32 prefixed UTF8 encoded string. + */ + readIString( offset?: number ): string; + + /** + * Reads a 32bit signed integer.This is an alias of ByteBuffer#readInt32. + */ + readInt( offset?: number ): number; + + /** + * Reads a 16bit signed integer. + */ + readInt16( offset?: number ): number; + + /** + * Reads a 32bit signed integer. + */ + readInt32( offset?: number ): number; + + /** + * Reads a 64bit signed integer. + */ + readInt64( offset?: number ): Long; + + /** + * Reads an 8bit signed integer. + */ + readInt8( offset?: number ): number; + + /** + * Reads a 64bit signed integer. This is an alias of ByteBuffer#readInt64. + */ + readLong( offset?: number ): Long; + + /** + * Reads a 16bit signed integer. This is an alias of ByteBuffer#readInt16. + */ + readShort( offset?: number ): number; + + /** + * Reads an UTF8 encoded string. This is an alias of ByteBuffer#readUTF8String. + */ + readString( length: number, metrics?: number, offset?: number ): string; + + /** + * Reads an UTF8 encoded string. + */ + readUTF8String( chars: number, offset?: number ): string; + + /** + * Reads a 16bit unsigned integer. + */ + readUint16( offset?: number ): number; + + /** + * Reads a 32bit unsigned integer. + */ + readUint32( offset?: number ): number; + + /** + * Reads a 64bit unsigned integer. + */ + readUint64( offset?: number ): Long; + /** + * Reads an 8bit unsigned integer. + */ + readUint8( offset?: number ): number; + + /** + * Reads a length as varint32 prefixed UTF8 encoded string. + */ + readVString( offset?: number ): string; + + /** + * Reads a 32bit base 128 variable-length integer. + */ + readVarint32( offset?: number ): number; + + /** + * Reads a zig-zag encoded 32bit base 128 variable-length integer. + */ + readVarint32ZiZag( offset?: number ): number; + + /** + * Reads a 64bit base 128 variable-length integer. Requires Long.js. + */ + readVarint64( offset?: number ): Long; + + /** + * Reads a zig-zag encoded 64bit base 128 variable-length integer. Requires Long.js. + */ + readVarint64ZigZag( offset?: number ): Long; + + /** + * Gets the number of remaining readable bytes. Contents are the bytes between ByteBuffer#offset and ByteBuffer#limit, so this returns limit - offset. + */ + remaining(): number; + + /** + * Resets this ByteBuffer's ByteBuffer#offset. If an offset has been marked through ByteBuffer#mark before, offset will be set to ByteBuffer#markedOffset, which will then be discarded. If no offset has been marked, sets offset = 0. + */ + reset(): ByteBuffer; + + /** + * Resizes this ByteBuffer to be backed by a buffer of at least the given capacity. Will do nothing if already that large or larger. + */ + resize( capacity: number ): ByteBuffer; + + /** + * Reverses this ByteBuffer's contents + */ + reverse( begin?: number, end?: number ): ByteBuffer; + + /** + * Skips the next length bytes. This will just advance + */ + skip( length: number ): ByteBuffer; + + /** + * Slices this ByteBuffer by creating a cloned instance with offset = begin and limit = end. + */ + slice( begin?: number, end?: number ): ByteBuffer; + + /** + * Returns a raw buffer compacted to contain this ByteBuffer's contents. Contents are the bytes between ByteBuffer#offset and ByteBuffer#limit. Will transparently ByteBuffer#flip this ByteBuffer if offset > limit but the actual offsets remain untouched. This is an alias of ByteBuffer#toBuffer. + */ + toArrayBuffer( forceCopy?: boolean ): ArrayBuffer; + + /** + * Encodes this ByteBuffer's contents to a base64 encoded string. + */ + toBase64( begin?: number, end?: number ): string; + + /** + * Encodes this ByteBuffer to a binary encoded string, that is using only characters 0x00-0xFF as bytes. + */ + toBinary( begin?: number, end?: number ): string; + + /** + * Returns a copy of the backing buffer that contains this ByteBuffer's contents. Contents are the bytes between ByteBuffer#offset and ByteBuffer#limit. Will transparently ByteBuffer#flip this ByteBuffer if offset > limit but the actual offsets remain untouched. + */ + toBuffer( forceCopy?: boolean ): ArrayBuffer; + + /** + *Encodes this ByteBuffer to a hex encoded string with marked offsets. Offset symbols are: + * < : offset, + * ' : markedOffset, + * > : limit, + * | : offset and limit, + * [ : offset and markedOffset, + * ] : markedOffset and limit, + * ! : offset, markedOffset and limit + */ + toDebug( columns?: boolean ): string | Array + + /** + * Encodes this ByteBuffer's contents to a hex encoded string. + */ + toHex( begin?: number, end?: number ): string; + + /** + * Converts the ByteBuffer's contents to a string. + */ + toString( encoding?: string ): string; + + /** + * Encodes this ByteBuffer's contents between ByteBuffer#offset and ByteBuffer#limit to an UTF8 encoded string. + */ + toUTF8(): string; + + /** + * Writes an 8bit signed integer. This is an alias of ByteBuffer#writeInt8. + */ + writeByte( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a NULL-terminated UTF8 encoded string. For this to work the specified string must not contain any NULL characters itself. + */ + writeCString( str: string, offset?: number ): ByteBuffer; + + /** + * Writes a 64bit float. This is an alias of ByteBuffer#writeFloat64. + */ + writeDouble( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 32bit float. This is an alias of ByteBuffer#writeFloat32. + */ + writeFloat( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 32bit float. + */ + writeFloat32( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 64bit float. + */ + writeFloat64( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a length as uint32 prefixed UTF8 encoded string. + */ + writeIString( str: string, offset?: number ): ByteBuffer; + + /** + * Writes a 32bit signed integer. This is an alias of ByteBuffer#writeInt32. + */ + writeInt( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 16bit signed integer. + */ + writeInt16( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 32bit signed integer. + */ + writeInt32( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 64bit signed integer. + */ + writeInt64( value: number | Long, offset?: number ): ByteBuffer; + + /** + * Writes an 8bit signed integer. + */ + writeInt8( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 16bit signed integer. This is an alias of ByteBuffer#writeInt16. + */ + writeShort( value: number, offset?: number ): ByteBuffer; + + /** + * Writes an UTF8 encoded string.This is an alias of ByteBuffer#writeUTF8String. + */ + WriteString( str: string, offset?: number ): ByteBuffer | number; + + /** + * Writes an UTF8 encoded string. + */ + writeUTF8String( str: string, offset?: number ): ByteBuffer | number; + + /** + * Writes a 16bit unsigned integer. + */ + writeUint16( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 32bit unsigned integer. + */ + writeUint32( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a 64bit unsigned integer. + */ + writeUint64( value: number | Long, offset?: number ): ByteBuffer; + + /** + * Writes an 8bit unsigned integer. + */ + writeUint8( value: number, offset?: number ): ByteBuffer; + + /** + * Writes a length as varint32 prefixed UTF8 encoded string. + */ + writeVString( str: string, offset?: number ): ByteBuffer | number; + + /** + * Writes a 32bit base 128 variable-length integer. + */ + writeVarint32( value: number, offset?: number ): ByteBuffer | number; + + /** + * Writes a zig-zag encoded 32bit base 128 variable-length integer. + */ + writeVarint32ZigZag( value: number, offset?: number ): ByteBuffer | number; + + /** + * Writes a 64bit base 128 variable-length integer. + */ + writeVarint64( value: number | Long, offset?: number ): ByteBuffer; + + /** + * Writes a zig-zag encoded 64bit base 128 variable-length integer. + */ + writeVarint64ZigZag( value: number | Long, offset?: number ): ByteBuffer | number; +} + +declare module 'bytebuffer' { + export = ByteBuffer; +} diff --git a/chartjs/chart-tests.ts b/chartjs/chart-tests.ts index 4bd8820c6c..452ddbf623 100644 --- a/chartjs/chart-tests.ts +++ b/chartjs/chart-tests.ts @@ -325,7 +325,7 @@ var myDoughnutChart = new Chart(ctx).Doughnut(pieData, { animateRotate: true, animateScale: false, legendTemplate: "
    -legend\"><% for (var i=0; i
  • \"><%if(segments[i].label){%><%=segments[i].label%><%}%>
  • <%}%>
" -}); +}); var myDoughnutChartLegend: string = myDoughnutChart.generateLegend(); var myDoughnutChartImage: string = myDoughnutChart.toBase64Image(); @@ -341,3 +341,32 @@ myDoughnutChart.resize(); myDoughnutChart.update(); myDoughnutChart.stop(); myDoughnutChart.destroy(); + +// Test using charts with overrides of a subset of global options +var partialOpts: ChartSettings = { + showTooltips: true, + tooltipEvents: ["mousemove", "touchstart", "touchmove"], + tooltipFillColor: "rgba(0,0,0,0.8)", + tooltipFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + tooltipFontSize: 14, + tooltipFontStyle: "normal", + tooltipFontColor: "#fff", + tooltipTitleFontFamily: "'Helvetica Neue', 'Helvetica', 'Arial', sans-serif", + tooltipTitleFontSize: 14, + tooltipTitleFontStyle: "bold", + tooltipTitleFontColor: "#fff", + tooltipYPadding: 6, + tooltipXPadding: 6, + tooltipCaretSize: 8, + tooltipCornerRadius: 6, + tooltipXOffset: 10, + tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%= value %>" +}; + +var my2ndLineChart = new Chart(ctx).Line(lineData, partialOpts); +var my2ndBarChart = new Chart(ctx).Bar(barData, partialOpts); +var my2ndRadarChart = new Chart(ctx).Radar(radarData, partialOpts); +var my2ndPolarAreaChart = new Chart(ctx).PolarArea(polarAreaData, partialOpts); +var my2ndPieChart = new Chart(ctx).Pie(pieData, partialOpts); +var my2ndDoughnutChart = new Chart(ctx).Doughnut(pieData, partialOpts); + diff --git a/chartjs/chart.d.ts b/chartjs/chart.d.ts index d337d144a6..62f393b8a1 100644 --- a/chartjs/chart.d.ts +++ b/chartjs/chart.d.ts @@ -33,49 +33,49 @@ interface CircularChartData { } interface ChartSettings { - animation: boolean; - animationSteps: number; - animationEasing: string; - showScale: boolean; - scaleOverride: boolean; - scaleSteps: number; - scaleStepWidth: number; - scaleStartValue: number; - scaleLineColor: string; - scaleLineWidth: number; - scaleShowLabels: boolean; - scaleLabel: string; - scaleIntegersOnly: boolean; - scaleBeginAtZero: boolean; - scaleFontFamily: string; - scaleFontSize: number; - scaleFontStyle: string; - scaleFontColor: string; - responsive: boolean; - maintainAspectRatio: boolean; - showTooltips: boolean; - tooltipEvents: string[]; - tooltipFillColor: string; - tooltipFontFamily: string; - tooltipFontSize: number; - tooltipFontStyle: string; - tooltipFontColor: string; - tooltipTitleFontFamily: string; - tooltipTitleFontSize: number; - tooltipTitleFontStyle: string; - tooltipTitleFontColor: string; - tooltipYPadding: number; - tooltipXPadding: number; - tooltipCaretSize: number; - tooltipCornerRadius: number; - tooltipXOffset: number; - tooltipTemplate: string; - multiTooltipTemplate: string; - onAnimationProgress: () => any; - onAnimationComplete: () => any; + animation?: boolean; + animationSteps?: number; + animationEasing?: string; + showScale?: boolean; + scaleOverride?: boolean; + scaleSteps?: number; + scaleStepWidth?: number; + scaleStartValue?: number; + scaleLineColor?: string; + scaleLineWidth?: number; + scaleShowLabels?: boolean; + scaleLabel?: string; + scaleIntegersOnly?: boolean; + scaleBeginAtZero?: boolean; + scaleFontFamily?: string; + scaleFontSize?: number; + scaleFontStyle?: string; + scaleFontColor?: string; + responsive?: boolean; + maintainAspectRatio?: boolean; + showTooltips?: boolean; + tooltipEvents?: string[]; + tooltipFillColor?: string; + tooltipFontFamily?: string; + tooltipFontSize?: number; + tooltipFontStyle?: string; + tooltipFontColor?: string; + tooltipTitleFontFamily?: string; + tooltipTitleFontSize?: number; + tooltipTitleFontStyle?: string; + tooltipTitleFontColor?: string; + tooltipYPadding?: number; + tooltipXPadding?: number; + tooltipCaretSize?: number; + tooltipCornerRadius?: number; + tooltipXOffset?: number; + tooltipTemplate?: string; + multiTooltipTemplate?: string; + onAnimationProgress?: () => any; + onAnimationComplete?: () => any; } -interface ChartOptions { +interface ChartOptions extends ChartSettings { scaleShowGridLines?: boolean; scaleGridLineColor?: string; scaleGridLineWidth?: number; @@ -138,7 +138,7 @@ interface BarChartOptions extends ChartOptions { barDatasetSpacing?: number; } -interface RadarChartOptions { +interface RadarChartOptions extends ChartSettings { scaleShowLine?: boolean; angleShowLineOut?: boolean; scaleShowLabels?: boolean; @@ -159,7 +159,7 @@ interface RadarChartOptions { legendTemplate?: string; } -interface PolarAreaChartOptions { +interface PolarAreaChartOptions extends ChartSettings { scaleShowLabelBackdrop?: boolean; scaleBackdropColor?: string; scaleBeginAtZero?: boolean; @@ -176,7 +176,7 @@ interface PolarAreaChartOptions { legendTemplate?: string; } -interface PieChartOptions { +interface PieChartOptions extends ChartSettings { segmentShowStroke?: boolean; segmentStrokeColor?: string; segmentStrokeWidth?: number; diff --git a/ckeditor/ckeditor.d.ts b/ckeditor/ckeditor.d.ts index 0164bb09b9..b3c2f45243 100644 --- a/ckeditor/ckeditor.d.ts +++ b/ckeditor/ckeditor.d.ts @@ -1139,4 +1139,12 @@ declare module CKEDITOR { function isTabEnabled(editor: editor, dialogName: string, tabName: string): boolean; function okButton(): void; } -} + + module lang { + var languages: any; + var rtl: any; + + function load(languageCode: string, defaultLanguage: string, callback: Function): void; + function detect(defaultLanguage: string, probeLanguage: string): string; + } +} \ No newline at end of file diff --git a/compose-function/compose-function-tests.ts b/compose-function/compose-function-tests.ts new file mode 100644 index 0000000000..dd0a80feff --- /dev/null +++ b/compose-function/compose-function-tests.ts @@ -0,0 +1,21 @@ +/// + +const numberToNumber = (a: number): number => a + 2; +const numberToString = (a: number): string => "foo"; +const stringToNumber = (a: string): number => 5; + +import composeFunction = require("compose-function"); +const t1: number = composeFunction(numberToNumber, numberToNumber)(5); +const t2: string = composeFunction(numberToString, numberToNumber)(5); +const t3: string = composeFunction(numberToString, stringToNumber)("f"); +const t4: (a: string) => number = composeFunction( + (f: (a: string) => number) => ((p: string) => 5), + (f: (a: number) => string) => ((p: string) => 4) + )(numberToString); + + +const t5: number = composeFunction(stringToNumber, numberToString, numberToNumber)(5); +const t6: string = composeFunction(numberToString, stringToNumber, numberToString, numberToNumber)(5); + +const t7: string = composeFunction( + numberToString, numberToNumber, stringToNumber, numberToString, stringToNumber)("fo"); diff --git a/compose-function/compose-function.d.ts b/compose-function/compose-function.d.ts new file mode 100644 index 0000000000..d4f205fd32 --- /dev/null +++ b/compose-function/compose-function.d.ts @@ -0,0 +1,31 @@ +// Type definitions for compose-function +// Project: https://github.com/stoeffel/compose-function +// Definitions by: Denis Sokolov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "compose-function" { + // Hardcoded signatures for 2-4 parameters + function f( + f1: (b: B) => C, + f2: (a: A) => B + ): (a: A) => C + function f( + f1: (b: C) => D, + f2: (a: B) => C, + f3: (a: A) => B + ): (a: A) => D + function f( + f1: (b: D) => E, + f2: (a: C) => D, + f3: (a: B) => C, + f4: (a: A) => B + ): (a: A) => E + + // Minimal typing for more than 4 parameters + function f( + f1: (a: any) => Result, + ...functions: Function[] + ): (a: any) => Result + + export = f; +} diff --git a/cordova/plugins/Device.d.ts b/cordova/plugins/Device.d.ts index a25c1aadc8..1abb37596e 100644 --- a/cordova/plugins/Device.d.ts +++ b/cordova/plugins/Device.d.ts @@ -26,6 +26,9 @@ interface Device { version: string; /** Get the device's manufacturer. */ manufacturer: string; -} + /** Whether the device is running on a simulator. */ + isVirtual: boolean; + /** Get the device hardware serial number. */ + serial: string;} declare var device: Device; \ No newline at end of file diff --git a/dexie/dexie.d.ts b/dexie/dexie.d.ts index d6c26283c2..13b9b31e0b 100644 --- a/dexie/dexie.d.ts +++ b/dexie/dexie.d.ts @@ -38,7 +38,7 @@ declare class Dexie { static deepClone(obj: Object): Object; - version(versionNumber: number): Dexie.Version + version(versionNumber: number): Dexie.Version; on: { (eventName: string, subscriber: () => any): void; @@ -48,7 +48,7 @@ declare class Dexie { populate: Dexie.DexieEvent; blocked: Dexie.DexieEvent; versionchange: Dexie.DexieVersionChangeEvent; - } + }; open(): Dexie.Promise; diff --git a/email-validator/email-validator-tests.ts b/email-validator/email-validator-tests.ts new file mode 100644 index 0000000000..61d4c6dfa6 --- /dev/null +++ b/email-validator/email-validator-tests.ts @@ -0,0 +1,13 @@ +/// + +import emailValidator = require('email-validator'); +import { validate } from 'email-validator'; + +var result: boolean; + +// Trivial code requires trivial tests +result = validate('some email'); +result = validate(null); + +result = emailValidator.validate('some email'); +result = emailValidator.validate(null); diff --git a/email-validator/email-validator.d.ts b/email-validator/email-validator.d.ts new file mode 100644 index 0000000000..299ebb19f6 --- /dev/null +++ b/email-validator/email-validator.d.ts @@ -0,0 +1,8 @@ +// Type definitions for email-validator 1.0.3 +// Project: https://github.com/Sembiance/email-validator +// Definitions by: Paul Lessing +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module "email-validator" { + export function validate(email: String): boolean; +} diff --git a/envify/envify.d.ts b/envify/envify.d.ts index 39479f503f..cc343ad33b 100644 --- a/envify/envify.d.ts +++ b/envify/envify.d.ts @@ -3,12 +3,14 @@ // Definitions by: Qubo // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module "envify" { - var envify: Function; + var envify: (file: string, environment: { [name: string]: any }) => NodeJS.ReadWriteStream; export = envify; } declare module "envify/custom" { - function envify(environment: { [name: string]: any }): Function; + function envify(environment: { [name: string]: any }): (file: string, environment: { [name: string]: any }) => NodeJS.ReadWriteStream; export = envify; } diff --git a/flux/flux-tests.ts b/flux/flux-tests.ts index f41d15aff1..24369ef2dd 100644 --- a/flux/flux-tests.ts +++ b/flux/flux-tests.ts @@ -1,6 +1,12 @@ /// +/// import flux = require('flux') +import FluxUtils = require('flux/utils') +import React = require('react') + +var Component = React.Component +var Container = FluxUtils.Container // // Basic dispatcher usage @@ -78,4 +84,46 @@ class CustomDispatcher extends flux.Dispatcher { var customDispatcher = new CustomDispatcher() -export = customDispatcher \ No newline at end of file +export = customDispatcher + + +// Sample Reduce Store +class CounterStore extends FluxUtils.ReduceStore { + getInitialState(): number { + return 0; + } + + reduce(state: number, action: any): number { + switch (action.type) { + case 'increment': + return state + 1; + + case 'square': + return state * state; + + default: + return state; + } + } +} + +const Store = new CounterStore(basicDispatcher); + +// Sample Flux container with CounterStore +class CounterContainer extends Component { + static getStores() { + return [Store]; + } + + static calculateState(prevState: any) { + return { + counter: Store.getState(), + }; + } + + render() { + return this.state.counter; + } +} + +const container = Container.create(CounterContainer); diff --git a/flux/flux.d.ts b/flux/flux.d.ts index bf5bafac4b..c65892321c 100644 --- a/flux/flux.d.ts +++ b/flux/flux.d.ts @@ -1,8 +1,10 @@ // Type definitions for Flux // Project: http://facebook.github.io/flux/ -// Definitions by: Steve Baker +// Definitions by: Steve Baker , Giedrius Grabauskas // Definitions: https://github.com/borisyankov/DefinitelyTyped +/// + declare module Flux { /** @@ -65,3 +67,127 @@ declare module Flux { declare module "flux" { export = Flux; } + +declare module FluxUtils { + + export class Container { + constructor(); + /** + * Create is used to transform a react class into a container + * that updates its state when relevant stores change. + * The provided base class must have static methods getStores() and calculateState(). + */ + static create(base: React.ComponentClass, options?: any): React.ComponentClass; + } + + /** + * This class extends ReduceStore and defines the state as an immutable map. + */ + // TODO: Change to > + export class MapStore extends ReduceStore { + /** + * Access the value at the given key. + * Throws an error if the key does not exist in the cache. + */ + at(key: K): V; + + /** + * Check if the cache has a particular key + */ + has(key: K): boolean; + + /** + * Get the value of a particular key. + * Returns undefined if the key does not exist in the cache. + */ + get(key: K): V; + + /** + * Gets an array of keys and puts the values in a map if they exist, + * it allows providing a previous result to update instead of generating a new map. + * Providing a previous result allows the possibility of keeping the same reference if the keys did not change. + */ + // TODO: Update with Immutable interface. + // getAll(keys: Immutable.IndexedIterable, prev?: Immutable.Map): Immutable.Map; + getAll(keys: any, prev?: any): any; + } + + export class ReduceStore extends Store { + /** + * Getter that exposes the entire state of this store. + * If your state is not immutable you should override this and not expose state directly. + */ + getState(): T; + + /** + * Constructs the initial state for this store. + * This is called once during construction of the store. + */ + getInitialState(): T; + + /** + * Reduces the current state, and an action to the new state of this store. + * All subclasses must implement this method. + * This method should be pure and have no side-effects. + */ + reduce(state: T, action: any): T; + + /** + * Checks if two versions of state are the same. + * You do not need to override this if your state is immutable. + */ + areEqual(one: T, two: T): boolean; + + } + + export class Store { + + /** + * Constructs and registers an instance of this store with the given dispatcher. + */ + constructor(dispatcher: Flux.Dispatcher); + + /** + * Adds a listener to the store, when the store changes the given callback will be called. + * A token is returned that can be used to remove the listener. + * Calling the remove() function on the returned token will remove the listener. + */ + addListener(callback: Function): { remove: Function }; + + /** + * Returns the dispatcher this store is registered with. + */ + getDispatcher(): Flux.Dispatcher; + + /** + * Returns the dispatch token that the dispatcher recognizes this store by. + * Can be used to waitFor() this store. + */ + getDispatchToken(): string; + + /** + * Ask if a store has changed during the current dispatch. + * Can only be invoked while dispatching. + * This can be used for constructing derived stores that depend on data from other stores. + */ + hasChanged(): boolean; + + /** + *Emit an event notifying all listeners that this store has changed. + * This can only be invoked when dispatching. + * Changes are de-duplicated and resolved at the end of this store's __onDispatch function. + */ + __emitChange(): void; + + /** + * Subclasses must override this method. + * This is how the store receives actions from the dispatcher. + * All state mutation logic must be done during this method. + */ + __onDispatch(payload: any): void; + } +} + +declare module 'flux/utils' { + export = FluxUtils; +} diff --git a/fs-extra/fs-extra-tests.ts b/fs-extra/fs-extra-tests.ts index 0919ef1b08..80655ab5b8 100644 --- a/fs-extra/fs-extra-tests.ts +++ b/fs-extra/fs-extra-tests.ts @@ -45,6 +45,7 @@ var openOpts: fs.OpenOptions; var watcher: fs.FSWatcher; var readStreeam: stream.Readable; var writeStream: stream.Writable; +var outputStream: stream.Writable; fs.copy(src, dest, errorCallback); fs.copy(src, dest, (src: string) => { @@ -150,7 +151,7 @@ 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); @@ -217,6 +218,17 @@ fs.exists(path, (exists: boolean) => { }); bool = fs.existsSync(path); +fs.ensureDir(path, errorCallback); +fs.ensureDirSync(path); +fs.ensureFile(path, errorCallback); +fs.ensureFileSync(path); +fs.ensureLink(path, errorCallback); +fs.ensureLinkSync(path); +fs.ensureSymlink(path, errorCallback); +fs.ensureSymlinkSync(path); +fs.emptyDir(path, errorCallback); +fs.emptyDirSync(path); + readStreeam = fs.createReadStream(path); readStreeam = fs.createReadStream(path, { flags: str, @@ -231,3 +243,9 @@ writeStream = fs.createWriteStream(path, { encoding: str, string: str }); +outputStream = fs.createOutputStream(path); +outputStream = fs.createOutputStream(path, { + flags: str, + encoding: str, + string: str +}); diff --git a/fs-extra/fs-extra.d.ts b/fs-extra/fs-extra.d.ts index 852956a71b..d997d12a89 100644 --- a/fs-extra/fs-extra.d.ts +++ b/fs-extra/fs-extra.d.ts @@ -167,6 +167,15 @@ declare module "fs-extra" { export function exists(path: string, callback?: (exists: boolean) => void ): void; export function existsSync(path: string): boolean; export function ensureDir(path: string, cb: (err: Error) => void): void; + export function ensureDirSync(path: string): void; + export function ensureFile(path: string, cb: (err: Error) => void): void; + export function ensureFileSync(path: string): void; + export function ensureLink(path: string, cb: (err: Error) => void): void; + export function ensureLinkSync(path: string): void; + export function ensureSymlink(path: string, cb: (err: Error) => void): void; + export function ensureSymlinkSync(path: string): void; + export function emptyDir(path: string, callback?: (err: Error) => void): void; + export function emptyDirSync(path: string): boolean; export interface OpenOptions { encoding?: string; @@ -192,4 +201,5 @@ declare module "fs-extra" { } export function createReadStream(path: string, options?: ReadStreamOptions): ReadStream; export function createWriteStream(path: string, options?: WriteStreamOptions): WriteStream; + export function createOutputStream(path: string, options?: WriteStreamOptions): WriteStream; } diff --git a/googlemaps/google.maps.d.ts b/googlemaps/google.maps.d.ts index 298f2f6ea6..3ac35b0482 100644 --- a/googlemaps/google.maps.d.ts +++ b/googlemaps/google.maps.d.ts @@ -849,7 +849,7 @@ declare module google.maps { formatted_address: string; geometry: GeocoderGeometry; partial_match: boolean; - postcode_localities: string[] + postcode_localities: string[]; types: string[]; } @@ -1822,7 +1822,7 @@ declare module google.maps { matched_substrings: PredictionSubstring[]; place_id: string; terms: PredictionTerm[]; - types: string[] + types: string[]; } export interface PredictionTerm { diff --git a/gulp-babel/gulp-babel-tests.ts b/gulp-babel/gulp-babel-tests.ts index 75175cf6f5..e5daf3617a 100644 --- a/gulp-babel/gulp-babel-tests.ts +++ b/gulp-babel/gulp-babel-tests.ts @@ -1,7 +1,7 @@ /// /// -import babel from 'gulp-babel'; +import babel = require('gulp-babel'); var x: NodeJS.ReadWriteStream = babel(); var x: NodeJS.ReadWriteStream = babel({}); diff --git a/gulp-babel/gulp-babel.d.ts b/gulp-babel/gulp-babel.d.ts index 36846cac43..98d33881cf 100644 --- a/gulp-babel/gulp-babel.d.ts +++ b/gulp-babel/gulp-babel.d.ts @@ -6,7 +6,7 @@ /// declare module 'gulp-babel' { - export default function(options?: { + function babel(options?: { filename?: string, filenameRelative?: string, presets?: string[], @@ -35,4 +35,6 @@ declare module 'gulp-babel' { env?: any, retainLines?: boolean }): NodeJS.ReadWriteStream; + + export = babel; } diff --git a/gulp-uglify/gulp-uglify.d.ts b/gulp-uglify/gulp-uglify.d.ts index 840b5110bd..05eb937ed3 100644 --- a/gulp-uglify/gulp-uglify.d.ts +++ b/gulp-uglify/gulp-uglify.d.ts @@ -170,6 +170,6 @@ declare module "gulp-uglify" { */ comments_before: string[]; } - + namespace GulpUglify {} export = GulpUglify; -} \ No newline at end of file +} diff --git a/hapi/hapi.d.ts b/hapi/hapi.d.ts index 7f2fab90e6..b31c24b163 100644 --- a/hapi/hapi.d.ts +++ b/hapi/hapi.d.ts @@ -7,10 +7,6 @@ /// -/// - - - declare module "hapi" { import http = require("http"); @@ -21,6 +17,17 @@ declare module "hapi" { [key: string]: T; } + interface IThenable { + then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IThenable; + then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IThenable; + } + + interface IPromise extends IThenable { + then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => U | IThenable): IPromise; + then(onFulfilled?: (value: R) => U | IThenable, onRejected?: (error: any) => void): IPromise; + catch(onRejected?: (error: any) => U | IThenable): IPromise; + } + /** Boom Module for errors. https://github.com/hapijs/boom * boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties: */ export interface IBoom extends Error { @@ -234,12 +241,12 @@ declare module "hapi" { When calling reply(), the framework waits until process.nextTick() to continue processing the request and transmit the response. This enables making changes to the returned response object before the response is sent. This means the framework will resume as soon as the handler method exits. To suspend this behavior, the returned response object supports the following methods: hold(), send() */ export interface IReply { (err: Error, - result?: string|number|boolean|Buffer|stream.Stream | Promise | T, + result?: string|number|boolean|Buffer|stream.Stream | IPromise | T, /** Note that when used to return both an error and credentials in the authentication methods, reply() must be called with three arguments function(err, null, data) where data is the additional authentication information. */ credentialData?: any ): IBoom; /** Note that if result is a Stream with a statusCode property, that status code will be used as the default response code. */ - (result: string|number|boolean|Buffer|stream.Stream | Promise | T): Response; + (result: string|number|boolean|Buffer|stream.Stream | IPromise | T): Response; /** Returns control back to the framework without setting a response. If called in the handler, the response defaults to an empty payload with status code 200. * The data argument is only used for passing back authentication data and is ignored elsewhere. */ @@ -897,22 +904,32 @@ declare module "hapi" { export interface IServerInject { - (options: { + (options: string | { /** the request HTTP method (e.g. 'POST'). Defaults to 'GET'.*/ method: string; /** the request URL. If the URI includes an authority (e.g. 'example.com:8080'), it is used to automatically set an HTTP 'Host' header, unless one was specified in headers.*/ url: string; /** an object with optional request headers where each key is the header name and the value is the header content. Defaults to no additions to the default Shot headers.*/ - headers: IDictionary; - /**- an optional string or buffer containing the request payload (object must be manually converted to a string first). Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided.*/ - payload: string|Buffer; - /**an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials.*/ - credentials: any; + headers?: IDictionary; + /** n optional string, buffer or object containing the request payload. In case of an object it will be converted to a string for you. Defaults to no payload. Note that payload processing defaults to 'application/json' if no 'Content-Type' header provided.*/ + payload?: string|{}|Buffer; + /** an optional credentials object containing authentication information. The credentials are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Defaults to no credentials.*/ + credentials?: any; + /** an optional artifacts object containing authentication artifact information. The artifacts are used to bypass the default authentication strategies, and are validated directly as if they were received via an authentication scheme. Ignored if set without credentials. Defaults to no artifacts.*/ + artifacts?: any; + /** sets the initial value of request.app*/ + app?: any; + /** sets the initial value of request.plugins*/ + plugins?: any; + /** allows access to routes with config.isInternal set to true. Defaults to false.*/ + allowInternals?: boolean; + /** sets the remote address for the incoming connection.*/ + remoteAddress?: boolean; /**object with options used to simulate client request stream conditions for testing: error - if true, emits an 'error' event after payload transmission (if any). Defaults to false. close - if true, emits a 'close' event after payload transmission (if any). Defaults to false. end - if false, does not end the stream. Defaults to true.*/ - simulate: { + simulate?: { error: boolean; close: boolean; end: boolean; diff --git a/highcharts/highcharts.d.ts b/highcharts/highcharts.d.ts index 94277ca252..e86d4b86c4 100644 --- a/highcharts/highcharts.d.ts +++ b/highcharts/highcharts.d.ts @@ -1304,7 +1304,7 @@ interface HighchartsChartOptions3dFrame { * @default 'transparent' * @since 4.0 */ - color?: string | HighchartsGradient, + color?: string | HighchartsGradient; /** * Thickness of the panel. * @default 1 diff --git a/intro.js/intro.js-tests.ts b/intro.js/intro.js-tests.ts index b49eb5078e..b8e8126ae9 100644 --- a/intro.js/intro.js-tests.ts +++ b/intro.js/intro.js-tests.ts @@ -9,11 +9,11 @@ intro.setOptions({ intro: "Hello world!" }, { - element: document.querySelector('#step1'), + element: document.querySelector('#step1') as HTMLElement, intro : "This is a tooltip." }, { - element : document.querySelectorAll('#step2')[0], + element : document.querySelectorAll('#step2')[0] as HTMLElement, intro : "Ok, wasn't that fun?", position: 'right' }, diff --git a/intro.js/intro.js.d.ts b/intro.js/intro.js.d.ts index d54a5456ef..15a73f5178 100644 --- a/intro.js/intro.js.d.ts +++ b/intro.js/intro.js.d.ts @@ -14,7 +14,7 @@ declare module IntroJs { interface Step { intro: string; element?: string|HTMLElement; - position?: Positions; + position?: string|Positions; } interface Options { diff --git a/ionic/ionic-tests.ts b/ionic/ionic-tests.ts index ee8647b08c..c68846715e 100644 --- a/ionic/ionic-tests.ts +++ b/ionic/ionic-tests.ts @@ -84,13 +84,19 @@ class IonicTestController { private testActionSheet(): void { var closeActionSheetFn: ()=>void = this.$ionicActionSheet.show({ - buttons: [], + buttons: [{ text: 'A button' }], titleText: "titleText", cancelText: "cancelText", destructiveText: "destructiveText", cancel: ()=>{ console.log("cancel"); }, - buttonClicked: ()=>{ console.log("buttonClicked"); }, - destructiveButtonClicked: ()=>{ console.log("destructiveButtonClicked"); }, + buttonClicked: (index)=>{ + console.log("buttonClicked"); + return index === 0; + }, + destructiveButtonClicked: ()=>{ + console.log("destructiveButtonClicked"); + return false; + }, cancelOnStateChange: true, cssClass: "cssClass" }); @@ -249,7 +255,7 @@ class IonicTestController { okType: "okType", cancelText: "Cancel", cancelType: "cancelType" - }).then(() => console.log("popover shown")) + }).then((result) => console.log(result === true ? "confirmed": "cancelled")) this.$ionicPopup.confirm({ title: "title", subTitle: "subTitle", diff --git a/ionic/ionic.d.ts b/ionic/ionic.d.ts index 688a253edd..bb009df513 100644 --- a/ionic/ionic.d.ts +++ b/ionic/ionic.d.ts @@ -102,14 +102,17 @@ declare module ionic { interface IonicActionSheetService { show(options: IonicActionSheetOptions): ()=>void; } + interface IonicActionSheetButton { + text: string; + } interface IonicActionSheetOptions { - buttons?: Array; + buttons?: Array; titleText?: string; cancelText?: string; destructiveText?: string; cancel?: ()=>any; - buttonClicked?: (index: any)=>any; - destructiveButtonClicked?: ()=>any; + buttonClicked?: (index: number)=>boolean; + destructiveButtonClicked?: ()=>boolean; cancelOnStateChange?: boolean; cssClass?: string; } @@ -246,10 +249,13 @@ declare module ionic { interface IonicPopupService { show(options: IonicPopupFullOptions): IonicPopupPromise; alert(options: IonicPopupAlertOptions): IonicPopupPromise; - confirm(options: IonicPopupConfirmOptions): IonicPopupPromise; + confirm(options: IonicPopupConfirmOptions): IonicPopupConfirmPromise; prompt(options: IonicPopupPromptOptions): IonicPopupPromise; } + interface IonicPopupConfirmPromise extends ng.IPromise { + close(value?: boolean): void; + } interface IonicPopupPromise extends ng.IPromise { close(value?: any): any; } diff --git a/jake/jake.d.ts b/jake/jake.d.ts index 1812b818b7..95614374cc 100644 --- a/jake/jake.d.ts +++ b/jake/jake.d.ts @@ -40,6 +40,16 @@ declare function fail(...err:any[]): void; */ declare function file(name:string, prereqs?:string[], action?:()=>void, opts?:jake.FileTaskOptions): jake.FileTask; +/** + * Creates Jake FileTask from regex patterns + * @name name/pattern of the Task + * @param source calculated from the name pattern + * @param prereqs Prerequisites to be run before this task + * @param action The action to perform for this task + * @param opts Perform this task asynchronously. If you flag a task with this option, you must call the global `complete` method inside the task's action, for execution to proceed to the next task. + */ +declare function rule(pattern: RegExp, source: string | { (name: string): string; }, prereqs?: string[], action?: () => void, opts?: jake.TaskOptions): void; + /** * Creates a namespace which allows logical grouping of tasks, and prevents name-collisions with task-names. Namespaces can be nested inside of other namespaces. * @param name The name of the namespace @@ -185,6 +195,11 @@ declare module jake{ * @default false */ async?: boolean; + + /** + * number of parllel async tasks + */ + parallelLimit?: number; } /** diff --git a/jasmine-matchers/jasmine-matchers-tests.ts b/jasmine-matchers/jasmine-matchers-tests.ts index d1cbc0f90f..f281b4a830 100644 --- a/jasmine-matchers/jasmine-matchers-tests.ts +++ b/jasmine-matchers/jasmine-matchers-tests.ts @@ -27,8 +27,8 @@ describe('toBeArray', function () { }); it('should pass for [1,"",{}]', function () { expect([ - 1, - "", + 1, + "", { } ]).toBeArray(); @@ -115,13 +115,13 @@ describe('toBeOneOf', function () { describe('matches', function () { it('should find "a" in ["a", "b"]', function () { expect('a').toBeOneOf([ - 'a', + 'a', 'b' ]); }); it('should find "uxebu" in ["company", "uxebu"]', function () { expect('uxebu').toBeOneOf([ - 'company', + 'company', 'uxebu' ]); }); @@ -129,30 +129,30 @@ describe('toBeOneOf', function () { describe('non-matches', function () { it('should not find "" in [" ", "0"]', function () { expect('').not.toBeOneOf([ - ' ', + ' ', '0' ]); }); it('should not find "a" in ["b", "c"]', function () { expect('a').not.toBeOneOf([ - 'b', + 'b', 'c' ]); }); }); }); describe('toBeCloseToOneOf', function () { - function oneDigitOff(actual, expected) { + function oneDigitOff(actual: any, expected: any) { var actualInt = parseInt(actual, 10); return actualInt - 1 <= expected && actualInt + 1 >= expected; } - function tenPercentOff(actual, expected) { + function tenPercentOff(actual: any, expected: any) { return expected * 0.9 <= actual && expected * 1.1 >= actual; } - function oneDigitOrTenPercentOff(actual, expected) { + function oneDigitOrTenPercentOff(actual: any, expected: any) { return oneDigitOff(actual, expected) || tenPercentOff(actual, expected); } - function twoDecimalsOff(actual, expected) { + function twoDecimalsOff(actual: any, expected: any) { var lower = ((expected * 100) - 2) / 100; var upper = ((expected * 100) + 2) / 100; return lower <= actual && upper >= actual; @@ -160,25 +160,25 @@ describe('toBeCloseToOneOf', function () { describe('matches', function () { it('should say 7 is close to one of [8, 9]', function () { expect(7).toBeCloseToOneOf([ - 8, + 8, 9 ], oneDigitOff); }); it('should say 2 is 10% off of one of [2.2, 1.0]', function () { expect(2).toBeCloseToOneOf([ - 2.2, + 2.2, 1.0 ], tenPercentOff); }); it('should say 7 is close to one of [8, 9]', function () { expect(7).toBeCloseToOneOf([ - 8, + 8, 9 ], oneDigitOrTenPercentOff); }); it('should say 1.345 two decimals off of [1.325, 1.365]', function () { expect(1.345).toBeCloseToOneOf([ - 1.325, + 1.325, 1.365 ], twoDecimalsOff); }); @@ -186,26 +186,26 @@ describe('toBeCloseToOneOf', function () { describe('non-matches', function () { it('should say 7 is NOT one off of [9, 10, 11]', function () { expect(7).not.toBeCloseToOneOf([ - 9, - 10, + 9, + 10, 11 ], oneDigitOff); }); it('should say 1 is close to one of [8, 9]', function () { expect(1).not.toBeCloseToOneOf([ - 8, + 8, 9 ], oneDigitOrTenPercentOff); }); it('should say 1.9 is NOT 10% off of one of [2.2, 1.0]', function () { expect(1.9).not.toBeCloseToOneOf([ - 2.2, + 2.2, 1.0 ], tenPercentOff); }); it('should say 1.345 two decimals off of [1.325, 1.365]', function () { expect(1.304).not.toBeCloseToOneOf([ - 1.325, + 1.325, 1.365 ], twoDecimalsOff); }); @@ -216,7 +216,7 @@ describe('toContainOnce', function () { describe('matches', function () { it('should work for arrays', function () { expect([ - 1, + 1, 2 ]).toContainOnce(1); }); @@ -227,7 +227,7 @@ describe('toContainOnce', function () { describe('non-matches', function () { it('should work for arrays', function () { expect([ - 1, + 1, 2 ]).not.toContainOnce(3); }); @@ -257,7 +257,7 @@ describe('toHaveLength', function () { describe('toHaveProperties', function () { describe('matches', function () { it('should work for `{x:0, y:undefined}`', function () { - var obj = { + var obj: any = { x: 0, y: undefined }; @@ -268,7 +268,7 @@ describe('toHaveProperties', function () { describe('toHavePropertiesWithValues', function () { describe('matches', function () { it('should work with a reference object', function () { - function C() { + var C: any = function C() { this.x = 0; } C.prototype.y = 'arbitrary'; @@ -283,7 +283,7 @@ describe('toHavePropertiesWithValues', function () { describe('toHaveOwnProperties', function () { describe('matches', function () { it('should work for `{x:0, y:undefined}`', function () { - var obj = { + var obj: any = { x: 0, y: undefined }; @@ -322,14 +322,14 @@ describe('toHaveBeenCalledXTimes', function () { describe('toExactlyHaveProperties', function () { describe('matches', function () { it('should work for `{x:0, y:undefined}`', function () { - var obj = { + var obj: any = { x: 0, y: undefined }; expect(obj).toExactlyHaveProperties('x', 'y'); }); it('should work in any order', function () { - var obj = { + var obj: any = { x: 0, y: undefined }; @@ -338,14 +338,14 @@ describe('toExactlyHaveProperties', function () { }); describe('non-matches', function () { it('should work for too many properties', function () { - var obj = { + var obj: any = { x: 0, y: undefined }; expect(obj).not.toExactlyHaveProperties('x'); }); it('should work for missing properties', function () { - var obj = { + var obj: any = { x: 0, y: undefined }; @@ -375,17 +375,17 @@ describe('toEndWith', function () { describe('matches', function () { it('should work for string', function () { expect([ - '1', + '1', '2' ]).toEndWith('2'); }); it('should work for array', function () { expect([ - 3, - 4, + 3, + 4, 5 ]).toEndWith([ - 4, + 4, 5 ]); }); @@ -393,17 +393,17 @@ describe('toEndWith', function () { describe('non-matches', function () { it('should work for string', function () { expect([ - '1', + '1', '2' ]).not.toEndWith('3'); }); it('should work for array', function () { expect([ - 3, - 4, + 3, + 4, 5 ]).not.toEndWith([ - 3, + 3, 4 ]); }); @@ -419,8 +419,8 @@ describe('toEachEndWith', function () { }); it('should work for array with multiple elements', function () { expect([ - 'one', - 'zwee', + 'one', + 'zwee', 'three' ]).toEachEndWith('e'); }); @@ -433,8 +433,8 @@ describe('toEachEndWith', function () { }); it('should work for array with multiple elements', function () { expect([ - 'one', - 'zwei', + 'one', + 'zwei', 'three' ]).not.toEachEndWith('e'); }); @@ -449,8 +449,8 @@ describe('toSomeEndWith', function () { }); it('should work for array with multiple elements', function () { expect([ - 'one', - 'zwee', + 'one', + 'zwee', 'three' ]).toSomeEndWith('ee'); }); @@ -463,8 +463,8 @@ describe('toSomeEndWith', function () { }); it('should work for array with multiple elements', function () { expect([ - 'one', - 'zwei', + 'one', + 'zwei', 'three' ]).not.toSomeEndWith('a'); }); @@ -491,17 +491,17 @@ describe('toStartWith', function () { describe('matches', function () { it('should work for string', function () { expect([ - '1', + '1', '2' ]).toStartWith('1'); }); it('should work for array', function () { expect([ - 3, - 4, + 3, + 4, 5 ]).toStartWith([ - 3, + 3, 4 ]); }); @@ -509,17 +509,17 @@ describe('toStartWith', function () { describe('non-matches', function () { it('should work for string', function () { expect([ - '1', + '1', '2' ]).not.toStartWith('3'); }); it('should work for array', function () { expect([ - 3, - 4, + 3, + 4, 5 ]).not.toStartWith([ - 4, + 4, 5 ]); }); @@ -535,8 +535,8 @@ describe('toEachStartWith', function () { }); it('should work for array with multiple elements', function () { expect([ - 'one', - 'onetwo', + 'one', + 'onetwo', 'onethree' ]).toEachStartWith('o'); }); @@ -549,8 +549,8 @@ describe('toEachStartWith', function () { }); it('should work for array with multiple elements', function () { expect([ - 'one', - 'two', + 'one', + 'two', 'onethree' ]).not.toEachStartWith('o'); }); @@ -565,8 +565,8 @@ describe('toSomeStartWith', function () { }); it('should work for array with multiple elements', function () { expect([ - 'one', - 'onetwo', + 'one', + 'onetwo', 'three' ]).toSomeStartWith('one'); }); @@ -579,8 +579,8 @@ describe('toSomeStartWith', function () { }); it('should work for array with multiple elements', function () { expect([ - 'one', - 'two', + 'one', + 'two', 'onethree' ]).not.toSomeStartWith('a'); }); @@ -610,19 +610,19 @@ describe('toStartWithEither', function () { describe('matches', function () { it('should work for string', function () { expect([ - '1', + '1', '2' ]).toStartWithEither('1', '2'); }); it('should work for array', function () { expect([ - 3, - 4, + 3, + 4, 5 ]).toStartWithEither([ 4 ], [ - 3, + 3, 4 ]); }); @@ -630,20 +630,20 @@ describe('toStartWithEither', function () { describe('non-matches', function () { it('should work for string', function () { expect([ - '1', + '1', '2' ]).not.toStartWithEither('3'); }); it('should work for array', function () { expect([ - 3, - 4, + 3, + 4, 5 ]).not.toStartWithEither([ - 5, + 5, 6 ], [ - 4, + 4, 5 ]); }); diff --git a/js-combinatorics/js-combinatorics-global-tests.ts b/js-combinatorics/js-combinatorics-global-tests.ts new file mode 100644 index 0000000000..e8591fbc20 --- /dev/null +++ b/js-combinatorics/js-combinatorics-global-tests.ts @@ -0,0 +1,99 @@ +/// + +const p:number = Combinatorics.P(1, 2); +const c:number = Combinatorics.C(1, 2); +const factorial:number = Combinatorics.factorial(5); +const factoradic:number[] = Combinatorics.factoradic(5); + +const power = Combinatorics.power(["a", "b", "c"]); +const nextPower:string[] = power.next(); +power.forEach((i:string[]) => console.log(i)); +const powersLengths:number[] = power.map((i:string[]) => i.length); +const filteredPowers:string[][] = power.filter((i:string[]) => i.length > 0); +const allPowers:string[][] = power.toArray(); +const powersCount = power.length; +const nthPower:string[] = power.nth(3); + +const limitedCombination = Combinatorics.combination(["a", "b", "c"], 2); +const combination = Combinatorics.combination(["a", "b", "c"]); +const nextCombination:string[] = combination.next(); +combination.forEach((i:string[]) => console.log(i)); +const combinationsLengths:number[] = combination.map((i:string[]) => i.length); +const filteredCombinations:string[][] = combination.filter((i:string[]) => i.length > 0); +const allCombinations:string[][] = combination.toArray(); +const combinationsCount = combination.length; + +const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2); +const permutation = Combinatorics.permutation(["a", "b", "c"]); +const nextPermutation:string[] = permutation.next(); +permutation.forEach((i:string[]) => console.log(i)); +const permutationsLengths:number[] = permutation.map((i:string[]) => i.length); +const filteredPermutations:string[][] = permutation.filter((i:string[]) => i.length > 0); +const allPermutations:string[][] = permutation.toArray(); +const permutationsCount = permutation.length; + +const permutationCombination = Combinatorics.permutationCombination(["a", "b", "c"]); +const nextPermutationCombinations:string[] = permutationCombination.next(); +permutationCombination.forEach((i:string[]) => console.log(i)); +const permutationCombinationsLengths:number[] = permutationCombination.map((i:string[]) => i.length); +const filteredPermutationCombinationss:string[][] = permutationCombination.filter((i:string[]) => i.length > 0); +const allPermutationCombinationss:string[][] = permutationCombination.toArray(); +const permutationCombinationsCount = permutationCombination.length; + +const limitedBaseN = Combinatorics.baseN(["a", "b", "c"], 2); +const baseN = Combinatorics.baseN(["a", "b", "c"]); +const nextbaseN:string[] = baseN.next(); +baseN.forEach((i:string[]) => console.log(i)); +const baseNsLengths:number[] = baseN.map((i:string[]) => i.length); +const filteredbaseNs:string[][] = baseN.filter((i:string[]) => i.length > 0); +const allbaseNs:string[][] = baseN.toArray(); +const baseNsCount = baseN.length; +const nthbaseN:string[] = baseN.nth(3); + +const cartesianProduct1 = Combinatorics.cartesianProduct(["a", "b", "c"]); +const nextCartesianProduct1:[string] = cartesianProduct1.next(); +const nextCartesianProduct1Char = nextCartesianProduct1[0].substr(0, 1); +cartesianProduct1.forEach((i:[string]) => console.log(i)); +const cartesianProduct1sLengths:number[] = cartesianProduct1.map((i:[string]) => i.length); +const filteredCartesianProduct1s:[string][] = cartesianProduct1.filter((i:[string]) => i.length > 0); +const allCartesianProduct1s:[string][] = cartesianProduct1.toArray(); +const cartesianProduct1sCount = cartesianProduct1.length; +const nthCartesianProduct1:[string] = cartesianProduct1.nth(3); +const cartesianProduct1ByCoords:[string] = cartesianProduct1.get(1); + +const cartesianProduct2 = Combinatorics.cartesianProduct(["a", "b", "c"], [1, 2, 3]); +const nextCartesianProduct2:[string, number] = cartesianProduct2.next(); +const nextCartesianProduct2Char = nextCartesianProduct2[0].substr(0, 1); +const nextCartesianProduct2Num = nextCartesianProduct2[1].toFixed(2); +cartesianProduct2.forEach((i:[string, number]) => console.log(i)); +const cartesianProduct2sLengths:number[] = cartesianProduct2.map((i:[string, number]) => i.length); +const filteredCartesianProduct2s:[string, number][] = cartesianProduct2.filter((i:[string, number]) => i.length > 0); +const allCartesianProduct2s:[string, number][] = cartesianProduct2.toArray(); +const cartesianProduct2sCount = cartesianProduct2.length; +const nthCartesianProduct2:[string, number] = cartesianProduct2.nth(3); +const cartesianProduct2ByCoords:[string, number] = cartesianProduct2.get(1, 1); + +const cartesianProduct3 = Combinatorics.cartesianProduct(["a", "b", "c"], [1, 2, 3], [true, false]); +const nextCartesianProduct3:[string, number, boolean] = cartesianProduct3.next(); +const nextCartesianProduct3Char = nextCartesianProduct3[0].substr(0, 1); +const nextCartesianProduct3Num = nextCartesianProduct3[1].toFixed(2); +const nextCartesianProduct4Cond = nextCartesianProduct3[2] === true; +cartesianProduct3.forEach((i:[string, number, boolean]) => console.log(i)); +const cartesianProduct3sLengths:number[] = cartesianProduct3.map((i:[string, number, boolean]) => i.length); +const filteredCartesianProduct3s:[string, number, boolean][] = cartesianProduct3.filter((i:[string, number, boolean]) => i.length > 0); +const allCartesianProduct3s:[string, number, boolean][] = cartesianProduct3.toArray(); +const cartesianProduct3sCount = cartesianProduct3.length; +const nthCartesianProduct3:[string, number, boolean] = cartesianProduct3.nth(3); +const cartesianProduct3ByCoords:[string, number, boolean] = cartesianProduct3.get(1, 1); + +const cartesianProductAny = Combinatorics.cartesianProduct(["a", 1, true], [false, 2, "b"]); +const nextCartesianProductAny:any[] = cartesianProductAny.next(); +cartesianProductAny.forEach((i:any[]) => console.log(i)); +const cartesianProductAnysLengths:number[] = cartesianProductAny.map((i:any[]) => i.length); +const filteredCartesianProductAnys:any[][] = cartesianProductAny.filter((i:any[]) => i.length > 0); +const allCartesianProductAnys:any[][] = cartesianProductAny.toArray(); +const cartesianProductAnysCount = cartesianProductAny.length; +const nthCartesianProductAny:any[] = cartesianProductAny.nth(3); +const cartesianProductAnyByCoords:any[] = cartesianProductAny.get(1, 1); + +const version:string = Combinatorics.VERSION; diff --git a/js-combinatorics/js-combinatorics-global.d.ts b/js-combinatorics/js-combinatorics-global.d.ts new file mode 100644 index 0000000000..20c302981c --- /dev/null +++ b/js-combinatorics/js-combinatorics-global.d.ts @@ -0,0 +1,8 @@ +// Type definitions for js-combinatorics v0.5.0 (global) +// Project: https://github.com/dankogai/js-combinatorics +// Definitions by: Vasya Aksyonov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +import Combinatorics = __Combinatorics; diff --git a/js-combinatorics/js-combinatorics-tests.ts b/js-combinatorics/js-combinatorics-tests.ts new file mode 100644 index 0000000000..08e04c374f --- /dev/null +++ b/js-combinatorics/js-combinatorics-tests.ts @@ -0,0 +1,95 @@ +/// + +import * as Combinatorics from "js-combinatorics"; + +const p:number = Combinatorics.P(1, 2); +const c:number = Combinatorics.C(1, 2); +const factorial:number = Combinatorics.factorial(5); +const factoradic:number[] = Combinatorics.factoradic(5); + +const power = Combinatorics.power(["a", "b", "c"]); +const nextPower:string[] = power.next(); +power.forEach((i:string[]) => console.log(i)); +const powersLengths:number[] = power.map((i:string[]) => i.length); +const filteredPowers:string[][] = power.filter((i:string[]) => i.length > 0); +const allPowers:string[][] = power.toArray(); +const powersCount = power.length; +const nthPower:string[] = power.nth(3); + +const limitedCombination = Combinatorics.combination(["a", "b", "c"], 2); +const combination = Combinatorics.combination(["a", "b", "c"]); +const nextCombination:string[] = combination.next(); +combination.forEach((i:string[]) => console.log(i)); +const combinationsLengths:number[] = combination.map((i:string[]) => i.length); +const filteredCombinations:string[][] = combination.filter((i:string[]) => i.length > 0); +const allCombinations:string[][] = combination.toArray(); +const combinationsCount = combination.length; + +const limitedPermutation = Combinatorics.permutation(["a", "b", "c"], 2); +const permutation = Combinatorics.permutation(["a", "b", "c"]); +const nextPermutation:string[] = permutation.next(); +permutation.forEach((i:string[]) => console.log(i)); +const permutationsLengths:number[] = permutation.map((i:string[]) => i.length); +const filteredPermutations:string[][] = permutation.filter((i:string[]) => i.length > 0); +const allPermutations:string[][] = permutation.toArray(); +const permutationsCount = permutation.length; + +const permutationCombination = Combinatorics.permutationCombination(["a", "b", "c"]); +const nextPermutationCombinations:string[] = permutationCombination.next(); +permutationCombination.forEach((i:string[]) => console.log(i)); +const permutationCombinationsLengths:number[] = permutationCombination.map((i:string[]) => i.length); +const filteredPermutationCombinationss:string[][] = permutationCombination.filter((i:string[]) => i.length > 0); +const allPermutationCombinationss:string[][] = permutationCombination.toArray(); +const permutationCombinationsCount = permutationCombination.length; + +const limitedBaseN = Combinatorics.baseN(["a", "b", "c"], 2); +const baseN = Combinatorics.baseN(["a", "b", "c"]); +const nextbaseN:string[] = baseN.next(); +baseN.forEach((i:string[]) => console.log(i)); +const baseNsLengths:number[] = baseN.map((i:string[]) => i.length); +const filteredbaseNs:string[][] = baseN.filter((i:string[]) => i.length > 0); +const allbaseNs:string[][] = baseN.toArray(); +const baseNsCount = baseN.length; +const nthbaseN:string[] = baseN.nth(3); + +const cartesianProduct1 = Combinatorics.cartesianProduct(["a", "b", "c"]); +const nextCartesianProduct1:[string] = cartesianProduct1.next(); +cartesianProduct1.forEach((i:[string]) => console.log(i)); +const cartesianProduct1sLengths:number[] = cartesianProduct1.map((i:[string]) => i.length); +const filteredCartesianProduct1s:[string][] = cartesianProduct1.filter((i:[string]) => i.length > 0); +const allCartesianProduct1s:[string][] = cartesianProduct1.toArray(); +const cartesianProduct1sCount = cartesianProduct1.length; +const nthCartesianProduct1:[string] = cartesianProduct1.nth(3); +const cartesianProduct1ByCoords:[string] = cartesianProduct1.get(1); + +const cartesianProduct2 = Combinatorics.cartesianProduct(["a", "b", "c"], [1, 2, 3]); +const nextCartesianProduct2:[string, number] = cartesianProduct2.next(); +cartesianProduct2.forEach((i:[string, number]) => console.log(i)); +const cartesianProduct2sLengths:number[] = cartesianProduct2.map((i:[string, number]) => i.length); +const filteredCartesianProduct2s:[string, number][] = cartesianProduct2.filter((i:[string, number]) => i.length > 0); +const allCartesianProduct2s:[string, number][] = cartesianProduct2.toArray(); +const cartesianProduct2sCount = cartesianProduct2.length; +const nthCartesianProduct2:[string, number] = cartesianProduct2.nth(3); +const cartesianProduct2ByCoords:[string, number] = cartesianProduct2.get(1, 1); + +const cartesianProduct3 = Combinatorics.cartesianProduct(["a", "b", "c"], [1, 2, 3], [true, false]); +const nextCartesianProduct3:[string, number, boolean] = cartesianProduct3.next(); +cartesianProduct3.forEach((i:[string, number, boolean]) => console.log(i)); +const cartesianProduct3sLengths:number[] = cartesianProduct3.map((i:[string, number, boolean]) => i.length); +const filteredCartesianProduct3s:[string, number, boolean][] = cartesianProduct3.filter((i:[string, number, boolean]) => i.length > 0); +const allCartesianProduct3s:[string, number, boolean][] = cartesianProduct3.toArray(); +const cartesianProduct3sCount = cartesianProduct3.length; +const nthCartesianProduct3:[string, number, boolean] = cartesianProduct3.nth(3); +const cartesianProduct3ByCoords:[string, number, boolean] = cartesianProduct3.get(1, 1); + +const cartesianProductAny = Combinatorics.cartesianProduct(["a", 1, true], [false, 2, "b"]); +const nextCartesianProductAny:any[] = cartesianProductAny.next(); +cartesianProductAny.forEach((i:any[]) => console.log(i)); +const cartesianProductAnysLengths:number[] = cartesianProductAny.map((i:any[]) => i.length); +const filteredCartesianProductAnys:any[][] = cartesianProductAny.filter((i:any[]) => i.length > 0); +const allCartesianProductAnys:any[][] = cartesianProductAny.toArray(); +const cartesianProductAnysCount = cartesianProductAny.length; +const nthCartesianProductAny:any[] = cartesianProductAny.nth(3); +const cartesianProductAnyByCoords:any[] = cartesianProductAny.get(1, 1); + +const version:string = Combinatorics.VERSION; diff --git a/js-combinatorics/js-combinatorics.d.ts b/js-combinatorics/js-combinatorics.d.ts new file mode 100644 index 0000000000..270e98b641 --- /dev/null +++ b/js-combinatorics/js-combinatorics.d.ts @@ -0,0 +1,135 @@ +// Type definitions for js-combinatorics v0.5.0 +// Project: https://github.com/dankogai/js-combinatorics +// Definitions by: Vasya Aksyonov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare namespace __Combinatorics { + + interface IGenerator { + + /** + * Returns the element or undefined if no more element is available. + */ + next():T; + + /** + * Applies the callback function for each element. + */ + forEach(f:(item:T) => void):void; + + /** + * All elements at once with function applied to each element. + */ + map(f:(item:T) => TResult):TResult[]; + + /** + * Returns an array with elements that passes the filter function. + */ + filter(predicate:(item:T) => boolean):T[]; + + /** + * All elements at once. + */ + toArray():T[]; + + /** + * Returns the number of elements to be generated which equals to generator.toArray().length + * but it is precalculated without actually generating elements. + * Handy when you prepare for large iteration. + */ + length:number; + + } + + interface IPredictableGenerator extends IGenerator { + + /** + * Returns the nth element (starting 0). + */ + nth(n:number):T; + + } + + interface ICartesianProductGenerator extends IPredictableGenerator { + + /** + * Arguments are coordinates in integer. + * Arguments can be out of bounds but it returns undefined in such cases. + */ + get(...coordinates:number[]):T; + + } + + /** + * Calculates m P n + */ + function P(m:number, n:number):number; + + /** + * Calculates m C n + */ + function C(m:number, n:number):number; + + /** + * Calculates n! + */ + function factorial(n:number):number; + + /** + * Returns the factoradic representation of n in array, in least significant order. + * See http://en.wikipedia.org/wiki/Factorial_number_system + */ + function factoradic(n:number):number[]; + + /** + * Generates the power set of array. + */ + function power(a:T[]):IPredictableGenerator; + + /** + * Generates the combination of array with n elements. + * When n is ommited, the length of the array is used. + */ + function combination(a:T[], n?:number):IGenerator; + + /** + * Generates the permutation of array with n elements. + * When n is ommited, the length of the array is used. + */ + function permutation(a:T[], n?:number):IGenerator; + + /** + * Generates the permutation of the combination of n. + * Equivalent to permutation(combination(a)), but more efficient. + */ + function permutationCombination(a:T[]):IGenerator; + + /** + * Generates n-digit "numbers" where each digit is an element in array. + * Note this "number" is in the least significant order. + * When n is ommited, the length of the array is used. + */ + function baseN(a:T[], n?:number):IPredictableGenerator; + + /** + * Generates the cartesian product of the arrays. All arguments must be arrays with more than one element. + */ + function cartesianProduct(a1:T1[]):ICartesianProductGenerator<[T1]>; + function cartesianProduct(a1:T1[], a2:T2[]):ICartesianProductGenerator<[T1, T2]>; + function cartesianProduct(a1:T1[], a2:T2[], a3:T3[]):ICartesianProductGenerator<[T1, T2, T3]>; + function cartesianProduct(a1:T1[], a2:T2[], a3:T3[], a4:T4[]):ICartesianProductGenerator<[T1, T2, T3, T4]>; + function cartesianProduct(a1:T1[], a2:T2[], a3:T3[], a4:T4[], a5:T5[]):ICartesianProductGenerator<[T1, T2, T3, T4, T5]>; + function cartesianProduct(a1:T1[], a2:T2[], a3:T3[], a4:T4[], a5:T5[], a6:T6[]):ICartesianProductGenerator<[T1, T2, T3, T4, T5, T6]>; + function cartesianProduct(a1:T1[], a2:T2[], a3:T3[], a4:T4[], a5:T5[], a6:T6[], a7:T7[]):ICartesianProductGenerator<[T1, T2, T3, T4, T5, T6, T7]>; + function cartesianProduct(a1:T1[], a2:T2[], a3:T3[], a4:T4[], a5:T5[], a6:T6[], a7:T7[], a8:T8[]):ICartesianProductGenerator<[T1, T2, T3, T4, T5, T6, T7, T8]>; + function cartesianProduct(a1:T1[], a2:T2[], a3:T3[], a4:T4[], a5:T5[], a6:T6[], a7:T7[], a8:T8[], a9:T9[]):ICartesianProductGenerator<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>; + function cartesianProduct(a1:T1[], a2:T2[], a3:T3[], a4:T4[], a5:T5[], a6:T6[], a7:T7[], a8:T8[], a9:T9[], a10:T10[]):ICartesianProductGenerator<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>; + function cartesianProduct(...a:any[][]):ICartesianProductGenerator; + + const VERSION:string; + +} + +declare module "js-combinatorics" { + export = __Combinatorics; +} diff --git a/jsonwebtoken/jsonwebtoken.d.ts b/jsonwebtoken/jsonwebtoken.d.ts index 205970f6a1..bb74aa8538 100644 --- a/jsonwebtoken/jsonwebtoken.d.ts +++ b/jsonwebtoken/jsonwebtoken.d.ts @@ -22,8 +22,13 @@ declare module "jsonwebtoken" { * - none: No digital signature or MAC value included */ algorithm?: string; - /** @member {number} - Lifetime for the token in minutes */ + /** + *@deprecated - see expiresIn + *@member {number} - Lifetime for the token in minutes + */ expiresInMinutes?: number; + /** @member {string} - Lifetime for the token expressed in a string describing a time span [rauchg/ms](https://github.com/rauchg/ms.js). Eg: `60`, `"2 days"`, `"10h"`, `"7d"` */ + expiresIn?: string; audience?: string; subject?: string; issuer?: string; @@ -33,6 +38,7 @@ declare module "jsonwebtoken" { export interface VerifyOptions { audience?: string; issuer?: string; + maxAge?: string; } export interface VerifyCallbak { diff --git a/jwt-decode/jwt-decode-tests.ts b/jwt-decode/jwt-decode-tests.ts new file mode 100644 index 0000000000..66d639b409 --- /dev/null +++ b/jwt-decode/jwt-decode-tests.ts @@ -0,0 +1,12 @@ + /// +import jwtDecode = require('jwt-decode'); + +let token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJmb28iOiJiYXIiLCJleHAiOjEzOTMyODY4OTMsImlhdCI6MTM5MzI2ODg5M30.4-iaDojEVl0pJQMjrbM1EzUIfAZgsbK_kgnVyVxFSVo"; + +interface TokenDto { + foo: string; + exp: number; + iat: number; +} + +let decodedToken = jwtDecode(token) as TokenDto; diff --git a/jwt-decode/jwt-decode.d.ts b/jwt-decode/jwt-decode.d.ts new file mode 100644 index 0000000000..67d7aac163 --- /dev/null +++ b/jwt-decode/jwt-decode.d.ts @@ -0,0 +1,16 @@ +// Type definitions for jwt-decode v1.4.0 +// Project: https://github.com/auth0/jwt-decode +// Definitions by: Giedrius Grabauskas +// Definitions: https://github.com/borisyankov/DefinitelyTyped + + +declare module JwtDecode { + interface JwtDecodeStatic { + (token: string): any; + } +} + +declare module 'jwt-decode' { + var jwtDecode: JwtDecode.JwtDecodeStatic; + export = jwtDecode; +} diff --git a/leaflet-label/leaflet-label.d.ts b/leaflet-label/leaflet-label.d.ts index a77def73c0..02d94a3214 100644 --- a/leaflet-label/leaflet-label.d.ts +++ b/leaflet-label/leaflet-label.d.ts @@ -56,6 +56,7 @@ declare module L { className?: string; clickable?: boolean; direction?: string; // 'left' | 'right' | 'auto'; + pane?: string; noHide?: boolean; offset?: Point; opacity?: number; diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index bdc08ccdc7..9cae2a8721 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -453,13 +453,58 @@ module TestDropWhile { } // _.fill -var testFillArray = [1, 2, 3]; -var testFillList: _.List = {0: 1, 1: 2, 2: 3, length: 3}; +module TestFill { + let array: number[]; + let list: _.List; -result = _.fill(testFillArray, 'a', 0, 3); -result = <_.List>_.fill(testFillList, 'a', 0, 3); -result = _(testFillArray).fill(0, 0, 3).value(); -result = <_.List>_(testFillList).fill(0, 0, 3).value(); + { + let result: number[]; + + result = _.fill(array, 42); + result = _.fill(array, 42, 0); + result = _.fill(array, 42, 0, 10); + } + + { + let result: _.List; + + result = _.fill(list, 42); + result = _.fill(list, 42, 0); + result = _.fill(list, 42, 0, 10); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(array).fill(42); + result = _(array).fill(42, 0); + result = _(array).fill(42, 0, 10); + } + + { + let result: _.LoDashImplicitObjectWrapper<_.List>; + + result = _(list).fill(42); + result = _(list).fill(42, 0); + result = _(list).fill(42, 0, 10); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(array).chain().fill(42); + result = _(array).chain().fill(42, 0); + result = _(array).chain().fill(42, 0, 10); + } + + { + let result: _.LoDashExplicitObjectWrapper<_.List>; + + result = _(list).chain().fill(42); + result = _(list).chain().fill(42, 0); + result = _(list).chain().fill(42, 0, 10); + } +} // _.findIndex module TestFindIndex { @@ -615,18 +660,40 @@ module TestFlattenDeep { result = _.flattenDeep(recursiveArray); result = _.flattenDeep(listOfMaybeRecursiveArraysOrValues); - - result = _(recursiveArray).flattenDeep().value(); - - result = _(listOfMaybeRecursiveArraysOrValues).flattenDeep().value(); } { - let result: any; + let result: any[]; result = _.flattenDeep(recursiveList); + } - result = _(recursiveList).flattenDeep().value(); + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(recursiveArray).flattenDeep(); + + result = _(listOfMaybeRecursiveArraysOrValues).flattenDeep(); + } + + { + let result: _.LoDashImplicitArrayWrapper; + + result = _(recursiveList).flattenDeep(); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(recursiveArray).chain().flattenDeep(); + + result = _(listOfMaybeRecursiveArraysOrValues).chain().flattenDeep(); + } + + { + let result: _.LoDashExplicitArrayWrapper; + + result = _(recursiveList).chain().flattenDeep(); } } @@ -1164,17 +1231,86 @@ module TestSlice { // _.sortedIndex module TestSortedIndex { - result = _.sortedIndex([20, 30, 50], 40); - result = _.sortedIndex([{ 'x': 20 }, { 'x': 30 }, { 'x': 50 }], { 'x': 40 }, 'x'); - var sortedIndexDict: { wordToNumber: { [idx: string]: number } } = { - 'wordToNumber': { 'twenty': 20, 'thirty': 30, 'fourty': 40, 'fifty': 50 } - }; - result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word: string) { - return sortedIndexDict.wordToNumber[word]; - }); - result = _.sortedIndex(['twenty', 'thirty', 'fifty'], 'fourty', function (word: string) { - return this.wordToNumber[word]; - }, sortedIndexDict); + type SampleType = {a: number; b: string; c: boolean;}; + + let array: SampleType[]; + let list: _.List; + + let value: SampleType; + + let stringIterator: (x: string) => number; + let arrayIterator: (x: SampleType) => number; + let listIterator: (x: SampleType) => number; + + { + let result: number; + + result = _.sortedIndex('', ''); + result = _.sortedIndex('', '', stringIterator); + result = _.sortedIndex('', '', stringIterator, any); + result = _.sortedIndex('', '', stringIterator); + result = _.sortedIndex('', '', stringIterator, any); + + result = _.sortedIndex(array, value); + result = _.sortedIndex(array, value, arrayIterator); + result = _.sortedIndex(array, value, arrayIterator, any); + result = _.sortedIndex(array, value, ''); + result = _.sortedIndex(array, value, {a: 42}); + result = _.sortedIndex(array, value, arrayIterator); + result = _.sortedIndex(array, value, arrayIterator, any); + result = _.sortedIndex<{a: number}, SampleType>(array, value, {a: 42}); + + result = _.sortedIndex(list, value); + result = _.sortedIndex(list, value, listIterator); + result = _.sortedIndex(list, value, listIterator, any); + result = _.sortedIndex(list, value, ''); + result = _.sortedIndex(list, value, {a: 42}); + result = _.sortedIndex(list, value, listIterator); + result = _.sortedIndex(list, value, listIterator, any); + result = _.sortedIndex<{a: number}, SampleType>(list, value, {a: 42}); + + result = _('').sortedIndex(''); + result = _('').sortedIndex('', stringIterator); + result = _('').sortedIndex('', stringIterator, any); + + result = _(array).sortedIndex(value); + result = _(array).sortedIndex(value, arrayIterator); + result = _(array).sortedIndex(value, arrayIterator, any); + result = _(array).sortedIndex(value, ''); + result = _(array).sortedIndex<{a: number}>(value, {a: 42}); + + result = _(list).sortedIndex(value); + result = _(list).sortedIndex(value, listIterator); + result = _(list).sortedIndex(value, listIterator, any); + result = _(list).sortedIndex(value, ''); + result = _(list).sortedIndex(value, {a: 42}); + result = _(list).sortedIndex(value, listIterator); + result = _(list).sortedIndex(value, listIterator, any); + result = _(list).sortedIndex<{a: number}, SampleType>(value, {a: 42}); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _('').chain().sortedIndex(''); + result = _('').chain().sortedIndex('', stringIterator); + result = _('').chain().sortedIndex('', stringIterator, any); + + result = _(array).chain().sortedIndex(value); + result = _(array).chain().sortedIndex(value, arrayIterator); + result = _(array).chain().sortedIndex(value, arrayIterator, any); + result = _(array).chain().sortedIndex(value, ''); + result = _(array).chain().sortedIndex<{a: number}>(value, {a: 42}); + + result = _(list).chain().sortedIndex(value); + result = _(list).chain().sortedIndex(value, listIterator); + result = _(list).chain().sortedIndex(value, listIterator, any); + result = _(list).chain().sortedIndex(value, ''); + result = _(list).chain().sortedIndex(value, {a: 42}); + result = _(list).chain().sortedIndex(value, listIterator); + result = _(list).chain().sortedIndex(value, listIterator, any); + result = _(list).chain().sortedIndex<{a: number}, SampleType>(value, {a: 42}); + } } // _.sortedLastIndex @@ -3396,21 +3532,154 @@ module TestForEachRight { } } -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'); +// _.groupBy +module TestGroupBy { + type SampleType = {a: number; b: string; c: boolean;}; -result = <_.Dictionary>_.groupBy({ prop1: 4.2, prop2: 6.1, prop3: 6.4}, function (num) { return Math.floor(num); }); -result = <_.Dictionary>_.groupBy({ prop1: 4.2, prop2: 6.1, prop3: 6.4}, function (num) { return this.floor(num); }, Math); -result = <_.Dictionary>_.groupBy({ prop1: 'one', prop2: 'two', prop3: 'three'}, 'length'); + let array: SampleType[]; + let list: _.List; + let dictionary: _.Dictionary; -result = <_.Dictionary>_([4.2, 6.1, 6.4]).groupBy(function (num) { return Math.floor(num); }).value(); -result = <_.Dictionary>_([4.2, 6.1, 6.4]).groupBy(function (num) { return this.floor(num); }, Math).value(); -result = <_.Dictionary>_(['one', 'two', 'three']).groupBy('length').value(); + let stringIterator: (char: string, index: number, string: string) => number; + let listIterator: (value: SampleType, index: number, collection: _.List) => number; + let dictionaryIterator: (value: SampleType, key: string, collection: _.Dictionary) => number; -result = <_.Dictionary>_({ prop1: 4.2, prop2: 6.1, prop3: 6.4}).groupBy(function (num) { return Math.floor(num); }).value(); -result = <_.Dictionary>_({ prop1: 4.2, prop2: 6.1, prop3: 6.4}).groupBy(function (num) { return this.floor(num); }, Math).value(); -result = <_.Dictionary>_({ prop1: 'one', prop2: 'two', prop3: 'three'}).groupBy('length').value(); + { + let result: _.Dictionary; + + result = _.groupBy(''); + result = _.groupBy('', stringIterator); + result = _.groupBy('', stringIterator, any); + result = _.groupBy('', stringIterator); + result = _.groupBy('', stringIterator, any); + } + + { + let result: _.Dictionary; + + result = _.groupBy(array); + result = _.groupBy(array, listIterator); + result = _.groupBy(array, listIterator, any); + result = _.groupBy(array, ''); + result = _.groupBy(array, '', any); + result = _.groupBy(array, {a: 42}); + + result = _.groupBy(array, listIterator); + result = _.groupBy(array, listIterator, any); + result = _.groupBy(array, '', true); + result = _.groupBy<{a: number}, SampleType>(array, {a: 42}); + + result = _.groupBy(list); + result = _.groupBy(list, listIterator); + result = _.groupBy(list, listIterator, any); + result = _.groupBy(list, ''); + result = _.groupBy(list, '', any); + result = _.groupBy(list, {a: 42}); + + result = _.groupBy(list, listIterator); + result = _.groupBy(list, listIterator, any); + result = _.groupBy(list, '', true); + result = _.groupBy<{a: number}, SampleType>(list, {a: 42}); + + result = _.groupBy(dictionary); + result = _.groupBy(dictionary, dictionaryIterator); + result = _.groupBy(dictionary, dictionaryIterator, any); + result = _.groupBy(dictionary, ''); + result = _.groupBy(dictionary, '', any); + result = _.groupBy(dictionary, {a: 42}); + + result = _.groupBy(dictionary, dictionaryIterator); + result = _.groupBy(dictionary, dictionaryIterator, any); + result = _.groupBy(dictionary, '', true); + result = _.groupBy<{a: number}, SampleType>(dictionary, {a: 42}); + } + + { + let result: _.LoDashImplicitObjectWrapper<_.Dictionary>; + + result = _('').groupBy(); + result = _('').groupBy(stringIterator); + result = _('').groupBy(stringIterator, any); + } + + { + let result: _.LoDashImplicitObjectWrapper<_.Dictionary>; + + result = _(array).groupBy(); + result = _(array).groupBy(listIterator); + result = _(array).groupBy(listIterator, any); + result = _(array).groupBy(''); + result = _(array).groupBy('', true); + result = _(array).groupBy<{a: number}>({a: 42}); + + result = _(list).groupBy(); + result = _(list).groupBy(listIterator); + result = _(list).groupBy(listIterator, any); + result = _(list).groupBy(''); + result = _(list).groupBy('', any); + result = _(list).groupBy({a: 42}); + + result = _(list).groupBy(listIterator); + result = _(list).groupBy(listIterator, any); + result = _(list).groupBy('', true); + result = _(list).groupBy<{a: number}, SampleType>({a: 42}); + + result = _(dictionary).groupBy(); + result = _(dictionary).groupBy(dictionaryIterator); + result = _(dictionary).groupBy(dictionaryIterator, any); + result = _(dictionary).groupBy(''); + result = _(dictionary).groupBy('', any); + result = _(dictionary).groupBy({a: 42}); + + result = _(dictionary).groupBy(dictionaryIterator); + result = _(dictionary).groupBy(dictionaryIterator, any); + result = _(dictionary).groupBy('', true); + result = _(dictionary).groupBy<{a: number}, SampleType>({a: 42}); + } + + { + let result: _.LoDashExplicitObjectWrapper<_.Dictionary>; + + result = _('').chain().groupBy(); + result = _('').chain().groupBy(stringIterator); + result = _('').chain().groupBy(stringIterator, any); + } + + { + let result: _.LoDashExplicitObjectWrapper<_.Dictionary>; + + result = _(array).chain().groupBy(); + result = _(array).chain().groupBy(listIterator); + result = _(array).chain().groupBy(listIterator, any); + result = _(array).chain().groupBy(''); + result = _(array).chain().groupBy('', true); + result = _(array).chain().groupBy<{a: number}>({a: 42}); + + result = _(list).chain().groupBy(); + result = _(list).chain().groupBy(listIterator); + result = _(list).chain().groupBy(listIterator, any); + result = _(list).chain().groupBy(''); + result = _(list).chain().groupBy('', any); + result = _(list).chain().groupBy({a: 42}); + + result = _(list).chain().groupBy(listIterator); + result = _(list).chain().groupBy(listIterator, any); + result = _(list).chain().groupBy('', true); + result = _(list).chain().groupBy<{a: number}, SampleType>({a: 42}); + + result = _(dictionary).chain().groupBy(); + result = _(dictionary).chain().groupBy(dictionaryIterator); + result = _(dictionary).chain().groupBy(dictionaryIterator, any); + result = _(dictionary).chain().groupBy(''); + result = _(dictionary).chain().groupBy('', any); + result = _(dictionary).chain().groupBy({a: 42}); + + result = _(dictionary).chain().groupBy(dictionaryIterator); + result = _(dictionary).chain().groupBy(dictionaryIterator, any); + result = _(dictionary).chain().groupBy('', true); + result = _(dictionary).chain().groupBy<{a: number}, SampleType>({a: 42}); + } +} // _.include module TestInclude { @@ -4487,11 +4756,39 @@ source.addEventListener('message', <_.LoDashImplicitObjectWrapper>_(fu 'maxWait': 1000 }), false); -var returnedDebounce = _.throttle(function (a: any) { return a * 5; }, 5); -returnedThrottled(4); +// _.defer +module TestDefer { + type SampleFunc = (a: number, b: string) => boolean; -result = _.defer(function () { console.log('deferred'); }); -result = <_.LoDashImplicitWrapper>_(function () { console.log('deferred'); }).defer(); + let func: SampleFunc; + + { + let result: number; + + result = _.defer(func); + result = _.defer(func, any); + result = _.defer(func, any, any); + result = _.defer(func, any, any, any); + } + + { + let result: _.LoDashImplicitWrapper; + + result = _(func).defer(); + result = _(func).defer(any); + result = _(func).defer(any, any); + result = _(func).defer(any, any, any); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(func).chain().defer(); + result = _(func).chain().defer(any); + result = _(func).chain().defer(any, any); + result = _(func).chain().defer(any, any, any); + } +} // _.delay module TestDelay { @@ -4573,9 +4870,6 @@ result = _.memoize(testMemoizeFn, te result = (_(testMemoizeFn).memoize().value()); result = (_(testMemoizeFn).memoize(testMemoizeResolverFn).value()); -var returnedMemoize = _.throttle(function (a: any) { return a * 5; }, 5); -returnedMemoize(4); - // _.modArgs module TestModArgs { type Func1 = (a: boolean) => boolean; @@ -4670,9 +4964,6 @@ module TestOnce { } } -var returnedOnce = _.throttle(function (a: any) { return a * 5; }, 5); -returnedOnce(4); - var greetPartial = function (greeting: string, name: string) { return greeting + ' ' + name; }; var hi = _.partial(greetPartial, 'hi'); hi('moe'); @@ -4737,15 +5028,49 @@ interface TestSpreadResultFn { result = (_.spread(testSpreadFn))(['fred', 'hello']); result = (_(testSpreadFn).spread().value())(['fred', 'hello']); -var throttled = _.throttle(function () { }, 100); -jQuery(window).on('scroll', throttled); +// _.throttle +module TestThrottle { + interface SampleFunc { + (n: number, s: string): boolean; + } -jQuery('.interactive').on('click', _.throttle(function () { }, 300000, { - 'trailing': false -})); + interface Options { + leading?: boolean; + trailing?: boolean; + } -var returnedThrottled = _.throttle(function (a: any) { return a * 5; }, 5); -returnedThrottled(4); + interface ResultFunc { + (n: number, s: string): boolean; + cancel(): void; + } + + let func: SampleFunc; + let options: Options; + + { + let result: ResultFunc; + + result = _.throttle(func); + result = _.throttle(func, 42); + result = _.throttle(func, 42, options); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _(func).throttle(); + result = _(func).throttle(42); + result = _(func).throttle(42, options); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _(func).chain().throttle(); + result = _(func).chain().throttle(42); + result = _(func).chain().throttle(42, options); + } +} var helloWrap = function (name: string) { return 'hello ' + name; }; var helloWrap2 = _.wrap(helloWrap, function (func) { @@ -5092,10 +5417,25 @@ result = _(Array.prototype.push).isNative(); } // _.isNull -result = _.isNull(any); -result = _(1).isNull(); -result = _([]).isNull(); -result = _({}).isNull(); +module TestIsNull { + { + let result: boolean; + + result = _.isNull(any); + + result = _(1).isNull(); + result = _([]).isNull(); + result = _({}).isNull(); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(1).chain().isNull(); + result = _([]).chain().isNull(); + result = _({}).chain().isNull(); + } +} // _.isNumber result = _.isNumber(any); @@ -6117,10 +6457,9 @@ module TestFindKey { // _.findLastKey module TestFindLastKey { - let result: string; - { let predicateFn: (value: any, key?: string, object?: {}) => boolean; + let result: string; result = _.findLastKey<{a: string;}>({a: ''}); @@ -6147,6 +6486,7 @@ module TestFindLastKey { { let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + let result: string; result = _.findLastKey({a: ''}, predicateFn); result = _.findLastKey({a: ''}, predicateFn, any); @@ -6154,6 +6494,30 @@ module TestFindLastKey { result = _<{a: string;}>({a: ''}).findLastKey(predicateFn); result = _<{a: string;}>({a: ''}).findLastKey(predicateFn, any); } + + { + let predicateFn: (value: any, key?: string, object?: {}) => boolean; + let result: _.LoDashExplicitWrapper; + + result = _<{a: string;}>({a: ''}).chain().findLastKey(); + + result = _<{a: string;}>({a: ''}).chain().findLastKey(predicateFn); + result = _<{a: string;}>({a: ''}).chain().findLastKey(predicateFn, any); + + + result = _<{a: string;}>({a: ''}).chain().findLastKey(''); + result = _<{a: string;}>({a: ''}).chain().findLastKey('', any); + + result = _<{a: string;}>({a: ''}).chain().findLastKey<{a: number;}>({a: 42}); + } + + { + let predicateFn: (value: string, key?: string, collection?: _.Dictionary) => boolean; + let result: _.LoDashExplicitWrapper; + + result = _<{a: string;}>({a: ''}).chain().findLastKey(predicateFn); + result = _<{a: string;}>({a: ''}).chain().findLastKey(predicateFn, any); + } } // _.forIn @@ -6399,12 +6763,30 @@ module TestHas { } // _.invert -{ - let result: TResult; - result = _.invert({}); - result = _.invert({}, true); - result = _({}).invert().value(); - result = _({}).invert(true).value(); +module TestInvert { + { + let result: TResult; + + result = _.invert({}); + result = _.invert({}, true); + + result = _.invert({}); + result = _.invert({}, true); + } + + { + let result: _.LoDashImplicitObjectWrapper; + + result = _({}).invert(); + result = _({}).invert(true); + } + + { + let result: _.LoDashExplicitObjectWrapper; + + result = _({}).chain().invert(); + result = _({}).chain().invert(true); + } } // _.keys diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index ad465c5c39..ed8d72443a 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -749,6 +749,81 @@ declare module _ { ): LoDashExplicitArrayWrapper; } + //_.fill + interface LoDashStatic { + /** + * Fills elements of array with value from start up to, but not including, end. + * + * Note: This method mutates array. + * + * @param array The array to fill. + * @param value The value to fill array with. + * @param start The start position. + * @param end The end position. + * @return Returns array. + */ + fill( + array: any[], + value: T, + start?: number, + end?: number + ): T[]; + + /** + * @see _.fill + */ + fill( + array: List, + value: T, + start?: number, + end?: number + ): List; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.fill + */ + fill( + value: T, + start?: number, + end?: number + ): LoDashImplicitArrayWrapper; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.fill + */ + fill( + value: T, + start?: number, + end?: number + ): LoDashImplicitObjectWrapper>; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.fill + */ + fill( + value: T, + start?: number, + end?: number + ): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.fill + */ + fill( + value: T, + start?: number, + end?: number + ): LoDashExplicitObjectWrapper>; + } + //_.findIndex interface LoDashStatic { /** @@ -1131,14 +1206,28 @@ declare module _ { /** * @see _.flattenDeep */ - flattenDeep(): LoDashImplicitArrayWrapper; + flattenDeep(): LoDashImplicitArrayWrapper; } interface LoDashImplicitObjectWrapper { /** * @see _.flattenDeep */ - flattenDeep(): LoDashImplicitArrayWrapper; + flattenDeep(): LoDashImplicitArrayWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.flattenDeep + */ + flattenDeep(): LoDashExplicitArrayWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.flattenDeep + */ + flattenDeep(): LoDashExplicitArrayWrapper; } //_.head @@ -1842,71 +1931,226 @@ declare module _ { //_.sortedIndex interface LoDashStatic { /** - * Uses a binary search to determine the smallest index at which a value should be inserted - * into a given sorted array in order to maintain the sort order of the array. If a callback - * is provided it will be executed for value and each element of array to compute their sort - * ranking. The callback is bound to thisArg and invoked with one argument; (value). - * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. - * - * If an object is provided for callback the created "_.where" style callback will return - * true for elements that have the properties of the given object, else false. - * @param array The sorted list. - * @param value The value to determine its index within `list`. - * @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 - **/ + * Uses a binary search to determine the lowest index at which value should be inserted into array in order to maintain its sort order. If an iteratee function is provided it’s invoked for value and each element of array to compute their sort ranking. The iteratee is bound to thisArg and invoked with one argument; (value). + * + * If a property name is provided for iteratee the created _.property style callback returns the property value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for elements that have a matching property value, else false. + * + * If an object is provided for iteratee the created _.matches style callback returns true for elements that have the properties of the given object, else false. + * + * @param array The sorted array to inspect. + * @param value The value to evaluate. + * @param iteratee The function invoked per iteration. + * @return The this binding of iteratee. + */ sortedIndex( array: List, value: T, - callback?: (x: T) => TSort, - thisArg?: any): number; + iteratee?: (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 - **/ + * @see _.sortedIndex + */ sortedIndex( array: List, value: T, - pluckValue: string): number; + iteratee?: (x: T) => any, + thisArg?: any + ): number; /** - * @see _.sortedIndex - * @param pluckValue the _.where style callback - **/ - sortedIndex( - array: Array, + * @see _.sortedIndex + */ + sortedIndex( + array: List, value: T, - whereValue: W): number; + iteratee: string + ): number; /** - * @see _.sortedIndex - * @param pluckValue the _.where style callback - **/ + * @see _.sortedIndex + */ sortedIndex( array: List, value: T, - whereValue: W): number; + iteratee: W + ): number; + + /** + * @see _.sortedIndex + */ + sortedIndex( + array: List, + value: T, + iteratee: Object + ): number; + } + + interface LoDashImplicitWrapper { + /** + * @see _.sortedIndex + */ + sortedIndex( + value: string, + iteratee?: (x: string) => TSort, + thisArg?: any + ): number; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee?: (x: T) => TSort, + thisArg?: any + ): number; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: string + ): number; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: W + ): number; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee?: (x: T) => TSort, + thisArg?: any + ): number; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee?: (x: T) => any, + thisArg?: any + ): number; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: string + ): number; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: W + ): number; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: Object + ): number; + } + + interface LoDashExplicitWrapper { + /** + * @see _.sortedIndex + */ + sortedIndex( + value: string, + iteratee?: (x: string) => TSort, + thisArg?: any + ): LoDashExplicitWrapper; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee?: (x: T) => TSort, + thisArg?: any + ): LoDashExplicitWrapper; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: string + ): LoDashExplicitWrapper; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: W + ): LoDashExplicitWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee?: (x: T) => TSort, + thisArg?: any + ): LoDashExplicitWrapper; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee?: (x: T) => any, + thisArg?: any + ): LoDashExplicitWrapper; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: string + ): LoDashExplicitWrapper; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: W + ): LoDashExplicitWrapper; + + /** + * @see _.sortedIndex + */ + sortedIndex( + value: T, + iteratee: Object + ): LoDashExplicitWrapper; } //_.sortedLastIndex @@ -4215,15 +4459,6 @@ declare module _ { //_.each interface LoDashStatic { - /** - * @see _.forEach - */ - each( - collection: string, - iteratee?: StringIterator, - thisArg?: any - ): string; - /** * @see _.forEach */ @@ -4250,6 +4485,24 @@ declare module _ { iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; + + /** + * @see _.forEach + */ + each( + collection: T, + iteratee?: ObjectIterator, + thisArgs?: any + ): T; + + /** + * @see _.forEach + */ + each( + collection: T, + iteratee?: ObjectIterator, + thisArgs?: any + ): T; } interface LoDashImplicitWrapper { @@ -4257,7 +4510,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: StringIterator, + iteratee: ListIterator, thisArg?: any ): LoDashImplicitWrapper; } @@ -4287,7 +4540,7 @@ declare module _ { * @see _.forEach */ each( - iteratee: StringIterator, + iteratee: ListIterator, thisArg?: any ): LoDashExplicitWrapper; } @@ -4314,15 +4567,6 @@ declare module _ { //_.eachRight interface LoDashStatic { - /** - * @see _.forEachRight - */ - eachRight( - collection: string, - iteratee?: StringIterator, - thisArg?: any - ): string; - /** * @see _.forEachRight */ @@ -4349,6 +4593,24 @@ declare module _ { iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; + + /** + * @see _.forEachRight + */ + eachRight( + collection: T, + iteratee?: ObjectIterator, + thisArgs?: any + ): T; + + /** + * @see _.forEachRight + */ + eachRight( + collection: T, + iteratee?: ObjectIterator, + thisArgs?: any + ): T; } interface LoDashImplicitWrapper { @@ -4356,7 +4618,7 @@ declare module _ { * @see _.forEachRight */ eachRight( - iteratee: StringIterator, + iteratee: ListIterator, thisArg?: any ): LoDashImplicitWrapper; } @@ -4386,7 +4648,7 @@ declare module _ { * @see _.forEachRight */ eachRight( - iteratee: StringIterator, + iteratee: ListIterator, thisArg?: any ): LoDashExplicitWrapper; } @@ -4566,55 +4828,6 @@ declare module _ { ): LoDashExplicitWrapper; } - //_.fill - interface LoDashStatic { - /** - * Fills elements of array with value from start up to, but not including, end. - * - * Note: This method mutates array. - * - * @param array (Array): The array to fill. - * @param value (*): The value to fill array with. - * @param [start=0] (number): The start position. - * @param [end=array.length] (number): The end position. - * @return (Array): Returns array. - */ - fill( - array: any[], - value: any, - start?: number, - end?: number): TResult[]; - - /** - * @see _.fill - */ - fill( - array: List, - value: any, - start?: number, - end?: number): List; - } - - interface LoDashImplicitArrayWrapper { - /** - * @see _.fill - */ - fill( - value: TResult, - start?: number, - end?: number): LoDashImplicitArrayWrapper; - } - - interface LoDashImplicitObjectWrapper { - /** - * @see _.fill - */ - fill( - value: TResult, - start?: number, - end?: number): LoDashImplicitObjectWrapper>; - } - //_.filter interface LoDashStatic { /** @@ -5089,15 +5302,6 @@ declare module _ { * @param iteratee The function invoked per iteration. * @param thisArg The this binding of iteratee. */ - forEach( - collection: string, - iteratee?: StringIterator, - thisArg?: any - ): string; - - /** - * @see _.forEach - */ forEach( collection: T[], iteratee?: ListIterator, @@ -5121,6 +5325,24 @@ declare module _ { iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; + + /** + * @see _.forEach + */ + forEach( + collection: T, + iteratee?: ObjectIterator, + thisArgs?: any + ): T; + + /** + * @see _.forEach + */ + forEach( + collection: T, + iteratee?: ObjectIterator, + thisArgs?: any + ): T; } interface LoDashImplicitWrapper { @@ -5128,7 +5350,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: StringIterator, + iteratee: ListIterator, thisArg?: any ): LoDashImplicitWrapper; } @@ -5158,7 +5380,7 @@ declare module _ { * @see _.forEach */ forEach( - iteratee: StringIterator, + iteratee: ListIterator, thisArg?: any ): LoDashExplicitWrapper; } @@ -5194,15 +5416,6 @@ declare module _ { * @param iteratee The function called per iteration. * @param thisArg The this binding of callback. */ - forEachRight( - collection: string, - iteratee?: StringIterator, - thisArg?: any - ): string; - - /** - * @see _.forEachRight - */ forEachRight( collection: T[], iteratee?: ListIterator, @@ -5226,6 +5439,24 @@ declare module _ { iteratee?: DictionaryIterator, thisArg?: any ): Dictionary; + + /** + * @see _.forEachRight + */ + forEachRight( + collection: T, + iteratee?: ObjectIterator, + thisArgs?: any + ): T; + + /** + * @see _.forEachRight + */ + forEachRight( + collection: T, + iteratee?: ObjectIterator, + thisArgs?: any + ): T; } interface LoDashImplicitWrapper { @@ -5233,7 +5464,7 @@ declare module _ { * @see _.forEachRight */ forEachRight( - iteratee: StringIterator, + iteratee: ListIterator, thisArg?: any ): LoDashImplicitWrapper; } @@ -5263,7 +5494,7 @@ declare module _ { * @see _.forEachRight */ forEachRight( - iteratee: StringIterator, + iteratee: ListIterator, thisArg?: any ): LoDashExplicitWrapper; } @@ -5291,130 +5522,257 @@ declare module _ { //_.groupBy interface LoDashStatic { /** - * Creates an object composed of keys generated from the results of running each element - * of a collection through the callback. The corresponding value of each key is an array - * of the elements responsible for generating the key. The callback is bound to thisArg - * and invoked with three arguments; (value, index|key, collection). - * - * If a property name is provided for callback the created "_.pluck" style callback will - * return the property value of the given element. - * If an object is provided for callback the created "_.where" style callback will return - * true for elements that have the properties of the given object, else false - * @param collection The collection to iterate over. - * @param callback The function called per iteration. - * @param thisArg The this binding of callback. - * @return Returns the composed aggregate object. - **/ - groupBy( - collection: Array, - callback?: ListIterator, - thisArg?: any): Dictionary; - - /** - * @see _.groupBy - **/ - groupBy( + * Creates an object composed of keys generated from the results of running each element of collection through + * iteratee. The corresponding value of each key is an array of the elements responsible for generating the + * key. The iteratee is bound to thisArg and invoked with three arguments: + * (value, index|key, collection). + * + * If a property name is provided for iteratee the created _.property style callback returns the property + * value of the given element. + * + * If a value is also provided for thisArg the created _.matchesProperty style callback returns true for + * elements that have a matching property value, else false. + * + * If an object is provided for iteratee the created _.matches style callback returns true for elements that + * have the properties of the given object, else false. + * + * @param collection The collection to iterate over. + * @param iteratee The function invoked per iteration. + * @param thisArg The this binding of iteratee. + * @return Returns the composed aggregate object. + */ + groupBy( collection: List, - callback?: ListIterator, - thisArg?: any): Dictionary; + iteratee?: ListIterator, + thisArg?: any + ): Dictionary; /** - * @see _.groupBy - * @param pluckValue _.pluck style callback - **/ + * @see _.groupBy + */ groupBy( - collection: Array, - pluckValue: string): Dictionary; + collection: List, + iteratee?: ListIterator, + thisArg?: any + ): Dictionary; /** - * @see _.groupBy - * @param pluckValue _.pluck style callback - **/ - groupBy( - 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 - **/ - groupBy( - collection: List, - whereValue: W): Dictionary; - - /** - * @see _.groupBy - **/ - groupBy( + * @see _.groupBy + */ + groupBy( collection: Dictionary, - callback?: DictionaryIterator, - thisArg?: any): Dictionary; + iteratee?: DictionaryIterator, + thisArg?: any + ): Dictionary; /** - * @see _.groupBy - * @param pluckValue _.pluck style callback - **/ - groupBy( - collection: Dictionary, - pluckValue: string): Dictionary; + * @see _.groupBy + */ + groupBy( + collection: Dictionary, + iteratee?: DictionaryIterator, + thisArg?: any + ): Dictionary; /** - * @see _.groupBy - * @param whereValue _.where style callback - **/ - groupBy( - collection: Dictionary, - whereValue: W): Dictionary; + * @see _.groupBy + */ + groupBy( + collection: List|Dictionary, + iteratee?: string, + thisArg?: TValue + ): Dictionary; + + /** + * @see _.groupBy + */ + groupBy( + collection: List|Dictionary, + iteratee?: string, + thisArg?: any + ): Dictionary; + + /** + * @see _.groupBy + */ + groupBy( + collection: List|Dictionary, + iteratee?: TWhere + ): Dictionary; + + /** + * @see _.groupBy + */ + groupBy( + collection: List|Dictionary, + iteratee?: Object + ): Dictionary; + } + + interface LoDashImplicitWrapper { + /** + * @see _.groupBy + */ + groupBy( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitObjectWrapper>; } interface LoDashImplicitArrayWrapper { /** - * @see _.groupBy - **/ - groupBy( - callback: ListIterator, - thisArg?: any): _.LoDashImplicitObjectWrapper<_.Dictionary>; + * @see _.groupBy + */ + groupBy( + iteratee?: ListIterator, + thisArg?: any + ): LoDashImplicitObjectWrapper>; /** - * @see _.groupBy - **/ - groupBy( - pluckValue: string): _.LoDashImplicitObjectWrapper<_.Dictionary>; + * @see _.groupBy + */ + groupBy( + iteratee?: string, + thisArg?: TValue + ): LoDashImplicitObjectWrapper>; /** - * @see _.groupBy - **/ - groupBy( - whereValue: W): _.LoDashImplicitObjectWrapper<_.Dictionary>; + * @see _.groupBy + */ + groupBy( + iteratee?: TWhere + ): LoDashImplicitObjectWrapper>; } interface LoDashImplicitObjectWrapper { /** - * @see _.groupBy - **/ - groupBy( - callback: ListIterator, - thisArg?: any): _.LoDashImplicitObjectWrapper<_.Dictionary>; + * @see _.groupBy + */ + groupBy( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashImplicitObjectWrapper>; /** - * @see _.groupBy - **/ - groupBy( - pluckValue: string): _.LoDashImplicitObjectWrapper<_.Dictionary>; + * @see _.groupBy + */ + groupBy( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashImplicitObjectWrapper>; /** - * @see _.groupBy - **/ - groupBy( - whereValue: W): _.LoDashImplicitObjectWrapper<_.Dictionary>; + * @see _.groupBy + */ + groupBy( + iteratee?: string, + thisArg?: TValue + ): LoDashImplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: string, + thisArg?: any + ): LoDashImplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: TWhere + ): LoDashImplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: Object + ): LoDashImplicitObjectWrapper>; + } + + interface LoDashExplicitWrapper { + /** + * @see _.groupBy + */ + groupBy( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitObjectWrapper>; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.groupBy + */ + groupBy( + iteratee?: ListIterator, + thisArg?: any + ): LoDashExplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: string, + thisArg?: TValue + ): LoDashExplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: TWhere + ): LoDashExplicitObjectWrapper>; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.groupBy + */ + groupBy( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashExplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: ListIterator|DictionaryIterator, + thisArg?: any + ): LoDashExplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: string, + thisArg?: TValue + ): LoDashExplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: string, + thisArg?: any + ): LoDashExplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: TWhere + ): LoDashExplicitObjectWrapper>; + + /** + * @see _.groupBy + */ + groupBy( + iteratee?: Object + ): LoDashExplicitObjectWrapper>; } //_.include @@ -7913,24 +8271,33 @@ declare module _ { //_.defer interface LoDashStatic { /** - * Defers executing the func function until the current call stack has cleared. Additional - * arguments will be provided to func when it is invoked. - * @param func The function to defer. - * @param args Arguments to invoke the function with. - * @return The timer id. - **/ - defer( - func: Function, - ...args: any[]): number; + * Defers invoking the func until the current call stack has cleared. Any additional arguments are provided to + * func when it’s invoked. + * + * @param func The function to defer. + * @param args The arguments to invoke the function with. + * @return Returns the timer id. + */ + defer( + func: T, + ...args: any[] + ): number; } interface LoDashImplicitObjectWrapper { /** - * @see _.defer - **/ + * @see _.defer + */ defer(...args: any[]): LoDashImplicitWrapper; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.defer + */ + defer(...args: any[]): LoDashExplicitWrapper; + } + //_.delay interface LoDashStatic { /** @@ -8359,41 +8726,62 @@ declare module _ { //_.throttle - interface LoDashStatic { - /** - * Creates a function that, when executed, will only call the func function at most once per - * every wait milliseconds. Provide an options object to indicate that func should be invoked - * on the leading and/or trailing edge of the wait timeout. Subsequent calls to the throttled - * function will return the result of the last func call. - * - * Note: If leading and trailing options are true func will be called on the trailing edge of - * the timeout only if the the throttled function is invoked more than once during the wait timeout. - * @param func The function to throttle. - * @param wait The number of milliseconds to throttle executions to. - * @param options The options object. - * @param options.leading Specify execution on the leading edge of the timeout. - * @param options.trailing Specify execution on the trailing edge of the timeout. - * @return The new throttled function. - **/ - throttle( - func: T, - wait: number, - options?: ThrottleSettings): T; - } - interface ThrottleSettings { - /** - * If you'd like to disable the leading-edge call, pass this as false. - **/ + * If you'd like to disable the leading-edge call, pass this as false. + */ leading?: boolean; /** - * If you'd like to disable the execution on the trailing-edge, pass false. - **/ + * If you'd like to disable the execution on the trailing-edge, pass false. + */ trailing?: boolean; } + interface LoDashStatic { + /** + * Creates a throttled function that only invokes func at most once per every wait milliseconds. The throttled + * function comes with a cancel method to cancel delayed invocations. Provide an options object to indicate + * that func should be invoked on the leading and/or trailing edge of the wait timeout. Subsequent calls to + * the throttled function return the result of the last func call. + * + * Note: If leading and trailing options are true, func is invoked on the trailing edge of the timeout only if + * the the throttled function is invoked more than once during the wait timeout. + * + * @param func The function to throttle. + * @param wait The number of milliseconds to throttle invocations to. + * @param options The options object. + * @param options.leading Specify invoking on the leading edge of the timeout. + * @param options.trailing Specify invoking on the trailing edge of the timeout. + * @return Returns the new throttled function. + */ + throttle( + func: T, + wait?: number, + options?: ThrottleSettings + ): T & Cancelable; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.throttle + */ + throttle( + wait?: number, + options?: ThrottleSettings + ): LoDashImplicitObjectWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.throttle + */ + throttle( + wait?: number, + options?: ThrottleSettings + ): LoDashExplicitObjectWrapper; + } + //_.wrap interface LoDashStatic { /** @@ -8919,9 +9307,10 @@ declare module _ { interface LoDashStatic { /** * Checks if value is null. + * * @param value The value to check. * @return Returns true if value is null, else false. - **/ + */ isNull(value?: any): boolean; } @@ -8932,6 +9321,13 @@ declare module _ { isNull(): boolean; } + interface LoDashExplicitWrapperBase { + /** + * see _.isNull + */ + isNull(): LoDashExplicitWrapper; + } + //_.isNumber interface LoDashStatic { /** @@ -10544,6 +10940,39 @@ declare module _ { ): string; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: DictionaryIterator, + thisArg?: any + ): LoDashExplicitWrapper; + + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: ObjectIterator, + thisArg?: any + ): LoDashExplicitWrapper; + + /** + * @see _.findLastKey + */ + findLastKey( + predicate?: string, + thisArg?: any + ): LoDashExplicitWrapper; + + /** + * @see _.findLastKey + */ + findLastKey>( + predicate?: TWhere + ): LoDashExplicitWrapper; + } + //_.forIn interface LoDashStatic { /** @@ -10823,7 +11252,18 @@ declare module _ { * @param multiValue Allow multiple values per key. * @return Returns the new inverted object. */ - invert(object: T, multiValue?: boolean): TResult; + invert( + object: T, + multiValue?: boolean + ): TResult; + + /** + * @see _.invert + */ + invert( + object: Object, + multiValue?: boolean + ): TResult; } interface LoDashImplicitObjectWrapper { @@ -10833,6 +11273,13 @@ declare module _ { invert(multiValue?: boolean): LoDashImplicitObjectWrapper; } + interface LoDashExplicitObjectWrapper { + /** + * @see _.invert + */ + invert(multiValue?: boolean): LoDashExplicitObjectWrapper; + } + //_.keys interface LoDashStatic { /** @@ -13077,6 +13524,10 @@ declare module _ { interface StringRepresentable { toString(): string; } + + interface Cancelable { + cancel(): void; + } } declare module "lodash" { diff --git a/long/long-tests.ts b/long/long-tests.ts index f70835f662..928cc94530 100644 --- a/long/long-tests.ts +++ b/long/long-tests.ts @@ -2,7 +2,7 @@ import Long = require("long"); -var val: dcodeIO.Long; +var val: Long; var n: number = 42; var b: boolean = true; var s: string = "1337"; diff --git a/long/long.d.ts b/long/long.d.ts index 32d773b9d1..492dc3362b 100644 --- a/long/long.d.ts +++ b/long/long.d.ts @@ -1,75 +1,352 @@ -// Type definitions for Long.js v2.2.5 -// Project: https://github.com/dcodeIO/Long.js +// Type definitions for long.js 3.0.2 +// Project: https://github.com/dcodeIO/long.js // Definitions by: Peter Kooijmans // Definitions: https://github.com/borisyankov/DefinitelyTyped +// Definitions by: Denis Cappellin -declare module dcodeIO { - interface LongStatic { - new (low: number, high?: number, unsigned?: boolean): Long; +declare class Long +{ + /** + * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as signed integers. See the from* functions below for more convenient ways of constructing Longs. + */ + constructor( low: number, high?: number, unsigned?: boolean ); - MAX_UNSIGNED_VALUE: Long; - MAX_VALUE: Long; - MIN_VALUE: Long; - NEG_ONE: Long; - ONE: Long; - UONE: Long; - UZERO: Long; - ZERO: Long; + /** + * Maximum unsigned value. + */ + static MAX_UNSIGNED_VALUE: Long; - fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long; - fromInt(value: number, unsigned?: boolean): Long; - fromNumber(value: number, unsigned?: boolean): Long; - fromString(str: string, unsigned?: boolean | number, radix?: number): Long; - fromValue(val: Long | number | string): Long; - isLong(obj: any): boolean; - } + /** + * Maximum signed value. + */ + static MAX_VALUE: Long; - interface Long { - high: number; - low: number; - unsigned: boolean; + /** + * Minimum signed value. + */ + static MIN_VALUE: Long; - add(other: Long | number | string): Long; - and(other: Long | number | string): Long; - compare(other: Long | number | string): number; - div(divisor: Long | number | string): Long; - equals(other: Long | number | string): boolean; - getHighBits(): number; - getHighBitsUnsigned(): number; - getLowBits(): number; - getLowBitsUnsigned(): number; - getNumBitsAbs(): number; - greaterThan(other: Long | number | string): boolean; - greaterThanOrEqual(other: Long | number | string): boolean; - isEven(): boolean; - isNegative(): boolean; - isOdd(): boolean; - isPositive(): boolean; - isZero(): boolean; - lessThan(other: Long | number | string): boolean; - lessThanOrEqual(other: Long | number | string): boolean; - modulo(divisor: Long | number | string): Long; - multiply(multiplier: Long | number | string): Long; - negate(): Long; - not(): Long; - notEquals(other: Long | number | string): boolean; - or(other: Long | number | string): Long; - shiftLeft(numBits: number | Long): Long; - shiftRight(numBits: number | Long): Long; - shiftRightUnsigned(numBits: number | Long): Long; - subtract(other: Long | number | string): Long; - toInt(): number; - toNumber(): number; - toSigned(): Long; - toString(radix?: number): string; - toUnsigned(): Long; - xor(other: Long | number | string): Long; - } + /** + * Signed negative one. + */ + static NEG_ONE: Long; - export var Long: LongStatic; + /** + * Signed one. + */ + static ONE: Long; + + /** + * Unsigned one. + */ + static UONE: Long; + + /** + * Unsigned zero. + */ + static UZERO: Long; + + /** + * Signed zero + */ + static ZERO: Long; + + /** + * The high 32 bits as a signed value. + */ + high: number; + + /** + * The low 32 bits as a signed value. + */ + low: number; + + /** + * Whether unsigned or not. + */ + unsigned: boolean; + + /** + * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits. + */ + static fromBits( lowBits:number, highBits:number, unsigned?:boolean ): Long; + + /** + * Returns a Long representing the given 32 bit integer value. + */ + static fromInt( value: number, unsigned?: boolean ): Long; + + /** + * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned. + */ + static fromNumber( value: number, unsigned?: boolean ): Long; + + /** + * Returns a Long representation of the given string, written using the specified radix. + */ + static fromString( str: string, unsigned?: boolean | number, radix?: number ): Long; + + /** + * Tests if the specified object is a Long. + */ + static isLong( obj: any ): boolean; + + /** + * Converts the specified value to a Long. + */ + static fromValue( val: Long | number | string | {low: number, high: number, unsigned: boolean} ): Long; + + /** + * Returns the sum of this and the specified Long. + */ + add( addend: number | Long | string ): Long; + + /** + * Returns the bitwise AND of this Long and the specified. + */ + and( other: Long | number | string ): Long; + + /** + * Compares this Long's value with the specified's. + */ + compare( other: Long | number | string ): number; + + /** + * Compares this Long's value with the specified's. + */ + comp( other: Long | number | string ): number; + + /** + * Returns this Long divided by the specified. + */ + divide( divisor: Long | number | string ): Long; + + /** + * Returns this Long divided by the specified. + */ + div( divisor: Long | number | string ): Long; + + /** + * Tests if this Long's value equals the specified's. + */ + equals( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value equals the specified's. + */ + eq( other: Long | number | string ): boolean; + + /** + * Gets the high 32 bits as a signed integer. + */ + getHighBits(): number; + + /** + * Gets the high 32 bits as an unsigned integer. + */ + getHighBitsUnsigned(): number; + + /** + * Gets the low 32 bits as a signed integer. + */ + getLowBits(): number; + + /** + * Gets the low 32 bits as an unsigned integer. + */ + getLowBitsUnsigned(): number; + + /** + * Gets the number of bits needed to represent the absolute value of this Long. + */ + getNumBitsAbs(): number; + + /** + * Tests if this Long's value is greater than the specified's. + */ + greaterThan( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is greater than the specified's. + */ + gt( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is greater than or equal the specified's. + */ + greaterThanOrEqual( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is greater than or equal the specified's. + */ + gte( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is even. + */ + isEven(): boolean; + + /** + * Tests if this Long's value is negative. + */ + isNegative(): boolean; + + /** + * Tests if this Long's value is odd. + */ + isOdd(): boolean; + + /** + * Tests if this Long's value is positive. + */ + isPositive(): boolean; + + /** + * Tests if this Long's value equals zero. + */ + isZero(): boolean; + + /** + * Tests if this Long's value is less than the specified's. + */ + lessThan( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is less than the specified's. + */ + lt( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is less than or equal the specified's. + */ + lessThanOrEqual( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value is less than or equal the specified's. + */ + lte( other: Long | number | string ): boolean; + + /** + * Returns this Long modulo the specified. + */ + modulo( other: Long | number | string ): Long; + + /** + * Returns this Long modulo the specified. + */ + mod( other: Long | number | string ): Long; + + /** + * Returns the product of this and the specified Long. + */ + multiply( multiplier: Long | number | string ): Long; + + /** + * Returns the product of this and the specified Long. + */ + mul( multiplier: Long | number | string ): Long; + + /** + * Negates this Long's value. + */ + negate(): Long; + + /** + * Negates this Long's value. + */ + neg(): Long; + + /** + * Returns the bitwise NOT of this Long. + */ + not(): Long; + + /** + * Tests if this Long's value differs from the specified's. + */ + notEquals( other: Long | number | string ): boolean; + + /** + * Tests if this Long's value differs from the specified's. + */ + neq( other: Long | number | string ): boolean; + + /** + * Returns the bitwise OR of this Long and the specified. + */ + or( other: Long | number | string ): Long; + + /** + * Returns this Long with bits shifted to the left by the given amount. + */ + shiftLeft( numBits: number | Long ): Long; + + /** + * Returns this Long with bits shifted to the left by the given amount. + */ + shl( numBits: number | Long ): Long; + + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + */ + shiftRight( numBits: number | Long ): Long; + + /** + * Returns this Long with bits arithmetically shifted to the right by the given amount. + */ + shr( numBits: number | Long ): Long; + + /** + * Returns this Long with bits logically shifted to the right by the given amount. + */ + shiftRightUnsigned( numBits: number | Long ): Long; + + /** + * Returns this Long with bits logically shifted to the right by the given amount. + */ + shru( numBits: number | Long ): Long; + + /** + * Returns the difference of this and the specified Long. + */ + subtract( subtrahend: number | Long | string ): Long; + + /** + * Returns the difference of this and the specified Long. + */ + sub( subtrahend: number | Long |string ): Long; + + /** + * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer. + */ + toInt(): number; + + /** + * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa). + */ + toNumber(): number; + + /** + * Converts this Long to signed. + */ + toSigned(): Long; + + /** + * Converts the Long to a string written in the specified radix. + */ + toString( radix?: number ): string; + + /** + * Converts this Long to unsigned. + */ + toUnsigned(): Long; + + /** + * Returns the bitwise XOR of this Long and the given one. + */ + xor( other: Long | number | string ): Long; } -declare module "long" { - var Long: dcodeIO.LongStatic; +declare module 'long' { export = Long; } \ No newline at end of file diff --git a/material-ui/material-ui.d.ts b/material-ui/material-ui.d.ts index 33ec4ba863..df6a088a7a 100644 --- a/material-ui/material-ui.d.ts +++ b/material-ui/material-ui.d.ts @@ -172,6 +172,7 @@ declare namespace __MaterialUI { interface CardActionsProps extends React.Props { expandable?: boolean; showExpandableButton?: boolean; + style?: React.CSSProperties; } export class CardActions extends React.Component { } @@ -179,6 +180,7 @@ declare namespace __MaterialUI { interface CardExpandableProps extends React.Props { onExpanding?: (isExpanded: boolean) => void; expanded?: boolean; + style?: React.CSSProperties; } export class CardExpandable extends React.Component { } @@ -302,6 +304,7 @@ declare namespace __MaterialUI { size?: number; color?: string; innerStyle?: React.CSSProperties; + style?: React.CSSProperties; } export class CircularProgress extends React.Component { @@ -367,6 +370,7 @@ declare namespace __MaterialUI { actionFocus?: string; autoDetectWindowHeight?: boolean; autoScrollBodyContent?: boolean; + style?: React.CSSProperties; bodyStyle?: React.CSSProperties; contentClassName?: string; contentInnerStyle?: React.CSSProperties; @@ -518,6 +522,7 @@ declare namespace __MaterialUI { menuItemClassName?: string; menuItemClassNameSubheader?: string; menuItemClassNameLink?: string; + style?: React.CSSProperties; } export class LeftNav extends React.Component { } @@ -537,6 +542,7 @@ declare namespace __MaterialUI { subheader?: string; subheaderStyle?: React.CSSProperties; zDepth?: number; + style?: React.CSSProperties; } export class List extends React.Component { } @@ -568,6 +574,7 @@ declare namespace __MaterialUI { primaryText?: React.ReactNode; secondaryText?: React.ReactNode; secondaryTextLines?: number; + style?: React.CSSProperties; } export class ListItem extends React.Component { } @@ -593,6 +600,7 @@ declare namespace __MaterialUI { toggle?: boolean; onTouchTap?: TouchTapEventHandler; isDisabled?: boolean; + style?: React.CSSProperties; // for MenuItems.Types.NESTED items?: MenuItemRequest[]; @@ -609,6 +617,7 @@ declare namespace __MaterialUI { active?: boolean; onItemTap?: ItemTapEventHandler; menuItemStyle?: React.CSSProperties; + style?: React.CSSProperties; } export class Menu extends React.Component { } @@ -628,6 +637,7 @@ declare namespace __MaterialUI { onToggle?: (e: React.MouseEvent, key: number, toggled: boolean) => void; selected?: boolean; active?: boolean; + style?: React.CSSProperties; } export class MenuItem extends React.Component { static Types: { LINK: string, SUBHEADER: string, NESTED: string, } @@ -721,6 +731,7 @@ declare namespace __MaterialUI { size?: number; status?: string; top: number; + style?: React.CSSProperties; } export class RefreshIndicator extends React.Component { } @@ -729,12 +740,14 @@ declare namespace __MaterialUI { interface CircleRippleProps extends React.Props { color?: string; opacity?: number; + style?: React.CSSProperties; } export class CircleRipple extends React.Component { } interface FocusRippleProps extends React.Props { color?: string; + style?: React.CSSProperties; innerStyle?: React.CSSProperties; opacity?: number; show?: boolean; @@ -746,6 +759,7 @@ declare namespace __MaterialUI { centerRipple?: boolean; color?: string; opacity?: number; + style?: React.CSSProperties; } export class TouchRipple extends React.Component { } @@ -798,6 +812,7 @@ declare namespace __MaterialUI { required?: boolean; step?: number; value?: number; + style?: React.CSSProperties; } export class Slider extends React.Component { } @@ -806,6 +821,7 @@ declare namespace __MaterialUI { color?: string; hoverColor?: string; viewBox?: string; + style?: React.CSSProperties; } export class SvgIcon extends React.Component { } @@ -1053,6 +1069,7 @@ declare namespace __MaterialUI { backgroundColor?: string; borderColor?: string; }; + isRtl: boolean; } interface RawTheme { @@ -1080,7 +1097,7 @@ declare namespace __MaterialUI { export var Transitions: Transitions; interface Typography { - textFullBlack:string; + textFullBlack: string; textDarkBlack: string; textLightBlack: string; textMinBlack: string; @@ -1109,6 +1126,7 @@ declare namespace __MaterialUI { onShow?: () => void; onDismiss?: () => void; openOnMount?: boolean; + style?: React.CSSProperties; } export class Snackbar extends React.Component { } @@ -1119,6 +1137,7 @@ declare namespace __MaterialUI { value?: string; selected?: boolean; width?: string; + style?: React.CSSProperties; // Called by Tabs component onActive?: (tab: Tab) => void; @@ -1156,8 +1175,9 @@ declare namespace __MaterialUI { onCellHoverExit?: (row: number, column: number) => void; onRowHover?: (row: number) => void; onRowHoverExit?: (row: number) => void; - onRowSelection?: (selectedRows: number[])=> void; + onRowSelection?: (selectedRows: number[]) => void; selectable?: boolean; + style?: React.CSSProperties; } export class Table extends React.Component { } @@ -1172,17 +1192,19 @@ declare namespace __MaterialUI { onCellHoverExit?: (row: number, column: number) => void; onRowHover?: (row: number) => void; onRowHoverExit?: (row: number) => void; - onRowSelection?: (selectedRows: number[])=> void; + onRowSelection?: (selectedRows: number[]) => void; preScanRows?: boolean; selectable?: boolean; showRowHover?: boolean; stripedRows?: boolean; + style?: React.CSSProperties; } export class TableBody extends React.Component { } interface TableFooterProps extends React.Props { adjustForCheckbox?: boolean; + style?: React.CSSProperties; } export class TableFooter extends React.Component { } @@ -1193,15 +1215,17 @@ declare namespace __MaterialUI { enableSelectAll?: boolean; onSelectAll?: (event: React.MouseEvent) => void; selectAllSelected?: boolean; + style?: React.CSSProperties; } export class TableHeader extends React.Component { } interface TableHeaderColumnProps extends React.Props { columnNumber?: number; - onClick?: (e: React.MouseEvent, column: number) => void; + onClick?: (e: React.MouseEvent, column: number) => void; tooltip?: string; tooltipStyle?: React.CSSProperties; + style?: React.CSSProperties; } export class TableHeaderColumn extends React.Component { } @@ -1219,6 +1243,7 @@ declare namespace __MaterialUI { selectable?: boolean; selected?: boolean; striped?: boolean; + style?: React.CSSProperties; } export class TableRow extends React.Component { } @@ -1228,6 +1253,7 @@ declare namespace __MaterialUI { hoverable?: boolean; onHover?: (e: React.MouseEvent, column: number) => void; onHoverExit?: (e: React.MouseEvent, column: number) => void; + style?: React.CSSProperties; } export class TableRowColumn extends React.Component { } @@ -1311,23 +1337,27 @@ declare namespace __MaterialUI { namespace Toolbar { interface ToolbarProps extends React.Props { + style?: React.CSSProperties; } export class Toolbar extends React.Component { } interface ToolbarGroupProps extends React.Props { float?: string; + style?: React.CSSProperties; } export class ToolbarGroup extends React.Component { } interface ToolbarSeparatorProps extends React.Props { + style?: React.CSSProperties; } export class ToolbarSeparator extends React.Component { } interface ToolbarTitleProps extends React.HTMLAttributes, React.Props { - text?: string; + text?: string; + style?: React.CSSProperties; } export class ToolbarTitle extends React.Component { } @@ -1349,9 +1379,9 @@ declare namespace __MaterialUI { color: string; } interface ColorManipulator { - fade(color: string, amount: string|number): string; - lighten(color: string, amount: string|number): string; - darken(color: string, amount: string|number): string; + fade(color: string, amount: string | number): string; + lighten(color: string, amount: string | number): string; + darken(color: string, amount: string | number): string; contrastRatio(background: string, foreground: string): number; contrastRatioLevel(background: string, foreground: string): ContrastLevel; } @@ -1443,6 +1473,7 @@ declare namespace __MaterialUI { value?: string | Array; width?: string | number; touchTapCloseDelay?: number; + style?: React.CSSProperties; onKeyboardFocus?: React.FocusEventHandler; onItemTouchTap?: (e: TouchTapEvent, item: React.ReactElement) => void; @@ -1462,6 +1493,7 @@ declare namespace __MaterialUI { value?: string | Array; width?: string | number; zDepth?: number; + style?: React.CSSProperties; } export class Menu extends React.Component{ } @@ -1477,6 +1509,7 @@ declare namespace __MaterialUI { rightIcon?: React.ReactElement; secondaryText?: React.ReactNode; value?: string; + style?: React.CSSProperties; onEscKeyDown?: React.KeyboardEventHandler; onItemTouchTap?: (e: TouchTapEvent, item: React.ReactElement) => void; diff --git a/meteor/meteor.d.ts b/meteor/meteor.d.ts index ee6c1db412..222de7ae7d 100644 --- a/meteor/meteor.d.ts +++ b/meteor/meteor.d.ts @@ -616,7 +616,7 @@ declare module Mongo { insert(doc: T, callback?: Function): string; rawCollection(): any; rawDatabase(): any; - remove(selector: Mongo.Selector | Mongo.ObjectID | string, callback?: Function): void; + remove(selector: Mongo.Selector | Mongo.ObjectID | string, callback?: Function): number; update(selector: Mongo.Selector | Mongo.ObjectID | string, modifier: Mongo.Modifier, options?: { multi?: boolean; upsert?: boolean; diff --git a/ng-stomp/ng-stomp-tests.ts b/ng-stomp/ng-stomp-tests.ts new file mode 100644 index 0000000000..4f9092c207 --- /dev/null +++ b/ng-stomp/ng-stomp-tests.ts @@ -0,0 +1,49 @@ +/// +/// + +module ngStompTesting { + + "use strict"; + var ngStompTest = "ngStompTest"; + + class test { + constructor(private ngstomp:ngStomp) { + var connectHeaders ={ + "Auth": "user", + "Accept": "lol" + }; + + ngstomp.connect('/endpoint', connectHeaders) + + + // frame = CONNECTED headers + .then(function (frame) { + + this.subscription = ngstomp.subscribe('/dest', function (payload, headers, res) { + this.payload = payload; + }, { + "headers": "are awesome" + }); + + // Unsubscribe + this.subscription.unsubscribe(); + + // Send message + ngstomp.send('/dest', { + message: 'body' + }, { + priority: 9, + custom: 42 //Custom Headers + }); + + // Disconnect + ngstomp.disconnect(function () { + + }); + }); + } + + } + + angular.module("app").controller(ngStompTest, test); +} \ No newline at end of file diff --git a/ng-stomp/ng-stomp.d.ts b/ng-stomp/ng-stomp.d.ts new file mode 100644 index 0000000000..7cf263eeb6 --- /dev/null +++ b/ng-stomp/ng-stomp.d.ts @@ -0,0 +1,36 @@ +// Type definitions for ngStomp +// Project: https://github.com/beevelop/ng-stomp +// Definitions by: Lukasz Potapczuk +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + + +interface ngStomp { + sock:any; + stomp:any; + debug:any; + off: any; + + setDebug:(callback:Function)=> void; + + connect: (endpoint:string, headers?:Headers)=> angular.IHttpPromise; + + disconnect: (callback:()=>void) => angular.IHttpPromise; + + subscribe: (destination:string, callback:(payload:string, headers:Headers, res:Function)=>void, headers?:Headers, scope?:any) => any; + + unsubscribe: () => any; + + send: (destination:string, body:any, headers:Headers)=> any; + + } + + interface Headers { + [key: string]: any; + } + + + + + + diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index da07b4d07c..6dc63bfb0b 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -2,254 +2,217 @@ "name": "DefinitelyTyped", "version": "0.0.1", "dependencies": { + "assertion-error": { + "version": "1.0.1", + "from": "assertion-error@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.1.tgz" + }, + "balanced-match": { + "version": "0.3.0", + "from": "balanced-match@>=0.3.0 <0.4.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.3.0.tgz" + }, + "bluebird": { + "version": "2.10.2", + "from": "bluebird@>=2.10.1 <3.0.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.2.tgz" + }, + "brace-expansion": { + "version": "1.1.2", + "from": "brace-expansion@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.2.tgz" + }, + "concat-map": { + "version": "0.0.1", + "from": "concat-map@0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" + }, + "core-util-is": { + "version": "1.0.2", + "from": "core-util-is@>=1.0.0 <1.1.0", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz" + }, + "definition-header": { + "version": "0.1.0", + "from": "definition-header@>=0.1.0 <0.2.0", + "resolved": "https://registry.npmjs.org/definition-header/-/definition-header-0.1.0.tgz" + }, "definition-tester": { "version": "0.3.0", "from": "definition-tester@0.3.0", + "resolved": "https://registry.npmjs.org/definition-tester/-/definition-tester-0.3.0.tgz" + }, + "findup-sync": { + "version": "0.3.0", + "from": "findup-sync@>=0.3.0 <0.4.0", + "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz" + }, + "git-wrapper": { + "version": "0.1.1", + "from": "git-wrapper@>=0.1.1 <0.2.0", + "resolved": "https://registry.npmjs.org/git-wrapper/-/git-wrapper-0.1.1.tgz" + }, + "glob": { + "version": "5.0.15", + "from": "glob@>=5.0.14 <6.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz" + }, + "hoek": { + "version": "2.16.3", + "from": "hoek@>=2.2.0 <3.0.0", + "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz" + }, + "inflight": { + "version": "1.0.4", + "from": "inflight@>=1.0.4 <2.0.0", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz" + }, + "inherits": { + "version": "2.0.1", + "from": "inherits@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" + }, + "isarray": { + "version": "0.0.1", + "from": "isarray@0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" + }, + "isemail": { + "version": "1.2.0", + "from": "isemail@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz" + }, + "joi": { + "version": "4.9.0", + "from": "joi@>=4.0.0 <5.0.0", + "resolved": "https://registry.npmjs.org/joi/-/joi-4.9.0.tgz" + }, + "joi-assert": { + "version": "0.0.3", + "from": "joi-assert@0.0.3", + "resolved": "https://registry.npmjs.org/joi-assert/-/joi-assert-0.0.3.tgz" + }, + "jsonparse": { + "version": "0.0.5", + "from": "jsonparse@0.0.5", + "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz" + }, + "JSONStream": { + "version": "0.8.4", + "from": "JSONStream@>=0.8.4 <0.9.0", + "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz" + }, + "lazy.js": { + "version": "0.4.2", + "from": "lazy.js@>=0.4.2 <0.5.0", + "resolved": "https://registry.npmjs.org/lazy.js/-/lazy.js-0.4.2.tgz" + }, + "manticore": { + "version": "0.2.4", + "from": "manticore@>=0.2.4 <0.3.0", + "resolved": "https://registry.npmjs.org/manticore/-/manticore-0.2.4.tgz", "dependencies": { "bluebird": { - "version": "2.10.1", - "from": "bluebird@>=2.10.1 <3.0.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-2.10.1.tgz" - }, - "definition-header": { - "version": "0.1.0", - "from": "definition-header@>=0.1.0 <0.2.0", - "resolved": "https://registry.npmjs.org/definition-header/-/definition-header-0.1.0.tgz", - "dependencies": { - "joi": { - "version": "4.9.0", - "from": "joi@>=4.0.0 <5.0.0", - "resolved": "https://registry.npmjs.org/joi/-/joi-4.9.0.tgz", - "dependencies": { - "hoek": { - "version": "2.16.3", - "from": "hoek@>=2.2.0 <3.0.0", - "resolved": "https://registry.npmjs.org/hoek/-/hoek-2.16.3.tgz" - }, - "topo": { - "version": "1.0.3", - "from": "topo@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/topo/-/topo-1.0.3.tgz" - }, - "isemail": { - "version": "1.2.0", - "from": "isemail@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/isemail/-/isemail-1.2.0.tgz" - }, - "moment": { - "version": "2.10.6", - "from": "moment@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.10.6.tgz" - } - } - }, - "joi-assert": { - "version": "0.0.3", - "from": "joi-assert@0.0.3", - "resolved": "https://registry.npmjs.org/joi-assert/-/joi-assert-0.0.3.tgz", - "dependencies": { - "assertion-error": { - "version": "1.0.1", - "from": "assertion-error@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.1.tgz" - } - } - }, - "parsimmon": { - "version": "0.5.1", - "from": "parsimmon@>=0.5.0 <0.6.0", - "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-0.5.1.tgz", - "dependencies": { - "pjs": { - "version": "5.1.1", - "from": "pjs@>=5.0.0 <6.0.0", - "resolved": "https://registry.npmjs.org/pjs/-/pjs-5.1.1.tgz" - } - } - }, - "xregexp": { - "version": "2.0.0", - "from": "xregexp@>=2.0.0 <2.1.0", - "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz" - } - } - }, - "findup-sync": { - "version": "0.3.0", - "from": "findup-sync@>=0.3.0 <0.4.0", - "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.3.0.tgz" - }, - "git-wrapper": { - "version": "0.1.1", - "from": "git-wrapper@>=0.1.1 <0.2.0", - "resolved": "https://registry.npmjs.org/git-wrapper/-/git-wrapper-0.1.1.tgz" - }, - "glob": { - "version": "5.0.14", - "from": "glob@>=5.0.14 <6.0.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.14.tgz", - "dependencies": { - "inflight": { - "version": "1.0.4", - "from": "inflight@>=1.0.4 <2.0.0", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.4.tgz", - "dependencies": { - "wrappy": { - "version": "1.0.1", - "from": "wrappy@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" - } - } - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@>=2.0.0 <3.0.0", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - }, - "minimatch": { - "version": "2.0.10", - "from": "minimatch@>=2.0.1 <3.0.0", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-2.0.10.tgz", - "dependencies": { - "brace-expansion": { - "version": "1.1.0", - "from": "brace-expansion@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.0.tgz", - "dependencies": { - "balanced-match": { - "version": "0.2.0", - "from": "balanced-match@>=0.2.0 <0.3.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-0.2.0.tgz" - }, - "concat-map": { - "version": "0.0.1", - "from": "concat-map@0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" - } - } - } - } - }, - "once": { - "version": "1.3.2", - "from": "once@>=1.3.0 <2.0.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.3.2.tgz", - "dependencies": { - "wrappy": { - "version": "1.0.1", - "from": "wrappy@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" - } - } - }, - "path-is-absolute": { - "version": "1.0.0", - "from": "path-is-absolute@>=1.0.0 <2.0.0", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" - } - } - }, - "lazy.js": { - "version": "0.4.2", - "from": "lazy.js@>=0.4.2 <0.5.0", - "resolved": "https://registry.npmjs.org/lazy.js/-/lazy.js-0.4.2.tgz" - }, - "manticore": { - "version": "0.2.4", - "from": "manticore@>=0.2.4 <0.3.0", - "resolved": "https://registry.npmjs.org/manticore/-/manticore-0.2.4.tgz", - "dependencies": { - "JSONStream": { - "version": "0.8.4", - "from": "JSONStream@>=0.8.4 <0.9.0", - "resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-0.8.4.tgz", - "dependencies": { - "jsonparse": { - "version": "0.0.5", - "from": "jsonparse@0.0.5", - "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-0.0.5.tgz" - }, - "through": { - "version": "2.3.8", - "from": "through@>=2.2.7 <3.0.0", - "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" - } - } - }, - "bluebird": { - "version": "1.2.4", - "from": "bluebird@>=1.2.4 <2.0.0", - "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-1.2.4.tgz" - }, - "through2": { - "version": "0.5.1", - "from": "through2@>=0.5.1 <0.6.0", - "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz", - "dependencies": { - "readable-stream": { - "version": "1.0.33", - "from": "readable-stream@>=1.0.17 <1.1.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz", - "dependencies": { - "core-util-is": { - "version": "1.0.1", - "from": "core-util-is@>=1.0.0 <1.1.0", - "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.1.tgz" - }, - "isarray": { - "version": "0.0.1", - "from": "isarray@0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz" - }, - "string_decoder": { - "version": "0.10.31", - "from": "string_decoder@>=0.10.0 <0.11.0", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" - }, - "inherits": { - "version": "2.0.1", - "from": "inherits@>=2.0.1 <2.1.0", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz" - } - } - }, - "xtend": { - "version": "3.0.0", - "from": "xtend@>=3.0.0 <3.1.0", - "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz" - } - } - }, - "type-detect": { - "version": "0.1.2", - "from": "type-detect@>=0.1.2 <0.2.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.2.tgz" - } - } - }, - "optimist": { - "version": "0.6.1", - "from": "optimist@>=0.6.1 <0.7.0", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", - "dependencies": { - "wordwrap": { - "version": "0.0.3", - "from": "wordwrap@>=0.0.2 <0.1.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" - }, - "minimist": { - "version": "0.0.10", - "from": "minimist@>=0.0.1 <0.1.0", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz" - } - } + "version": "1.2.4", + "from": "bluebird@>=1.2.4 <2.0.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-1.2.4.tgz" } } }, + "minimatch": { + "version": "3.0.0", + "from": "minimatch@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.0.tgz" + }, + "minimist": { + "version": "0.0.10", + "from": "minimist@>=0.0.1 <0.1.0", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz" + }, + "moment": { + "version": "2.10.6", + "from": "moment@>=2.0.0 <3.0.0", + "resolved": "https://registry.npmjs.org/moment/-/moment-2.10.6.tgz" + }, + "once": { + "version": "1.3.3", + "from": "once@>=1.3.0 <2.0.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.3.3.tgz" + }, + "optimist": { + "version": "0.6.1", + "from": "optimist@>=0.6.1 <0.7.0", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz" + }, + "parsimmon": { + "version": "0.5.1", + "from": "parsimmon@>=0.5.0 <0.6.0", + "resolved": "https://registry.npmjs.org/parsimmon/-/parsimmon-0.5.1.tgz" + }, + "path-is-absolute": { + "version": "1.0.0", + "from": "path-is-absolute@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.0.tgz" + }, + "pjs": { + "version": "5.1.1", + "from": "pjs@>=5.0.0 <6.0.0", + "resolved": "https://registry.npmjs.org/pjs/-/pjs-5.1.1.tgz" + }, + "readable-stream": { + "version": "1.0.33", + "from": "readable-stream@>=1.0.17 <1.1.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.0.33.tgz" + }, + "string_decoder": { + "version": "0.10.31", + "from": "string_decoder@>=0.10.0 <0.11.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz" + }, + "through": { + "version": "2.3.8", + "from": "through@>=2.2.7 <3.0.0", + "resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz" + }, + "through2": { + "version": "0.5.1", + "from": "through2@>=0.5.1 <0.6.0", + "resolved": "https://registry.npmjs.org/through2/-/through2-0.5.1.tgz" + }, + "topo": { + "version": "1.1.0", + "from": "topo@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/topo/-/topo-1.1.0.tgz" + }, + "type-detect": { + "version": "0.1.2", + "from": "type-detect@>=0.1.2 <0.2.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.2.tgz" + }, "typescript": { - "version": "1.6.2", - "from": "typescript@1.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-1.6.2.tgz" + "version": "1.7.3", + "from": "typescript@1.7.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-1.7.3.tgz" + }, + "wordwrap": { + "version": "0.0.3", + "from": "wordwrap@>=0.0.2 <0.1.0", + "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz" + }, + "wrappy": { + "version": "1.0.1", + "from": "wrappy@>=1.0.0 <2.0.0", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz" + }, + "xregexp": { + "version": "2.0.0", + "from": "xregexp@>=2.0.0 <2.1.0", + "resolved": "https://registry.npmjs.org/xregexp/-/xregexp-2.0.0.tgz" + }, + "xtend": { + "version": "3.0.0", + "from": "xtend@>=3.0.0 <3.1.0", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-3.0.0.tgz" } } } diff --git a/p2/p2-tests.ts b/p2/p2-tests.ts new file mode 100644 index 0000000000..63c213321c --- /dev/null +++ b/p2/p2-tests.ts @@ -0,0 +1,45 @@ +/// + +// Create a physics world, where bodies and constraints live +var world = new p2.World({ + gravity:[0, -9.82] +}); + +// Create an empty dynamic body +var circleBody = new p2.Body({ + mass: 5, + position: [0, 10] +}); + +// Add a circle shape to the body. +var circleShape = new p2.Circle({ radius: 1 }); +circleBody.addShape(circleShape); + +// ...and add the body to the world. +// If we don't add it to the world, it won't be simulated. +world.addBody(circleBody); + +// Create an infinite ground plane. +var groundBody = new p2.Body({ + mass: 0 // Setting mass to 0 makes the body static +}); +var groundShape = new p2.Plane(); +groundBody.addShape(groundShape); +world.addBody(groundBody); + +// To get the trajectories of the bodies, +// we must step the world forward in time. +// This is done using a fixed time step size. +var timeStep = 1 / 60; // seconds + +// The "Game loop". Could be replaced by, for example, requestAnimationFrame. +setInterval(function(){ + + // The step method moves the bodies forward in time. + world.step(timeStep); + + // Print the circle position to console. + // Could be replaced by a render call. + console.log("Circle y position: " + circleBody.position[1]); + +}, 1000 * timeStep); diff --git a/p2/p2.d.ts b/p2/p2.d.ts new file mode 100644 index 0000000000..a0e3f8b6af --- /dev/null +++ b/p2/p2.d.ts @@ -0,0 +1,1005 @@ +// Type definitions for p2.js v0.7.1 +// Project: https://github.com/schteppe/p2.js/ +// Definitions by: Clark Stevenson +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module p2 { + + export class AABB { + + constructor(options?: { + upperBound?: number[]; + lowerBound?: number[]; + }); + + setFromPoints(points: number[][], position: number[], angle: number, skinSize: number): void; + copy(aabb: AABB): void; + extend(aabb: AABB): void; + overlaps(aabb: AABB): boolean; + + } + + export class Broadphase { + + static AABB: number; + static BOUNDING_CIRCLE: number; + + static NAIVE: number; + static SAP: number; + + static boundingRadiusCheck(bodyA: Body, bodyB: Body): boolean; + static aabbCheck(bodyA: Body, bodyB: Body): boolean; + static canCollide(bodyA: Body, bodyB: Body): boolean; + + constructor(type: number); + + type: number; + result: Body[]; + world: World; + boundingVolumeType: number; + + setWorld(world: World): void; + getCollisionPairs(world: World): Body[]; + boundingVolumeCheck(bodyA: Body, bodyB: Body): boolean; + + } + + export class GridBroadphase extends Broadphase { + + constructor(options?: { + xmin?: number; + xmax?: number; + ymin?: number; + ymax?: number; + nx?: number; + ny?: number; + }); + + xmin: number; + xmax: number; + ymin: number; + ymax: number; + nx: number; + ny: number; + binsizeX: number; + binsizeY: number; + + } + + export class NativeBroadphase extends Broadphase { + + } + + export class Narrowphase { + + contactEquations: ContactEquation[]; + frictionEquations: FrictionEquation[]; + enableFriction: boolean; + enableEquations: boolean; + slipForce: number; + frictionCoefficient: number; + surfaceVelocity: number; + reuseObjects: boolean; + resuableContactEquations: any[]; + reusableFrictionEquations: any[]; + restitution: number; + stiffness: number; + relaxation: number; + frictionStiffness: number; + frictionRelaxation: number; + enableFrictionReduction: boolean; + contactSkinSize: number; + + collidedLastStep(bodyA: Body, bodyB: Body): boolean; + reset(): void; + createContactEquation(bodyA: Body, bodyB: Body, shapeA: Shape, shapeB: Shape): ContactEquation; + createFrictionFromContact(c: ContactEquation): FrictionEquation; + + } + + export class SAPBroadphase extends Broadphase { + + axisList: Body[]; + axisIndex: number; + + } + + export class Constraint { + + static DISTANCE: number; + static GEAR: number; + static LOCK: number; + static PRISMATIC: number; + static REVOLUTE: number; + + constructor(bodyA: Body, bodyB: Body, type: number, options?: { + collideConnected?: boolean; + wakeUpBodies?: boolean; + }); + + type: number; + equeations: Equation[]; + bodyA: Body; + bodyB: Body; + collideConnected: boolean; + + update(): void; + setStiffness(stiffness: number): void; + setRelaxation(relaxation: number): void; + + } + + export class DistanceConstraint extends Constraint { + + constructor(bodyA: Body, bodyB: Body, type: number, options?: { + collideConnected?: boolean; + wakeUpBodies?: boolean; + distance?: number; + localAnchorA?: number[]; + localAnchorB?: number[]; + maxForce?: number; + }); + + localAnchorA: number[]; + localAnchorB: number[]; + distance: number; + maxForce: number; + upperLimitEnabled: boolean; + upperLimit: number; + lowerLimitEnabled: boolean; + lowerLimit: number; + position: number; + + setMaxForce(f: number): void; + getMaxForce(): number; + + } + + export class GearConstraint extends Constraint { + + constructor(bodyA: Body, bodyB: Body, type: number, options?: { + collideConnected?: boolean; + wakeUpBodies?: boolean; + angle?: number; + ratio?: number; + maxTorque?: number; + }); + + ratio: number; + angle: number; + + setMaxTorque(torque: number): void; + getMaxTorque(): number; + + } + + export class LockConstraint extends Constraint { + + constructor(bodyA: Body, bodyB: Body, type: number, options?: { + collideConnected?: boolean; + wakeUpBodies?: boolean; + localOffsetB?: number[]; + localAngleB?: number; + maxForce?: number; + }); + + setMaxForce(force: number): void; + getMaxForce(): number; + + } + + export class PrismaticConstraint extends Constraint { + + constructor(bodyA: Body, bodyB: Body, type: number, options?: { + collideConnected?: boolean; + wakeUpBodies?: boolean; + maxForce?: number; + localAnchorA?: number[]; + localAnchorB?: number[]; + localAxisA?: number[]; + disableRotationalLock?: boolean; + upperLimit?: number; + lowerLimit?: number; + }); + + localAnchorA: number[]; + localAnchorB: number[]; + localAxisA: number[]; + position: number; + velocity: number; + lowerLimitEnabled: boolean; + upperLimitEnabled: boolean; + lowerLimit: number; + upperLimit: number; + upperLimitEquation: ContactEquation; + lowerLimitEquation: ContactEquation; + motorEquation: Equation; + motorEnabled: boolean; + motorSpeed: number; + + enableMotor(): void; + disableMotor(): void; + setLimits(lower: number, upper: number): void; + + } + + export class RevoluteConstraint extends Constraint { + + constructor(bodyA: Body, bodyB: Body, type: number, options?: { + collideConnected?: boolean; + wakeUpBodies?: boolean; + worldPivot?: number[]; + localPivotA?: number[]; + localPivotB?: number[]; + maxForce?: number; + }); + + pivotA: number[]; + pivotB: number[]; + motorEquation: RotationalVelocityEquation; + motorEnabled: boolean; + angle: number; + lowerLimitEnabled: boolean; + upperLimitEnabled: boolean; + lowerLimit: number; + upperLimit: number; + upperLimitEquation: ContactEquation; + lowerLimitEquation: ContactEquation; + + enableMotor(): void; + disableMotor(): void; + motorIsEnabled(): boolean; + setLimits(lower: number, upper: number): void; + setMotorSpeed(speed: number): void; + getMotorSpeed(): number; + + } + + export class AngleLockEquation extends Equation { + + constructor(bodyA: Body, bodyB: Body, options?: { + angle?: number; + ratio?: number; + }); + + computeGq(): number; + setRatio(ratio: number): number; + setMaxTorque(torque: number): number; + + } + + export class ContactEquation extends Equation { + + constructor(bodyA: Body, bodyB: Body); + + contactPointA: number[]; + penetrationVec: number[]; + contactPointB: number[]; + normalA: number[]; + restitution: number; + firstImpact: boolean; + shapeA: Shape; + shapeB: Shape; + + computeB(a: number, b: number, h: number): number; + + } + + export class Equation { + + static DEFAULT_STIFFNESS: number; + static DEFAULT_RELAXATION: number; + + constructor(bodyA: Body, bodyB: Body, minForce?: number, maxForce?: number); + + minForce: number; + maxForce: number; + bodyA: Body; + bodyB: Body; + stiffness: number; + relaxation: number; + G: number[]; + offset: number; + a: number; + b: number; + epsilon: number; + timeStep: number; + needsUpdate: boolean; + multiplier: number; + relativeVelocity: number; + enabled: boolean; + + gmult(G: number[], vi: number[], wi: number[], vj: number[], wj: number[]): number; + computeB(a: number, b: number, h: number): number; + computeGq(): number; + computeGW(): number; + computeGWlambda(): number; + computeGiMf(): number; + computeGiMGt(): number; + addToWlambda(deltalambda: number): number; + computeInvC(eps: number): number; + + } + + export class FrictionEquation extends Equation { + + constructor(bodyA: Body, bodyB: Body, slipForce: number); + + contactPointA: number[]; + contactPointB: number[]; + t: number[]; + shapeA: Shape; + shapeB: Shape; + frictionCoefficient: number; + + setSlipForce(slipForce: number): number; + getSlipForce(): number; + computeB(a: number, b: number, h: number): number; + + } + + export class RotationalLockEquation extends Equation { + + constructor(bodyA: Body, bodyB: Body, options?: { + angle?: number; + }); + + angle: number; + + computeGq(): number; + + } + + export class RotationalVelocityEquation extends Equation { + + constructor(bodyA: Body, bodyB: Body); + + computeB(a: number, b: number, h: number): number; + + } + + export class EventEmitter { + + on(type: string, listener: Function, context: any): EventEmitter; + has(type: string, listener: Function): boolean; + off(type: string, listener: Function): EventEmitter; + emit(event: any): EventEmitter; + + } + + export class ContactMaterialOptions { + + friction: number; + restitution: number; + stiffness: number; + relaxation: number; + frictionStiffness: number; + frictionRelaxation: number; + surfaceVelocity: number; + + } + + export class ContactMaterial { + + static idCounter: number; + + constructor(materialA: Material, materialB: Material, options?: ContactMaterialOptions); + + id: number; + materialA: Material; + materialB: Material; + friction: number; + restitution: number; + stiffness: number; + relaxation: number; + frictionStuffness: number; + frictionRelaxation: number; + surfaceVelocity: number; + contactSkinSize: number; + + } + + export class Material { + + static idCounter: number; + + constructor(id: number); + + id: number; + + } + + export class vec2 { + + static crossLength(a: number[], b: number[]): number; + static crossVZ(out: number[], vec: number[], zcomp: number): number; + static crossZV(out: number[], zcomp: number, vec: number[]): number; + static rotate(out: number[], a: number[], angle: number): void; + static rotate90cw(out: number[], a: number[]): number; + static centroid(out: number[], a: number[], b: number[], c: number[]): number[]; + static create(): number[]; + static clone(a: number[]): number[]; + static fromValues(x: number, y: number): number[]; + static copy(out: number[], a: number[]): number[]; + static set(out: number[], x: number, y: number): number[]; + static toLocalFrame(out: number[], worldPoint: number[], framePosition: number[], frameAngle: number): void; + static toGlobalFrame(out: number[], localPoint: number[], framePosition: number[], frameAngle: number): void; + static add(out: number[], a: number[], b: number[]): number[]; + static subtract(out: number[], a: number[], b: number[]): number[]; + static sub(out: number[], a: number[], b: number[]): number[]; + static multiply(out: number[], a: number[], b: number[]): number[]; + static mul(out: number[], a: number[], b: number[]): number[]; + static divide(out: number[], a: number[], b: number[]): number[]; + static div(out: number[], a: number[], b: number[]): number[]; + static scale(out: number[], a: number[], b: number): number[]; + static distance(a: number[], b: number[]): number; + static dist(a: number[], b: number[]): number; + static squaredDistance(a: number[], b: number[]): number; + static sqrDist(a: number[], b: number[]): number; + static length(a: number[]): number; + static len(a: number[]): number; + static squaredLength(a: number[]): number; + static sqrLen(a: number[]): number; + static negate(out: number[], a: number[]): number[]; + static normalize(out: number[], a: number[]): number[]; + static dot(a: number[], b: number[]): number; + static str(a: number[]): string; + + } + + export interface BodyOptions { + + mass?: number; + position?: number[]; + velocity?: number[]; + angle?: number; + angularVelocity?: number; + force?: number[]; + angularForce?: number; + fixedRotation?: boolean; + + } + + export class Body extends EventEmitter { + + sleepyEvent: { + type: string; + }; + + sleepEvent: { + type: string; + }; + + wakeUpEvent: { + type: string; + }; + + static DYNAMIC: number; + static STATIC: number; + static KINEMATIC: number; + static AWAKE: number; + static SLEEPY: number; + static SLEEPING: number; + + constructor(options?: BodyOptions); + + id: number; + world: World; + shapes: Shape[]; + mass: number; + invMass: number; + inertia: number; + invInertia: number; + invMassSolve: number; + invInertiaSolve: number; + fixedRotation: number; + position: number[]; + interpolatedPosition: number[]; + interpolatedAngle: number; + previousPosition: number[]; + previousAngle: number; + velocity: number[]; + vlambda: number[]; + wlambda: number[]; + angle: number; + angularVelocity: number; + force: number[]; + angularForce: number; + damping: number; + angularDamping: number; + type: number; + boundingRadius: number; + aabb: AABB; + aabbNeedsUpdate: boolean; + allowSleep: boolean; + wantsToSleep: boolean; + sleepState: number; + sleepSpeedLimit: number; + sleepTimeLimit: number; + gravityScale: number; + collisionResponse: boolean; + + updateSolveMassProperties(): void; + setDensity(density: number): void; + getArea(): number; + getAABB(): AABB; + updateAABB(): void; + updateBoundingRadius(): void; + addShape(shape: Shape, offset?: number[], angle?: number): void; + removeShape(shape: Shape): boolean; + updateMassProperties(): void; + applyForce(force: number[], worldPoint: number[]): void; + toLocalFrame(out: number[], worldPoint: number[]): void; + toWorldFrame(out: number[], localPoint: number[]): void; + fromPolygon(path: number[][], options?: { + optimalDecomp?: boolean; + skipSimpleCheck?: boolean; + removeCollinearPoints?: any; //boolean | number + }): boolean; + adjustCenterOfMass(): void; + setZeroForce(): void; + resetConstraintVelocity(): void; + applyDamping(dy: number): void; + wakeUp(): void; + sleep(): void; + sleepTick(time: number, dontSleep: boolean, dt: number): void; + getVelocityFromPosition(story: number[], dt: number): number[]; + getAngularVelocityFromPosition(timeStep: number): number; + overlaps(body: Body): boolean; + + } + + export class Spring { + + constructor(bodyA: Body, bodyB: Body, options?: { + + stiffness?: number; + damping?: number; + localAnchorA?: number[]; + localAnchorB?: number[]; + worldAnchorA?: number[]; + worldAnchorB?: number[]; + + }); + + stiffness: number; + damping: number; + bodyA: Body; + bodyB: Body; + + applyForce(): void; + + } + + export class LinearSpring extends Spring { + + localAnchorA: number[]; + localAnchorB: number[]; + restLength: number; + + setWorldAnchorA(worldAnchorA: number[]): void; + setWorldAnchorB(worldAnchorB: number[]): void; + getWorldAnchorA(result: number[]): number[]; + getWorldAnchorB(result: number[]): number[]; + applyForce(): void; + + } + + export class RotationalSpring extends Spring { + + constructor(bodyA: Body, bodyB: Body, options?: { + restAngle?: number; + stiffness?: number; + damping?: number; + }); + + restAngle: number; + + } + + export interface CapsuleOptions extends SharedShapeOptions { + + length?: number; + radius?: number; + + } + + export class Capsule extends Shape { + + constructor(options?: CapsuleOptions); + + length: number; + radius: number; + + } + + export interface CircleOptions extends SharedShapeOptions { + + radius?: number; + + } + + export class Circle extends Shape { + + constructor(options?: CircleOptions); + + radius: number; + + } + + export interface ConvexOptions extends SharedShapeOptions { + + length?: number; + radius?: number; + + } + + export class Convex extends Shape { + + static triangleArea(a: number[], b: number[], c: number[]): number; + + constructor(options?: ConvexOptions); + + vertices: number[][]; + axes: number[]; + centerOfMass: number[]; + triangles: number[]; + boundingRadius: number; + + projectOntoLocalAxis(localAxis: number[], result: number[]): void; + projectOntoWorldAxis(localAxis: number[], shapeOffset: number[], shapeAngle: number, result: number[]): void; + + updateCenterOfMass(): void; + + } + + export interface HeightfieldOptions extends SharedShapeOptions { + + heights?: number[]; + minValue?: number; + maxValue?: number; + elementWidth?: number; + + } + + export class Heightfield extends Shape { + + constructor(options?: HeightfieldOptions); + + data: number[]; + maxValue: number; + minValue: number; + elementWidth: number; + + } + + export interface SharedShapeOptions { + + position?: number[]; + angle?: number; + collisionGroup?: number; + collisionResponse?: boolean; + collisionMask?: number; + sensor?: boolean; + + } + + export interface ShapeOptions extends SharedShapeOptions { + + type?: number; + + } + + export class Shape { + + static idCounter: number; + static CIRCLE: number; + static PARTICLE: number; + static PLANE: number; + static CONVEX: number; + static LINE: number; + static BOX: number; + static CAPSULE: number; + static HEIGHTFIELD: number; + + constructor(options?: ShapeOptions); + + type: number; + id: number; + position: number[]; + angle: number; + boundingRadius: number; + collisionGroup: number; + collisionResponse: boolean; + collisionMask: number; + material: Material; + area: number; + sensor: boolean; + + computeMomentOfInertia(mass: number): number; + updateBoundingRadius(): number; + updateArea(): void; + computeAABB(out: AABB, position: number[], angle: number): void; + + } + + export interface LineOptions extends SharedShapeOptions { + + length?: number; + + } + + export class Line extends Shape { + + constructor(options?: LineOptions); + + length: number; + + } + + export class Particle extends Shape { + + constructor(options?: SharedShapeOptions); + + } + + export class Plane extends Shape { + + constructor(options?: SharedShapeOptions); + + } + + export interface BoxOptions { + + width?: number; + height?: number; + + } + + export class Box extends Shape { + + constructor(options?: BoxOptions); + + width: number; + height: number; + + } + + export class Solver extends EventEmitter { + + static GS: number; + static ISLAND: number; + + constructor(options?: {}, type?: number); + + type: number; + equations: Equation[]; + equationSortFunction: Equation; //Equation | boolean + + solve(dy: number, world: World): void; + solveIsland(dy: number, island: Island): void; + sortEquations(): void; + addEquation(eq: Equation): void; + addEquations(eqs: Equation[]): void; + removeEquation(eq: Equation): void; + removeAllEquations(): void; + + } + + export class GSSolver extends Solver { + + constructor(options?: { + iterations?: number; + tolerance?: number; + }); + + iterations: number; + tolerance: number; + useZeroRHS: boolean; + frictionIterations: number; + usedIterations: number; + + solve(h: number, world: World): void; + + } + + export class OverlapKeeper { + + constructor(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Shape); + + shapeA: Shape; + shapeB: Shape; + bodyA: Body; + bodyB: Body; + + tick(): void; + setOverlapping(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Body): void; + bodiesAreOverlapping(bodyA: Body, bodyB: Body): boolean; + set(bodyA: Body, shapeA: Shape, bodyB: Body, shapeB: Shape): void; + + } + + export class TupleDictionary { + + data: number[]; + keys: number[]; + + getKey(id1: number, id2: number): string; + getByKey(key: number): number; + get(i: number, j: number): number; + set(i: number, j: number, value: number): number; + reset(): void; + copy(dict: TupleDictionary): void; + + } + + export class Utils { + + static appendArray(a: Array, b: Array): Array; + static splice(array: Array, index: number, howMany: number): void; + static extend(a: any, b: any): void; + static defaults(options: any, defaults: any): any; + + } + + export class Island { + + equations: Equation[]; + bodies: Body[]; + + reset(): void; + getBodies(result: any): Body[]; + wantsToSleep(): boolean; + sleep(): boolean; + + } + + export class IslandManager extends Solver { + + static getUnvisitedNode(nodes: IslandNode[]): IslandNode; // IslandNode | boolean + + equations: Equation[]; + islands: Island[]; + nodes: IslandNode[]; + + visit(node: IslandNode, bds: Body[], eqs: Equation[]): void; + bfs(root: IslandNode, bds: Body[], eqs: Equation[]): void; + split(world: World): Island[]; + + } + + export class IslandNode { + + constructor(body: Body); + + body: Body; + neighbors: IslandNode[]; + equations: Equation[]; + visited: boolean; + + reset(): void; + + } + + export class World extends EventEmitter { + + postStepEvent: { + type: string; + }; + + addBodyEvent: { + type: string; + }; + + removeBodyEvent: { + type: string; + }; + + addSpringEvent: { + type: string; + }; + + impactEvent: { + type: string; + bodyA: Body; + bodyB: Body; + shapeA: Shape; + shapeB: Shape; + contactEquation: ContactEquation; + }; + + postBroadphaseEvent: { + type: string; + pairs: Body[]; + }; + + beginContactEvent: { + type: string; + shapeA: Shape; + shapeB: Shape; + bodyA: Body; + bodyB: Body; + contactEquations: ContactEquation[]; + }; + + endContactEvent: { + type: string; + shapeA: Shape; + shapeB: Shape; + bodyA: Body; + bodyB: Body; + }; + + preSolveEvent: { + type: string; + contactEquations: ContactEquation[]; + frictionEquations: FrictionEquation[]; + }; + + static NO_SLEEPING: number; + static BODY_SLEEPING: number; + static ISLAND_SLEEPING: number; + + static integrateBody(body: Body, dy: number): void; + + constructor(options?: { + solver?: Solver; + gravity?: number[]; + broadphase?: Broadphase; + islandSplit?: boolean; + doProfiling?: boolean; + }); + + springs: Spring[]; + bodies: Body[]; + solver: Solver; + narrowphase: Narrowphase; + islandManager: IslandManager; + gravity: number[]; + frictionGravity: number; + useWorldGravityAsFrictionGravity: boolean; + useFrictionGravityOnZeroGravity: boolean; + doProfiling: boolean; + lastStepTime: number; + broadphase: Broadphase; + constraints: Constraint[]; + defaultMaterial: Material; + defaultContactMaterial: ContactMaterial; + lastTimeStep: number; + applySpringForces: boolean; + applyDamping: boolean; + applyGravity: boolean; + solveConstraints: boolean; + contactMaterials: ContactMaterial[]; + time: number; + stepping: boolean; + islandSplit: boolean; + emitImpactEvent: boolean; + sleepMode: number; + + addConstraint(c: Constraint): void; + addContactMaterial(contactMaterial: ContactMaterial): void; + removeContactMaterial(cm: ContactMaterial): void; + getContactMaterial(materialA: Material, materialB: Material): ContactMaterial; // ContactMaterial | boolean + removeConstraint(c: Constraint): void; + step(dy: number, timeSinceLastCalled?: number, maxSubSteps?: number): void; + runNarrowphase(np: Narrowphase, bi: Body, si: Shape, xi: any[], ai: number, bj: Body, sj: Shape, xj: any[], aj: number, cm: number, glen: number): void; + addSpring(s: Spring): void; + removeSpring(s: Spring): void; + addBody(body: Body): void; + removeBody(body: Body): void; + getBodyByID(id: number): Body; //Body | boolean + disableBodyCollision(bodyA: Body, bodyB: Body): void; + enableBodyCollision(bodyA: Body, bodyB: Body): void; + clear(): void; + clone(): World; + hitTest(worldPoint: number[], bodies: Body[], precision: number): Body[]; + setGlobalEquationParameters(parameters: { + relaxation?: number; + stiffness?: number; + }): void; + setGlobalStiffness(stiffness: number): void; + setGlobalRelaxation(relaxation: number): void; + } + +} diff --git a/package.json b/package.json index 2b9d019f80..52cc5b7196 100644 --- a/package.json +++ b/package.json @@ -20,22 +20,22 @@ "node": ">= 0.12.0" }, "scripts": { - "test": "./node_modules/.bin/dt --changes", - "changes": "./node_modules/.bin/dt --changes", - "lint": "./node_modules/.bin/dt --lint", - "tscparams": "./node_modules/.bin/dt --tscparams --no-tests --no-headers", - "all": "./node_modules/.bin/dt", - "dry": "./node_modules/.bin/dt --dry --changes", - "list": "./node_modules/.bin/dt --dry --print-files --print-refmap", - "last": "./node_modules/.bin/dt --dry --print-files --print-refmap --changes", - "files": "./node_modules/.bin/dt --dry --print-files", - "refmap": "./node_modules/.bin/dt --dry --print-refmap", - "help": "./node_modules/.bin/dt -h" + "test": "dt --changes", + "changes": "dt --changes", + "lint": "dt --lint", + "tscparams": "dt --tscparams --no-tests --no-headers", + "all": "dt", + "dry": "dt --dry --changes", + "list": "dt --dry --print-files --print-refmap", + "last": "dt --dry --print-files --print-refmap --changes", + "files": "dt --dry --print-files", + "refmap": "dt --dry --print-refmap", + "help": "dt -h" }, "dependencies": { }, "devDependencies": { "definition-tester": "0.3.0", - "typescript": "1.6.2" + "typescript": "1.7.3" } } diff --git a/pako/pako-tests.ts b/pako/pako-tests.ts new file mode 100644 index 0000000000..b364d971ff --- /dev/null +++ b/pako/pako-tests.ts @@ -0,0 +1,17 @@ +/// + +import pako = require("pako"); + +var chunk1 = new Uint8Array([1,2,3,4,5,6,7,8,9]) +var chunk2 = new Uint8Array([10,11,12,13,14,15,16,17,18,19]); + +var deflate = new pako.Deflate({ level: 3}); + +deflate.push(chunk1, false); +deflate.push(chunk2, true); // true -> last chunk + +if (deflate.err) { + throw new Error( deflate.err.toString() ); +} + +console.log(deflate.result); \ No newline at end of file diff --git a/pako/pako.d.ts b/pako/pako.d.ts new file mode 100644 index 0000000000..1b86f81fa9 --- /dev/null +++ b/pako/pako.d.ts @@ -0,0 +1,63 @@ +// Type definitions for pako 0.2.8 +// Project: https://github.com/nodeca/pako +// Definitions by: Denis Cappellin +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module Pako { + + /** + * Compress data with deflate algorithm and options. + */ + export function deflate( data: Uint8Array | Array | string, options?: any ): string; + /** + * The same as deflate, but creates raw data, without wrapper (header and adler32 crc). + */ + export function deflateRaw( data: Uint8Array | Array | string, options?: any ): string; + /** + * The same as deflate, but create gzip wrapper instead of deflate one. + */ + export function gzip( data: Uint8Array | Array | string, options?: any ): string; + /** + * Decompress data with inflate/ungzip and options. Autodetect format via wrapper header + * by default. That's why we don't provide separate ungzip method. + */ + export function inflate( data: Uint8Array | Array | string, options?: any ): Uint8Array; + export function inflate( data: Uint8Array | Array | string, options?: any ): Array; + export function inflate( data: Uint8Array | Array | string, options?: any ): String; + /** + * The same as inflate, but creates raw data, without wrapper (header and adler32 crc). + */ + export function inflateRaw( data: Uint8Array | Array | string, options?: any ): Uint8Array; + export function inflateRaw( data: Uint8Array | Array | string, options?: any ): Array; + export function inflateRaw( data: Uint8Array | Array | string, options?: any ): string; + /** + * Just shortcut to inflate, because it autodetects format by header.content. Done for convenience. + */ + export function ungzip( data: Uint8Array | Array | string, options?: any ): Uint8Array; + export function ungzip( data: Uint8Array | Array | string, options?: any ): Array; + export function ungzip( data: Uint8Array | Array | string, options?: any ): string; + + export class Deflate { + constructor( options?: any ); + err: number; + msg: string; + result: Uint8Array | Array; + onData( chunk: Uint8Array | Array | string ): void; + onEnd( status: number ): void; + push( data: Uint8Array | Array | ArrayBuffer | string, mode?: number | boolean ): boolean; + } + + export class Inflate { + constructor( options?: any ); + err: number; + msg: string; + result: Uint8Array | Array | string; + onData( chunk: Uint8Array | Array | string ): void; + onEnd( status: number ): void; + push( data: Uint8Array | Array | ArrayBuffer | string, mode?: number | boolean ): boolean; + } +} + +declare module 'pako' { + export = Pako; +} diff --git a/q/Q.d.ts b/q/Q.d.ts index 50ee49c52a..ba30b2745a 100644 --- a/q/Q.d.ts +++ b/q/Q.d.ts @@ -206,6 +206,11 @@ declare module Q { * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. */ export function all(promises: IPromise[]): Promise; + + /** + * Returns a promise for the first of an array of promises to become settled. + */ + export function race(promises: IPromise[]): Promise; /** * Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected. diff --git a/query-string/query-string-tests.ts b/query-string/query-string-tests.ts new file mode 100644 index 0000000000..597d270f2e --- /dev/null +++ b/query-string/query-string-tests.ts @@ -0,0 +1,13 @@ +/// + +import qs = require('query-string'); + +qs.stringify({ foo: 'bar' }); +qs.stringify({ foo: 'bar', bar: 'baz' }); + +qs.parse('?foo=bar'); +qs.parse('#foo=bar'); +qs.parse('&foo=bar&foo=baz'); + +qs.extract('http://foo.bar/?abc=def&hij=klm'); +qs.extract('http://foo.bar/?foo=bar'); diff --git a/query-string/query-string.d.ts b/query-string/query-string.d.ts new file mode 100644 index 0000000000..e4d76d0030 --- /dev/null +++ b/query-string/query-string.d.ts @@ -0,0 +1,27 @@ +// Type definitions for query-string v3.0.0 +// Project: https://github.com/sindresorhus/query-string +// Definitions by: Sam Verschueren +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module "query-string" { + /** + * Parse a query string into an object. + * Leading ? or # are ignored, so you can pass location.search or location.hash directly. + * @param str + */ + export function parse(str: string): any; + + /** + * Stringify an object into a query string, sorting the keys. + * + * @param obj + */ + export function stringify(obj: any): string; + + /** + * Extract a query string from a URL that can be passed into .parse(). + * + * @param str + */ + export function extract(str: string): string; +} diff --git a/qunit/qunit-tests.ts b/qunit/qunit-tests.ts index dd0335aedc..9a3486118f 100644 --- a/qunit/qunit-tests.ts +++ b/qunit/qunit-tests.ts @@ -170,6 +170,30 @@ QUnit.module("module A", { } }); +QUnit.module("module with async setup and teardown", { + setup: function (assert) { + var done = assert.async(); + setTimeout(function () { + // prepare something for all following tests + }); + }, + teardown: function (assert) { + // clean up after each test + } +}); + +QUnit.module("module with async setup and teardown", { + beforeEach: function (assert: QUnitAssert) { + var done = assert.async(); + setTimeout(function () { + // prepare something for all following tests + }); + }, + afterEach: function () { + // clean up after each test + } +}); + QUnit.test("a test", function (assert) { function square(x) { diff --git a/qunit/qunit.d.ts b/qunit/qunit.d.ts index fde535a688..98b513b9ae 100644 --- a/qunit/qunit.d.ts +++ b/qunit/qunit.d.ts @@ -148,23 +148,27 @@ interface URLConfigItem { interface LifecycleObject { /** * Runs before each test + * @param assert * @deprecated */ - setup?: () => void; + setup?: (assert: QUnitAssert) => void; /** * Runs after each test + * @param assert * @deprecated */ - teardown?: () => void; + teardown?: (assert: QUnitAssert) => void; /** * Runs before each test + * @param assert */ - beforeEach?: () => void; + beforeEach?: (assert: QUnitAssert) => void; /** * Runs after each test + * @param assert */ - afterEach?: () => void; + afterEach?: (assert: QUnitAssert) => void; /** * Any additional properties on the hooks object will be added to that context. diff --git a/ratelimiter/ratelimiter-tests.ts b/ratelimiter/ratelimiter-tests.ts new file mode 100644 index 0000000000..14d42422e0 --- /dev/null +++ b/ratelimiter/ratelimiter-tests.ts @@ -0,0 +1,17 @@ +/// +/// + +import redis = require('redis'); +import Limiter = require('ratelimiter'); + +let id: string; +let db: redis.RedisClient; +let limit = new Limiter({ id: id, db: db }); + +const str: string = limit.inspect(); + +limit.get((err, limit): void => { + const total: number = limit.total; + const remaining: number = limit.remaining; + const reset: number = limit.reset; +}); diff --git a/ratelimiter/ratelimiter.d.ts b/ratelimiter/ratelimiter.d.ts new file mode 100644 index 0000000000..6e9883dd53 --- /dev/null +++ b/ratelimiter/ratelimiter.d.ts @@ -0,0 +1,59 @@ +// Type definitions for ratelimiter 2.1.1 +// Project: https://github.com/tj/node-ratelimiter +// Definitions by: Aya Morisawa +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare module "ratelimiter" { + import { RedisClient } from 'redis'; + + interface LimiterOption { + /** + * The identifier to limit against (typically a user id) + */ + id: string; + + /** + * Redis connection instance + */ + db: RedisClient; + + /** + * Max requests within duration + */ + max?: number; + + /** + * Duration of limit in milliseconds + */ + duration?: number; + } + + interface LimiterInfo { + /** + * max value + */ + total: number; + + /** + * Number of calls left in current duration without decreasing current get + */ + remaining: number; + + /** + * Time in milliseconds until the end of current duration + */ + reset: number; + } + + class Limiter { + constructor(opts: LimiterOption); + + inspect(): string; + + get(fn: (err: any, info: LimiterInfo) => void): void; + } + + export = Limiter; +} diff --git a/react-native/react-native-tests.tsx b/react-native/react-native-tests.tsx index 2783ebeb08..f2e4cc22f6 100644 --- a/react-native/react-native-tests.tsx +++ b/react-native/react-native-tests.tsx @@ -3,10 +3,8 @@ Note: This must be compiled with the target set to ES6 - The content of index.io.js could be something like - 'use strict'; import { AppRegistry } from 'react-native' @@ -15,11 +13,7 @@ The content of index.io.js could be something like AppRegistry.registerComponent('MopNative', () => Welcome); - - -NOTE: I (Bruno Grieder) complete these definitions as I port the UI Explorer to Typescript -If you are in a hurry for the latest definitions, or are looking for typescript examples, -check https://github.com/bgrieder/RNTSExplorer +For a list of complete Typescript examples: check https://github.com/bgrieder/RNTSExplorer */ diff --git a/react-native/react-native.d.ts b/react-native/react-native.d.ts index 60f8afd1a2..dc6cc5e3c5 100644 --- a/react-native/react-native.d.ts +++ b/react-native/react-native.d.ts @@ -5,24 +5,24 @@ /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // -// These definitions are meant to be used with the TSC compiler target set to ES6 +// USING: these definitions are meant to be used with the TSC compiler target set to ES6 // -// This work is based on an original work made by Bernd Paradies: https://github.com/bparadie +// USAGE EXAMPLES: check the RNTSExplorer project at https://github.com/bgrieder/RNTSExplorer // -// WARNING: this work is very much beta: -// -it is still missing react-native definitions (see below) -// -it re-exports the whole of react 0.14 which may not be what react-native actually does +// CONTRIBUTING: please open pull requests and make sure that the changes do not break RNTSExplorer (they should not) +// Do not hesitate to open a pull request against RNTSExplorer to provide an example for a case not covered by the current App // -// I (Bruno Grieder) complete these definitions as I port the UI Explorer to Typescript -// If you are in a hurry for the latest definitions, check those in https://github.com/bgrieder/RNTSExplorer +// CREDITS: This work is based on an original work made by Bernd Paradies: https://github.com/bparadie // /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// +//so we know what is "original" React import React = __React; -declare namespace ReactNative { +//react-native "extends" react +declare namespace __React { /** @@ -47,7 +47,7 @@ declare namespace ReactNative { // not in lib.es6.d.ts but called by react-native - done(callback?: (value: T) => void): void; + done( callback?: ( value: T ) => void ): void; } export interface PromiseConstructor { @@ -121,6 +121,7 @@ declare namespace ReactNative { // @see lib.es6.d.ts export var Promise: PromiseConstructor; + //TODO: BGR: Replace with ComponentClass ? // node_modules/react-tools/src/classic/class/ReactClass.js export interface ReactClass { // TODO: @@ -135,6 +136,73 @@ declare namespace ReactNative { export type Runnable = ( appParameters: any ) => void; + // Similar to React.SyntheticEvent except for nativeEvent + interface NativeSyntheticEvent { + bubbles: boolean + cancelable: boolean + currentTarget: EventTarget + defaultPrevented: boolean + eventPhase: number + isTrusted: boolean + nativeEvent: T + preventDefault(): void + stopPropagation(): void + target: EventTarget + timeStamp: Date + type: string + } + + export interface NativeTouchEvent { + /** + * Array of all touch events that have changed since the last event + */ + changedTouches: NativeTouchEvent[] + + /** + * The ID of the touch + */ + identifier: string + + /** + * The X position of the touch, relative to the element + */ + locationX: number + + /** + * The Y position of the touch, relative to the element + */ + locationY: number + + /** + * The X position of the touch, relative to the screen + */ + pageX: number + + /** + * The Y position of the touch, relative to the screen + */ + pageY: number + + /** + * The node id of the element receiving the touch event + */ + target: string + + /** + * A time identifier for the touch, useful for velocity calculation + */ + timestamp: number + + /** + * Array of all current touches on the screen + */ + touches : NativeTouchEvent[] + } + + export interface GestureResponderEvent extends NativeSyntheticEvent { + } + + export interface PointProperties { x: number y: number @@ -147,8 +215,23 @@ declare namespace ReactNative { right?: number } + /** + * //FIXME: need to find documentation on which compoenent is a native (i.e. non composite component) + */ export interface NativeComponent { - setNativeProps: (props: Object) => void + setNativeProps: ( props: Object ) => void + } + + /** + * //FIXME: need to find documentation on which component is a TTouchable and can implement that interface + * @see React.DOMAtributes + */ + export interface Touchable { + onTouchStart?: ( event: GestureResponderEvent ) => void + onTouchMove?: ( event: GestureResponderEvent ) => void + onTouchEnd?: ( event: GestureResponderEvent ) => void + onTouchCancel?: ( event: GestureResponderEvent ) => void + onTouchEndCapture?: ( event: GestureResponderEvent ) => void } export type AppConfig = { @@ -583,55 +666,6 @@ declare namespace ReactNative { } - export interface GestureResponderEvent { - nativeEvent : { - /** - * Array of all touch events that have changed since the last event - */ - changedTouches: any[] - - /** - * The ID of the touch - */ - identifier: string - - /** - * The X position of the touch, relative to the element - */ - locationX: number - - /** - * The Y position of the touch, relative to the element - */ - locationY: number - - /** - * The X position of the touch, relative to the screen - */ - pageX: number - - /** - * The Y position of the touch, relative to the screen - */ - pageY: number - - /** - * The node id of the element receiving the touch event - */ - target: string - - /** - * A time identifier for the touch, useful for velocity calculation - */ - timestamp: number - - /** - * Array of all current touches on the screen - */ - touches : any[] - } - } - /** * Gesture recognition on mobile devices is much more complicated than web. * A touch can go through several phases as the app determines what the user's intention is. @@ -667,12 +701,12 @@ declare namespace ReactNative { /** * Does this view want to become responder on the start of a touch? */ - onStartShouldSetResponder?: (event: GestureResponderEvent) => boolean + onStartShouldSetResponder?: ( event: GestureResponderEvent ) => boolean /** * Called for every touch move on the View when it is not the responder: does this view want to "claim" touch responsiveness? */ - onMoveShouldSetResponder?: (event: GestureResponderEvent) => boolean + onMoveShouldSetResponder?: ( event: GestureResponderEvent ) => boolean /** * If the View returns true and attempts to become the responder, one of the following will happen: @@ -682,12 +716,12 @@ declare namespace ReactNative { * The View is now responding for touch events. * This is the time to highlight and show the user what is happening */ - onResponderGrant?: (event: GestureResponderEvent) => void + onResponderGrant?: ( event: GestureResponderEvent ) => void /** * Something else is the responder right now and will not release it */ - onResponderReject?: (event: GestureResponderEvent) => void + onResponderReject?: ( event: GestureResponderEvent ) => void /** * If the view is responding, the following handlers can be called: @@ -696,25 +730,25 @@ declare namespace ReactNative { /** * The user is moving their finger */ - onResponderMove?: (event: GestureResponderEvent) => void + onResponderMove?: ( event: GestureResponderEvent ) => void /** * Fired at the end of the touch, ie "touchUp" */ - onResponderRelease?: (event: GestureResponderEvent) => void + onResponderRelease?: ( event: GestureResponderEvent ) => void /** * Something else wants to become responder. * Should this view release the responder? Returning true allows release */ - onResponderTerminationRequest?: (event: GestureResponderEvent) => boolean + onResponderTerminationRequest?: ( event: GestureResponderEvent ) => boolean /** * The responder has been taken from the View. * Might be taken by other views after a call to onResponderTerminationRequest, * or might be taken by the OS without asking (happens with control center/ notification center on iOS) */ - onResponderTerminate?: (event: GestureResponderEvent) => void + onResponderTerminate?: ( event: GestureResponderEvent ) => void /** * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, @@ -729,7 +763,7 @@ declare namespace ReactNative { * So if a parent View wants to prevent the child from becoming responder on a touch start, * it should have a onStartShouldSetResponderCapture handler which returns true. */ - onStartShouldSetResponderCapture?: (event: GestureResponderEvent) => boolean + onStartShouldSetResponderCapture?: ( event: GestureResponderEvent ) => boolean /** * onStartShouldSetResponder and onMoveShouldSetResponder are called with a bubbling pattern, @@ -864,7 +898,7 @@ declare namespace ReactNative { /** * @see https://facebook.github.io/react-native/docs/view.html#props */ - export interface ViewProperties extends ViewPropertiesAndroid, ViewPropertiesIOS, GestureResponderHandlers, React.Props { + export interface ViewProperties extends ViewPropertiesAndroid, ViewPropertiesIOS, GestureResponderHandlers, Touchable, React.Props { /** * Overrides the text that's read by the screen reader when the user interacts with the element. By default, the label is constructed by traversing all the children and accumulating all the Text nodes separated by space. @@ -1680,7 +1714,7 @@ declare namespace ReactNative { showsPointsOfInterest?: boolean } - export interface MapViewProperties extends MapViewPropertiesIOS, React.Props { + export interface MapViewProperties extends MapViewPropertiesIOS, Touchable, React.Props { /** * Map annotations with title/subtitle. @@ -2423,7 +2457,6 @@ declare namespace ReactNative { } - export interface PixelRatioStatic { get(): number; } @@ -2632,7 +2665,7 @@ declare namespace ReactNative { zoomScale?: number } - export interface ScrollViewProperties extends ScrollViewIOSProperties { + export interface ScrollViewProperties extends ScrollViewIOSProperties, Touchable { /** * These styles will be applied to the scroll view content container which @@ -2962,13 +2995,13 @@ declare namespace ReactNative { * eventName is expected to be `change` * //FIXME: No doc - inferred from NetInfo.js */ - addEventListener: (eventName: string, listener: (result: T) => void) => void + addEventListener: ( eventName: string, listener: ( result: T ) => void ) => void /** * eventName is expected to be `change` * //FIXME: No doc - inferred from NetInfo.js */ - removeEventListener: (eventName: string, listener: (result: T) => void) => void + removeEventListener: ( eventName: string, listener: ( result: T ) => void ) => void } /** @@ -2996,30 +3029,6 @@ declare namespace ReactNative { isConnectionMetered: any } - /** - * //FIXME: Documentation ? - */ - export interface PanResponderEvent { - - bubbles: boolean - cancelable: boolean - currentTarget: number - defaultPrevented: boolean - dispatchConfig: any - dispatchMarker: any - eventPhase: any - isDefaultPrevented: () => boolean - isPropagationStopped: () => boolean - isTrusted: boolean - nativeEvent: GestureResponderEvent - path: any - target: number - timeStamp: number - touchHistory: any[] - type: any - - } - export interface PanResponderGestureState { @@ -3083,19 +3092,19 @@ declare namespace ReactNative { * @see documentation of GestureResponderHandlers */ export interface PanResponderCallbacks { - onMoveShouldSetPanResponder?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => boolean - onStartShouldSetPanResponder?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void - onPanResponderGrant?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void - onPanResponderMove?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void - onPanResponderRelease?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void - onPanResponderTerminate?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void + onMoveShouldSetPanResponder?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean + onStartShouldSetPanResponder?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void + onPanResponderGrant?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void + onPanResponderMove?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void + onPanResponderRelease?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void + onPanResponderTerminate?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void - onMoveShouldSetPanResponderCapture?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => boolean - onStartShouldSetPanResponderCapture?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => boolean - onPanResponderReject?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void - onPanResponderStart?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void - onPanResponderEnd?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => void - onPanResponderTerminationRequest?: ( e: PanResponderEvent, gestureState: PanResponderGestureState ) => boolean + onMoveShouldSetPanResponderCapture?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean + onStartShouldSetPanResponderCapture?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean + onPanResponderReject?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void + onPanResponderStart?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void + onPanResponderEnd?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => void + onPanResponderTerminationRequest?: ( e: GestureResponderEvent, gestureState: PanResponderGestureState ) => boolean } export interface PanResponderInstance { @@ -3145,7 +3154,143 @@ declare namespace ReactNative { create( config: PanResponderCallbacks ): PanResponderInstance } + export interface PushNotificationPermissions { + alert?: boolean + badge?: boolean + sound?: boolean + } + export interface PushNotification { + + + /** + * An alias for `getAlert` to get the notification's main message string + */ + getMessage(): string | Object + + /** + * Gets the sound string from the `aps` object + */ + getSound(): string + + /** + * Gets the notification's main message from the `aps` object + */ + getAlert(): string | Object + + /** + * Gets the badge count number from the `aps` object + */ + getBadgeCount(): number + + /** + * Gets the data object on the notif + */ + getData(): Object + + } + + + /** + * Handle push notifications for your app, including permission handling and icon badge number. + * @see https://facebook.github.io/react-native/docs/pushnotificationios.html#content + * + * //FIXME: BGR: The documentation seems completely off compared to the actual js implementation. I could never get the example to run + */ + export interface PushNotificationIOSStatic { + + /** + * Sets the badge number for the app icon on the home screen + */ + setApplicationIconBadgeNumber( number: number ): void + + /** + * Gets the current badge number for the app icon on the home screen + */ + getApplicationIconBadgeNumber( callback: ( badge: number ) => void ): void + + /** + * Attaches a listener to remote notifications while the app is running in the + * foreground or the background. + * + * The handler will get be invoked with an instance of `PushNotificationIOS` + * + * The type MUST be 'notification' + */ + addEventListener( type: string, handler: ( notification: PushNotification ) => void ):void + + /** + * Requests all notification permissions from iOS, prompting the user's + * dialog box. + */ + requestPermissions(): void + + /** + * See what push permissions are currently enabled. `callback` will be + * invoked with a `permissions` object: + * + * - `alert` :boolean + * - `badge` :boolean + * - `sound` :boolean + */ + checkPermissions( callback: ( permissions: PushNotificationPermissions ) => void ): void + + /** + * Removes the event listener. Do this in `componentWillUnmount` to prevent + * memory leaks + */ + removeEventListener( type: string, handler: ( notification: PushNotification ) => void ): void + + /** + * An initial notification will be available if the app was cold-launched + * from a notification. + * + * The first caller of `popInitialNotification` will get the initial + * notification object, or `null`. Subsequent invocations will return null. + */ + popInitialNotification(): PushNotification + } + + + /** + * @enum('default', 'light-content') + */ + export type StatusBarStyle = string + + /** + * @enum('none','fade', 'slide') + */ + type StatusBarAnimation = string + + + /** + * //FIXME: No documentation is available (although this is self explanatory) + * + * @see https://facebook.github.io/react-native/docs/statusbarios.html#content + */ + export interface StatusBarIOSStatic { + + setStyle(style: StatusBarStyle, animated?: boolean): void + + setHidden(hidden: boolean, animation?: StatusBarAnimation): void + + setNetworkActivityIndicatorVisible(visible: boolean): void + } + + /** + * The Vibration API is exposed at VibrationIOS.vibrate(). + * On iOS, calling this function will trigger a one second vibration. + * The vibration is asynchronous so this method will return immediately. + * + * There will be no effect on devices that do not support Vibration, eg. the iOS simulator. + * + * Vibration patterns are currently unsupported. + * + * @see https://facebook.github.io/react-native/docs/vibrationios.html#content + */ + export interface VibrationIOSStatic { + vibrate(): void + } ////////////////////////////////////////////////////////////////////////// // @@ -3248,6 +3393,20 @@ declare namespace ReactNative { export var PanResponder: PanResponderStatic export type PanResponder = PanResponderStatic + export var PushNotificationIOS: PushNotificationIOSStatic + export type PushNotificationIOS = PushNotificationIOSStatic + + export var StatusBarIOS: StatusBarIOSStatic + export type StatusBarIOS = StatusBarIOSStatic + + export var VibrationIOS: VibrationIOSStatic + export type VibrationIOS = VibrationIOSStatic + + + // + // /TODO: BGR: These are leftovers of the initial port that must be revisited + // + export var SegmentedControlIOS: React.ComponentClass export var PixelRatio: PixelRatioStatic @@ -3256,216 +3415,11 @@ declare namespace ReactNative { export type DeviceEventSubscription = DeviceEventSubscriptionStatic export var InteractionManager: InteractionManagerStatic - - - ////////////////////////////////////////////////////////////////////////// - // - // R E A C T - 0 . 1 4 - // - ////////////////////////////////////////////////////////////////////////// - - - export type ReactType = React.ReactType; - - export interface ReactElement

extends React.ReactElement

{} - - export interface ClassicElement

extends React.ClassicElement

{} - - export interface DOMElement

extends React.DOMElement

{} - - export type HTMLElement =React.ReactHTMLElement; - export type SVGElement = React.ReactSVGElement; - - // - // Factories - // ---------------------------------------------------------------------- - - export interface Factory

extends React.Factory

{} - - export interface ClassicFactory

extends React.ClassicFactory

{} - - export interface DOMFactory

extends React.DOMFactory

{} - - export type HTMLFactory = React.HTMLFactory; - export type SVGFactory = React.SVGFactory; - - // - // React Nodes - // http://facebook.github.io/react/docs/glossary.html - // ---------------------------------------------------------------------- - - export type ReactText = React.ReactText; - export type ReactChild = React.ReactChild; - - // Should be Array but type aliases cannot be recursive - export type ReactFragment = React.ReactFragment; - export type ReactNode = React.ReactNode; - - // - // Top Level API - // ---------------------------------------------------------------------- - - export function createClass( spec: React.ComponentSpec ): React.ClassicComponentClass

; - - export function createFactory

( type: string ): React.DOMFactory

; - export function createFactory

( type: React.ClassicComponentClass

| string ): React.ClassicFactory

; - export function createFactory

( type: React.ComponentClass

): React.Factory

; - - export function createElement

( type: string, - props?: P, - ...children: React.ReactNode[] ): React.DOMElement

; - export function createElement

( type: React.ClassicComponentClass

| string, - props?: P, - ...children: React.ReactNode[] ): React.ClassicElement

; - export function createElement

( type: React.ComponentClass

, - props?: P, - ...children: React.ReactNode[] ): React.ReactElement

; - - export function cloneElement

( element: React.DOMElement

, - props?: P, - ...children: React.ReactNode[] ): React.DOMElement

; - export function cloneElement

( element: React.ClassicElement

, - props?: P, - ...children: React.ReactNode[] ): React.ClassicElement

; - export function cloneElement

( element: React.ReactElement

, - props?: P, - ...children: React.ReactNode[] ): React.ReactElement

; - - export function isValidElement( object: {} ): boolean; - - export var DOM: React.ReactDOM; - export var PropTypes: React.ReactPropTypes; - export var Children: React.ReactChildren; - - // - // Component API - // ---------------------------------------------------------------------- - - // Base component for plain JS classes - export class Component extends React.Component {} - - export interface ClassicComponent extends React.ClassicComponent {} - - export interface DOMComponent

extends ClassicComponent { - tagName: string; - } - - export interface ChildContextProvider extends React.ChildContextProvider {} - - // - // Class Interfaces - // ---------------------------------------------------------------------- - - export interface ComponentClass

extends React.ComponentClass

{} - - export interface ClassicComponentClass

extends React.ClassicComponentClass

{} - - // - // Component Specs and Lifecycle - // ---------------------------------------------------------------------- - - export interface ComponentLifecycle extends React.ComponentLifecycle {} - - export interface Mixin extends React.Mixin {} - - export interface ComponentSpec extends React.ComponentSpec {} - - // - // Event System - // ---------------------------------------------------------------------- - - export interface SyntheticEvent extends React.SyntheticEvent {} - - export interface DragEvent extends React.DragEvent {} - - export interface ClipboardEvent extends React.ClipboardEvent {} - - export interface KeyboardEvent extends React.KeyboardEvent {} - - - export interface FocusEvent extends React.FocusEvent {} - - export interface FormEvent extends React.FormEvent {} - - export interface MouseEvent extends React.MouseEvent {} - - export interface TouchEvent extends React.TouchEvent {} - - export interface UIEvent extends React.UIEvent {} - - export interface WheelEvent extends React.WheelEvent {} - - // - // Event Handler Types - // ---------------------------------------------------------------------- - - export interface EventHandler extends React.EventHandler {} - - export interface DragEventHandler extends React.DragEventHandler {} - export interface ClipboardEventHandler extends React.ClipboardEventHandler {} - export interface KeyboardEventHandler extends React.KeyboardEventHandler {} - export interface FocusEventHandler extends React.FocusEventHandler {} - export interface FormEventHandler extends React.FormEventHandler {} - export interface MouseEventHandler extends React.MouseEventHandler {} - export interface TouchEventHandler extends React.TouchEventHandler {} - export interface UIEventHandler extends React.UIEventHandler {} - export interface WheelEventHandler extends React.WheelEventHandler {} - - // - // Props / DOM Attributes - // ---------------------------------------------------------------------- - - export interface Props extends React.Props {} - - export interface DOMAttributes extends React.DOMAttributes {} - - // This interface is not complete. Only properties accepting - // unitless numbers are listed here (see CSSProperty.js in React) - export interface CSSProperties extends React.CSSProperties {} - - export interface HTMLAttributes extends React.HTMLAttributes {} - - export interface SVGAttributes extends React.SVGAttributes {} - - // - // React.DOM - // ---------------------------------------------------------------------- - - export interface ReactDOM extends React.ReactDOM {} - - // - // React.PropTypes - // ---------------------------------------------------------------------- - - export interface Validator extends React.Validator {} - - export interface Requireable extends React.Requireable {} - - export interface ValidationMap extends React.ValidationMap {} - - export interface ReactPropTypes extends React.ReactPropTypes {} - - // - // React.Children - // ---------------------------------------------------------------------- - - export interface ReactChildren extends React.ReactChildren {} - - // - // Browser Interfaces - // https://github.com/nikeee/2048-typescript/blob/master/2048/js/touch.d.ts - // ---------------------------------------------------------------------- - - export interface AbstractView extends React.AbstractView {} - - export interface Touch extends React.Touch {} - - export interface TouchList extends React.TouchList {} - // // Additional ( and controversial) // + ////////////////////////////////////////////////////////////////////////// export function __spread( target: any, ...sources: any[] ): any; @@ -3504,10 +3458,16 @@ declare namespace ReactNative { declare module "react-native" { + import ReactNative = __React export default ReactNative } +declare var global: __React.GlobalStatic +declare function require( name: string ): any + + +//TODO: BGR: this is a left-over from the initial port. Not sure it makes any sense declare module "Dimensions" { import React from 'react-native'; @@ -3518,7 +3478,3 @@ declare module "Dimensions" { var ExportDimensions: Dimensions; export = ExportDimensions; } - -declare var global: ReactNative.GlobalStatic - -declare function require( name: string ): any diff --git a/react-router/react-router.d.ts b/react-router/react-router.d.ts index 7063d2ab66..2010a1f496 100644 --- a/react-router/react-router.d.ts +++ b/react-router/react-router.d.ts @@ -310,6 +310,11 @@ declare module "react-router/lib/useRoutes" { } +declare module "react-router/lib/PatternUtils" { + + export function formatPattern(pattern: string, params: {}): string; + +} declare module "react-router/lib/RouteUtils" { @@ -396,12 +401,33 @@ declare module "react-router" { import { createRoutes } from "react-router/lib/RouteUtils" + import { formatPattern } from "react-router/lib/PatternUtils" + import RoutingContext from "react-router/lib/RoutingContext" import PropTypes from "react-router/lib/PropTypes" import match from "react-router/lib/match" + // PlainRoute is defined in the API documented at: + // https://github.com/rackt/react-router/blob/master/docs/API.md + // but not included in any of the .../lib modules above. + export type PlainRoute = ReactRouter.PlainRoute + + // The following definitions are also very useful to export + // because by using these types lots of potential type errors + // can be exposed: + export type EnterHook = ReactRouter.EnterHook + export type LeaveHook = ReactRouter.LeaveHook + export type ParseQueryString = ReactRouter.ParseQueryString + export type RedirectFunction = ReactRouter.RedirectFunction + export type RouteComponentProps = ReactRouter.RouteComponentProps; + export type RouteHook = ReactRouter.RouteHook + export type StringifyQuery = ReactRouter.StringifyQuery + export type RouterListener = ReactRouter.RouterListener + export type RouterState = ReactRouter.RouterState + export type HistoryBase = ReactRouter.HistoryBase + export { Router, Link, @@ -415,6 +441,7 @@ declare module "react-router" { RouteContext, useRoutes, createRoutes, + formatPattern, RoutingContext, PropTypes, match diff --git a/restangular/restangular-tests.ts b/restangular/restangular-tests.ts index 9b5a9c30b9..dba7099dad 100644 --- a/restangular/restangular-tests.ts +++ b/restangular/restangular-tests.ts @@ -50,7 +50,7 @@ myApp.config((RestangularProvider: restangular.IProvider) => { }); -interface MyAppScope extends ng.IScope { +interface MyAppScope extends angular.IScope { accounts: string[]; allAccounts: any[]; account: any; diff --git a/restangular/restangular.d.ts b/restangular/restangular.d.ts index b09e4affd0..db17e51cf8 100644 --- a/restangular/restangular.d.ts +++ b/restangular/restangular.d.ts @@ -16,30 +16,19 @@ declare module 'restangular' { declare module restangular { - interface IPromise extends ng.IPromise { + interface IPromise extends angular.IPromise { call(methodName: string, params?: any): IPromise; get(fieldName: string): IPromise; $object: T; } - interface ICollectionPromise extends ng.IPromise { + interface ICollectionPromise extends angular.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; - withCredentials?: boolean; - data?: any; - transformRequest?: any; - transformResponse?: any; - timeout?: any; // number | promise - } - interface IResponse { status: number; data: any; @@ -60,14 +49,14 @@ declare module restangular { 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; + setResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: angular.IDeferred) => any): void; + setResponseExtractor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: angular.IDeferred) => any): void; + addResponseInterceptor(responseInterceptor: (data: any, operation: string, what: string, url: string, response: IResponse, deferred: angular.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; + setFullRequestInterceptor(fullRequestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: angular.IRequestShortcutConfig) => {element: any; headers: any; params: any}): void; + addFullRequestInterceptor(requestInterceptor: (element: any, operation: string, what: string, url: string, headers: any, params: any, httpConfig: angular.IRequestShortcutConfig) => {headers: any; params: any; element: any; httpConfig: angular.IRequestShortcutConfig}): void; + setErrorInterceptor(errorInterceptor: (response: IResponse, deferred: angular.IDeferred) => any): void; setRestangularFields(fields: {[fieldName: string]: string}): void; setMethodOverriders(overriders: string[]): void; setJsonp(jsonp: boolean): void; @@ -124,7 +113,7 @@ declare module restangular { clone(): IElement; plain(): any; plain(): T; - withHttpConfig(httpConfig: IRequestConfig): IElement; + withHttpConfig(httpConfig: angular.IRequestShortcutConfig): IElement; save(queryParams?: any, headers?: any): IPromise; getRestangularUrl(): string; } @@ -139,7 +128,7 @@ declare module restangular { options(queryParams?: any, headers?: any): IPromise; patch(queryParams?: any, headers?: any): IPromise; putElement(idx: any, params: any, headers: any): IPromise; - withHttpConfig(httpConfig: IRequestConfig): ICollection; + withHttpConfig(httpConfig: angular.IRequestShortcutConfig): ICollection; clone(): ICollection; plain(): any; plain(): T[]; diff --git a/restify/restify.d.ts b/restify/restify.d.ts index 596637f23c..d3e5e35f83 100644 --- a/restify/restify.d.ts +++ b/restify/restify.d.ts @@ -110,6 +110,7 @@ declare module "restify" { version ?: string; responseTimeHeader ?: string; responseTimeFormatter ?: (durationInMilliseconds: number) => any; + handleUpgrades ?: boolean; } interface ClientOptions { diff --git a/source-map/source-map.d.ts b/source-map/source-map.d.ts index 3ddd49b537..34aae2b6a2 100644 --- a/source-map/source-map.d.ts +++ b/source-map/source-map.d.ts @@ -73,8 +73,8 @@ declare module SourceMap { constructor(line: number, column: number, source: string); constructor(line: number, column: number, source: string, chunk?: string, name?: string); public static fromStringWithSourceMap(code: string, sourceMapConsumer: SourceMapConsumer, relativePath?: string): SourceNode; - public add(chunk: string): void; - public prepend(chunk: string): void; + public add(chunk: any): SourceNode; + public prepend(chunk: any): SourceNode; public setSourceContent(sourceFile: string, sourceContent: string): void; public walk(fn: (chunk: string, mapping: MappedPosition) => void): void; public walkSourceContents(fn: (file: string, content: string) => void): void; diff --git a/superagent/superagent-tests.ts b/superagent/superagent-tests.ts index 466fc33a12..58b6840440 100644 --- a/superagent/superagent-tests.ts +++ b/superagent/superagent-tests.ts @@ -1,17 +1,20 @@ -/// +/// /// // via: http://visionmedia.github.io/superagent/ -import request = require('superagent') -import fs = require('fs'); +import * as request from 'superagent'; +import * as fs from 'fs'; + +// Examples taken from https://github.com/visionmedia/superagent/blob/gh-pages/docs/index.md +// and https://github.com/visionmedia/superagent/blob/master/Readme.md request .post('/api/pet') .send({ name: 'Manny', species: 'cat' }) .set('X-API-Key', 'foobar') .set('Accept', 'application/json') - .end((res: request.Response) => { + .end((err, res) => { if (res.ok) { console.log('yay got ' + JSON.stringify(res.body)); } else { @@ -25,7 +28,7 @@ agent .send({ name: 'Manny', species: 'cat' }) .set('X-API-Key', 'foobar') .set('Accept', 'application/json') - .end((res: request.Response) => { + .end((err, res) => { if (res.error) { console.log('oh no ' + res.error.message); } else { @@ -33,8 +36,19 @@ agent } }); +// Plugins +var nocache = require('superagent-no-cache'); +var prefix = require('superagent-prefix')('/static'); -var callback = (res: request.Response) => {}; +request + .get('/some-url') + .use(prefix) // Prefixes *only* this request + .use(nocache) // Prevents caching of *only* this request + .end(function(err, res){ + // Do something + }); + +var callback = (err: any, res: request.Response) => {}; // Request basics request @@ -44,6 +58,10 @@ request request('GET', '/search') .end(callback); +request + .get('http://example.com/search') + .end(callback); + request .head('/favicon.ico') .end(callback); @@ -100,6 +118,12 @@ request .query('range=1..5') .end(callback); +// HEAD requests +request + .head('/users') + .query({ email: 'joe@smith.com' }) + .end(callback); + // POST / PUT requests request.post('/user') .set('Content-Type', 'application/json') @@ -139,6 +163,7 @@ request.post('/user') request.post('/user') .type('png'); +// Setting Accept request.get('/user') .accept('application/json'); @@ -254,5 +279,3 @@ request .attach('image', 'path/to/tobi.png') .on('error', (err: any) => {}) .end(callback); - - diff --git a/superagent/superagent.d.ts b/superagent/superagent.d.ts index a5118a7645..493d287efb 100644 --- a/superagent/superagent.d.ts +++ b/superagent/superagent.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SuperAgent 0.15.4 +// Type definitions for SuperAgent v1.4.0 // Project: https://github.com/visionmedia/superagent // Definitions by: Alex Varju // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -8,7 +8,7 @@ declare module "superagent" { import stream = require('stream'); - type CallbackHandler = { (err: any, res: request.Response): void; }|{ (res: request.Response): void; }; + type CallbackHandler = (err: any, res: request.Response) => void; var request: request.SuperAgentStatic; @@ -102,6 +102,7 @@ declare module "superagent" { set(field: Object): Req; timeout(ms: number): Req; type(val: string): Req; + use(fn: Function): Req; withCredentials(): Req; write(data: string, encoding?: string): Req; write(data: Buffer, encoding?: string): Req; diff --git a/supertest/supertest-tests.ts b/supertest/supertest-tests.ts index d76c97ea48..5e0de8ad8c 100644 --- a/supertest/supertest-tests.ts +++ b/supertest/supertest-tests.ts @@ -1,8 +1,8 @@ /// /// -import supertest = require('supertest') -import express = require('express'); +import * as supertest from 'supertest'; +import * as express from 'express'; var app = express(); @@ -11,7 +11,7 @@ supertest(app) .expect('Content-Type', /json/) .expect('Content-Length', '20') .expect(201) - .end((err: any, res: supertest.Response) => { + .end((err, res) => { if (err) throw err; }); @@ -56,4 +56,3 @@ function hasPreviousAndNextKeys(res: supertest.Response) { if (!('next' in res.body)) return "missing next key"; if (!('prev' in res.body)) throw new Error("missing prev key"); } - diff --git a/supertest/supertest.d.ts b/supertest/supertest.d.ts index dccbd47c8b..9ca154e2f5 100644 --- a/supertest/supertest.d.ts +++ b/supertest/supertest.d.ts @@ -1,4 +1,4 @@ -// Type definitions for SuperTest 0.14.0 +// Type definitions for SuperTest v1.1.0 // Project: https://github.com/visionmedia/supertest // Definitions by: Alex Varju // Definitions: https://github.com/borisyankov/DefinitelyTyped @@ -8,7 +8,7 @@ declare module "supertest" { import superagent = require('superagent'); - type CallbackHandler = { (err: any, res: supertest.Response): void; }|{ (res: supertest.Response): void; }; + type CallbackHandler = (err: any, res: supertest.Response) => void; function supertest(app: any): supertest.SuperTest; @@ -29,6 +29,7 @@ declare module "supertest" { expect(field: string, val: string, callback?: CallbackHandler): Test; expect(field: string, val: RegExp, callback?: CallbackHandler): Test; expect(checker: (res: Response) => any): Test; + end(callback?: CallbackHandler): Test; } interface Response extends superagent.Response { diff --git a/threejs/three.d.ts b/threejs/three.d.ts index b01c38c63a..fb890afe6a 100644 --- a/threejs/three.d.ts +++ b/threejs/three.d.ts @@ -4588,6 +4588,8 @@ declare module THREE { }; }; + shadowMap: WebGLShadowMapInstance; + /** * Return the WebGL context. */ diff --git a/ui-grid/ui-grid.d.ts b/ui-grid/ui-grid.d.ts index 06d6314c03..e6dd7468d0 100644 --- a/ui-grid/ui-grid.d.ts +++ b/ui-grid/ui-grid.d.ts @@ -3857,7 +3857,7 @@ declare module uiGrid { * defaults to uiGridConstants.filter.INPUT, which gives a text box. If set to uiGridConstants.filter.SELECT * then a select box will be shown with options selectOptions */ - type?: number; + type?: number | string; /** * options in the format [{ value: 1, label: 'male' }]. No i18n filter is provided, you need to perform the i18n * on the values before you provide them @@ -3870,7 +3870,7 @@ declare module uiGrid { disableCancelButton?: boolean; } export interface ISelectOption { - value: number; + value: number | string; label: string; } diff --git a/umzug/umzug-tests.ts b/umzug/umzug-tests.ts new file mode 100644 index 0000000000..95d7521fd3 --- /dev/null +++ b/umzug/umzug-tests.ts @@ -0,0 +1,134 @@ +/// +/// +/// + +import Umzug = require("umzug"); +import Sequelize = require("sequelize"); + + +var umzug = new Umzug({}); + +umzug.up().then(function (result) { + // do something with the result +}); + +umzug.execute({ + migrations: ['some-id', 'some-other-id'], + method: 'up' +}).then(function (migrations) { + // "migrations" will be an Array of all executed/reverted migrations. +}); + +umzug.pending().then(function (migrations) { + // "migrations" will be an Array with the names of + // pending migrations. +}); + +umzug.executed().then(function (migrations) { + // "migrations" will be an Array of already executed migrations. +}); + +umzug.up().then(function (migrations) { + // "migrations" will be an Array with the names of the + // executed migrations. +}); + +umzug.up({ to: '20141101203500-task' }).then(function (migrations) {}); + +umzug.up({ migrations: ['20141101203500-task', '20141101203501-task-2'] }); + +umzug.up('20141101203500-task'); // Runs just the passed migration +umzug.up(['20141101203500-task', '20141101203501-task-2']); + +umzug.down().then(function (migration) { + // "migration" will the name of the reverted migration. +}); + +umzug.down({ to: '20141031080000-task' }).then(function (migrations) { + // "migrations" will be an Array with the names of all reverted migrations. +}); + +umzug.down({ migrations: ['20141101203500-task', '20141101203501-task-2'] }); + +umzug.down('20141101203500-task'); // Runs just the passed migration +umzug.down(['20141101203500-task', '20141101203501-task-2']); + +var AnotherUmzug = new Umzug({ + // The storage. + // Possible values: 'json', 'sequelize', an object + storage: 'json', + + // The options for the storage. + // Check the available storages for further details. + storageOptions: {}, + + // The logging function. + // A function that gets executed everytime migrations start and have ended. + logging: false, + + // The name of the positive method in migrations. + upName: 'up', + + // The name of the negative method in migrations. + downName: 'down', + + migrations: { + // The params that gets passed to the migrations. + // Might be an array or a synchronous function which returns an array. + params: [], + + // The path to the migrations directory. + path: 'migrations', + + // The pattern that determines whether or not a file is a migration. + pattern: /^\d+[\w-]+\.js$/, + + // A function that receives and returns the to be executed function. + // This can be used to modify the function. + wrap: function (fun : Function) { return fun; } + } +}); + +var AnotherUmzug = new Umzug({ + // The storage. + // Possible values: 'json', 'sequelize', an object + storage: 'json', + storageOptions: { + path: process.cwd() + '/db/sequelize-meta.json' + } +}); + +var sequelize = new Sequelize(''); + +var AnotherUmzug = new Umzug({ + // The storage. + // Possible values: 'json', 'sequelize', an object + storage: 'sequelize', + storageOptions: { + // The configured instance of Sequelize. + // Optional if `model` is passed. + sequelize: sequelize, + + // The to be used Sequelize model. + // Must have column name matching `columnName` option + // Optional of `sequelize` is passed. + model: sequelize.define( 'model', {} ), + + // The name of the to be used model. + // Defaults to 'SequelizeMeta' + modelName: 'Schema', + + // The name of table to create if `model` option is not supplied + // Defaults to `modelName` + tableName: 'Schema', + + // The name of table column holding migration name. + // Defaults to 'name'. + columnName: 'migration', + + // The type of the column holding migration name. + // Defaults to `Sequelize.STRING` + columnType: Sequelize.STRING(100) + } + +}); diff --git a/umzug/umzug.d.ts b/umzug/umzug.d.ts new file mode 100644 index 0000000000..2e2b20a7c1 --- /dev/null +++ b/umzug/umzug.d.ts @@ -0,0 +1,188 @@ +// Type definitions for Umzug v1.7.0 +// Project: https://github.com/sequelize/umzug +// Definitions by: Ivan Drinchev +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// + +declare module "umzug" { + + import Sequelize = require("sequelize"); + + interface MigrationOptions { + + /* + * The params that gets passed to the migrations. + * Might be an array or a synchronous function which returns an array. + */ + params?: Array; + + /** The path to the migrations directory. */ + path?: string; + + /** The pattern that determines whether or not a file is a migration. */ + pattern?: RegExp; + + /** + * A function that receives and returns the to be executed function. + * This can be used to modify the function. + */ + wrap?: ( fn : T ) => T; + + } + + interface JSONStorageOptions { + + /** + * The path to the json storage. + * Defaults to process.cwd() + '/umzug.json'; + */ + path?: string; + + } + + interface SequelizeStorageOptions { + + /** + * The configured instance of Sequelize. + * Optional if `model` is passed. + */ + sequelize?: Sequelize.Sequelize; + + /** + * The to be used Sequelize model. + * Must have column name matching `columnName` option + * Optional of `sequelize` is passed. + */ + model?: Sequelize.Model; + + /** + * The name of the to be used model. + * Defaults to 'SequelizeMeta' + */ + modelName?: string; + + /** + * The name of table to create if `model` option is not supplied + * Defaults to `modelName` + */ + tableName?: string; + + /** + * The name of table column holding migration name. + * Defaults to 'name'. + */ + columnName: string; + + /** + * The type of the column holding migration name. + * Defaults to `Sequelize.STRING` + */ + columnType: Sequelize.DataTypeAbstract; + + } + + interface ExecuteOptions { + migrations?: Array; + method?: string; + } + + interface UmzugOptions { + + /** + * The storage. + * Possible values: 'json', 'sequelize', an object + */ + storage?: string; + + /** + * The options for the storage. + */ + storageOptions?: JSONStorageOptions | SequelizeStorageOptions | Object; + + /** + * The logging function. + * A function that gets executed everytime migrations start and have ended. + */ + logging? : boolean | Function; + + /** + * The name of the positive method in migrations. + */ + upName? : string; + + /** + * The name of the negative method in migrations. + */ + downName? : string; + + /** + * Options for defined migration + */ + migrations? : MigrationOptions; + + } + + interface UpDownToOptions { + + /** + * It is also possible to pass the name of a migration in order to + * just run the migrations from the current state to the passed + * migration name. + */ + to: string; + + } + + interface UpDownMigrationsOptions { + + /** + * Running specific migrations while ignoring the right order, can be + * done like this: + */ + migrations: Array; + + } + + class Umzug { + + constructor(options?: UmzugOptions); + + /** + * The execute method is a general purpose function that runs for + * every specified migrations the respective function. + */ + execute(options? : ExecuteOptions) : Promise>; + + /** + * You can get a list of pending/not yet executed migrations like this: + */ + pending() : Promise>; + + /** + * You can get a list of already executed migrations like this: + */ + executed() : Promise>; + + /** + * The up method can be used to execute all pending migrations. + */ + up(migration?: string) : Promise; + up(migrations?: Array) : Promise>; + up(options?: UpDownToOptions | UpDownMigrationsOptions ) : Promise>; + + /** + * The down method can be used to revert the last executed migration. + */ + down(migration?: string) : Promise; + down(migrations?: Array) : Promise>; + down(options?: UpDownToOptions | UpDownMigrationsOptions ) : Promise>; + + } + + var umzug : typeof Umzug; + + export = umzug; + +} diff --git a/wreck/wreck-tests.ts b/wreck/wreck-tests.ts new file mode 100644 index 0000000000..6e7abab0e5 --- /dev/null +++ b/wreck/wreck-tests.ts @@ -0,0 +1,39 @@ +/// + +import Wreck = require('wreck'); + +Wreck.get('https://google.com/', {}, function (err: any, res: any, payload: any) { + /* do stuff */ +}); + + +var method = 'GET'; // GET, POST, PUT, DELETE +var uri = 'https://google.com/'; +var readableStream = Wreck.toReadableStream('foo=bar'); + +var wreck = Wreck.defaults({ + headers: { 'x-foo-bar': 123 } +}); + +// cascading example -- does not alter `wreck` +var wreckWithTimeout = wreck.defaults({ + timeout: 5 +}); + +// all attributes are optional +var options = { + maxBytes: 1048576, // 1 MB, default: unlimited + rejectUnauthorized: true +}; + +var optionalCallback = function (err: any, res: any) { + + /* handle err if it exists, in which case res will be undefined */ + + // buffer the response stream + Wreck.read(res, null, function (err: any, body: any) { + /* do stuff */ + }); +}; + +var req = wreck.request(method, uri, options, optionalCallback); diff --git a/wreck/wreck.d.ts b/wreck/wreck.d.ts new file mode 100644 index 0000000000..8bc7b2d249 --- /dev/null +++ b/wreck/wreck.d.ts @@ -0,0 +1,41 @@ +// Type definitions for wreck 7.0.0 +// Project: https://github.com/hapijs/wreck +// Definitions by: Marcin Porębski +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module "wreck" +{ + import http = require('http'); + import stream = require('stream'); + + + interface WreckObject + { + defaults: (options: any) => WreckObject; + + request: (method: string, uri: string, options: any, callback?: (err: any, response: http.IncomingMessage) => void) => http.ClientRequest; + + read: (response: http.IncomingMessage, options: any, callback: (err: any, payload: any) => void) => void; + + get: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + post: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + patch: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + put: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + delete: (uri: string, options: any, callback: (err: any, response: http.IncomingMessage, payload: any) => void) => http.ClientRequest; + + toReadableStream: (payload: any, encoding?: string) => stream.Readable; + + parseCacheControl: (field: string) => any; + + agents: { + http: http.Agent, + https: http.Agent + }; + } + + var wreck: WreckObject; + + export = wreck; +} diff --git a/youtube/youtube.d.ts b/youtube/youtube.d.ts index 6e5066cf97..a90ab4c88a 100644 --- a/youtube/youtube.d.ts +++ b/youtube/youtube.d.ts @@ -44,6 +44,7 @@ declare module YT { origin?: string; playerpiid?: string; playlist?: string[]; + playsinline?: number; rel?: number; showinfo?: number; start?: number;