mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-06 16:20:26 +08:00
Merge branch 'master' into express4
Conflicts: express/express.d.ts
This commit is contained in:
+1
-6
@@ -23,12 +23,7 @@ Properties
|
||||
*~
|
||||
|
||||
# test folder
|
||||
!_infrastructure/*.js
|
||||
!_infrastructure/tests/*
|
||||
!_infrastructure/tests/*.js
|
||||
!_infrastructure/tests/*/*.js
|
||||
!_infrastructure/tests/*/*/*.js
|
||||
!_infrastructure/tests/*/*/*/*.js
|
||||
_infrastructure/tests/build
|
||||
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
+23
-2
@@ -49,6 +49,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [Commander](http://github.com/visionmedia/commander.js) (by [Marcelo Dezem](https://github.com/mdezem))
|
||||
* [configstore](http://github.com/yeoman/configstore) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
* [Cordova](http://cordova.apache.org) (by [Microsoft Open Technologies, Inc.](http://msopentech.com/))
|
||||
* [Cordovarduino](https://github.com/stereolux/cordovarduino) (by [Hendrik Maus](https://github.com/hendrikmaus))
|
||||
* [Couchbase / Couchnode](https://github.com/couchbase/couchnode) (by [Basarat Ali Syed](https://github.com/basarat))
|
||||
* [Crossfilter](https://github.com/square/crossfilter) (by [Schmulik Raskin](https://github.com/schmuli))
|
||||
* [crypto-js](https://code.google.com/p/crypto-js/) (by [Gia Bảo @ Sân Đình](https://github.com/giabao)). @see [cryptojs.d.ts repo](https://github.com/giabao/cryptojs.d.ts)
|
||||
@@ -83,10 +84,12 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [Firefox](https://developer.mozilla.org/en-US/docs/Web/API) (by [vvakame](https://github.com/vvakame))
|
||||
* [FlexSlider](http://www.woothemes.com/flexslider/) (by [Diullei Gomes](https://github.com/Diullei))
|
||||
* [Flight by Twitter](http://flightjs.github.com/flight/) (by [Jonathan Hedrén](https://github.com/jonathanhedren))
|
||||
* [flipsnap.js](http://pxgrid.github.io/js-flipsnap/) (by [kubosho_](https://github.com/kubosho), [gsino](https://github.com/gsino), [Mayuki Sawatari](https://github.com/mayuki))
|
||||
* [Foundation](http://foundation.zurb.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [FPSMeter](http://darsa.in/fpsmeter/) (by [Aaron Lampros](https://github.com/alampros))
|
||||
* [fs-extra](https://github.com/jprichardson/node-fs-extra) (by [midknight41](https://github.com/midknight41))
|
||||
* [FullCalendar](http://arshaw.com/fullcalendar/) (by [Neil Stalker](https://github.com/nestalk))
|
||||
* [Fuse.js](https://github.com/krisk/Fuse) (by [Greg Smith](https://github.com/smrq))
|
||||
* [Gamepad](http://www.w3.org/TR/gamepad/) (by [Kon](http://phyzkit.net/))
|
||||
* [GeoJSON](http://geojson.org/) (by [Jake Bruun](https://github.com/cobster))
|
||||
* [Giraffe](https://github.com/barc/backbone.giraffe) (by [Matt McCray](https://github.com/darthapo))
|
||||
@@ -120,6 +123,8 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [iCheck](http://damirfoy.com/iCheck/) (by [Dániel Tar](https://github.com/qcz))
|
||||
* [Impress.js](https://github.com/bartaz/impress.js) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Imagemagick](http://github.com/rsms/node-imagemagick) (by [Carlos Ballesteros Velasco](https://github.com/soywiz))
|
||||
* [interact.js](http://github.com/taye/interact.js) (by [Douglas Eichelberger](https://github.com/dduugg))
|
||||
* [Ionic-Cordova](https://github.com/driftyco/) (by [Hendrik Maus](https://github.com/hendrikmaus))
|
||||
* [iScroll](http://cubiq.org/iscroll-4) (by [Boris Yankov](https://github.com/borisyankov) and [Christiaan Rakowski](https://github.com/csrakowski))
|
||||
* [IxJS (Interactive extensions)](https://github.com/Reactive-Extensions/IxJS) (by [Igor Oleinikov](https://github.com/Igorbek))
|
||||
* [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/))
|
||||
@@ -131,7 +136,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [jQuery](http://jquery.com/) (from TypeScript samples)
|
||||
* [jQuery Mobile](http://jquerymobile.com) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [jQuery UI](http://jqueryui.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [jQuery.Address](https://github.com/asual/jquery-address) (by [Martin Duparc](https://github.com/martinduparc/))
|
||||
* [jQuery.Address](https://github.com/asual/jquery-address) (by [Martin Duparc](https://github.com/martinduparc/) and [Tim Klingeleers](https://github.com/mardaneus86/))
|
||||
* [jQuery.areYouSure](https://github.com/codedance/jquery.AreYouSure) (by [Jon Egerton](https://github.com/jonegerton))
|
||||
* [jQuery.autosize](http://www.jacklmoore.com/autosize/) (by [Jack Moore](http://www.jacklmoore.com/))
|
||||
* [jQuery.BBQ](http://benalman.com/projects/jquery-bbq-plugin/) (by [Adam R. Smith](https://github.com/sunetos))
|
||||
@@ -154,10 +159,15 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [jQuery.jNotify](http://jnotify.codeplex.com) (by [James Curran](https://github.com/jamescurran/))
|
||||
* [jQuery.joyride](http://zurb.com/playground/jquery-joyride-feature-tour-plugin) (by [Vincent Bortone](https://github.com/vbortone))
|
||||
* [jQuery.jSignature](https://github.com/willowsystems/jSignature) (by [Patrick Magee](https://github.com/pjmagee))
|
||||
* [jQuery.notifyBar](http://www.whoop.ee/posts/2013-04-05-the-resurrection-of-jquery-notify-bar/) (by [Shunsuke Ohtani](https://github.com/zaneli))
|
||||
* [jQuery.noty](http://needim.github.io/noty/) (by [Aaron King](https://github.com/kingdango/))
|
||||
* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb))
|
||||
* [jQuery.payment](http://needim.github.io/noty/) (by [Eric J. Smith](https://github.com/ejsmith/))
|
||||
* [jQuery.pickadate](https://github.com/amsul/pickadate.js) (by [Theodore Brown](https://github.com/theodorejb))
|
||||
* [jQuery.pjax](https://github.com/defunkt/jquery-pjax) (by [Junle Li](https://github.com/lijunle))
|
||||
* [jQuery.pjax.falsandtru](https://github.com/falsandtru/jquery.pjax.js/) (by [NewNotMoon](http://new.not-moon.net/))
|
||||
* [jQuery.pnotify](http://sciactive.github.io/pnotify/) (by [David Sichau](https://github.com/DavidSichau/))
|
||||
* [jQuery.postMessage](http://benalman.com/projects/jquery-postmessage-plugin/) (by [Junle Li](https://github.com/lijunle))
|
||||
* [jQuery.prettyphoto](https://github.com/scaron/prettyphoto) (by [Paul Gaske](https://github.com/pgaske))
|
||||
* [jQuery.scrollTo](https://github.com/flesler/jquery.scrollTo) (by [Neil Stalker](https://github.com/nestalk/))
|
||||
* [jQuery.simplePagination](https://github.com/flaviusmatis/simplePagination.js) (by [Natan Vivo](https://github.com/nvivo/))
|
||||
* [jquery.superLink](http://james.padolsey.com/demos/plugins/jQuery/superLink/superlink.jquery.js) (by [Blake Niemyjski](https://github.com/niemyjski))
|
||||
@@ -185,9 +195,11 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [jsTree](http://www.jstree.com/) (by [Adam Pluciński](https://github.com/adaskothebeast))
|
||||
* [JWPlayer](http://developer.longtailvideo.com/trac/) (by [Martin Duparc](https://github.com/martinduparc/))
|
||||
* [KeyboardJS](https://github.com/RobertWHurst/KeyboardJS) (by [Vincent Bortone](https://github.com/vbortone/))
|
||||
* [keymaster.js](https://github.com/madrobby/keymaster) (by [Marting W. Kirst](https://github.com/nitram509/))
|
||||
* [KineticJS](http://kineticjs.com/) (by [Basarat Ali Syed](https://github.com/basarat))
|
||||
* [Knockback](http://kmalakoff.github.com/knockback/) (by [Marcel Binot](https://github.com/docgit))
|
||||
* [Knockout.js](http://knockoutjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Knockout.Amd.Helpers](https://github.com/rniemeyer/knockout-amd-helpers) (by [David Sichau](https://github.com/DavidSichau/))
|
||||
* [Knockout.DeferredUpdates](https://github.com/mbest/knockout-deferred-updates) (by [Sebastián Galiano](https://github.com/sgaliano))
|
||||
* [Knockout.ES5](https://github.com/SteveSanderson/knockout-es5) (by [Sebastián Galiano](https://github.com/sgaliano))
|
||||
* [Knockout.Mapper](https://github.com/LucasLorentz/knockout.mapper) (by [Brandon Meyer](https://github.com/BMeyerKC))
|
||||
@@ -210,6 +222,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [Logg](https://github.com/dpup/node-logg) (by [Bret Little](https://github.com/blittle))
|
||||
* [Long.js](https://github.com/dcodeIO/Long.js) (by [Toshihide Hara](https://github.com/kerug))
|
||||
* [lz-string](https://github.com/pieroxy/lz-string) (by [Roman Nikitin](https://github.com/M0ns1gn0r))
|
||||
* [Mapbox](https://github.com/mapbox/mapbox.js/) (by [Maxime Fabre](https://github.com/anahkiasen))
|
||||
* [Marked](https://github.com/chjj/marked) (by [William Orr](https://github.com/worr))
|
||||
* [MathJax](https://github.com/mathjax/MathJax) (by [Roland Zwaga](https://github.com/rolandzwaga))
|
||||
* [mCustomScrollbar](https://github.com/malihu/malihu-custom-scrollbar-plugin) (by [Sarah Williams](https://github.com/flurg))
|
||||
@@ -218,6 +231,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [Microsoft Live Connect](http://msdn.microsoft.com/en-us/library/live/hh243643.aspx) (by [John Vilk](https://github.com/jvilk))
|
||||
* [Minimatch](https://github.com/isaacs/minimatch) (by [vvakame](https://github.com/vvakame))
|
||||
* [minimist](https://github.com/substack/minimist) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
* [Mixpanel](https://github.com/mixpanel/mixpanel-js) (by [Knut Eirik Leira Hjelle](https://github.com/hjellek))
|
||||
* [mixto](https://github.com/atom/mixto) (by [vvakame](https://github.com/vvakame))
|
||||
* [Modernizr](http://modernizr.com/) (by [Boris Yankov](https://github.com/borisyankov) and [Theodore Brown](https://github.com/theodorejb/))
|
||||
* [Moment.js](https://github.com/timrwood/moment) (by [Michael Lakerveld](https://github.com/Lakerfield))
|
||||
@@ -244,6 +258,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [OpenLayers](https://github.com/openlayers/openlayers) (by [Ilya Bolkhovsky](https://github.com/bolhovsky/))
|
||||
* [Optimist](https://github.com/substack/node-optimist) (by [Carlos Ballesteros Velasco](https://github.com/soywiz))
|
||||
* [Passport](http://passportjs.org/) (by [Hiroki Horiuchi](https://github.com/horiuchi/))
|
||||
* [passport-strategy](https://github.com/jaredhanson/passport-strategy) (by [Lior Mualem](https://github.com/liorm))
|
||||
* [pathwatcher](http://atom.github.io/node-pathwatcher/) (by [vvakame](https://github.com/vvakame))
|
||||
* [Parallel.js](https://github.com/adambom/parallel.js) (by [Josh Baldwin](https://github.com/jbaldwin))
|
||||
* [Parsimmon](https://github.com/jayferd/parsimmon) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
@@ -270,6 +285,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [Raphael](http://raphaeljs.com/) (by [CheCoxshall](https://github.com/CheCoxshall))
|
||||
* [Restangular](https://github.com/mgonto/restangular/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [require.js](http://requirejs.org/) (by [Josh Baldwin](https://github.com/jbaldwin/))
|
||||
* [rtree.js] (https://github.com/leaflet-extras/RTree) (by [Omede Firouz](https://github.com/oefirouz))
|
||||
* [Sammy.js](http://sammyjs.org/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Select2](http://ivaynberg.github.com/select2/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Selenium WebDriverJS](https://code.google.com/p/selenium/) (by [Bill Armstrong](https://github.com/BillArmstrong))
|
||||
@@ -284,6 +300,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [socket.io](http://socket.io) (by [William Orr](https://github.com/worr))
|
||||
* [socket.io-client](http://socket.io) (by [Maido Kaara](https://github.com/v3rm0n))
|
||||
* [SockJS](https://github.com/sockjs/sockjs-client) (by [Emil Ivanov](https://github.com/vladev))
|
||||
* [sockjs-node](https://github.com/sockjs/sockjs-node) (by [Phil McCloghry-Laing](https://github.com/pmccloghrylaing))
|
||||
* [SoundJS](http://www.createjs.com/#!/SoundJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [Spin](http://fgnass.github.com/spin.js/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [sqlite3](https://github.com/mapbox/node-sqlite3) (by [Nick Malaguti](https://github.com/nmalaguti))
|
||||
@@ -299,6 +316,8 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [Teechart](http://www.steema.com) (by [Steema](http://www.steema.com))
|
||||
* [text-buffer](https://github.com/atom/text-buffer) (by [vvakame](https://github.com/vvakame))
|
||||
* [three.js](http://mrdoob.github.com/three.js/) (by [Kon](http://phyzkit.net/))
|
||||
* [TimelineJS](https://github.com/NUKnightLab/TimelineJS) (by [Roland Zwaga](https://github.com/rolandzwaga))
|
||||
* [timezonecomplete](https://github.com/SpiritIT/timezonecomplete) (by [Rogier Schouten](https://github.com/rogierschouten))
|
||||
* [Toastr](https://github.com/CodeSeven/toastr) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [trunk8](https://github.com/rviscomi/trunk8) (by [Blake Niemyjski](https://github.com/niemyjski))
|
||||
* [TweenJS](http://www.createjs.com/#!/TweenJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
@@ -315,6 +334,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [urlrouter](https://github.com/fengmk2/urlrouter) (by [Carlos Ballesteros Velasco](https://github.com/soywiz))
|
||||
* [UUID.js](https://github.com/LiosK/UUID.js) (by [Jason Jarrett](https://github.com/staxmanade))
|
||||
* [Valerie](https://github.com/davewatts/valerie) (by [Howard Richards](https://github.com/conficient))
|
||||
* [Velocity](http://velocityjs.org/) (by [Greg Smith](https://github.com/smrq))
|
||||
* [Viewporter](https://github.com/zynga/viewporter) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [Vimeo](http://developer.vimeo.com/player/js-api) (by [Daz Wilkin](https://github.com/DazWilkin/))
|
||||
* [vinyl](https://github.com/wearefractal/vinyl) (by [vvakame](https://github.com/vvakame/))
|
||||
@@ -325,6 +345,7 @@ All definitions files include a header with the author and editors, so at some p
|
||||
* [WinRT](http://msdn.microsoft.com/en-us/library/windows/apps/br211377.aspx) (from TypeScript samples)
|
||||
* [ws](http://einaros.github.io/ws/) (by [Paul Loyd](https://github.com/loyd))
|
||||
* [x2js](https://code.google.com/p/x2js/) (by [Hiroki Horiuchi](https://github.com/horiuchi/))
|
||||
* [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js) (by [Michel Salib](https://github.com/michelsalib))
|
||||
* [XRegExp](http://xregexp.com/) (by [Bart van der Schoor](https://github.com/Bartvds))
|
||||
* [YouTube](https://developers.google.com/youtube/) (by [Daz Wilkin](https://github.com/DazWilkin/))
|
||||
* [YouTube Analytics API](https://developers.google.com/youtube/analytics/) (by [Frank M](https://github.com/sgtfrankieboy))
|
||||
|
||||
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Finch 0.5.13
|
||||
// Project: https://github.com/stoodder/finchjs
|
||||
// Definitions by: https://github.com/DavidSichau
|
||||
// Project: https://github.com/stoodder/finchjs
|
||||
// Definitions by: David Sichau <https://github.com/DavidSichau>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
/// <reference path="JSONStream.d.ts" />
|
||||
|
||||
import json = require('JSONStream');
|
||||
|
||||
var read: NodeJS.ReadableStream;
|
||||
var write: NodeJS.WritableStream;
|
||||
|
||||
read = read.pipe(json.parse('*'));
|
||||
read = read.pipe(json.parse(['foo/*', 'bar/*']));
|
||||
|
||||
read = json.stringify();
|
||||
read = json.stringify('{', ',', '}');
|
||||
|
||||
read = json.stringifyObject();
|
||||
read = json.stringifyObject('{', ',', '}');
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
// Type definitions for JSONStream v0.8.0
|
||||
// Project: http://github.com/dominictarr/JSONStream
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module 'JSONStream' {
|
||||
|
||||
export interface Options {
|
||||
recurse: boolean;
|
||||
}
|
||||
|
||||
export function parse(pattern: any): NodeJS.ReadWriteStream;
|
||||
export function parse(patterns: any[]): NodeJS.ReadWriteStream;
|
||||
|
||||
export function stringify(): NodeJS.ReadWriteStream;
|
||||
export function stringify(open: string, sep: string, close: string): NodeJS.ReadWriteStream;
|
||||
|
||||
export function stringifyObject(): NodeJS.ReadWriteStream;
|
||||
export function stringifyObject(open: string, sep: string, close: string): NodeJS.ReadWriteStream;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
require('definition-tester');
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
@@ -1 +0,0 @@
|
||||
tsc runner.ts --target ES5 --out runner.js --module commonjs --sourcemap
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,367 +0,0 @@
|
||||
/// <reference path="typings/tsd.d.ts" />
|
||||
|
||||
/// <reference path="src/exec.ts" />
|
||||
|
||||
/// <reference path="src/file.ts" />
|
||||
/// <reference path="src/tsc.ts" />
|
||||
/// <reference path="src/timer.ts" />
|
||||
/// <reference path="src/util.ts" />
|
||||
|
||||
/// <reference path="src/index.ts" />
|
||||
/// <reference path="src/changes.ts" />
|
||||
|
||||
/// <reference path="src/printer.ts" />
|
||||
/// <reference path="src/reporter/reporter.ts" />
|
||||
|
||||
/// <reference path="src/suite/suite.ts" />
|
||||
/// <reference path="src/suite/syntax.ts" />
|
||||
/// <reference path="src/suite/testEval.ts" />
|
||||
/// <reference path="src/suite/tscParams.ts" />
|
||||
|
||||
module DT {
|
||||
require('source-map-support').install();
|
||||
|
||||
// hacky typing
|
||||
var Lazy: LazyJS.LazyStatic = require('lazy.js');
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
var os = require('os');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var assert = require('assert');
|
||||
|
||||
var tsExp = /\.ts$/;
|
||||
|
||||
export var DEFAULT_TSC_VERSION = '0.9.7';
|
||||
|
||||
interface PackageJSON {
|
||||
scripts: {[key:string]: string};
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Single test
|
||||
/////////////////////////////////
|
||||
export class Test {
|
||||
constructor(public suite: ITestSuite, public tsfile: File, public options?: TscExecOptions) {
|
||||
}
|
||||
|
||||
public run(): Promise<TestResult> {
|
||||
return Tsc.run(this.tsfile.filePathWithName, this.options).then((execResult: ExecResult) => {
|
||||
var testResult = new TestResult();
|
||||
testResult.hostedBy = this.suite;
|
||||
testResult.targetFile = this.tsfile;
|
||||
testResult.options = this.options;
|
||||
|
||||
testResult.stdout = execResult.stdout;
|
||||
testResult.stderr = execResult.stderr;
|
||||
testResult.exitCode = execResult.exitCode;
|
||||
|
||||
return testResult;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Parallel execute Tests
|
||||
/////////////////////////////////
|
||||
export class TestQueue {
|
||||
|
||||
private queue: Function[] = [];
|
||||
private active: Test[] = [];
|
||||
private concurrent: number;
|
||||
|
||||
constructor(concurrent: number) {
|
||||
this.concurrent = Math.max(1, concurrent);
|
||||
}
|
||||
|
||||
// add to queue and return a promise
|
||||
run(test: Test): Promise<TestResult> {
|
||||
var defer = Promise.defer();
|
||||
// add a closure to queue
|
||||
this.queue.push(() => {
|
||||
// run it
|
||||
var p = test.run();
|
||||
p.then(defer.resolve.bind(defer), defer.reject.bind(defer));
|
||||
p.finally(() => {
|
||||
var i = this.active.indexOf(test);
|
||||
if (i > -1) {
|
||||
this.active.splice(i, 1);
|
||||
}
|
||||
this.step();
|
||||
});
|
||||
// return it
|
||||
return test;
|
||||
});
|
||||
this.step();
|
||||
// defer it
|
||||
return defer.promise;
|
||||
}
|
||||
|
||||
private step(): void {
|
||||
while (this.queue.length > 0 && this.active.length < this.concurrent) {
|
||||
this.active.push(this.queue.pop().call(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Test results
|
||||
/////////////////////////////////
|
||||
export class TestResult {
|
||||
hostedBy: ITestSuite;
|
||||
targetFile: File;
|
||||
options: TscExecOptions;
|
||||
|
||||
stdout: string;
|
||||
stderr: string;
|
||||
exitCode: number;
|
||||
|
||||
public get success(): boolean {
|
||||
return this.exitCode === 0;
|
||||
}
|
||||
}
|
||||
|
||||
export interface ITestRunnerOptions {
|
||||
tscVersion:string;
|
||||
concurrent?:number;
|
||||
testChanges?:boolean;
|
||||
skipTests?:boolean;
|
||||
printFiles?:boolean;
|
||||
printRefMap?:boolean;
|
||||
findNotRequiredTscparams?:boolean;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// The main class to kick things off
|
||||
/////////////////////////////////
|
||||
export class TestRunner {
|
||||
private timer: Timer;
|
||||
private suites: ITestSuite[] = [];
|
||||
|
||||
public changes: GitChanges;
|
||||
public index: FileIndex;
|
||||
public print: Print;
|
||||
|
||||
constructor(public dtPath: string, public options: ITestRunnerOptions = {tscVersion: DT.DEFAULT_TSC_VERSION}) {
|
||||
this.options.findNotRequiredTscparams = !!this.options.findNotRequiredTscparams;
|
||||
|
||||
this.index = new FileIndex(this, this.options);
|
||||
this.changes = new GitChanges(this);
|
||||
|
||||
this.print = new Print(this.options.tscVersion);
|
||||
}
|
||||
|
||||
public addSuite(suite: ITestSuite): void {
|
||||
this.suites.push(suite);
|
||||
}
|
||||
|
||||
public checkAcceptFile(fileName: string): boolean {
|
||||
var ok = tsExp.test(fileName);
|
||||
ok = ok && fileName.indexOf('_infrastructure') < 0;
|
||||
ok = ok && fileName.indexOf('node_modules/') < 0;
|
||||
ok = ok && /^[a-z]/i.test(fileName);
|
||||
return ok;
|
||||
}
|
||||
|
||||
public run(): Promise<boolean> {
|
||||
this.timer = new Timer();
|
||||
this.timer.start();
|
||||
|
||||
this.print.printChangeHeader();
|
||||
|
||||
// only includes .d.ts or -tests.ts or -test.ts or .ts
|
||||
return this.index.readIndex().then(() => {
|
||||
return this.changes.readChanges();
|
||||
}).then((changes: string[]) => {
|
||||
this.print.printAllChanges(changes);
|
||||
return this.index.collectDiff(changes);
|
||||
}).then(() => {
|
||||
this.print.printRemovals(this.index.removed);
|
||||
this.print.printRelChanges(this.index.changed);
|
||||
return this.index.parseFiles();
|
||||
}).then(() => {
|
||||
if (this.options.printRefMap) {
|
||||
this.print.printRefMap(this.index, this.index.refMap);
|
||||
}
|
||||
if (Lazy(this.index.missing).some((arr: any[]) => arr.length > 0)) {
|
||||
this.print.printMissing(this.index, this.index.missing);
|
||||
this.print.printBoldDiv();
|
||||
// bail
|
||||
return Promise.cast(false);
|
||||
}
|
||||
if (this.options.printFiles) {
|
||||
this.print.printFiles(this.index.files);
|
||||
}
|
||||
return this.index.collectTargets().then((files) => {
|
||||
if (this.options.testChanges) {
|
||||
this.print.printQueue(files);
|
||||
return this.runTests(files);
|
||||
}
|
||||
else {
|
||||
this.print.printTestAll();
|
||||
return this.runTests(this.index.files)
|
||||
}
|
||||
}).then(() => {
|
||||
return !this.suites.some((suite) => {
|
||||
return suite.ngTests.length !== 0
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private runTests(files: File[]): Promise<boolean> {
|
||||
return Promise.attempt(() => {
|
||||
assert(Array.isArray(files), 'files must be array');
|
||||
|
||||
var syntaxChecking = new SyntaxChecking(this.options);
|
||||
var testEval = new TestEval(this.options);
|
||||
|
||||
if (!this.options.findNotRequiredTscparams) {
|
||||
this.addSuite(syntaxChecking);
|
||||
this.addSuite(testEval);
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
syntaxChecking.filterTargetFiles(files),
|
||||
testEval.filterTargetFiles(files)
|
||||
]);
|
||||
}).spread((syntaxFiles, testFiles) => {
|
||||
this.print.init(syntaxFiles.length, testFiles.length, files.length);
|
||||
this.print.printHeader(this.options);
|
||||
|
||||
if (this.options.findNotRequiredTscparams) {
|
||||
this.addSuite(new FindNotRequiredTscparams(this.options, this.print));
|
||||
}
|
||||
|
||||
return Promise.reduce(this.suites, (count, suite: ITestSuite) => {
|
||||
suite.testReporter = suite.testReporter || new DefaultTestReporter(this.print);
|
||||
|
||||
this.print.printSuiteHeader(suite.testSuiteName);
|
||||
|
||||
if (this.options.skipTests) {
|
||||
this.print.printWarnCode('skipped test');
|
||||
return Promise.cast(count++);
|
||||
}
|
||||
|
||||
return suite.start(files, (testResult) => {
|
||||
this.print.printTestComplete(testResult);
|
||||
}).then((suite) => {
|
||||
this.print.printSuiteComplete(suite);
|
||||
return count++;
|
||||
});
|
||||
}, 0);
|
||||
}).then((count) => {
|
||||
this.timer.end();
|
||||
this.finaliseTests(files);
|
||||
});
|
||||
}
|
||||
|
||||
private finaliseTests(files: File[]): void {
|
||||
var testEval: TestEval = Lazy(this.suites).filter((suite) => {
|
||||
return suite instanceof TestEval;
|
||||
}).first();
|
||||
|
||||
if (testEval) {
|
||||
var existsTestTypings: string[] = Lazy(testEval.testResults).map((testResult) => {
|
||||
return testResult.targetFile.dir;
|
||||
}).reduce((a: string[], b: string) => {
|
||||
return a.indexOf(b) < 0 ? a.concat([b]) : a;
|
||||
}, []);
|
||||
|
||||
var typings: string[] = Lazy(files).map((file) => {
|
||||
return file.dir;
|
||||
}).reduce((a: string[], b: string) => {
|
||||
return a.indexOf(b) < 0 ? a.concat([b]) : a;
|
||||
}, []);
|
||||
|
||||
var withoutTestTypings: string[] = typings.filter((typing) => {
|
||||
return existsTestTypings.indexOf(typing) < 0;
|
||||
});
|
||||
|
||||
this.print.printDiv();
|
||||
this.print.printTypingsWithoutTest(withoutTestTypings);
|
||||
}
|
||||
|
||||
this.print.printDiv();
|
||||
this.print.printTotalMessage();
|
||||
|
||||
this.print.printDiv();
|
||||
this.print.printElapsedTime(this.timer.asString, this.timer.time);
|
||||
|
||||
this.suites.filter((suite: ITestSuite) => {
|
||||
return suite.printErrorCount;
|
||||
}).forEach((suite: ITestSuite) => {
|
||||
this.print.printSuiteErrorCount(suite.errorHeadline, suite.ngTests.length, suite.testResults.length);
|
||||
});
|
||||
if (testEval) {
|
||||
this.print.printSuiteErrorCount('Without tests', withoutTestTypings.length, typings.length, true);
|
||||
}
|
||||
|
||||
this.print.printDiv();
|
||||
|
||||
if (this.suites.some((suite) => {
|
||||
return suite.ngTests.length !== 0
|
||||
})) {
|
||||
this.print.printErrorsHeader();
|
||||
|
||||
this.suites.filter((suite) => {
|
||||
return suite.ngTests.length !== 0;
|
||||
}).forEach((suite) => {
|
||||
suite.ngTests.forEach((testResult) => {
|
||||
this.print.printErrorsForFile(testResult);
|
||||
});
|
||||
this.print.printBoldDiv();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var optimist: Optimist = require('optimist')(process.argv);
|
||||
optimist.default('try-without-tscparams', false);
|
||||
optimist.default('single-thread', false);
|
||||
optimist.default('tsc-version', DEFAULT_TSC_VERSION);
|
||||
|
||||
optimist.default('test-changes', false);
|
||||
optimist.default('skip-tests', false);
|
||||
optimist.default('print-files', false);
|
||||
optimist.default('print-refmap', false);
|
||||
|
||||
optimist.boolean('help');
|
||||
optimist.describe('help', 'print help');
|
||||
optimist.alias('h', 'help');
|
||||
|
||||
var argv: any = optimist.argv;
|
||||
|
||||
var dtPath = path.resolve(path.dirname((module).filename), '..', '..');
|
||||
var cpuCores = os.cpus().length;
|
||||
|
||||
if (argv.help) {
|
||||
optimist.showHelp();
|
||||
var pkg: PackageJSON = require('../../package.json');
|
||||
console.log('Scripts:');
|
||||
console.log('');
|
||||
Lazy(pkg.scripts).keys().each((key) => {
|
||||
console.log(' $ npm run ' + key);
|
||||
});
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
var testFull = process.env['TRAVIS_BRANCH'] ? /\w\/full$/.test(process.env['TRAVIS_BRANCH']) : false;
|
||||
|
||||
new TestRunner(dtPath, {
|
||||
concurrent: argv['single-thread'] ? 1 : Math.max(Math.min(24, cpuCores), 2),
|
||||
tscVersion: argv['tsc-version'],
|
||||
testChanges: testFull ? false : argv['test-changes'], // allow magic branch
|
||||
skipTests: argv['skip-tests'],
|
||||
printFiles: argv['print-files'],
|
||||
printRefMap: argv['print-refmap'],
|
||||
findNotRequiredTscparams: argv['try-without-tscparam']
|
||||
}).run().then((success) => {
|
||||
if (!success) {
|
||||
process.exit(1);
|
||||
}
|
||||
}).catch((err) => {
|
||||
throw err;
|
||||
process.exit(2);
|
||||
});
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/// <reference path="../_ref.d.ts" />
|
||||
/// <reference path="../runner.ts" />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var Git = require('git-wrapper');
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
export class GitChanges {
|
||||
|
||||
git;
|
||||
options = {};
|
||||
|
||||
constructor(private runner: TestRunner) {
|
||||
var dir = path.join(this.runner.dtPath, '.git');
|
||||
if (!fs.existsSync(dir)) {
|
||||
throw new Error('cannot locate git-dir: ' + dir);
|
||||
}
|
||||
this.options['git-dir'] = dir;
|
||||
|
||||
this.git = new Git(this.options);
|
||||
this.git.exec = Promise.promisify(this.git.exec);
|
||||
}
|
||||
|
||||
public readChanges(): Promise<string[]> {
|
||||
var opts = {};
|
||||
var args = ['--name-only HEAD~1'];
|
||||
return this.git.exec('diff', opts, args).then((msg: string) => {
|
||||
return msg.replace(/^\s+/, '').replace(/\s+$/, '').split(/\r?\n/g);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
var nodeExec = require('child_process').exec;
|
||||
|
||||
export class ExecResult {
|
||||
error;
|
||||
stdout = '';
|
||||
stderr = '';
|
||||
exitCode: number;
|
||||
}
|
||||
|
||||
export function exec(filename: string, cmdLineArgs: string[]): Promise<ExecResult> {
|
||||
return new Promise((resolve) => {
|
||||
var result = new ExecResult();
|
||||
result.exitCode = null;
|
||||
|
||||
var cmdLine = filename + ' ' + cmdLineArgs.join(' ');
|
||||
|
||||
nodeExec(cmdLine, {maxBuffer: 1 * 1024 * 1024}, (error, stdout, stderr) => {
|
||||
result.error = error;
|
||||
result.stdout = stdout;
|
||||
result.stderr = stderr;
|
||||
result.exitCode = error ? error.code : 0;
|
||||
resolve(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/// <reference path="../_ref.d.ts" />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var path = require('path');
|
||||
|
||||
export interface FileDict {
|
||||
[fullPath:string]: File;
|
||||
}
|
||||
|
||||
export interface FileArrDict {
|
||||
[fullPath:string]: File[];
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Given a document root + ts file pattern this class returns:
|
||||
// all the TS files OR just tests OR just definition files
|
||||
/////////////////////////////////
|
||||
export class File {
|
||||
baseDir: string;
|
||||
filePathWithName: string;
|
||||
dir: string;
|
||||
file: string;
|
||||
ext: string;
|
||||
fullPath: string;
|
||||
references: File[] = [];
|
||||
|
||||
constructor(baseDir: string, filePathWithName: string) {
|
||||
// why choose?
|
||||
this.baseDir = baseDir;
|
||||
this.filePathWithName = filePathWithName;
|
||||
this.ext = path.extname(this.filePathWithName);
|
||||
this.file = path.basename(this.filePathWithName, this.ext);
|
||||
this.dir = path.dirname(this.filePathWithName);
|
||||
this.fullPath = path.join(this.baseDir, this.dir, this.file + this.ext);
|
||||
|
||||
// lock it (shallow) (needs `use strict` in each file to work)
|
||||
// Object.freeze(this);
|
||||
}
|
||||
|
||||
toString(): string {
|
||||
return '[File ' + this.filePathWithName + ']';
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,208 +0,0 @@
|
||||
/// <reference path="../_ref.d.ts" />
|
||||
/// <reference path="../runner.ts" />
|
||||
/// <reference path="util.ts" />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var glob = require('glob');
|
||||
var Lazy: LazyJS.LazyStatic = require('lazy.js');
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
var readFile = Promise.promisify(fs.readFile);
|
||||
|
||||
/////////////////////////////////
|
||||
// Track all files in the repo: map full path to File objects
|
||||
/////////////////////////////////
|
||||
export class FileIndex {
|
||||
|
||||
files: File[];
|
||||
fileMap: FileDict;
|
||||
refMap: FileArrDict;
|
||||
options: ITestRunnerOptions;
|
||||
changed: FileDict;
|
||||
removed: FileDict;
|
||||
missing: FileArrDict;
|
||||
|
||||
constructor(private runner: TestRunner, options: ITestRunnerOptions) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public hasFile(target: string): boolean {
|
||||
return target in this.fileMap;
|
||||
}
|
||||
|
||||
public getFile(target: string): File {
|
||||
if (target in this.fileMap) {
|
||||
return this.fileMap[target];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public setFile(file: File): void {
|
||||
if (file.fullPath in this.fileMap) {
|
||||
throw new Error('cannot overwrite file');
|
||||
}
|
||||
this.fileMap[file.fullPath] = file;
|
||||
}
|
||||
|
||||
public readIndex(): Promise<void> {
|
||||
this.fileMap = Object.create(null);
|
||||
|
||||
return Promise.promisify(glob).call(glob, '**/*.ts', {
|
||||
cwd: this.runner.dtPath
|
||||
}).then((filesNames: string[]) => {
|
||||
this.files = Lazy(filesNames).filter((fileName) => {
|
||||
return this.runner.checkAcceptFile(fileName);
|
||||
}).map((fileName: string) => {
|
||||
var file = new File(this.runner.dtPath, fileName);
|
||||
this.fileMap[file.fullPath] = file;
|
||||
return file;
|
||||
}).toArray();
|
||||
});
|
||||
}
|
||||
|
||||
public collectDiff(changes: string[]): Promise<void> {
|
||||
return new Promise((resolve) => {
|
||||
// filter changes and bake map for easy lookup
|
||||
this.changed = Object.create(null);
|
||||
this.removed = Object.create(null);
|
||||
|
||||
Lazy(changes).filter((full) => {
|
||||
return this.runner.checkAcceptFile(full);
|
||||
}).uniq().each((local) => {
|
||||
var full = path.resolve(this.runner.dtPath, local);
|
||||
var file = this.getFile(full);
|
||||
if (!file) {
|
||||
// TODO figure out what to do here
|
||||
// what does it mean? deleted?ss
|
||||
file = new File(this.runner.dtPath, local);
|
||||
this.setFile(file);
|
||||
this.removed[full] = file;
|
||||
// console.log('not in index? %', file.fullPath);
|
||||
}
|
||||
else {
|
||||
this.changed[full] = file;
|
||||
}
|
||||
});
|
||||
// console.log('changed:\n' + Object.keys(this.changed).join('\n'));
|
||||
// console.log('removed:\n' + Object.keys(this.removed).join('\n'));
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
public parseFiles(): Promise<void> {
|
||||
return this.loadReferences(this.files).then(() => {
|
||||
return this.getMissingReferences();
|
||||
});
|
||||
}
|
||||
|
||||
private getMissingReferences(): Promise<void> {
|
||||
return Promise.attempt(() => {
|
||||
this.missing = Object.create(null);
|
||||
Lazy(this.removed).keys().each((removed) => {
|
||||
if (removed in this.refMap) {
|
||||
this.missing[removed] = this.refMap[removed];
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private loadReferences(files: File[]): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
var queue = files.slice(0);
|
||||
var active = [];
|
||||
var max = 50;
|
||||
var next = () => {
|
||||
if (queue.length === 0 && active.length === 0) {
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
// queue paralel
|
||||
while (queue.length > 0 && active.length < max) {
|
||||
var file = queue.pop();
|
||||
active.push(file);
|
||||
this.parseFile(file).then((file) => {
|
||||
active.splice(active.indexOf(file), 1);
|
||||
next();
|
||||
}).catch((err) => {
|
||||
queue = [];
|
||||
active = [];
|
||||
reject(err);
|
||||
});
|
||||
}
|
||||
};
|
||||
next();
|
||||
}).then(() => {
|
||||
// bake reverse reference map (referenced to referrers)
|
||||
this.refMap = Object.create(null);
|
||||
|
||||
Lazy(files).each((file) => {
|
||||
Lazy(file.references).each((ref) => {
|
||||
if (ref.fullPath in this.refMap) {
|
||||
this.refMap[ref.fullPath].push(file);
|
||||
}
|
||||
else {
|
||||
this.refMap[ref.fullPath] = [file];
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// TODO replace with a stream?
|
||||
private parseFile(file: File): Promise<File> {
|
||||
return readFile(file.filePathWithName, {
|
||||
encoding: 'utf8',
|
||||
flag: 'r'
|
||||
}).then((content) => {
|
||||
file.references = Lazy(extractReferenceTags(content)).map((ref) => {
|
||||
return path.resolve(path.dirname(file.fullPath), ref);
|
||||
}).reduce((memo: File[], ref) => {
|
||||
if (ref in this.fileMap) {
|
||||
memo.push(this.fileMap[ref]);
|
||||
}
|
||||
else {
|
||||
console.log('not mapped? -> ' + ref);
|
||||
}
|
||||
return memo;
|
||||
}, []);
|
||||
// return the object
|
||||
return file;
|
||||
});
|
||||
}
|
||||
|
||||
public collectTargets(): Promise<File[]> {
|
||||
return new Promise((resolve) => {
|
||||
// map out files linked to changes
|
||||
// - queue holds files touched by a change
|
||||
// - pre-fill with actually changed files
|
||||
// - loop queue, if current not seen:
|
||||
// - add to result
|
||||
// - from refMap queue all files referring to current
|
||||
|
||||
var result: FileDict = Object.create(null);
|
||||
var queue = Lazy<File>(this.changed).values().toArray();
|
||||
|
||||
while (queue.length > 0) {
|
||||
var next = queue.shift();
|
||||
var fp = next.fullPath;
|
||||
if (result[fp]) {
|
||||
continue;
|
||||
}
|
||||
result[fp] = next;
|
||||
if (fp in this.refMap) {
|
||||
var arr = this.refMap[fp];
|
||||
for (var i = 0, ii = arr.length; i < ii; i++) {
|
||||
// just add it and skip expensive checks
|
||||
queue.push(arr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
resolve(Lazy<File>(result).values().toArray());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,281 +0,0 @@
|
||||
/// <reference path="../_ref.d.ts" />
|
||||
/// <reference path="../runner.ts" />
|
||||
|
||||
module DT {
|
||||
|
||||
var os = require('os');
|
||||
|
||||
/////////////////////////////////
|
||||
// All the common things that we print are functions of this class
|
||||
/////////////////////////////////
|
||||
export class Print {
|
||||
|
||||
WIDTH = 77;
|
||||
|
||||
typings: number;
|
||||
tests: number;
|
||||
tsFiles: number
|
||||
|
||||
constructor(public version: string){
|
||||
|
||||
}
|
||||
|
||||
public init(typings: number, tests: number, tsFiles: number) {
|
||||
this.typings = typings;
|
||||
this.tests = tests;
|
||||
this.tsFiles = tsFiles;
|
||||
}
|
||||
|
||||
public out(s: any): Print {
|
||||
process.stdout.write(s);
|
||||
return this;
|
||||
}
|
||||
|
||||
public repeat(s: string, times: number): string {
|
||||
return new Array(times + 1).join(s);
|
||||
}
|
||||
|
||||
public printChangeHeader() {
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mDefinitelyTyped Diff Detector 0.1.0\33[0m \n');
|
||||
this.out('=============================================================================\n');
|
||||
}
|
||||
|
||||
public printHeader(options: ITestRunnerOptions) {
|
||||
var totalMem = Math.round(os.totalmem() / 1024 / 1024) + ' mb';
|
||||
var freemem = Math.round(os.freemem() / 1024 / 1024) + ' mb';
|
||||
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mDefinitelyTyped Test Runner 0.5.0\33[0m\n');
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[36m\33[1mTypescript version:\33[0m ' + this.version + '\n');
|
||||
this.out(' \33[36m\33[1mTypings :\33[0m ' + this.typings + '\n');
|
||||
this.out(' \33[36m\33[1mTests :\33[0m ' + this.tests + '\n');
|
||||
this.out(' \33[36m\33[1mTypeScript files :\33[0m ' + this.tsFiles + '\n');
|
||||
this.out(' \33[36m\33[1mTotal Memory :\33[0m ' + totalMem + '\n');
|
||||
this.out(' \33[36m\33[1mFree Memory :\33[0m ' + freemem + '\n');
|
||||
this.out(' \33[36m\33[1mCores :\33[0m ' + os.cpus().length + '\n');
|
||||
this.out(' \33[36m\33[1mConcurrent :\33[0m ' + options.concurrent + '\n');
|
||||
}
|
||||
|
||||
public printSuiteHeader(title: string) {
|
||||
var left = Math.floor((this.WIDTH - title.length ) / 2) - 1;
|
||||
var right = Math.ceil((this.WIDTH - title.length ) / 2) - 1;
|
||||
this.out(this.repeat('=', left)).out(' \33[34m\33[1m');
|
||||
this.out(title);
|
||||
this.out('\33[0m ').out(this.repeat('=', right)).printBreak();
|
||||
}
|
||||
|
||||
public printDiv() {
|
||||
this.out('-----------------------------------------------------------------------------\n');
|
||||
}
|
||||
|
||||
public printBoldDiv() {
|
||||
this.out('=============================================================================\n');
|
||||
}
|
||||
|
||||
public printErrorsHeader() {
|
||||
this.out('=============================================================================\n');
|
||||
this.out(' \33[34m\33[1mErrors in files\33[0m \n');
|
||||
this.out('=============================================================================\n');
|
||||
}
|
||||
|
||||
public printErrorsForFile(testResult: TestResult) {
|
||||
this.out('----------------- For file:' + testResult.targetFile.filePathWithName);
|
||||
this.printBreak().out(testResult.stderr).printBreak();
|
||||
}
|
||||
|
||||
public printBreak(): Print {
|
||||
this.out('\n');
|
||||
return this;
|
||||
}
|
||||
|
||||
public clearCurrentLine(): Print {
|
||||
this.out('\r\33[K');
|
||||
return this;
|
||||
}
|
||||
|
||||
public printSuccessCount(current: number, total: number) {
|
||||
var arb = (total === 0) ? 0 : (current / total);
|
||||
this.out(' \33[36m\33[1mSuccessful :\33[0m \33[32m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
|
||||
public printFailedCount(current: number, total: number) {
|
||||
var arb = (total === 0) ? 0 : (current / total);
|
||||
this.out(' \33[36m\33[1mFailure :\33[0m \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
|
||||
public printTypingsWithoutTestsMessage() {
|
||||
this.out(' \33[36m\33[1mTyping without tests\33[0m\n');
|
||||
}
|
||||
|
||||
public printTotalMessage() {
|
||||
this.out(' \33[36m\33[1mTotal\33[0m\n');
|
||||
}
|
||||
|
||||
public printElapsedTime(time: string, s: number) {
|
||||
this.out(' \33[36m\33[1mElapsed time :\33[0m ~' + time + ' (' + s + 's)\n');
|
||||
}
|
||||
|
||||
public printSuiteErrorCount(errorHeadline: string, current: number, total: number, warn: boolean = false) {
|
||||
var arb = (total === 0) ? 0 : (current / total);
|
||||
this.out(' \33[36m\33[1m').out(errorHeadline).out(this.repeat(' ', 16 - errorHeadline.length));
|
||||
if (warn) {
|
||||
this.out(': \33[31m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
else {
|
||||
this.out(': \33[33m\33[1m' + (arb * 100).toFixed(2) + '% (' + current + '/' + total + ')\33[0m\n');
|
||||
}
|
||||
}
|
||||
|
||||
public printSubHeader(file: string) {
|
||||
this.out(' \33[36m\33[1m' + file + '\33[0m\n');
|
||||
}
|
||||
|
||||
public printWarnCode(str: string) {
|
||||
this.out(' \33[31m\33[1m<' + str.toLowerCase().replace(/ +/g, '-') + '>\33[0m\n');
|
||||
}
|
||||
|
||||
public printLine(file: string) {
|
||||
this.out(file + '\n');
|
||||
}
|
||||
|
||||
public printElement(file: string) {
|
||||
this.out(' - ' + file + '\n');
|
||||
}
|
||||
|
||||
public printElement2(file: string) {
|
||||
this.out(' - ' + file + '\n');
|
||||
}
|
||||
|
||||
public printTypingsWithoutTestName(file: string) {
|
||||
this.out(' - \33[33m\33[1m' + file + '\33[0m\n');
|
||||
}
|
||||
|
||||
public printTypingsWithoutTest(withoutTestTypings: string[]) {
|
||||
if (withoutTestTypings.length > 0) {
|
||||
this.printTypingsWithoutTestsMessage();
|
||||
|
||||
this.printDiv();
|
||||
withoutTestTypings.forEach((t) => {
|
||||
this.printTypingsWithoutTestName(t);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public printTestComplete(testResult: TestResult): void {
|
||||
var reporter = testResult.hostedBy.testReporter;
|
||||
if (testResult.success) {
|
||||
reporter.printPositiveCharacter(testResult);
|
||||
}
|
||||
else {
|
||||
reporter.printNegativeCharacter(testResult);
|
||||
}
|
||||
}
|
||||
|
||||
public printSuiteComplete(suite: ITestSuite): void {
|
||||
this.printBreak();
|
||||
|
||||
this.printDiv();
|
||||
this.printElapsedTime(suite.timer.asString, suite.timer.time);
|
||||
this.printSuccessCount(suite.okTests.length, suite.testResults.length);
|
||||
this.printFailedCount(suite.ngTests.length, suite.testResults.length);
|
||||
}
|
||||
|
||||
public printTests(adding: FileDict): void {
|
||||
this.printDiv();
|
||||
this.printSubHeader('Testing');
|
||||
this.printDiv();
|
||||
|
||||
Object.keys(adding).sort().map((src) => {
|
||||
this.printLine(adding[src].filePathWithName);
|
||||
return adding[src];
|
||||
});
|
||||
}
|
||||
|
||||
public printQueue(files: File[]): void {
|
||||
this.printDiv();
|
||||
this.printSubHeader('Queued for testing');
|
||||
this.printDiv();
|
||||
|
||||
files.forEach((file) => {
|
||||
this.printLine(file.filePathWithName);
|
||||
});
|
||||
}
|
||||
|
||||
public printTestAll(): void {
|
||||
this.printDiv();
|
||||
this.printSubHeader('Ignoring changes, testing all files');
|
||||
}
|
||||
|
||||
public printFiles(files: File[]): void {
|
||||
this.printDiv();
|
||||
this.printSubHeader('Files');
|
||||
this.printDiv();
|
||||
|
||||
files.forEach((file) => {
|
||||
this.printLine(file.filePathWithName);
|
||||
file.references.forEach((file) => {
|
||||
this.printElement(file.filePathWithName);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public printMissing(index: FileIndex, refMap: FileArrDict): void {
|
||||
this.printDiv();
|
||||
this.printSubHeader('Missing references');
|
||||
this.printDiv();
|
||||
|
||||
Object.keys(refMap).sort().forEach((src) => {
|
||||
var ref = index.getFile(src);
|
||||
this.printLine('\33[31m\33[1m' + ref.filePathWithName + '\33[0m');
|
||||
refMap[src].forEach((file) => {
|
||||
this.printElement(file.filePathWithName);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public printAllChanges(paths: string[]): void {
|
||||
this.printSubHeader('All changes');
|
||||
this.printDiv();
|
||||
|
||||
paths.sort().forEach((line) => {
|
||||
this.printLine(line);
|
||||
});
|
||||
}
|
||||
|
||||
public printRelChanges(changeMap: FileDict): void {
|
||||
this.printDiv();
|
||||
this.printSubHeader('Interesting files');
|
||||
this.printDiv();
|
||||
|
||||
Object.keys(changeMap).sort().forEach((src) => {
|
||||
this.printLine(changeMap[src].filePathWithName);
|
||||
});
|
||||
}
|
||||
|
||||
public printRemovals(changeMap: FileDict): void {
|
||||
this.printDiv();
|
||||
this.printSubHeader('Removed files');
|
||||
this.printDiv();
|
||||
|
||||
Object.keys(changeMap).sort().forEach((src) => {
|
||||
this.printLine(changeMap[src].filePathWithName);
|
||||
});
|
||||
}
|
||||
|
||||
public printRefMap(index: FileIndex, refMap: FileArrDict): void {
|
||||
this.printDiv();
|
||||
this.printSubHeader('Referring');
|
||||
this.printDiv();
|
||||
|
||||
Object.keys(refMap).sort().forEach((src) => {
|
||||
var ref = index.getFile(src);
|
||||
this.printLine(ref.filePathWithName);
|
||||
refMap[src].forEach((file) => {
|
||||
this.printLine(' - ' + file.filePathWithName);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/// <reference path="../../_ref.d.ts" />
|
||||
/// <reference path="../printer.ts" />
|
||||
|
||||
module DT {
|
||||
/////////////////////////////////
|
||||
// Test reporter interface
|
||||
// for example, . and x
|
||||
/////////////////////////////////
|
||||
export interface ITestReporter {
|
||||
printPositiveCharacter(testResult: TestResult):void;
|
||||
printNegativeCharacter(testResult: TestResult):void;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Default test reporter
|
||||
/////////////////////////////////
|
||||
export class DefaultTestReporter implements ITestReporter {
|
||||
|
||||
index = 0;
|
||||
|
||||
constructor(public print: Print) {
|
||||
}
|
||||
|
||||
public printPositiveCharacter(testResult: TestResult) {
|
||||
this.print.out('\33[36m\33[1m' + '.' + '\33[0m');
|
||||
this.index++;
|
||||
this.printBreakIfNeeded(this.index);
|
||||
}
|
||||
|
||||
public printNegativeCharacter( testResult: TestResult) {
|
||||
this.print.out('x');
|
||||
this.index++;
|
||||
this.printBreakIfNeeded(this.index);
|
||||
}
|
||||
|
||||
private printBreakIfNeeded(index: number) {
|
||||
if (index % this.print.WIDTH === 0) {
|
||||
this.print.printBreak();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/// <reference path="../../runner.ts" />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
/////////////////////////////////
|
||||
// The interface for test suite
|
||||
/////////////////////////////////
|
||||
export interface ITestSuite {
|
||||
testSuiteName:string;
|
||||
errorHeadline:string;
|
||||
filterTargetFiles(files: File[]): Promise<File[]>;
|
||||
|
||||
start(targetFiles: File[], testCallback: (result: TestResult, index: number) => void): Promise<ITestSuite>;
|
||||
|
||||
testResults:TestResult[];
|
||||
okTests:TestResult[];
|
||||
ngTests:TestResult[];
|
||||
timer:Timer;
|
||||
|
||||
testReporter:ITestReporter;
|
||||
printErrorCount:boolean;
|
||||
}
|
||||
|
||||
/////////////////////////////////
|
||||
// Base class for test suite
|
||||
/////////////////////////////////
|
||||
export class TestSuiteBase implements ITestSuite {
|
||||
timer: Timer = new Timer();
|
||||
testResults: TestResult[] = [];
|
||||
testReporter: ITestReporter;
|
||||
printErrorCount = true;
|
||||
queue: TestQueue;
|
||||
|
||||
constructor(public options: ITestRunnerOptions, public testSuiteName: string, public errorHeadline: string) {
|
||||
this.queue = new TestQueue(options.concurrent);
|
||||
}
|
||||
|
||||
public filterTargetFiles(files: File[]): Promise<File[]> {
|
||||
throw new Error('please implement this method');
|
||||
}
|
||||
|
||||
public start(targetFiles: File[], testCallback: (result: TestResult) => void): Promise<ITestSuite> {
|
||||
this.timer.start();
|
||||
|
||||
return this.filterTargetFiles(targetFiles).then((targetFiles) => {
|
||||
// tests get queued for multi-threading
|
||||
return Promise.all(targetFiles.map((targetFile) => {
|
||||
return this.runTest(targetFile).then((result) => {
|
||||
testCallback(result);
|
||||
});
|
||||
}));
|
||||
}).then(() => {
|
||||
this.timer.end();
|
||||
return this;
|
||||
});
|
||||
}
|
||||
|
||||
public runTest(targetFile: File): Promise<TestResult> {
|
||||
return this.queue.run(new Test(this, targetFile, {
|
||||
tscVersion: this.options.tscVersion
|
||||
})).then((result) => {
|
||||
this.testResults.push(result);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
public get okTests(): TestResult[] {
|
||||
return this.testResults.filter((r) => {
|
||||
return r.success;
|
||||
});
|
||||
}
|
||||
|
||||
public get ngTests(): TestResult[] {
|
||||
return this.testResults.filter((r) => {
|
||||
return !r.success
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/// <reference path="../../runner.ts" />
|
||||
/// <reference path="../util.ts" />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
var endDts = /\w\.d\.ts$/i;
|
||||
|
||||
/////////////////////////////////
|
||||
// .d.ts syntax inspection
|
||||
/////////////////////////////////
|
||||
export class SyntaxChecking extends TestSuiteBase {
|
||||
|
||||
constructor(options: ITestRunnerOptions) {
|
||||
super(options, 'Syntax checking', 'Syntax error');
|
||||
}
|
||||
|
||||
public filterTargetFiles(files: File[]): Promise<File[]> {
|
||||
return Promise.cast(files.filter((file) => {
|
||||
return endDts.test(file.filePathWithName);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/// <reference path="../../runner.ts" />
|
||||
/// <reference path="../util.ts" />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
var endTestDts = /\w-tests?\.ts$/i;
|
||||
|
||||
/////////////////////////////////
|
||||
// Compile with *-tests.ts
|
||||
/////////////////////////////////
|
||||
export class TestEval extends TestSuiteBase {
|
||||
|
||||
constructor(options) {
|
||||
super(options, 'Typing tests', 'Failed tests');
|
||||
}
|
||||
|
||||
public filterTargetFiles(files: File[]): Promise<File[]> {
|
||||
return Promise.cast(files.filter((file) => {
|
||||
return endTestDts.test(file.filePathWithName);
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/// <reference path='../../runner.ts' />
|
||||
/// <reference path='../file.ts' />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
/////////////////////////////////
|
||||
// Try compile without .tscparams
|
||||
// It may indicate that it is compatible with --noImplicitAny maybe...
|
||||
/////////////////////////////////
|
||||
export class FindNotRequiredTscparams extends TestSuiteBase {
|
||||
testReporter: ITestReporter;
|
||||
printErrorCount = false;
|
||||
|
||||
constructor(options: ITestRunnerOptions, private print: Print) {
|
||||
super(options, 'Find not required .tscparams files', 'New arrival!');
|
||||
|
||||
this.testReporter = {
|
||||
printPositiveCharacter: (testResult: TestResult) => {
|
||||
this.print
|
||||
.clearCurrentLine()
|
||||
.printTypingsWithoutTestName(testResult.targetFile.filePathWithName);
|
||||
},
|
||||
printNegativeCharacter: (testResult: TestResult) => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public filterTargetFiles(files: File[]): Promise<File[]> {
|
||||
return Promise.filter(files, (file) => {
|
||||
return new Promise((resolve) => {
|
||||
fs.exists(file.filePathWithName + '.tscparams', resolve);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public runTest(targetFile: File): Promise<TestResult> {
|
||||
this.print.clearCurrentLine().out(targetFile.filePathWithName);
|
||||
|
||||
return this.queue.run(new Test(this, targetFile, {
|
||||
tscVersion: this.options.tscVersion,
|
||||
useTscParams: false,
|
||||
checkNoImplicitAny: true
|
||||
})).then((result) => {
|
||||
this.testResults.push(result);
|
||||
this.print.clearCurrentLine();
|
||||
return result
|
||||
});
|
||||
}
|
||||
|
||||
public get ngTests(): TestResult[] {
|
||||
// Do not show ng test results
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/// <reference path="../_ref.d.ts" />
|
||||
/// <reference path="../runner.ts" />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
/////////////////////////////////
|
||||
// Timer.start starts a timer
|
||||
// Timer.end stops the timer and sets asString to the pretty print value
|
||||
/////////////////////////////////
|
||||
export class Timer {
|
||||
startTime: number;
|
||||
time = 0;
|
||||
asString: string = '<not-started>'
|
||||
|
||||
public start() {
|
||||
this.time = 0;
|
||||
this.startTime = this.now();
|
||||
this.asString = '<started>';
|
||||
}
|
||||
|
||||
public now(): number {
|
||||
return Date.now();
|
||||
}
|
||||
|
||||
public end() {
|
||||
this.time = (this.now() - this.startTime) / 1000;
|
||||
this.asString = Timer.prettyDate(this.startTime, this.now());
|
||||
}
|
||||
|
||||
public static prettyDate(date1: number, date2: number): string {
|
||||
var diff = ((date2 - date1) / 1000);
|
||||
var day_diff = Math.floor(diff / 86400);
|
||||
|
||||
if (isNaN(day_diff) || day_diff < 0 || day_diff >= 31) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (<string><any> (day_diff == 0 && (
|
||||
diff < 60 && (diff + ' seconds') ||
|
||||
diff < 120 && '1 minute' ||
|
||||
diff < 3600 && Math.floor(diff / 60) + ' minutes' ||
|
||||
diff < 7200 && '1 hour' ||
|
||||
diff < 86400 && Math.floor(diff / 3600) + ' hours') ||
|
||||
day_diff == 1 && 'Yesterday' ||
|
||||
day_diff < 7 && day_diff + ' days' ||
|
||||
day_diff < 31 && Math.ceil(day_diff / 7) + ' weeks'));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
/// <reference path='../_ref.d.ts' />
|
||||
/// <reference path='../runner.ts' />
|
||||
/// <reference path='exec.ts' />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
export interface TscExecOptions {
|
||||
tscVersion?: string;
|
||||
useTscParams?: boolean;
|
||||
checkNoImplicitAny?: boolean;
|
||||
}
|
||||
|
||||
export class Tsc {
|
||||
public static run(tsfile: string, options: TscExecOptions): Promise<ExecResult> {
|
||||
var tscPath;
|
||||
return new Promise.attempt(() => {
|
||||
options = options || {};
|
||||
options.tscVersion = options.tscVersion || DEFAULT_TSC_VERSION;
|
||||
if (typeof options.checkNoImplicitAny === 'undefined') {
|
||||
options.checkNoImplicitAny = true;
|
||||
}
|
||||
if (typeof options.useTscParams === 'undefined') {
|
||||
options.useTscParams = true;
|
||||
}
|
||||
return fileExists(tsfile);
|
||||
}).then((exists) => {
|
||||
if (!exists) {
|
||||
throw new Error(tsfile + ' does not exist');
|
||||
}
|
||||
tscPath = './_infrastructure/tests/typescript/' + options.tscVersion + '/tsc.js';
|
||||
return fileExists(tscPath);
|
||||
}).then((exists) => {
|
||||
if (!exists) {
|
||||
throw new Error(tscPath + ' does not exist');
|
||||
}
|
||||
return fileExists(tsfile + '.tscparams');
|
||||
}).then(exists => {
|
||||
if (exists) {
|
||||
return readFile(tsfile + '.tscparams');
|
||||
} else {
|
||||
return new Promise('');
|
||||
}
|
||||
}).then((paramContents: string) => {
|
||||
var command = 'node ' + tscPath + ' --module commonjs ';
|
||||
if (options.useTscParams && paramContents.trim() !== '' && paramContents.trim() !== '""') {
|
||||
command += '@' + tsfile + '.tscparams';
|
||||
}
|
||||
else if (options.checkNoImplicitAny) {
|
||||
command += '--noImplicitAny';
|
||||
}
|
||||
return exec(command, [tsfile]);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
/// <reference path="../_ref.d.ts" />
|
||||
|
||||
module DT {
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var Lazy: LazyJS.LazyStatic = require('lazy.js');
|
||||
var Promise: typeof Promise = require('bluebird');
|
||||
|
||||
var referenceTagExp = /<reference[ \t]*path=["']?([\w\.\/_-]*)["']?[ \t]*\/>/g;
|
||||
|
||||
export function endsWith(str: string, suffix: string) {
|
||||
return str.indexOf(suffix, str.length - suffix.length) !== -1;
|
||||
}
|
||||
|
||||
export function extractReferenceTags(source: string): string[] {
|
||||
var ret: string[] = [];
|
||||
var match: RegExpExecArray;
|
||||
|
||||
if (!referenceTagExp.global) {
|
||||
throw new Error('referenceTagExp RegExp must have global flag');
|
||||
}
|
||||
referenceTagExp.lastIndex = 0;
|
||||
|
||||
while ((match = referenceTagExp.exec(source))) {
|
||||
if (match.length > 0 && match[1].length > 0) {
|
||||
ret.push(match[1]);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function fileExists(target: string): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.exists(target, (bool: boolean) => {
|
||||
resolve(bool);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function readFile(target: string): Promise<string> {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(target, 'utf-8', (err, contents: string) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve(contents);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,656 +0,0 @@
|
||||
// Type definitions for bluebird 1.0.0
|
||||
// Project: https://github.com/petkaantonov/bluebird
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// ES6 model with generics overload was sourced and trans-multiplied from es6-promises.d.ts
|
||||
// By: Campredon <https://github.com/fdecampredon/>
|
||||
|
||||
// Warning: recommended to use `tsc > v1.0.0` (critical bugs in generic code:
|
||||
// - https://github.com/borisyankov/DefinitelyTyped/issues/1563
|
||||
// - https://github.com/borisyankov/DefinitelyTyped/tree/def/bluebird
|
||||
|
||||
// Note: replicate changes to all overloads in both definition and test file
|
||||
// Note: keep both static and instance members inline (so similar)
|
||||
|
||||
// TODO fix remaining TODO annotations in both definition and test
|
||||
|
||||
// TODO verify support to have no return statement in handlers to get a Promise<void> (more overloads?)
|
||||
|
||||
declare class Promise<R> implements Promise.Thenable<R> {
|
||||
/**
|
||||
* Create a new promise. The passed in function will receive functions `resolve` and `reject` as its arguments which can be called to seal the fate of the created promise.
|
||||
*/
|
||||
constructor(callback: (resolve: (thenable: Promise.Thenable<R>) => void, reject: (error: any) => void) => void);
|
||||
constructor(callback: (resolve: (result: R) => void, reject: (error: any) => void) => void);
|
||||
|
||||
/**
|
||||
* Promises/A+ `.then()` with progress handler. Returns a new promise chained from this promise. The new promise will be rejected or resolved dedefer on the passed `fulfilledHandler`, `rejectedHandler` and the state of this promise.
|
||||
*/
|
||||
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill: (value: R) => Promise.Thenable<U>, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill: (value: R) => U, onReject: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
then<U>(onFulfill?: (value: R) => U, onReject?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* This is a catch-all exception handler, shortcut for calling `.then(null, handler)` on this promise. Any exception happening in a `.then`-chain will propagate to nearest `.catch` handler.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch<U>(onReject?: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(onReject?: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(onReject?: (error: any) => U): Promise<U>;
|
||||
caught<U>(onReject?: (error: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* This extends `.catch` to work more like catch-clauses in languages like Java or C#. Instead of manually checking `instanceof` or `.name === "SomeError"`, you may specify a number of error constructors which are eligible for this catch handler. The catch handler that is first met that has eligible constructors specified, is the one that will be called.
|
||||
*
|
||||
* This method also supports predicate-based filters. If you pass a predicate function instead of an error constructor, the predicate will receive the error as an argument. The return result of the predicate will be used determine whether the error handler should be called.
|
||||
*
|
||||
* Alias `.caught();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise<U>;
|
||||
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U): Promise<U>;
|
||||
|
||||
catch<U>(ErrorClass: Function, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
caught<U>(ErrorClass: Function, onReject: (error: any) => Promise.Thenable<U>): Promise<U>;
|
||||
|
||||
catch<U>(ErrorClass: Function, onReject: (error: any) => U): Promise<U>;
|
||||
caught<U>(ErrorClass: Function, onReject: (error: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like `.catch` but instead of catching all types of exceptions, it only catches those that don't originate from thrown errors but rather from explicit rejections.
|
||||
*/
|
||||
error<U>(onReject: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
error<U>(onReject: (reason: any) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise. There are special semantics for `.finally()` in that the final value cannot be modified from the handler.
|
||||
*
|
||||
* Alias `.lastly();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
finally(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
finally(handler: (value: R) => R): Promise<R>;
|
||||
finally(handler: (value: R) => void): Promise<void>;
|
||||
|
||||
lastly(handler: (value: R) => Promise.Thenable<R>): Promise<R>;
|
||||
lastly(handler: (value: R) => R): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise that follows this promise, but is bound to the given `thisArg` value. A bound promise will call its handlers with the bound value set to `this`. Additionally promises derived from a bound promise will also be bound promises with the same `thisArg` binding as the original promise.
|
||||
*/
|
||||
bind(thisArg: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but any unhandled rejection that ends up here will be thrown as an error.
|
||||
*/
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
done<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Shorthand for `.then(null, null, handler);`. Attach a progress handler that will be called if this promise is progressed. Returns a new promise chained from this promise.
|
||||
*/
|
||||
progressed(handler: (note: any) => any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.delay(this, ms)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
delay(ms: number): Promise<R>;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with this promise's fulfillment value or rejection reason. However, if this promise is not fulfilled or rejected within `ms` milliseconds, the returned promise is rejected with a `Promise.TimeoutError` instance.
|
||||
*
|
||||
* You may specify a custom error message with the `message` parameter.
|
||||
*/
|
||||
timeout(ms: number, message?: string): Promise<R>;
|
||||
|
||||
/**
|
||||
* Register a node-style callback on this promise. When this promise is is either fulfilled or rejected, the node callback will be called back with the node.js convention where error reason is the first argument and success value is the second argument. The error argument will be `null` in case of success.
|
||||
* Returns back this promise instead of creating a new one. If the `callback` argument is not a function, this method does not do anything.
|
||||
*/
|
||||
nodeify(callback: (err: any, value?: R) => void): Promise<R>;
|
||||
nodeify(...sink: any[]): void;
|
||||
|
||||
/**
|
||||
* Marks this promise as cancellable. Promises by default are not cancellable after v0.11 and must be marked as such for `.cancel()` to have any effect. Marking a promise as cancellable is infectious and you don't need to remark any descendant promise.
|
||||
*/
|
||||
cancellable(): Promise<R>;
|
||||
|
||||
/**
|
||||
* Cancel this promise. The cancellation will propagate to farthest cancellable ancestor promise which is still pending.
|
||||
*
|
||||
* That ancestor will then be rejected with a `CancellationError` (get a reference from `Promise.CancellationError`) object as the rejection reason.
|
||||
*
|
||||
* In a promise rejection handler you may check for a cancellation by seeing if the reason object has `.name === "Cancel"`.
|
||||
*
|
||||
* Promises are by default not cancellable. Use `.cancellable()` to mark a promise as cancellable.
|
||||
*/
|
||||
// TODO what to do with this?
|
||||
cancel<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Like `.then()`, but cancellation of the the returned promise or any of its descendant will not propagate cancellation to this promise or this promise's ancestors.
|
||||
*/
|
||||
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled: (value: R) => Promise.Thenable<U>, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Promise.Thenable<U>, onProgress?: (note: any) => any): Promise<U>;
|
||||
fork<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U, onProgress?: (note: any) => any): Promise<U>;
|
||||
|
||||
/**
|
||||
* Create an uncancellable promise based on this promise.
|
||||
*/
|
||||
uncancellable(): Promise<R>;
|
||||
|
||||
/**
|
||||
* See if this promise can be cancelled.
|
||||
*/
|
||||
isCancellable(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been fulfilled.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` has been rejected.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is still defer.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* See if this `promise` is resolved -> either fulfilled or rejected.
|
||||
*/
|
||||
isResolved(): boolean;
|
||||
|
||||
/**
|
||||
* Synchronously inspect the state of this `promise`. The `PromiseInspection` will represent the state of the promise as snapshotted at the time of calling `.inspect()`.
|
||||
*/
|
||||
inspect(): Promise.Inspection<R>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName].call(obj, arg...);
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
call(propertyName: string, ...args: any[]): Promise<any>;
|
||||
|
||||
/**
|
||||
* This is a convenience method for doing:
|
||||
*
|
||||
* <code>
|
||||
* promise.then(function(obj){
|
||||
* return obj[propertyName];
|
||||
* });
|
||||
* </code>
|
||||
*/
|
||||
// TODO find way to fix get()
|
||||
// get<U>(propertyName: string): Promise<U>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* return value;
|
||||
* });
|
||||
* </code>
|
||||
*
|
||||
* in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.return()`
|
||||
*
|
||||
* Alias `.thenReturn();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
return<U>(value: U): Promise<U>;
|
||||
thenReturn<U>(value: U): Promise<U>;
|
||||
return(): Promise<void>;
|
||||
thenReturn(): Promise<void>;
|
||||
|
||||
/**
|
||||
* Convenience method for:
|
||||
*
|
||||
* <code>
|
||||
* .then(function() {
|
||||
* throw reason;
|
||||
* });
|
||||
* </code>
|
||||
* Same limitations apply as with `.return()`.
|
||||
*
|
||||
* Alias `.thenThrow();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
throw(reason: Error): Promise<R>;
|
||||
thenThrow(reason: Error): Promise<R>;
|
||||
|
||||
/**
|
||||
* Convert to String.
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* This is implicitly called by `JSON.stringify` when serializing the object. Returns a serialized representation of the `Promise`.
|
||||
*/
|
||||
toJSON(): Object;
|
||||
|
||||
/**
|
||||
* Like calling `.then`, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.
|
||||
*/
|
||||
// TODO how to model instance.spread()? like Q?
|
||||
spread<U>(onFulfill: Function, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U>(onFulfill: Function, onReject?: (reason: any) => U): Promise<U>;
|
||||
/*
|
||||
// TODO or something like this?
|
||||
spread<U, W>(onFulfill: (...values: W[]) => Promise.Thenable<U>, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => Promise.Thenable<U>, onReject?: (reason: any) => U): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => Promise.Thenable<U>): Promise<U>;
|
||||
spread<U, W>(onFulfill: (...values: W[]) => U, onReject?: (reason: any) => U): Promise<U>;
|
||||
*/
|
||||
/**
|
||||
* Same as calling `Promise.all(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
all<U>(): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.props(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO how to model instance.props()?
|
||||
props(): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.settle(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
settle<U>(): Promise<Promise.Inspection<U>[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.any(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
any<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.some(thisPromise)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
some<U>(count: number): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.race(thisPromise, count)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
race<U>(): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.map(thisPromise, mapper)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => Promise.Thenable<U>): Promise<U>;
|
||||
map<Q, U>(mapper: (item: Q, index: number, arrayLength: number) => U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling `Promise.reduce(thisPromise, Function reducer, initialValue)`. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => Promise.Thenable<U>, initialValue?: U): Promise<U>;
|
||||
reduce<Q, U>(reducer: (memo: U, item: Q, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Same as calling ``Promise.filter(thisPromise, filterer)``. With the exception that if this promise is bound to a value, the returned promise is bound to that value too.
|
||||
*/
|
||||
// TODO type inference from array-resolving promise?
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => Promise.Thenable<boolean>): Promise<U>;
|
||||
filter<U>(filterer: (item: U, index: number, arrayLength: number) => boolean): Promise<U>;
|
||||
}
|
||||
|
||||
declare module Promise {
|
||||
|
||||
export interface Thenable<R> {
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => Thenable<U>, onRejected?: (error: any) => U): Thenable<U>;
|
||||
then<U>(onFulfilled: (value: R) => U, onRejected: (error: any) => Thenable<U>): Thenable<U>;
|
||||
then<U>(onFulfilled?: (value: R) => U, onRejected?: (error: any) => U): Thenable<U>;
|
||||
}
|
||||
|
||||
export interface Resolver<R> {
|
||||
/**
|
||||
* Resolve the underlying promise with `value` as the resolution value. If `value` is a thenable or a promise, the underlying promise will assume its state.
|
||||
*/
|
||||
resolve(value: R): void;
|
||||
|
||||
/**
|
||||
* Reject the underlying promise with `reason` as the rejection reason.
|
||||
*/
|
||||
reject(reason: any): void;
|
||||
|
||||
/**
|
||||
* Progress the underlying promise with `value` as the progression value.
|
||||
*/
|
||||
progress(value: any): void;
|
||||
|
||||
/**
|
||||
* Gives you a callback representation of the `PromiseResolver`. Note that this is not a method but a property. The callback accepts error object in first argument and success values on the 2nd parameter and the rest, I.E. node js conventions.
|
||||
*
|
||||
* If the the callback is called with multiple success values, the resolver fullfills its promise with an array of the values.
|
||||
*/
|
||||
// TODO specify resolver callback
|
||||
callback: Function;
|
||||
}
|
||||
|
||||
export interface Inspection<R> {
|
||||
/**
|
||||
* See if the underlying promise was fulfilled at the creation time of this inspection object.
|
||||
*/
|
||||
isFulfilled(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was rejected at the creation time of this inspection object.
|
||||
*/
|
||||
isRejected(): boolean;
|
||||
|
||||
/**
|
||||
* See if the underlying promise was defer at the creation time of this inspection object.
|
||||
*/
|
||||
isPending(): boolean;
|
||||
|
||||
/**
|
||||
* Get the fulfillment value of the underlying promise. Throws if the promise wasn't fulfilled at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
value(): R;
|
||||
|
||||
/**
|
||||
* Get the rejection reason for the underlying promise. Throws if the promise wasn't rejected at the creation time of this inspection object.
|
||||
*
|
||||
* throws `TypeError`
|
||||
*/
|
||||
error(): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
|
||||
*
|
||||
* Note about second argument: if it's specifically a true array, its values become respective arguments for the function call. Otherwise it is passed as is as the first argument for the function call.
|
||||
*
|
||||
* Alias for `attempt();` for compatibility with earlier ECMAScript version.
|
||||
*/
|
||||
// TODO find way to enable try() without tsc borking
|
||||
// see also: https://typescript.codeplex.com/workitem/2194
|
||||
/*
|
||||
export function try<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
export function try<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
*/
|
||||
|
||||
export function attempt<R>(fn: () => Promise.Thenable<R>, args?: any[], ctx?: any): Promise<R>;
|
||||
export function attempt<R>(fn: () => R, args?: any[], ctx?: any): Promise<R>;
|
||||
|
||||
/**
|
||||
* Returns a new function that wraps the given function `fn`. The new function will always return a promise that is fulfilled with the original functions return values or rejected with thrown exceptions from the original function.
|
||||
* This method is convenient when a function can sometimes return synchronously or throw synchronously.
|
||||
*/
|
||||
export function method(fn: Function): Function;
|
||||
|
||||
/**
|
||||
* Create a promise that is resolved with the given `value`. If `value` is a thenable or promise, the returned promise will assume its state.
|
||||
*/
|
||||
export function resolve<R>(value: Promise.Thenable<R>): Promise<R>;
|
||||
export function resolve<R>(value: R): Promise<R>;
|
||||
|
||||
/**
|
||||
* Create a promise that is rejected with the given `reason`.
|
||||
*/
|
||||
export function reject(reason: any): Promise<void>;
|
||||
|
||||
/**
|
||||
* Create a promise with undecided fate and return a `PromiseResolver` to control it. See resolution?: Promise(#promise-resolution).
|
||||
*/
|
||||
export function defer<R>(): Promise.Resolver<R>;
|
||||
|
||||
/**
|
||||
* Cast the given `value` to a trusted promise. If `value` is already a trusted `Promise`, it is returned as is. If `value` is not a thenable, a fulfilled is: Promise returned with `value` as its fulfillment value. If `value` is a thenable (Promise-like object, like those returned by jQuery's `$.ajax`), returns a trusted that: Promise assimilates the state of the thenable.
|
||||
*/
|
||||
export function cast<R>(value: Promise.Thenable<R>): Promise<R>;
|
||||
export function cast<R>(value: R): Promise<R>;
|
||||
|
||||
/**
|
||||
* Sugar for `Promise.resolve(undefined).bind(thisArg);`. See `.bind()`.
|
||||
*/
|
||||
export function bind(thisArg: any): Promise<void>;
|
||||
|
||||
/**
|
||||
* See if `value` is a trusted Promise.
|
||||
*/
|
||||
export function is(value: any): boolean;
|
||||
|
||||
/**
|
||||
* Call this right after the library is loaded to enabled long stack traces. Long stack traces cannot be disabled after being enabled, and cannot be enabled after promises have alread been created. Long stack traces imply a substantial performance penalty, around 4-5x for throughput and 0.5x for latency.
|
||||
*/
|
||||
export function longStackTraces(): void;
|
||||
|
||||
/**
|
||||
* Returns a promise that will be fulfilled with `value` (or `undefined`) after given `ms` milliseconds. If `value` is a promise, the delay will start counting down when it is fulfilled and the returned promise will be fulfilled with the fulfillment value of the `value` promise.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
export function delay<R>(value: Promise.Thenable<R>, ms: number): Promise<R>;
|
||||
export function delay<R>(value: R, ms: number): Promise<R>;
|
||||
export function delay(ms: number): Promise<void>;
|
||||
|
||||
/**
|
||||
* Returns a function that will wrap the given `nodeFunction`. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.
|
||||
*
|
||||
* If the `nodeFunction` calls its callback with multiple success values, the fulfillment value will be an array of them.
|
||||
*
|
||||
* If you pass a `receiver`, the `nodeFunction` will be called as a method on the `receiver`.
|
||||
*/
|
||||
// TODO how to model promisify?
|
||||
export function promisify(nodeFunction: Function, receiver?: any): Function;
|
||||
|
||||
/**
|
||||
* Promisifies the entire object by going through the object's properties and creating an async equivalent of each function on the object and its prototype chain. The promisified method name will be the original method name postfixed with `Async`. Returns the input object.
|
||||
*
|
||||
* Note that the original methods on the object are not overwritten but new methods are created with the `Async`-postfix. For example, if you `promisifyAll()` the node.js `fs` object use `fs.statAsync()` to call the promisified `stat` method.
|
||||
*/
|
||||
// TODO how to model promisifyAll?
|
||||
export function promisifyAll(target: Object): Object;
|
||||
|
||||
/**
|
||||
* Returns a function that can use `yield` to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
|
||||
*/
|
||||
// TODO fix coroutine GeneratorFunction
|
||||
export function coroutine<R>(generatorFunction: Function): Function;
|
||||
|
||||
/**
|
||||
* Spawn a coroutine which may yield promises to run asynchronous code synchronously. This feature requires the support of generators which are drafted in the next version of the language. Node version greater than `0.11.2` is required and needs to be executed with the `--harmony-generators` (or `--harmony`) command-line switch.
|
||||
*/
|
||||
// TODO fix spawn GeneratorFunction
|
||||
export function spawn<R>(generatorFunction: Function): Promise<R>;
|
||||
|
||||
/**
|
||||
* This is relevant to browser environments with no module loader.
|
||||
*
|
||||
* Release control of the `Promise` namespace to whatever it was before this library was loaded. Returns a reference to the library namespace so you can attach it to something else.
|
||||
*/
|
||||
export function noConflict(): typeof Promise;
|
||||
|
||||
/**
|
||||
* Add `handler` as the handler to call when there is a possibly unhandled rejection. The default handler logs the error stack to stderr or `console.error` in browsers.
|
||||
*
|
||||
* Passing no value or a non-function will have the effect of removing any kind of handling for possibly unhandled rejections.
|
||||
*/
|
||||
export function onPossiblyUnhandledRejection(handler: (reason: any) => any): void;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are fulfilled. The promise's fulfillment value is an array with fulfillment values at respective positions to the original array. If any promise in the array rejects, the returned promise is rejected with the rejection reason.
|
||||
*/
|
||||
// TODO enable more overloads
|
||||
// promise of array with promises of value
|
||||
export function all<R>(values: Thenable<Thenable<R>[]>): Promise<R[]>;
|
||||
// promise of array with values
|
||||
export function all<R>(values: Thenable<R[]>): Promise<R[]>;
|
||||
// array with promises of value
|
||||
export function all<R>(values: Thenable<R>[]): Promise<R[]>;
|
||||
// array with values
|
||||
export function all<R>(values: R[]): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Like ``Promise.all`` but for object properties instead of array items. Returns a promise that is fulfilled when all the properties of the object are fulfilled. The promise's fulfillment value is an object with fulfillment values at respective keys to the original object. If any promise in the object rejects, the returned promise is rejected with the rejection reason.
|
||||
*
|
||||
* If `object` is a trusted `Promise`, then it will be treated as a promise for object rather than for its properties. All other objects are treated for their properties as is returned by `Object.keys` - the object's own enumerable properties.
|
||||
*
|
||||
* *The original object is not modified.*
|
||||
*/
|
||||
// TODO verify this is correct
|
||||
// trusted promise for object
|
||||
export function props(object: Promise<Object>): Promise<Object>;
|
||||
// object
|
||||
export function props(object: Object): Promise<Object>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled when all the items in the array are either fulfilled or rejected. The fulfillment value is an array of ``PromiseInspection`` instances at respective positions in relation to the input array.
|
||||
*
|
||||
* *original: The array is not modified. The input array sparsity is retained in the resulting array.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
export function settle<R>(values: Thenable<Thenable<R>[]>): Promise<Promise.Inspection<R>[]>;
|
||||
// promise of array with values
|
||||
export function settle<R>(values: Thenable<R[]>): Promise<Promise.Inspection<R>[]>;
|
||||
// array with promises of value
|
||||
export function settle<R>(values: Thenable<R>[]): Promise<Promise.Inspection<R>[]>;
|
||||
// array with values
|
||||
export function settle<R>(values: R[]): Promise<Promise.Inspection<R>[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.some()`, with 1 as `count`. However, if the promise fulfills, the fulfillment value is not an array of 1 but the value directly.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
export function any<R>(values: Thenable<Thenable<R>[]>): Promise<R>;
|
||||
// promise of array with values
|
||||
export function any<R>(values: Thenable<R[]>): Promise<R>;
|
||||
// array with promises of value
|
||||
export function any<R>(values: Thenable<R>[]): Promise<R>;
|
||||
// array with values
|
||||
export function any<R>(values: R[]): Promise<R>;
|
||||
|
||||
/**
|
||||
* Given an array, or a promise of an array, which contains promises (or a mix of promises and values) return a promise that is fulfilled or rejected as soon as a promise in the array is fulfilled or rejected with the respective rejection reason or fulfillment value.
|
||||
*
|
||||
* **Note** If you pass empty array or a sparse array with no values, or a promise/thenable for such, it will be forever pending.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
export function race<R>(values: Thenable<Thenable<R>[]>): Promise<R>;
|
||||
// promise of array with values
|
||||
export function race<R>(values: Thenable<R[]>): Promise<R>;
|
||||
// array with promises of value
|
||||
export function race<R>(values: Thenable<R>[]): Promise<R>;
|
||||
// array with values
|
||||
export function race<R>(values: R[]): Promise<R>;
|
||||
|
||||
/**
|
||||
* Initiate a competetive race between multiple promises or values (values will become immediately fulfilled promises). When `count` amount of promises have been fulfilled, the returned promise is fulfilled with an array that contains the fulfillment values of the winners in order of resolution.
|
||||
*
|
||||
* If too many promises are rejected so that the promise can never become fulfilled, it will be immediately rejected with an array of rejection reasons in the order they were thrown in.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
export function some<R>(values: Thenable<Thenable<R>[]>, count: number): Promise<R[]>;
|
||||
// promise of array with values
|
||||
export function some<R>(values: Thenable<R[]>, count: number): Promise<R[]>;
|
||||
// array with promises of value
|
||||
export function some<R>(values: Thenable<R>[], count: number): Promise<R[]>;
|
||||
// array with values
|
||||
export function some<R>(values: R[], count: number): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Like `Promise.all()` but instead of having to pass an array, the array is generated from the passed variadic arguments.
|
||||
*/
|
||||
// variadic array with promises of value
|
||||
export function join<R>(...values: Thenable<R>[]): Promise<R[]>;
|
||||
// variadic array with values
|
||||
export function join<R>(...values: R[]): Promise<R[]>;
|
||||
|
||||
/**
|
||||
* Map an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `mapper` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the `mapper` function returns promises or thenables, the returned promise will wait for all the mapped results to be resolved as well.
|
||||
*
|
||||
* *The original array is not modified.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
export function map<R, U>(values: Thenable<Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => Thenable<U>): Promise<U[]>;
|
||||
export function map<R, U>(values: Thenable<Thenable<R>[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// promise of array with values
|
||||
export function map<R, U>(values: Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => Thenable<U>): Promise<U[]>;
|
||||
export function map<R, U>(values: Thenable<R[]>, mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// array with promises of value
|
||||
export function map<R, U>(values: Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => Thenable<U>): Promise<U[]>;
|
||||
export function map<R, U>(values: Thenable<R>[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
// array with values
|
||||
export function map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => Thenable<U>): Promise<U[]>;
|
||||
export function map<R, U>(values: R[], mapper: (item: R, index: number, arrayLength: number) => U): Promise<U[]>;
|
||||
|
||||
/**
|
||||
* Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `reducer` function with the signature `(total, current, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
|
||||
*
|
||||
* *The original array is not modified. If no `intialValue` is given and the array doesn't contain at least 2 items, the callback will not be called and `undefined` is returned. If `initialValue` is given and the array doesn't have at least 1 item, `initialValue` is returned.*
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
export function reduce<R, U>(values: Thenable<Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Thenable<U>, initialValue?: U): Promise<U>;
|
||||
export function reduce<R, U>(values: Thenable<Thenable<R>[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// promise of array with values
|
||||
export function reduce<R, U>(values: Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => Thenable<U>, initialValue?: U): Promise<U>;
|
||||
export function reduce<R, U>(values: Thenable<R[]>, reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with promises of value
|
||||
export function reduce<R, U>(values: Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => Thenable<U>, initialValue?: U): Promise<U>;
|
||||
export function reduce<R, U>(values: Thenable<R>[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
// array with values
|
||||
export function reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => Thenable<U>, initialValue?: U): Promise<U>;
|
||||
export function reduce<R, U>(values: R[], reducer: (total: U, current: R, index: number, arrayLength: number) => U, initialValue?: U): Promise<U>;
|
||||
|
||||
/**
|
||||
* Filter an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given `filterer` function with the signature `(item, index, arrayLength)` where `item` is the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.
|
||||
*
|
||||
* The return values from the filtered functions are coerced to booleans, with the exception of promises and thenables which are awaited for their eventual result.
|
||||
*
|
||||
* *The original array is not modified.
|
||||
*/
|
||||
// promise of array with promises of value
|
||||
export function filter<R>(values: Thenable<Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => Thenable<boolean>): Promise<R[]>;
|
||||
export function filter<R>(values: Thenable<Thenable<R>[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// promise of array with values
|
||||
export function filter<R>(values: Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => Thenable<boolean>): Promise<R[]>;
|
||||
export function filter<R>(values: Thenable<R[]>, filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// array with promises of value
|
||||
export function filter<R>(values: Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => Thenable<boolean>): Promise<R[]>;
|
||||
export function filter<R>(values: Thenable<R>[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
|
||||
// array with values
|
||||
export function filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => Thenable<boolean>): Promise<R[]>;
|
||||
export function filter<R>(values: R[], filterer: (item: R, index: number, arrayLength: number) => boolean): Promise<R[]>;
|
||||
}
|
||||
|
||||
declare module 'bluebird' {
|
||||
export = Promise;
|
||||
}
|
||||
-252
@@ -1,252 +0,0 @@
|
||||
// Type definitions for Lazy.js 0.3.2
|
||||
// Project: https://github.com/dtao/lazy.js/
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module LazyJS {
|
||||
|
||||
interface LazyStatic {
|
||||
|
||||
<T>(value: T[]):ArrayLikeSequence<T>;
|
||||
(value: any[]):ArrayLikeSequence<any>;
|
||||
<T>(value: Object):ObjectLikeSequence<T>;
|
||||
(value: Object):ObjectLikeSequence<any>;
|
||||
(value: string):StringLikeSequence;
|
||||
|
||||
strict():LazyStatic;
|
||||
|
||||
generate<T>(generatorFn: GeneratorCallback<T>, length?: number):GeneratedSequence<T>;
|
||||
|
||||
range(to: number):GeneratedSequence<number>;
|
||||
range(from: number, to: number, step?: number):GeneratedSequence<number>;
|
||||
|
||||
repeat<T>(value: T, count?: number):GeneratedSequence<T>;
|
||||
|
||||
on<T>(eventType: string):Sequence<T>;
|
||||
|
||||
readFile(path: string):StringLikeSequence;
|
||||
makeHttpRequest(path: string):StringLikeSequence;
|
||||
}
|
||||
|
||||
interface ArrayLike<T> {
|
||||
length:number;
|
||||
[index:number]:T;
|
||||
}
|
||||
|
||||
interface Callback {
|
||||
():void;
|
||||
}
|
||||
|
||||
interface ErrorCallback {
|
||||
(error: any):void;
|
||||
}
|
||||
|
||||
interface ValueCallback<T> {
|
||||
(value: T):void;
|
||||
}
|
||||
|
||||
interface GetKeyCallback<T> {
|
||||
(value: T):string;
|
||||
}
|
||||
|
||||
interface TestCallback<T> {
|
||||
(value: T):boolean;
|
||||
}
|
||||
|
||||
interface MapCallback<T, U> {
|
||||
(value: T):U;
|
||||
}
|
||||
|
||||
interface MapStringCallback {
|
||||
(value: string):string;
|
||||
}
|
||||
|
||||
interface NumberCallback<T> {
|
||||
(value: T):number;
|
||||
}
|
||||
|
||||
interface MemoCallback<T, U> {
|
||||
(memo: U, value: T):U;
|
||||
}
|
||||
|
||||
interface GeneratorCallback<T> {
|
||||
(index: number):T;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
interface Iterator<T> {
|
||||
new (sequence: Sequence<T>):Iterator<T>;
|
||||
current():T;
|
||||
moveNext():boolean;
|
||||
}
|
||||
|
||||
interface GeneratedSequence<T> extends Sequence<T> {
|
||||
new(generatorFn: GeneratorCallback<T>, length: number):GeneratedSequence<T>;
|
||||
length():number;
|
||||
}
|
||||
|
||||
interface AsyncSequence<T> extends SequenceBase<T> {
|
||||
each(callback: ValueCallback<T>):AsyncHandle<T>;
|
||||
}
|
||||
|
||||
interface AsyncHandle<T> {
|
||||
cancel():void;
|
||||
onComplete(callback: Callback):void;
|
||||
onError(callback: ErrorCallback):void;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
module Sequence {
|
||||
function define(methodName: string[], overrides: Object): Function;
|
||||
}
|
||||
|
||||
interface Sequence<T> extends SequenceBase<T> {
|
||||
each(eachFn: ValueCallback<T>):Sequence<T>;
|
||||
}
|
||||
|
||||
interface SequenceBase<T> extends SequenceBaser<T> {
|
||||
first():any;
|
||||
first(count: number):Sequence<T>;
|
||||
indexOf(value: any, startIndex?: number):Sequence<T>;
|
||||
|
||||
last():any;
|
||||
last(count: number):Sequence<T>;
|
||||
lastIndexOf(value: any):Sequence<T>;
|
||||
|
||||
reverse():Sequence<T>;
|
||||
}
|
||||
|
||||
interface SequenceBaser<T> {
|
||||
// TODO improve define() (needs ugly overload)
|
||||
async(interval: number):AsyncSequence<T>;
|
||||
chunk(size: number):Sequence<T>;
|
||||
compact():Sequence<T>;
|
||||
concat(var_args: T[]):Sequence<T>;
|
||||
consecutive(length: number):Sequence<T>;
|
||||
contains(value: T):boolean;
|
||||
countBy(keyFn: GetKeyCallback<T>): ObjectLikeSequence<T>;
|
||||
countBy(propertyName: string): ObjectLikeSequence<T>;
|
||||
dropWhile(predicateFn: TestCallback<T>): Sequence<T>;
|
||||
every(predicateFn: TestCallback<T>): boolean;
|
||||
filter(predicateFn: TestCallback<T>): Sequence<T>;
|
||||
find(predicateFn: TestCallback<T>): Sequence<T>;
|
||||
findWhere(properties: Object): Sequence<T>;
|
||||
|
||||
flatten(): Sequence<T>;
|
||||
groupBy(keyFn: GetKeyCallback<T>): ObjectLikeSequence<T>;
|
||||
initial(count?: number): Sequence<T>;
|
||||
intersection(var_args: T[]): Sequence<T>;
|
||||
invoke(methodName: string): Sequence<T>;
|
||||
isEmpty(): boolean;
|
||||
join(delimiter?: string): string;
|
||||
map<U>(mapFn: MapCallback<T, U>): Sequence<U>;
|
||||
|
||||
max(valueFn?: NumberCallback<T>): T;
|
||||
min(valueFn?: NumberCallback<T>): T;
|
||||
pluck(propertyName: string): Sequence<T>;
|
||||
reduce<U>(aggregatorFn: MemoCallback<T, U>, memo?: U): U;
|
||||
reduceRight<U>(aggregatorFn: MemoCallback<T, U>, memo: U): U;
|
||||
reject(predicateFn: TestCallback<T>): Sequence<T>;
|
||||
rest(count?: number): Sequence<T>;
|
||||
shuffle(): Sequence<T>;
|
||||
some(predicateFn?: TestCallback<T>): boolean;
|
||||
sortBy(sortFn: NumberCallback<T>): Sequence<T>;
|
||||
sortedIndex(value: T): Sequence<T>;
|
||||
sum(valueFn?: NumberCallback<T>): Sequence<T>;
|
||||
takeWhile(predicateFn: TestCallback<T>): Sequence<T>;
|
||||
union(var_args: T[]): Sequence<T>;
|
||||
uniq(): Sequence<T>;
|
||||
where(properties: Object): Sequence<T>;
|
||||
without(var_args: T[]): Sequence<T>;
|
||||
zip(var_args: T[]): Sequence<T>;
|
||||
|
||||
toArray(): T[];
|
||||
toObject(): Object;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
module ArrayLikeSequence {
|
||||
function define(methodName: string[], overrides: Object): Function;
|
||||
}
|
||||
|
||||
interface ArrayLikeSequence<T> extends Sequence<T> {
|
||||
// define()X;
|
||||
concat(): ArrayLikeSequence<T>;
|
||||
first(count?: number): ArrayLikeSequence<T>;
|
||||
get(index: number): T;
|
||||
length(): number;
|
||||
map<U>(mapFn: MapCallback<T, U>): ArrayLikeSequence<U>;
|
||||
pop(): ArrayLikeSequence<T>;
|
||||
rest(count?: number): ArrayLikeSequence<T>;
|
||||
reverse(): ArrayLikeSequence<T>;
|
||||
shift(): ArrayLikeSequence<T>;
|
||||
slice(begin: number, end?: number): ArrayLikeSequence<T>;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
module ObjectLikeSequence {
|
||||
function define(methodName: string[], overrides: Object): Function;
|
||||
}
|
||||
|
||||
interface ObjectLikeSequence<T> extends Sequence<T> {
|
||||
assign(other: Object): ObjectLikeSequence<T>;
|
||||
// throws error
|
||||
//async(): X;
|
||||
defaults(defaults: Object): ObjectLikeSequence<T>;
|
||||
functions(): Sequence<T>;
|
||||
get(property: string): ObjectLikeSequence<T>;
|
||||
invert(): ObjectLikeSequence<T>;
|
||||
keys(): Sequence<string>;
|
||||
omit(properties: string[]): ObjectLikeSequence<T>;
|
||||
pairs(): Sequence<T>;
|
||||
pick(properties: string[]): ObjectLikeSequence<T>;
|
||||
toArray(): T[];
|
||||
toObject(): Object;
|
||||
values(): Sequence<T>;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
||||
module StringLikeSequence {
|
||||
function define(methodName: string[], overrides: Object): Function;
|
||||
}
|
||||
|
||||
interface StringLikeSequence extends SequenceBaser<string> {
|
||||
charAt(index: number): string;
|
||||
charCodeAt(index: number): number;
|
||||
contains(value: string): boolean;
|
||||
endsWith(suffix: string): boolean;
|
||||
|
||||
first(): string;
|
||||
first(count: number): StringLikeSequence;
|
||||
|
||||
indexOf(substring: string, startIndex?: number): number;
|
||||
|
||||
last(): string;
|
||||
last(count: number): StringLikeSequence;
|
||||
|
||||
lastIndexOf(substring: string, startIndex?: number): number;
|
||||
mapString(mapFn: MapStringCallback): StringLikeSequence;
|
||||
match(pattern: RegExp): StringLikeSequence;
|
||||
reverse(): StringLikeSequence;
|
||||
|
||||
split(delimiter: string): StringLikeSequence;
|
||||
split(delimiter: RegExp): StringLikeSequence;
|
||||
|
||||
startsWith(prefix: string): boolean;
|
||||
substring(start: number, stop?: number): StringLikeSequence;
|
||||
toLowerCase(): StringLikeSequence;
|
||||
toUpperCase(): StringLikeSequence;
|
||||
}
|
||||
}
|
||||
|
||||
declare var Lazy: LazyJS.LazyStatic;
|
||||
|
||||
declare module 'lazy.js' {
|
||||
export = Lazy;
|
||||
}
|
||||
|
||||
-1258
File diff suppressed because it is too large
Load Diff
@@ -1,48 +0,0 @@
|
||||
// https://github.com/substack/node-optimist
|
||||
// sourced from https://github.com/soywiz/typescript-node-definitions/blob/master/optimist.d.ts
|
||||
// rehacked by @Bartvds
|
||||
|
||||
declare module Optimist {
|
||||
export interface Argv {
|
||||
_: string[];
|
||||
}
|
||||
export interface Optimist {
|
||||
default(name: string, value: any): Optimist;
|
||||
default(args: any): Optimist;
|
||||
|
||||
boolean(name: string): Optimist;
|
||||
boolean(names: string[]): Optimist;
|
||||
|
||||
string(name: string): Optimist;
|
||||
string(names: string[]): Optimist;
|
||||
|
||||
wrap(columns): Optimist;
|
||||
|
||||
help(): Optimist;
|
||||
showHelp(fn?: Function): Optimist;
|
||||
|
||||
usage(message: string): Optimist;
|
||||
|
||||
demand(key: string): Optimist;
|
||||
demand(key: number): Optimist;
|
||||
demand(key: string[]): Optimist;
|
||||
|
||||
alias(key: string, alias: string): Optimist;
|
||||
|
||||
describe(key: string, desc: string): Optimist;
|
||||
|
||||
options(key: string, opt: any): Optimist;
|
||||
|
||||
check(fn: Function);
|
||||
|
||||
parse(args: string[]): Optimist;
|
||||
|
||||
argv: Argv;
|
||||
}
|
||||
}
|
||||
interface Optimist extends Optimist.Optimist {
|
||||
(args: string[]): Optimist.Optimist;
|
||||
}
|
||||
declare module 'optimist' {
|
||||
export = Optimist;
|
||||
}
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
/// <reference path="node/node.d.ts" />
|
||||
/// <reference path="bluebird/bluebird.d.ts" />
|
||||
/// <reference path="lazy.js/lazy.js.d.ts" />
|
||||
/// <reference path="optimist/optimist.d.ts" />
|
||||
@@ -0,0 +1,32 @@
|
||||
/// <reference path="alertify.d.ts" />
|
||||
|
||||
alertify.init();
|
||||
|
||||
alertify.alert("This is an alert");
|
||||
alertify.alert("This is an alert with a callback", () => {
|
||||
alertify.success("Alert finished");
|
||||
}, "myCustomClass");
|
||||
|
||||
|
||||
alertify.confirm("This is a confirm request");
|
||||
alertify.confirm("This is a confirm request with a callback", () => {
|
||||
alertify.success("Confirm finished");
|
||||
}, "myCustomClass");
|
||||
|
||||
var custom = alertify.extend("custom");
|
||||
|
||||
alertify.log("log message 1");
|
||||
alertify.log("log message 2", "success", 3000);
|
||||
|
||||
alertify.prompt("prompt message 1");
|
||||
alertify.prompt("prompt message 2", () => { console.log("callback"); }, "ok", "myClass");
|
||||
|
||||
alertify.set({ delay: 1000 });
|
||||
alertify.set({ labels: { ok: "OK", cancel: "Cancel" }});
|
||||
alertify.set({ buttonFocus: "ok" });
|
||||
alertify.set({ buttonReverse: true });
|
||||
|
||||
alertify.success("This is a success message");
|
||||
alertify.error("This is an error message");
|
||||
|
||||
alertify.debug();
|
||||
Vendored
+124
@@ -0,0 +1,124 @@
|
||||
// Type definitions for alertify 0.3.11
|
||||
// Project: http://fabien-d.github.io/alertify.js/
|
||||
// Definitions by: John Jeffery <http://github.com/jjeffery>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare var alertify: alertify.IAlertifyStatic;
|
||||
|
||||
declare module alertify {
|
||||
interface IAlertifyStatic {
|
||||
/**
|
||||
* Create an alert dialog box
|
||||
* @param message The message passed from the callee
|
||||
* @param fn Callback function
|
||||
* @param cssClass Class(es) to append to dialog box
|
||||
* @return alertify (ie this)
|
||||
* @since 0.0.1
|
||||
*/
|
||||
alert(message: string, fn?: Function, cssClass?: string): IAlertifyStatic;
|
||||
|
||||
/**
|
||||
* Create a confirm dialog box
|
||||
* @param message The message passed from the callee
|
||||
* @param fn Callback function
|
||||
* @param cssClass Class(es) to append to dialog box
|
||||
* @return alertify (ie this)
|
||||
* @since 0.0.1
|
||||
*/
|
||||
confirm(message: string, fn?: Function, cssClass?: string): IAlertifyStatic;
|
||||
|
||||
/**
|
||||
* Extend the log method to create custom methods
|
||||
* @param type Custom method name
|
||||
* @return function for logging
|
||||
* @since 0.0.1
|
||||
*/
|
||||
extend(type: string): (message: string, wait?: number) => IAlertifyStatic;
|
||||
|
||||
/**
|
||||
* Initialize Alertify and create the 2 main elements.
|
||||
* Initialization will happen automatically on the first
|
||||
* use of alert, confirm, prompt or log.
|
||||
* @since 0.0.1
|
||||
*/
|
||||
init(): void;
|
||||
|
||||
/**
|
||||
* Show a new log message box
|
||||
* @param message The message passed from the callee
|
||||
* @param type Optional type of log message
|
||||
* @param wait Optional time (in ms) to wait before auto-hiding
|
||||
* @return alertify (ie this)
|
||||
* @since 0.0.1
|
||||
*/
|
||||
log(message: string, type?: string, wait?: number): IAlertifyStatic;
|
||||
|
||||
/**
|
||||
* Create a prompt dialog box
|
||||
* @param message The message passed from the callee
|
||||
* @param fn Callback function
|
||||
* @param placeholder Default value for prompt input
|
||||
* @param cssClass Class(es) to append to dialog
|
||||
* @return alertify (ie this)
|
||||
* @since 0.0.1
|
||||
*/
|
||||
prompt(message: string, fn?: Function, placeholder?: string, cssClass?: string): IAlertifyStatic;
|
||||
|
||||
/**
|
||||
* Shorthand for log messages
|
||||
* @param message The message passed from the callee
|
||||
* @return alertify (ie this)
|
||||
* @since 0.0.1
|
||||
*/
|
||||
success(message: string): IAlertifyStatic;
|
||||
|
||||
/**
|
||||
* Shorthand for log messages
|
||||
* @param message The message passed from the callee
|
||||
* @return alertify (ie this)
|
||||
* @since 0.0.1
|
||||
*/
|
||||
error(message: string): IAlertifyStatic;
|
||||
|
||||
/**
|
||||
* Used to set alertify properties
|
||||
* @param Properties
|
||||
* @since 0.2.11
|
||||
*/
|
||||
set(args: IProperties): void;
|
||||
|
||||
/**
|
||||
* The labels used for dialog buttons
|
||||
*/
|
||||
labels: ILabels;
|
||||
|
||||
/**
|
||||
* Attaches alertify.error to window.onerror method
|
||||
* @since 0.3.8
|
||||
*/
|
||||
debug(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Properties for alertify.set function
|
||||
*/
|
||||
interface IProperties {
|
||||
/** Default value for milliseconds display of log messages */
|
||||
delay?: number;
|
||||
|
||||
/** Default values for display of labels */
|
||||
labels?: ILabels;
|
||||
|
||||
/** Default button for focus */
|
||||
buttonFocus?: string;
|
||||
|
||||
/** Should buttons be displayed in reverse order */
|
||||
buttonReverse?: boolean;
|
||||
}
|
||||
|
||||
/** Labels for altertify.set function */
|
||||
interface ILabels {
|
||||
ok?: string;
|
||||
cancel?: string;
|
||||
}
|
||||
}
|
||||
@@ -176,8 +176,7 @@ amplify.request("twitter-mentions", { user: "amplifyjs" });
|
||||
|
||||
//Example:
|
||||
|
||||
amplify.request.decoders.appEnvelope =
|
||||
function (data, status, xhr, success, error) {
|
||||
var appEnvelopeDecoder: amplifyDecoder = function (data, status, xhr, success, error) {
|
||||
if (data.status === "success") {
|
||||
success(data.data);
|
||||
} else if (data.status === "fail" || data.status === "error") {
|
||||
@@ -187,6 +186,17 @@ function (data, status, xhr, success, error) {
|
||||
}
|
||||
};
|
||||
|
||||
//a new decoder can be added to the amplifyDecoders interface
|
||||
interface amplifyDecoders {
|
||||
appEnvelope: amplifyDecoder;
|
||||
}
|
||||
|
||||
amplify.request.decoders.appEnvelope = appEnvelopeDecoder;
|
||||
|
||||
//but you can also just add it via an index
|
||||
amplify.request.decoders['appEnvelopeStr'] = appEnvelopeDecoder;
|
||||
|
||||
|
||||
amplify.request.define("decoderExample", "ajax", {
|
||||
url: "/myAjaxUrl",
|
||||
type: "POST",
|
||||
|
||||
Vendored
+28
-6
@@ -3,11 +3,33 @@
|
||||
// Definitions by: Jonas Eriksson <https://github.com/joeriks/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
interface amplifyRequestSettings {
|
||||
resourceId: string;
|
||||
data?: any;
|
||||
success?: Function;
|
||||
error?: Function;
|
||||
success?: (...args: any[]) => void;
|
||||
error?: (...args: any[]) => void;
|
||||
}
|
||||
|
||||
interface amplifyDecoder {
|
||||
(
|
||||
data?: any,
|
||||
status?: string,
|
||||
xhr?: JQueryXHR,
|
||||
success?: (...args: any[]) => void,
|
||||
error?: (...args: any[]) => void
|
||||
): void
|
||||
}
|
||||
|
||||
interface amplifyDecoders {
|
||||
[decoderName: string]: amplifyDecoder;
|
||||
jsSend: amplifyDecoder;
|
||||
}
|
||||
|
||||
interface amplifyAjaxSettings extends JQueryAjaxSettings {
|
||||
cache?: any;
|
||||
decoder?: any /* string or amplifyDecoder */;
|
||||
}
|
||||
|
||||
interface amplifyRequest {
|
||||
@@ -39,7 +61,7 @@ interface amplifyRequest {
|
||||
* cache: See the cache section for more details.
|
||||
* decoder: See the decoder section for more details.
|
||||
*/
|
||||
define(resourceId: string, requestType: string, settings?: any): void;
|
||||
define(resourceId: string, requestType: string, settings?: amplifyAjaxSettings): void;
|
||||
|
||||
/***
|
||||
* Define a custom request.
|
||||
@@ -50,9 +72,9 @@ interface amplifyRequest {
|
||||
* success: Callback to invoke on success.
|
||||
* error: Callback to invoke on error.
|
||||
*/
|
||||
define(resourceId: string, resource: Function): void;
|
||||
|
||||
decoders: any;
|
||||
define(resourceId: string, resource: (settings: amplifyRequestSettings) => void): void;
|
||||
|
||||
decoders: amplifyDecoders;
|
||||
cache: any;
|
||||
}
|
||||
|
||||
|
||||
+11
-3
@@ -1,11 +1,18 @@
|
||||
// Type definitions for Angular Translate (pascalprecht.translate module)
|
||||
// Project: https://github.com/PascalPrecht/angular-translate
|
||||
// Definitions by: Michel Salib <michelsalib@hotmail.com>
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
|
||||
declare module ng.translate {
|
||||
|
||||
interface ITranslatePartialLoaderService {
|
||||
addPart(name: string): ITranslatePartialLoaderService;
|
||||
deletePart(name: string, removeData?: boolean): ITranslatePartialLoaderService;
|
||||
isPartAvailable(name: string): boolean;
|
||||
}
|
||||
|
||||
interface ITranslationTable {
|
||||
[key: string]: string;
|
||||
}
|
||||
@@ -13,7 +20,7 @@ declare module ng.translate {
|
||||
interface ILanguageKeyAlias {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
|
||||
interface IStorage {
|
||||
get(name: string): string;
|
||||
set(name: string, value: string): void;
|
||||
@@ -28,6 +35,7 @@ declare module ng.translate {
|
||||
interface ITranslateService {
|
||||
(key: string, ...params: string[]): ng.IPromise<string>;
|
||||
cloakClassName(): string;
|
||||
cloakClassName(name: string): ITranslateProvider;
|
||||
fallbackLanguage(langKey?: string): string;
|
||||
fallbackLanguage(langKey?: string[]): string;
|
||||
instant(translationId: string, interpolateParams?: any, interpolationId?: string): string;
|
||||
@@ -79,6 +87,6 @@ declare module ng.translate {
|
||||
usePostCompiling(value: boolean): ITranslateProvider;
|
||||
determinePreferredLanguage(fn?: () => void): ITranslateProvider;
|
||||
registerAvailableLanguageKeys(): string[];
|
||||
registerAvailableLanguageKeys(languageKeys: string[], aliases?: ILanguageKeyAlias[]): ITranslateProvider;
|
||||
registerAvailableLanguageKeys(languageKeys: string[], aliases?: ILanguageKeyAlias): ITranslateProvider;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,10 @@ myApp.config((
|
||||
$urlMatcherFactory: ng.ui.IUrlMatcherFactory) => {
|
||||
|
||||
var matcher: ng.ui.IUrlMatcher = $urlMatcherFactory.compile("/foo/:bar?param1");
|
||||
var obj: Object = matcher.exec('/user/bob', { x:'1', q:'hello' });
|
||||
var concat: ng.ui.IUrlMatcher = matcher.concat('/test');
|
||||
var str: string = matcher.format({ id:'bob', q:'yes' });
|
||||
var arr: string[] = matcher.parameters();
|
||||
|
||||
$urlRouterProvider
|
||||
.when('/test', '/list')
|
||||
@@ -78,12 +82,13 @@ interface IUrlLocatorTestService {
|
||||
|
||||
// Service for determining who the currently logged on user is.
|
||||
class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
static $inject = ["$http", "$rootScope", "$urlRouter"];
|
||||
static $inject = ["$http", "$rootScope", "$urlRouter", "$state"];
|
||||
|
||||
constructor(
|
||||
private $http: ng.IHttpService,
|
||||
private $rootScope: ng.IRootScopeService,
|
||||
private $urlRouter: ng.ui.IUrlRouterService
|
||||
private $urlRouter: ng.ui.IUrlRouterService,
|
||||
private $state: ng.ui.IStateService
|
||||
) {
|
||||
$rootScope.$on("$locationChangeSuccess", (event: ng.IAngularEvent) => this.onLocationChangeSuccess(event));
|
||||
}
|
||||
@@ -107,6 +112,23 @@ class UrlLocatorTestService implements IUrlLocatorTestService {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private stateServiceTest() {
|
||||
this.$state.go("myState");
|
||||
this.$state.transitionTo("myState");
|
||||
if (this.$state.includes("myState") === true) {
|
||||
//
|
||||
}
|
||||
if (this.$state.is("myState") === true) {
|
||||
//
|
||||
}
|
||||
if (this.$state.href("myState") === "/myState") {
|
||||
//
|
||||
}
|
||||
this.$state.get("myState");
|
||||
this.$state.get();
|
||||
this.$state.reload();
|
||||
}
|
||||
}
|
||||
|
||||
myApp.service("urlLocatorTest", UrlLocatorTestService);
|
||||
@@ -124,4 +146,3 @@ module UiViewScrollProviderTests {
|
||||
$uiViewScrollProvider.useAnchorScroll();
|
||||
}]);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+4
-3
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Angular JS 1.1.5+ (ui.router module)
|
||||
// Project: https://github.com/angular-ui/ui-router
|
||||
// Definitions by: Michel Salib <michelsalib@hotmail.com>
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../angularjs/angular.d.ts" />
|
||||
@@ -33,13 +33,13 @@ declare module ng.ui {
|
||||
interface IUrlMatcher {
|
||||
concat(pattern: string): IUrlMatcher;
|
||||
exec(path: string, searchParams: {}): {};
|
||||
parameters(): string[];
|
||||
format(values: {}): string;
|
||||
}
|
||||
|
||||
interface IUrlMatcherFactory {
|
||||
compile(pattern: string): IUrlMatcher;
|
||||
isMatcher(o: any): boolean;
|
||||
parameters(): string[];
|
||||
format(values: {}): string;
|
||||
}
|
||||
|
||||
interface IUrlRouterProvider extends IServiceProvider {
|
||||
@@ -86,6 +86,7 @@ declare module ng.ui {
|
||||
get(): IState[];
|
||||
current: IState;
|
||||
params: IStateParamsService;
|
||||
reload(): void;
|
||||
}
|
||||
|
||||
interface IStateParamsService {
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Angular JS 1.2+ (ngAnimate module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Michel Salib <michelsalib@hotmail.com>
|
||||
// Definitions by: Michel Salib <https://github.com/michelsalib>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular.d.ts" />
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
/// Type definitions for Angular JS 1.2 (ngCookies module)
|
||||
// Type definitions for Angular JS 1.2 (ngCookies module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
@@ -50,7 +50,7 @@ exceptionHandlerProvider.mode('log');
|
||||
|
||||
|
||||
///////////////////////////////////////
|
||||
// IExceptionHandlerProvider
|
||||
// ITimeoutService
|
||||
///////////////////////////////////////
|
||||
var timeoutService: ng.ITimeoutService;
|
||||
|
||||
@@ -60,6 +60,14 @@ timeoutService.flushNext();
|
||||
timeoutService.flushNext(1234);
|
||||
timeoutService.verifyNoPendingTasks();
|
||||
|
||||
////////////////////////////////////////
|
||||
// IIntervalService
|
||||
////////////////////////////////////////
|
||||
var intervalService: ng.IIntervalService;
|
||||
var intervalServiceTimeActuallyAdvanced: number;
|
||||
|
||||
intervalServiceTimeActuallyAdvanced = intervalService.flush();
|
||||
intervalServiceTimeActuallyAdvanced = intervalService.flush(1234);
|
||||
|
||||
///////////////////////////////////////
|
||||
// ILogService, ILogCall
|
||||
|
||||
Vendored
+9
@@ -61,6 +61,15 @@ declare module ng {
|
||||
flushNext(expectedDelay?: number): void;
|
||||
verifyNoPendingTasks(): void;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// IntervalService
|
||||
// see http://docs.angularjs.org/api/ngMock.$interval
|
||||
// Augments the original service
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IIntervalService {
|
||||
flush(millis?: number): number;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// LogService
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Angular JS 1.2 (ngResource module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels> (minor enhancements)
|
||||
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Michael Jess <http://github.com/miffels>
|
||||
// Definitions: https://github.com/daptiv/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular.d.ts" />
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
declare var $routeProvider: ng.route.IRouteProvider;
|
||||
$routeProvider
|
||||
.when('/projects/:projectId/dashboard',{
|
||||
controller: ''
|
||||
controller: '',
|
||||
templateUrl: '',
|
||||
caseInsensitiveMatch: true,
|
||||
reloadOnSearch: false
|
||||
})
|
||||
.otherwise({redirectTo: '/'});
|
||||
|
||||
Vendored
+78
-6
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Angular JS 1.2 (ngRoute module)
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: Jonathan Park
|
||||
// Definitions by: Jonathan Park <https://github.com/park9140>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="angular.d.ts" />
|
||||
@@ -15,7 +15,9 @@ declare module ng.route {
|
||||
// RouteParamsService
|
||||
// see http://docs.angularjs.org/api/ngRoute.$routeParams
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRouteParamsService {}
|
||||
interface IRouteParamsService {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// RouteService
|
||||
@@ -30,17 +32,73 @@ declare module ng.route {
|
||||
// to a controller that was not initialized as a result of a route maching.
|
||||
current?: ICurrentRoute;
|
||||
}
|
||||
|
||||
// see http://docs.angularjs.org/api/ngRoute.$routeProvider#when for options explanations
|
||||
|
||||
|
||||
/**
|
||||
* see http://docs.angularjs.org/api/ngRoute/provider/$routeProvider#when for API documentation
|
||||
*/
|
||||
interface IRoute {
|
||||
/**
|
||||
* {(string|function()=}
|
||||
* Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string.
|
||||
*/
|
||||
controller?: any;
|
||||
controllerAs?: any;
|
||||
/**
|
||||
* A controller alias name. If present the controller will be published to scope under the controllerAs name.
|
||||
*/
|
||||
controllerAs?: string;
|
||||
/**
|
||||
* Undocumented?
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* {string=|function()=}
|
||||
* Html template as a string or a function that returns an html template as a string which should be used by ngView or ngInclude directives. This property takes precedence over templateUrl.
|
||||
*
|
||||
* If template is a function, it will be called with the following parameters:
|
||||
*
|
||||
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
|
||||
*/
|
||||
template?: string;
|
||||
/**
|
||||
* {string=|function()=}
|
||||
* Path or function that returns a path to an html template that should be used by ngView.
|
||||
*
|
||||
* If templateUrl is a function, it will be called with the following parameters:
|
||||
*
|
||||
* {Array.<Object>} - route parameters extracted from the current $location.path() by applying the current route
|
||||
*/
|
||||
templateUrl?: any;
|
||||
/**
|
||||
* {Object.<string, function>=} - An optional map of dependencies which should be injected into the controller. If any of these dependencies are promises, the router will wait for them all to be resolved or one to be rejected before the controller is instantiated. If all the promises are resolved successfully, the values of the resolved promises are injected and $routeChangeSuccess event is fired. If any of the promises are rejected the $routeChangeError event is fired. The map object is:
|
||||
*
|
||||
* - key - {string}: a name of a dependency to be injected into the controller.
|
||||
* - factory - {string|function}: If string then it is an alias for a service. Otherwise if function, then it is injected and the return value is treated as the dependency. If the result is a promise, it is resolved before its value is injected into the controller. Be aware that ngRoute.$routeParams will still refer to the previous route within these resolve functions. Use $route.current.params to access the new route parameters, instead.
|
||||
*/
|
||||
resolve?: any;
|
||||
/**
|
||||
* {(string|function())=}
|
||||
* Value to update $location path with and trigger route redirection.
|
||||
*
|
||||
* If redirectTo is a function, it will be called with the following parameters:
|
||||
*
|
||||
* - {Object.<string>} - route parameters extracted from the current $location.path() by applying the current route templateUrl.
|
||||
* - {string} - current $location.path()
|
||||
* - {Object} - current $location.search()
|
||||
* - The custom redirectTo function is expected to return a string which will be used to update $location.path() and $location.search().
|
||||
*/
|
||||
redirectTo?: any;
|
||||
/**
|
||||
* Reload route when only $location.search() or $location.hash() changes.
|
||||
*
|
||||
* This option defaults to true. If the option is set to false and url in the browser changes, then $routeUpdate event is broadcasted on the root scope.
|
||||
*/
|
||||
reloadOnSearch?: boolean;
|
||||
/**
|
||||
* Match routes without being case sensitive
|
||||
*
|
||||
* This option defaults to false. If the option is set to true, then the particular route can be matched without being case sensitive
|
||||
*/
|
||||
caseInsensitiveMatch?: boolean;
|
||||
}
|
||||
|
||||
@@ -55,10 +113,24 @@ declare module ng.route {
|
||||
}
|
||||
|
||||
interface IRouteProvider extends IServiceProvider {
|
||||
/**
|
||||
* Sets route definition that will be used on route change when no other route definition is matched.
|
||||
*
|
||||
* @params Mapping information to be assigned to $route.current.
|
||||
*/
|
||||
otherwise(params: IRoute): IRouteProvider;
|
||||
/**
|
||||
* This is a description
|
||||
* Adds a new route definition to the $route service.
|
||||
*
|
||||
* @param path Route path (matched against $location.path). If $location.path contains redundant trailing slash or is missing one, the route will still match and the $location.path will be updated to add or drop the trailing slash to exactly match the route definition.
|
||||
*
|
||||
* - path can contain named groups starting with a colon: e.g. :name. All characters up to the next slash are matched and stored in $routeParams under the given name when the route matches.
|
||||
* - path can contain named groups starting with a colon and ending with a star: e.g.:name*. All characters are eagerly stored in $routeParams under the given name when the route matches.
|
||||
* - path can contain optional named groups with a question mark: e.g.:name?.
|
||||
*
|
||||
* For example, routes like /color/:color/largecode/:largecode*\/edit will match /color/brown/largecode/code/with/slashes/edit and extract: color: brown and largecode: code/with/slashes.
|
||||
*
|
||||
* @param route Mapping information to be assigned to $route.current on route match.
|
||||
*/
|
||||
when(path: string, route: IRoute): IRouteProvider;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Angular Scenario Testing
|
||||
// Project: http://angularjs.org
|
||||
// Definitions by: RomanoLindano
|
||||
// Definitions by: RomanoLindano <https://github.com/RomanoLindano>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
|
||||
@@ -220,9 +220,21 @@ foo.then((x) => {
|
||||
});
|
||||
|
||||
|
||||
var httpFoo: ng.IHttpPromise<number>;
|
||||
httpFoo.then((x) => {
|
||||
// When returning a promise the generic type must be inferred.
|
||||
var innerPromise : ng.IPromise<number>;
|
||||
return innerPromise;
|
||||
}).then((x) => {
|
||||
// must still be number.
|
||||
x.toFixed();
|
||||
});
|
||||
|
||||
|
||||
// angular.element() tests
|
||||
var element = angular.element("div.myApp");
|
||||
var scope: ng.IScope = element.scope();
|
||||
var isolateScope: ng.IScope = element.isolateScope();
|
||||
|
||||
|
||||
|
||||
|
||||
Vendored
+145
-23
@@ -51,16 +51,21 @@ declare module ng {
|
||||
isString(value: any): boolean;
|
||||
isUndefined(value: any): boolean;
|
||||
lowercase(str: string): string;
|
||||
/** construct your angular application
|
||||
official docs: Interface for configuring angular modules.
|
||||
see: http://docs.angularjs.org/api/angular.Module
|
||||
*/
|
||||
|
||||
/**
|
||||
* The angular.module is a global place for creating, registering and retrieving Angular modules. All modules (angular core or 3rd party) that should be available to an application must be registered using this mechanism.
|
||||
*
|
||||
* When passed two or more arguments, a new module is created. If passed only one argument, an existing module (the name passed as the first argument to module) is retrieved.
|
||||
*
|
||||
* @param name The name of the module to create or retrieve.
|
||||
* @param requires The names of modules this module depends on. If specified then new module is being created. If unspecified then the module is being retrieved for further configuration.
|
||||
* @param configFn Optional configuration function for the module.
|
||||
*/
|
||||
module(
|
||||
/** name of your module you want to create */
|
||||
name: string,
|
||||
/** name of modules yours depends on */
|
||||
requires?: string[],
|
||||
configFunction?: any): IModule;
|
||||
configFn?: Function): IModule;
|
||||
|
||||
noop(...args: any[]): void;
|
||||
toJson(obj: any, pretty?: boolean): string;
|
||||
uppercase(str: string): string;
|
||||
@@ -81,23 +86,61 @@ declare module ng {
|
||||
animation(name: string, animationFactory: Function): IModule;
|
||||
animation(name: string, inlineAnnotatedFunction: any[]): IModule;
|
||||
animation(object: Object): IModule;
|
||||
/** configure existing services.
|
||||
Use this method to register work which needs to be performed on module loading
|
||||
/**
|
||||
* Use this method to register work which needs to be performed on module loading.
|
||||
*
|
||||
* @param configFn Execute this function on module load. Useful for service configuration.
|
||||
*/
|
||||
config(configFn: Function): IModule;
|
||||
/** configure existing services.
|
||||
Use this method to register work which needs to be performed on module loading
|
||||
/**
|
||||
* Use this method to register work which needs to be performed on module loading.
|
||||
*
|
||||
* @param inlineAnnotatedFunction Execute this function on module load. Useful for service configuration.
|
||||
*/
|
||||
config(inlineAnnotatedFunction: any[]): IModule;
|
||||
/**
|
||||
* Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
|
||||
*
|
||||
* @param name The name of the constant.
|
||||
* @param value The constant value.
|
||||
*/
|
||||
constant(name: string, value: any): IModule;
|
||||
constant(object: Object): IModule;
|
||||
/**
|
||||
* The $controller service is used by Angular to create new controllers.
|
||||
*
|
||||
* This provider allows controller registration via the register method.
|
||||
*
|
||||
* @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
|
||||
* @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
|
||||
*/
|
||||
controller(name: string, controllerConstructor: Function): IModule;
|
||||
/**
|
||||
* The $controller service is used by Angular to create new controllers.
|
||||
*
|
||||
* This provider allows controller registration via the register method.
|
||||
*
|
||||
* @param name Controller name, or an object map of controllers where the keys are the names and the values are the constructors.
|
||||
* @param controllerConstructor Controller constructor fn (optionally decorated with DI annotations in the array notation).
|
||||
*/
|
||||
controller(name: string, inlineAnnotatedConstructor: any[]): IModule;
|
||||
controller(object : Object): IModule;
|
||||
directive(name: string, directiveFactory: Function): IModule;
|
||||
directive(name: string, inlineAnnotatedFunction: any[]): IModule;
|
||||
directive(object: Object): IModule;
|
||||
factory(name: string, serviceFactoryFunction: Function): IModule;
|
||||
/**
|
||||
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
|
||||
*
|
||||
* @param name The name of the instance.
|
||||
* @param $getFn The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
|
||||
*/
|
||||
factory(name: string, $getFn: Function): IModule;
|
||||
/**
|
||||
* Register a service factory, which will be called to return the service instance. This is short for registering a service where its provider consists of only a $get property, which is the given service factory function. You should use $provide.factory(getFn) if you do not need to configure your service in a provider.
|
||||
*
|
||||
* @param name The name of the instance.
|
||||
* @param inlineAnnotatedFunction The $getFn for the instance creation. Internally this is a short hand for $provide.provider(name, {$get: $getFn}).
|
||||
*/
|
||||
factory(name: string, inlineAnnotatedFunction: any[]): IModule;
|
||||
factory(object: Object): IModule;
|
||||
filter(name: string, filterFactoryFunction: Function): IModule;
|
||||
@@ -107,11 +150,25 @@ declare module ng {
|
||||
provider(name: string, inlineAnnotatedConstructor: any[]): IModule;
|
||||
provider(name: string, providerObject: auto.IProvider): IModule;
|
||||
provider(object: Object): IModule;
|
||||
/**
|
||||
* Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
|
||||
*/
|
||||
run(initializationFunction: Function): IModule;
|
||||
/**
|
||||
* Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the service have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
|
||||
*/
|
||||
run(inlineAnnotatedFunction: any[]): IModule;
|
||||
service(name: string, serviceConstructor: Function): IModule;
|
||||
service(name: string, inlineAnnotatedConstructor: any[]): IModule;
|
||||
service(object: Object): IModule;
|
||||
/**
|
||||
* Register a value service with the $injector, such as a string, a number, an array, an object or a function. This is short for registering a service where its provider's $get property is a factory function that takes no arguments and returns the value service.
|
||||
|
||||
Value services are similar to constant services, except that they cannot be injected into a module configuration function (see config) but they can be overridden by an Angular decorator.
|
||||
*
|
||||
* @param name The name of the instance.
|
||||
* @param value The value.
|
||||
*/
|
||||
value(name: string, value: any): IModule;
|
||||
value(object: Object): IModule;
|
||||
|
||||
@@ -166,6 +223,7 @@ declare module ng {
|
||||
$error: any;
|
||||
$addControl(control: ng.INgModelController): void;
|
||||
$removeControl(control: ng.INgModelController): void;
|
||||
$setValidity(validationErrorKey: string, isValid: boolean, control: ng.INgModelController): void;
|
||||
$setDirty(): void;
|
||||
$setPristine(): void;
|
||||
}
|
||||
@@ -241,6 +299,8 @@ declare module ng {
|
||||
|
||||
$parent: IScope;
|
||||
|
||||
$root: IRootScopeService;
|
||||
|
||||
$id: string;
|
||||
|
||||
// Hidden members
|
||||
@@ -263,13 +323,17 @@ declare module ng {
|
||||
// WindowService
|
||||
// see http://docs.angularjs.org/api/ng.$window
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IWindowService extends Window {}
|
||||
interface IWindowService extends Window {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// BrowserService
|
||||
// TODO undocumented, so we need to get it from the source code
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IBrowserService {}
|
||||
interface IBrowserService {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// TimeoutService
|
||||
@@ -455,16 +519,51 @@ declare module ng {
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
interface IRootElementService extends JQuery {}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// QService
|
||||
// see http://docs.angularjs.org/api/ng.$q
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* $q - service in module ng
|
||||
* A promise/deferred implementation inspired by Kris Kowal's Q.
|
||||
* See http://docs.angularjs.org/api/ng/service/$q
|
||||
*/
|
||||
interface IQService {
|
||||
/**
|
||||
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
|
||||
*
|
||||
* Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
|
||||
*
|
||||
* @param promises An array or hash of promises.
|
||||
*/
|
||||
all(promises: IPromise<any>[]): IPromise<any[]>;
|
||||
all(promises: {[id: string]: IPromise<any>;}): IPromise<{[id: string]: any}>;
|
||||
/**
|
||||
* Combines multiple promises into a single promise that is resolved when all of the input promises are resolved.
|
||||
*
|
||||
* Returns a single promise that will be resolved with an array/hash of values, each value corresponding to the promise at the same index/key in the promises array/hash. If any of the promises is resolved with a rejection, this resulting promise will be rejected with the same rejection value.
|
||||
*
|
||||
* @param promises An array or hash of promises.
|
||||
*/
|
||||
all(promises: { [id: string]: IPromise<any>; }): IPromise<{ [id: string]: any }>;
|
||||
/**
|
||||
* Creates a Deferred object which represents a task which will finish in the future.
|
||||
*/
|
||||
defer<T>(): IDeferred<T>;
|
||||
/**
|
||||
* Creates a promise that is resolved as rejected with the specified reason. This api should be used to forward rejection in a chain of promises. If you are dealing with the last promise in a promise chain, you don't need to worry about it.
|
||||
*
|
||||
* When comparing deferreds/promises to the familiar behavior of try/catch/throw, think of reject as the throw keyword in JavaScript. This also means that if you "catch" an error via a promise error callback and you want to forward the error to the promise derived from the current promise, you have to "rethrow" the error by returning a rejection constructed via reject.
|
||||
*
|
||||
* @param reason Constant, message, exception or an object representing the rejection reason.
|
||||
*/
|
||||
reject(reason?: any): IPromise<void>;
|
||||
/**
|
||||
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
|
||||
*
|
||||
* @param value Value or a promise
|
||||
*/
|
||||
when<T>(value: IPromise<T>): IPromise<T>;
|
||||
/**
|
||||
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
|
||||
*
|
||||
* @param value Value or a promise
|
||||
*/
|
||||
when<T>(value: T): IPromise<T>;
|
||||
}
|
||||
|
||||
@@ -756,9 +855,9 @@ declare module ng {
|
||||
|
||||
interface IHttpPromise<T> extends IPromise<T> {
|
||||
success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
|
||||
error(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
|
||||
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
|
||||
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
|
||||
error(callback: IHttpPromiseCallback<any>): IHttpPromise<T>;
|
||||
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
|
||||
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<any>) => any): IPromise<TResult>;
|
||||
}
|
||||
|
||||
interface IHttpProvider extends IServiceProvider {
|
||||
@@ -925,6 +1024,7 @@ declare module ng {
|
||||
controller(name: string): any;
|
||||
injector(): any;
|
||||
scope(): IScope;
|
||||
isolateScope(): IScope;
|
||||
|
||||
inheritedData(key: string, value: any): JQuery;
|
||||
inheritedData(obj: { [key: string]: any; }): JQuery;
|
||||
@@ -973,10 +1073,32 @@ declare module ng {
|
||||
// Documentation says it returns the registered instance, but actual
|
||||
// implementation does not return anything.
|
||||
// constant(name: string, value: any): any;
|
||||
/**
|
||||
* Register a constant service, such as a string, a number, an array, an object or a function, with the $injector. Unlike value it can be injected into a module configuration function (see config) and it cannot be overridden by an Angular decorator.
|
||||
*
|
||||
* @param name The name of the constant.
|
||||
* @param value The constant value.
|
||||
*/
|
||||
constant(name: string, value: any): void;
|
||||
|
||||
/**
|
||||
* Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
|
||||
*
|
||||
* @param name The name of the service to decorate.
|
||||
* @param decorator This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:
|
||||
*
|
||||
* $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
|
||||
*/
|
||||
decorator(name: string, decorator: Function): void;
|
||||
decorator(name: string, decoratorInline: any[]): void;
|
||||
/**
|
||||
* Register a service decorator with the $injector. A service decorator intercepts the creation of a service, allowing it to override or modify the behaviour of the service. The object returned by the decorator may be the original service, or a new service object which replaces or wraps and delegates to the original service.
|
||||
*
|
||||
* @param name The name of the service to decorate.
|
||||
* @param inlineAnnotatedFunction This function will be invoked when the service needs to be instantiated and should return the decorated service instance. The function is called using the injector.invoke method and is therefore fully injectable. Local injection arguments:
|
||||
*
|
||||
* $delegate - The original service instance, which can be monkey patched, configured, decorated or delegated to.
|
||||
*/
|
||||
decorator(name: string, inlineAnnotatedFunction: any[]): void;
|
||||
factory(name: string, serviceFactoryFunction: Function): ng.IServiceProvider;
|
||||
factory(name: string, inlineAnnotatedFunction: any[]): ng.IServiceProvider;
|
||||
provider(name: string, provider: ng.IServiceProvider): ng.IServiceProvider;
|
||||
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// Type definitions for ansicolors
|
||||
// Project: https://github.com/thlorenz/ansicolors
|
||||
// Definitions by: rogierschouten <https://github.com/rogierschouten>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "ansicolors" {
|
||||
var colors: {[index: string]: (s: string) => string;};
|
||||
export = colors;
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
""
|
||||
Vendored
+2
-2
@@ -121,12 +121,12 @@ declare module ArbiterDef {
|
||||
/**
|
||||
* Unsubscribing simply sets a flag which prevents the subscriber from executing, in case you want to re-subscribe later.
|
||||
*/
|
||||
unsubscribe(subscription_id: number);
|
||||
unsubscribe(subscription_id: number): boolean;
|
||||
|
||||
/**
|
||||
* After unsubscribing, you can later re-subscribe to begin receiving messages again.
|
||||
*/
|
||||
resubscribe(subscription_id: number);
|
||||
resubscribe(subscription_id: number): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
""
|
||||
Vendored
+2
-2
@@ -1,6 +1,6 @@
|
||||
// Type definitions for asciify 1.3.5
|
||||
// Project: https://www.npmjs.org/package/asciify
|
||||
// Definitions by: Alan Norbauer http://alan.norbauer.com
|
||||
// Definitions by: Alan Norbauer <http://alan.norbauer.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
@@ -26,4 +26,4 @@ declare module "asciify" {
|
||||
}
|
||||
|
||||
export = asciify
|
||||
}
|
||||
}
|
||||
|
||||
+60
-3
@@ -145,9 +145,8 @@ q.drain = function () {
|
||||
console.log('all items have been processed');
|
||||
}
|
||||
|
||||
q.push({ name: 'foo' }, function (err) {
|
||||
console.log('finished processing foo');
|
||||
});
|
||||
q.push({ name: 'foo' });
|
||||
|
||||
q.push({ name: 'bar' }, function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
@@ -156,6 +155,64 @@ q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
q.unshift({ name: 'foo' });
|
||||
|
||||
q.unshift({ name: 'bar' }, function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
q.unshift([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
var qLength : number = q.length();
|
||||
var qStarted : boolean = q.started;
|
||||
var qPaused : boolean = q.paused;
|
||||
var qProcessingCount : number = q.running();
|
||||
var qIsIdle : boolean = q.idle();
|
||||
|
||||
q.saturated = function() {
|
||||
console.log('queue is saturated.');
|
||||
}
|
||||
|
||||
q.empty = function() {
|
||||
console.log('queue is empty.');
|
||||
}
|
||||
|
||||
q.drain = function() {
|
||||
console.log('queue was drained.');
|
||||
}
|
||||
|
||||
q.pause();
|
||||
q.resume();
|
||||
q.kill();
|
||||
|
||||
// tests for strongly typed tasks
|
||||
var q2 = async.queue(function (task: string, callback) {
|
||||
console.log('Task: ' + task);
|
||||
callback();
|
||||
}, 1);
|
||||
|
||||
q2.push('task1');
|
||||
|
||||
q2.push('task2', function (error, results: string[]) {
|
||||
console.log('Finished tasks: ' + results.join(', '));
|
||||
});
|
||||
|
||||
q2.push(['task3', 'task4', 'task5'], function (error, results: string[]) {
|
||||
console.log('Finished tasks: ' + results.join(', '));
|
||||
});
|
||||
|
||||
q2.unshift('task1');
|
||||
|
||||
q2.unshift('task2', function (error, results: string[]) {
|
||||
console.log('Finished tasks: ' + results.join(', '));
|
||||
});
|
||||
|
||||
q2.unshift(['task3', 'task4', 'task5'], function (error, results: string[]) {
|
||||
console.log('Finished tasks: ' + results.join(', '));
|
||||
});
|
||||
|
||||
var filename = '';
|
||||
async.auto({
|
||||
get_data: function (callback) { },
|
||||
|
||||
Vendored
+37
-27
@@ -3,8 +3,8 @@
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
interface AsyncMultipleResultsCallback<T> { (err: string, results: T[]): any; }
|
||||
interface AsyncSingleResultCallback<T> { (err: string, result: T): void; }
|
||||
interface AsyncMultipleResultsCallback<T> { (err: Error, results: T[]): any; }
|
||||
interface AsyncSingleResultCallback<T> { (err: Error, result: T): void; }
|
||||
interface AsyncTimesCallback<T> { (n: number, callback: AsyncMultipleResultsCallback<T>): void; }
|
||||
|
||||
interface AsyncIterator<T, R> { (item: T, callback: AsyncSingleResultCallback<R>): void; }
|
||||
@@ -15,10 +15,20 @@ interface AsyncWorker<T> { (task: T, callback: Function): void; }
|
||||
interface AsyncQueue<T> {
|
||||
length(): number;
|
||||
concurrency: number;
|
||||
started: boolean;
|
||||
paused: boolean;
|
||||
push(task: T, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
saturated: AsyncMultipleResultsCallback<T>;
|
||||
empty: AsyncMultipleResultsCallback<T>;
|
||||
drain: AsyncMultipleResultsCallback<T>;
|
||||
push(task: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
unshift(task: T, callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
unshift(task: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
saturated: () => any;
|
||||
empty: () => any;
|
||||
drain: () => any;
|
||||
running(): number;
|
||||
idle(): boolean;
|
||||
pause(): void;
|
||||
resume(): void;
|
||||
kill(): void;
|
||||
}
|
||||
|
||||
interface Async {
|
||||
@@ -27,28 +37,28 @@ interface Async {
|
||||
forEach<T,R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
|
||||
forEachSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
|
||||
forEachLimit<T, R>(arr: T[], limit: number, iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): void;
|
||||
map<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>);
|
||||
mapSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>);
|
||||
filter<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
select<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
filterSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
selectSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
reject<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
rejectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>);
|
||||
detect<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
detectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
sortBy<T, V>(arr: T[], iterator: AsyncIterator<T, V>, callback: AsyncMultipleResultsCallback<T>);
|
||||
some<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
any<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>);
|
||||
every<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any);
|
||||
all<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any);
|
||||
concat<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>);
|
||||
concatSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>);
|
||||
map<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): any;
|
||||
mapSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R>, callback: AsyncMultipleResultsCallback<R>): any;
|
||||
filter<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
select<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
filterSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
selectSeries<T, R>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
reject<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
rejectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncSingleResultCallback<R>): any;
|
||||
detect<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
detectSeries<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
sortBy<T, V>(arr: T[], iterator: AsyncIterator<T, V>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
some<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
any<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: AsyncMultipleResultsCallback<T>): any;
|
||||
every<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any): any;
|
||||
all<T>(arr: T[], iterator: AsyncIterator<T, boolean>, callback: (result: boolean) => any): any;
|
||||
concat<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>): any;
|
||||
concatSeries<T, R>(arr: T[], iterator: AsyncIterator<T, R[]>, callback: AsyncMultipleResultsCallback<R>): any;
|
||||
|
||||
// Control Flow
|
||||
series<T>(tasks: T[], callback?: AsyncMultipleResultsCallback<T>): void;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
""
|
||||
@@ -1 +0,0 @@
|
||||
""
|
||||
Vendored
+26
-2
@@ -15,7 +15,7 @@
|
||||
// if js file include to another npm package (e.g. "space-pen", "mixto" and "emissary").
|
||||
// you should create a separate file.
|
||||
|
||||
// NOTE Document? You should use DevTools hehe...
|
||||
// API documentation : https://atom.io/docs/api/v0.106.0/api/docs/README.md.html
|
||||
|
||||
interface Window {
|
||||
atom: AtomCore.IAtom;
|
||||
@@ -941,6 +941,21 @@ declare module AtomCore {
|
||||
// TBD
|
||||
}
|
||||
|
||||
interface IPackage {
|
||||
mainModulePath: string;
|
||||
mainModule: any;
|
||||
enable(): void;
|
||||
disable(): void;
|
||||
isTheme(): boolean;
|
||||
getType(): string;
|
||||
getStylesheetType(): string;
|
||||
load(): IPackage;
|
||||
reset(): void;
|
||||
activate(): Q.Promise<any[]>;
|
||||
activateNow(): void;
|
||||
// TBD
|
||||
}
|
||||
|
||||
interface IPackageManager extends Emissary.IEmitter {
|
||||
packageDirPaths:string[];
|
||||
loadedPackages:any;
|
||||
@@ -957,7 +972,7 @@ declare module AtomCore {
|
||||
activate():void;
|
||||
registerPackageActivator(activator:any, types:any):void;
|
||||
activatePackages(packages:any):void;
|
||||
activatePackage(name:string):void;
|
||||
activatePackage(name:string):Q.Promise<IPackage>;
|
||||
deactivatePackages():void;
|
||||
deactivatePackage(name:string):void;
|
||||
getActivePackages():any;
|
||||
@@ -1010,7 +1025,14 @@ declare module AtomCore {
|
||||
interface IAtomStatic extends ISerializationStatic<IAtom> {
|
||||
version: number;
|
||||
loadSettings: IAtomSettings;
|
||||
|
||||
/* Load or create the Atom environment in the given mode */
|
||||
loadOrCreate(mode:'editor'):IAtom;
|
||||
/* Load or create the Atom environment in the given mode */
|
||||
loadOrCreate(mode:'spec'):IAtom;
|
||||
/* Load or create the Atom environment in the given mode */
|
||||
loadOrCreate(mode:string):IAtom;
|
||||
|
||||
loadState(mode:any):void;
|
||||
getStatePath(mode:any):string;
|
||||
getConfigDirPath():string;
|
||||
@@ -1023,6 +1045,8 @@ declare module AtomCore {
|
||||
new(state:IAtomState):IAtom;
|
||||
}
|
||||
|
||||
// https://atom.io/docs/api/v0.106.0/api/classes/Atom.html
|
||||
/* Global Atom class : instance members */
|
||||
interface IAtom {
|
||||
constructor:IAtomStatic;
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Type definitions for Auth0Widget.js
|
||||
// Project: Auth0.com
|
||||
// Project: http://auth0.com
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
@@ -45,4 +45,4 @@ declare var Auth0Widget: Auth0WidgetStatic;
|
||||
|
||||
declare module "Auth0Widget" {
|
||||
export = Auth0Widget
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Type definitions for Auth0.js
|
||||
// Project: Auth0.com
|
||||
// Project: http://auth0.com
|
||||
// Definitions by: Robert McLaws <https://github.com/advancedrei>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
@@ -130,4 +130,4 @@ declare var Auth0: Auth0Static;
|
||||
|
||||
declare module "Auth0" {
|
||||
export = Auth0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,21 +42,21 @@ declare module Microsoft.WindowsAzure {
|
||||
getTableName(): string;
|
||||
getMobileServiceClient(): MobileServiceClient;
|
||||
|
||||
insert(istance: any, paramsQS: Object, callback: (error: any, retInserted: any) => any): void;
|
||||
insert(istance: any, paramsQS: Object): asyncPromise;
|
||||
insert(istance: any): asyncPromise;
|
||||
insert(instance: any, paramsQS: Object, callback: (error: any, retInserted: any) => any): void;
|
||||
insert(instance: any, paramsQS: Object): asyncPromise;
|
||||
insert(instance: any): asyncPromise;
|
||||
|
||||
update(istance: any, paramsQS: Object, callback: (error: any, retUpdated: any) => any): void;
|
||||
update(istance: any, paramsQS: Object): asyncPromise;
|
||||
update(istance: any): asyncPromise;
|
||||
update(instance: any, paramsQS: Object, callback: (error: any, retUpdated: any) => any): void;
|
||||
update(instance: any, paramsQS: Object): asyncPromise;
|
||||
update(instance: any): asyncPromise;
|
||||
|
||||
lookup(id: number, paramsQS: Object, callback: (error: any, retValue: any) => any): void;
|
||||
lookup(id: number, paramsQS: Object): asyncPromise;
|
||||
lookup(id: number): asyncPromise;
|
||||
|
||||
del(istance: any, paramsQS: Object, callback: (error?: any) => void ): void;
|
||||
del(istance: any, paramsQS: Object): asyncPromise;
|
||||
del(istance: any): asyncPromise;
|
||||
del(instance: any, paramsQS: Object, callback: (error?: any) => void ): void;
|
||||
del(instance: any, paramsQS: Object): asyncPromise;
|
||||
del(instance: any): asyncPromise;
|
||||
|
||||
|
||||
read(query: IQuery, paramsQS: Object, callback: (error: any, retValues: any) => any): void;
|
||||
|
||||
+24
-13
@@ -113,9 +113,12 @@ class EmployeeCollection extends Backbone.Collection<Employee> {
|
||||
class Book extends Backbone.Model {
|
||||
title: string;
|
||||
author: string;
|
||||
published: boolean;
|
||||
}
|
||||
|
||||
class Library extends Backbone.Collection<Book> {
|
||||
// This model definition is here only to test type compatibility of the model, but it
|
||||
// is not necessary in working code as it is automatically inferred through generics.
|
||||
model: typeof Book;
|
||||
}
|
||||
|
||||
@@ -123,23 +126,31 @@ class Books extends Backbone.Collection<Book> { }
|
||||
|
||||
function test_collection() {
|
||||
|
||||
var books = new Library();
|
||||
var books = new Books();
|
||||
|
||||
books.each(book => {
|
||||
book.get("title");
|
||||
});
|
||||
var book1: Book = new Book({ title: "Title 1", author: "Mike" });
|
||||
books.add(book1);
|
||||
|
||||
var titles = books.map(book => {
|
||||
return book.get("title");
|
||||
});
|
||||
// Objects can be added to collection by casting to model type.
|
||||
// Compiler will check if object properties are valid for the cast.
|
||||
// This gives better type checking than declaring an `any` overload.
|
||||
books.add(<Book>{ title: "Title 2", author: "Mikey" });
|
||||
|
||||
var publishedBooks = books.filter(book => {
|
||||
return book.get("published") === true;
|
||||
});
|
||||
var model: Book = book1.collection.first();
|
||||
if (model !== book1) {
|
||||
throw new Error("Error");
|
||||
}
|
||||
|
||||
var alphabetical = books.sortBy((book: Book): number => {
|
||||
return null;
|
||||
});
|
||||
books.each(book =>
|
||||
book.get("title"));
|
||||
|
||||
var titles = books.map(book =>
|
||||
book.get("title"));
|
||||
|
||||
var publishedBooks = books.filter(book =>
|
||||
book.get("published") === true);
|
||||
|
||||
var alphabetical = books.sortBy((book: Book): number => null);
|
||||
}
|
||||
|
||||
//////////
|
||||
|
||||
Vendored
+26
-7
@@ -1,10 +1,8 @@
|
||||
// Type definitions for Backbone 1.0.0
|
||||
// Project: http://backbonejs.org/
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
|
||||
// Definitions by: Natan Vivo <https://github.com/nvivo/>
|
||||
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Natan Vivo <https://github.com/nvivo/>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts" />
|
||||
/// <reference path="../underscore/underscore.d.ts" />
|
||||
|
||||
@@ -97,6 +95,8 @@ declare module Backbone {
|
||||
attributes: any;
|
||||
changed: any[];
|
||||
cid: string;
|
||||
collection: Collection<any>;
|
||||
|
||||
/**
|
||||
* Default attributes for the model. It can be an object hash or a method returning an object hash.
|
||||
* For assigning an object hash, do it like this: this.defaults = <any>{ attribute: value, ... };
|
||||
@@ -113,8 +113,23 @@ declare module Backbone {
|
||||
|
||||
fetch(options?: ModelFetchOptions): JQueryXHR;
|
||||
|
||||
get(attributeName: string): any;
|
||||
set(attributeName: string, value: any, options?: ModelSetOptions): Model;
|
||||
/**
|
||||
* For strongly-typed access to attributes, use the `get` method only privately in public getter properties.
|
||||
* @example
|
||||
* get name(): string {
|
||||
* return super.get("name");
|
||||
* }
|
||||
**/
|
||||
/*private*/ get(attributeName: string): any;
|
||||
|
||||
/**
|
||||
* For strongly-typed assignment of attributes, use the `set` method only privately in public setter properties.
|
||||
* @example
|
||||
* set name(value: string) {
|
||||
* super.set("name", value);
|
||||
* }
|
||||
**/
|
||||
/*private*/ set(attributeName: string, value: any, options?: ModelSetOptions): Model;
|
||||
set(obj: any, options?: ModelSetOptions): Model;
|
||||
|
||||
change(): any;
|
||||
@@ -158,7 +173,6 @@ declare module Backbone {
|
||||
//model: typeof TModel;
|
||||
model: { new(): TModel; }; // workaround
|
||||
models: TModel[];
|
||||
collection: TModel;
|
||||
length: number;
|
||||
|
||||
constructor(models?: TModel[], options?: any);
|
||||
@@ -171,7 +185,12 @@ declare module Backbone {
|
||||
add(model: TModel, options?: AddOptions): Collection<TModel>;
|
||||
add(models: TModel[], options?: AddOptions): Collection<TModel>;
|
||||
at(index: number): TModel;
|
||||
/**
|
||||
* Get a model from a collection, specified by an id, a cid, or by passing in a model.
|
||||
**/
|
||||
get(id: number): TModel;
|
||||
get(id: string): TModel;
|
||||
get(id: Model): TModel;
|
||||
create(attributes: any, options?: ModelSaveOptions): TModel;
|
||||
pluck(attribute: string): any[];
|
||||
push(model: TModel, options?: AddOptions): TModel;
|
||||
@@ -360,7 +379,7 @@ declare module Backbone {
|
||||
|
||||
// Utility
|
||||
function noConflict(): typeof Backbone;
|
||||
function setDomLibrary(jQueryNew: any): any;
|
||||
var $: JQueryStatic;
|
||||
}
|
||||
|
||||
declare module "backbone" {
|
||||
|
||||
+28
-28
@@ -38,31 +38,31 @@ str = bl.toString();
|
||||
|
||||
num = bl.length;
|
||||
|
||||
buffer = bl.readDoubleBE(offset, noAssert);
|
||||
buffer = bl.readDoubleBE(offset);
|
||||
buffer = bl.readDoubleLE(offset, noAssert);
|
||||
buffer = bl.readDoubleLE(offset);
|
||||
buffer = bl.readFloatBE(offset, noAssert);
|
||||
buffer = bl.readFloatBE(offset);
|
||||
buffer = bl.readFloatLE(offset, noAssert);
|
||||
buffer = bl.readFloatLE(offset);
|
||||
buffer = bl.readInt32BE(offset, noAssert);
|
||||
buffer = bl.readInt32BE(offset);
|
||||
buffer = bl.readInt32LE(offset, noAssert);
|
||||
buffer = bl.readInt32LE(offset);
|
||||
buffer = bl.readUInt32BE(offset, noAssert);
|
||||
buffer = bl.readUInt32BE(offset);
|
||||
buffer = bl.readUInt32LE(offset, noAssert);
|
||||
buffer = bl.readUInt32LE(offset);
|
||||
buffer = bl.readInt16BE(offset, noAssert);
|
||||
buffer = bl.readInt16BE(offset);
|
||||
buffer = bl.readInt16LE(offset, noAssert);
|
||||
buffer = bl.readInt16LE(offset);
|
||||
buffer = bl.readUInt16BE(offset, noAssert);
|
||||
buffer = bl.readUInt16BE(offset);
|
||||
buffer = bl.readUInt16LE(offset, noAssert);
|
||||
buffer = bl.readUInt16LE(offset);
|
||||
buffer = bl.readInt8(offset, noAssert);
|
||||
buffer = bl.readInt8(offset);
|
||||
buffer = bl.readUInt8(offset, noAssert);
|
||||
buffer = bl.readUInt8(offset);
|
||||
num = bl.readDoubleBE(offset, noAssert);
|
||||
num = bl.readDoubleBE(offset);
|
||||
num = bl.readDoubleLE(offset, noAssert);
|
||||
num = bl.readDoubleLE(offset);
|
||||
num = bl.readFloatBE(offset, noAssert);
|
||||
num = bl.readFloatBE(offset);
|
||||
num = bl.readFloatLE(offset, noAssert);
|
||||
num = bl.readFloatLE(offset);
|
||||
num = bl.readInt32BE(offset, noAssert);
|
||||
num = bl.readInt32BE(offset);
|
||||
num = bl.readInt32LE(offset, noAssert);
|
||||
num = bl.readInt32LE(offset);
|
||||
num = bl.readUInt32BE(offset, noAssert);
|
||||
num = bl.readUInt32BE(offset);
|
||||
num = bl.readUInt32LE(offset, noAssert);
|
||||
num = bl.readUInt32LE(offset);
|
||||
num = bl.readInt16BE(offset, noAssert);
|
||||
num = bl.readInt16BE(offset);
|
||||
num = bl.readInt16LE(offset, noAssert);
|
||||
num = bl.readInt16LE(offset);
|
||||
num = bl.readUInt16BE(offset, noAssert);
|
||||
num = bl.readUInt16BE(offset);
|
||||
num = bl.readUInt16LE(offset, noAssert);
|
||||
num = bl.readUInt16LE(offset);
|
||||
num = bl.readInt8(offset, noAssert);
|
||||
num = bl.readInt8(offset);
|
||||
num = bl.readUInt8(offset, noAssert);
|
||||
num = bl.readUInt8(offset);
|
||||
|
||||
Vendored
+14
-14
@@ -20,20 +20,20 @@ declare module 'bl' {
|
||||
toString(encoding?: string, start?: number, end?: number): string;
|
||||
length: number;
|
||||
|
||||
readDoubleBE(offset: number, noAssert?: boolean): Buffer;
|
||||
readDoubleLE(offset: number, noAssert?: boolean): Buffer;
|
||||
readFloatBE(offset: number, noAssert?: boolean): Buffer;
|
||||
readFloatLE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt32BE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt32LE(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt32BE(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt32LE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt16BE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt16LE(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt16BE(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt16LE(offset: number, noAssert?: boolean): Buffer;
|
||||
readInt8(offset: number, noAssert?: boolean): Buffer;
|
||||
readUInt8(offset: number, noAssert?: boolean): Buffer;
|
||||
readDoubleBE(offset: number, noAssert?: boolean): number;
|
||||
readDoubleLE(offset: number, noAssert?: boolean): number;
|
||||
readFloatBE(offset: number, noAssert?: boolean): number;
|
||||
readFloatLE(offset: number, noAssert?: boolean): number;
|
||||
readInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32BE(offset: number, noAssert?: boolean): number;
|
||||
readUInt32LE(offset: number, noAssert?: boolean): number;
|
||||
readInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readUInt16BE(offset: number, noAssert?: boolean): number;
|
||||
readUInt16LE(offset: number, noAssert?: boolean): number;
|
||||
readInt8(offset: number, noAssert?: boolean): number;
|
||||
readUInt8(offset: number, noAssert?: boolean): number;
|
||||
}
|
||||
|
||||
export = BufferList;
|
||||
|
||||
+26
-7
@@ -5,6 +5,15 @@
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
|
||||
/**
|
||||
* All options that take a “Date” can handle a Date object; a String
|
||||
* formatted according to the given format; or a timedelta relative
|
||||
* to today, eg “-1d”, “+6m +1y”, etc, where valid units are “d” (day),
|
||||
* “w” (week), “m” (month), and “y” (year).
|
||||
*
|
||||
* See online docs for more info:
|
||||
* http://bootstrap-datepicker.readthedocs.org/en/release/options.html
|
||||
*/
|
||||
interface DatepickerOptions {
|
||||
format?: string;
|
||||
weekStart?: number;
|
||||
@@ -16,11 +25,21 @@ interface DatepickerOptions {
|
||||
todayHighlight?: boolean;
|
||||
keyboardNavigation?: boolean;
|
||||
language?: string;
|
||||
beforeShowDay?: (date: any) => any;
|
||||
calendarWeeks?: boolean;
|
||||
clearBtn?: boolean;
|
||||
daysOfWeekDisabled?: number[];
|
||||
forceParse?: boolean;
|
||||
inputs?: any[];
|
||||
minViewMode?: any;
|
||||
multidate?: any;
|
||||
multidateSeparator?: string;
|
||||
orientation?: string;
|
||||
}
|
||||
|
||||
interface DatepickerEventObject extends JQueryEventObject {
|
||||
date: Date;
|
||||
format(format?: string): string;
|
||||
date: Date;
|
||||
format(format?: string): string;
|
||||
}
|
||||
|
||||
interface JQuery {
|
||||
@@ -29,10 +48,10 @@ interface JQuery {
|
||||
datepicker(methodName: string, params: any): JQuery;
|
||||
datepicker(options: DatepickerOptions): JQuery;
|
||||
|
||||
off(events: "changeDate", selector?: string, handler?: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
off(events: "changeDate", handler: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
off(events: "changeDate", selector?: string, handler?: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
off(events: "changeDate", handler: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
|
||||
on(events: "changeDate", selector: string, data: any, handler?: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
on(events: "changeDate", selector: string, handler: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
on(events: 'changeDate', handler: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
on(events: "changeDate", selector: string, data: any, handler?: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
on(events: "changeDate", selector: string, handler: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
on(events: 'changeDate', handler: (eventObject: DatepickerEventObject) => any): JQuery;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
/// <reference path="bootstrap.v3.datetimepicker.d.ts" />
|
||||
|
||||
function test_cases() {
|
||||
$('#datetimepicker').datetimepicker();
|
||||
$('#datetimepicker').datetimepicker({
|
||||
pickDate: false
|
||||
});
|
||||
$('#datetimepicker').datetimepicker({
|
||||
pickTime: false
|
||||
});
|
||||
$('#datetimepicker').datetimepicker({
|
||||
minDate: '2012-12-31'
|
||||
});
|
||||
|
||||
$('#datetimepicker').data("DateTimePicker").setMaxDate('2012-12-31');
|
||||
|
||||
var startDate = new Date(2012, 1, 20);
|
||||
var endDate = new Date(2012, 1, 25);
|
||||
$('#datetimepicker2')
|
||||
.datetimepicker()
|
||||
.on("dp.change", function (ev) {
|
||||
if (ev.date.valueOf() > endDate.valueOf()) {
|
||||
$('#alert').show().find('strong').text('The start date must be before the end date.');
|
||||
} else {
|
||||
$('#alert').hide();
|
||||
startDate = ev.date;
|
||||
$('#date-start-display').text($('#date-start').data('date'));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
// Type definitions for Bootstrap datetimepicker v3
|
||||
// Project: http://eonasdan.github.io/bootstrap-datetimepicker
|
||||
// Definitions by: Jesica N. Fera <https://github.com/bayitajesi>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* bootstrap-datetimepicker.js 3.0.0 Copyright (c) 2014 Jonathan Peterson
|
||||
* Available via the MIT license.
|
||||
* see: http://eonasdan.github.io/bootstrap-datetimepicker or https://github.com/Eonasdan/bootstrap-datetimepicker for details.
|
||||
*/
|
||||
|
||||
/// <reference path="../jquery/jquery.d.ts"/>
|
||||
|
||||
declare module BootstrapV3DatetimePicker {
|
||||
interface DatetimepickerChangeEventObject extends JQueryEventObject {
|
||||
date: any;
|
||||
oldDate: any;
|
||||
}
|
||||
|
||||
interface DatetimepickerEventObject extends JQueryEventObject {
|
||||
date: any;
|
||||
}
|
||||
|
||||
interface DatetimepickerIcons {
|
||||
time?: string;
|
||||
date?: string;
|
||||
up?: string;
|
||||
down?: string;
|
||||
}
|
||||
|
||||
interface DatetimepickerOptions {
|
||||
pickDate?: boolean;
|
||||
pickTime?: boolean;
|
||||
useMinutes?: boolean;
|
||||
useSeconds?: boolean;
|
||||
useCurrent?: boolean;
|
||||
minuteStepping?: number;
|
||||
minDate?: any;
|
||||
maxDate?: any;
|
||||
showToday?: boolean;
|
||||
collapse?: boolean;
|
||||
language?: string;
|
||||
defaultDate?: string;
|
||||
disabledDates?: Array<any>;
|
||||
enabledDates?: Array<any>;
|
||||
icons?: DatetimepickerIcons;
|
||||
useStrict?: boolean;
|
||||
direction?: string;
|
||||
sideBySide?: boolean;
|
||||
daysOfWeekDisabled?: Array<any>;
|
||||
}
|
||||
|
||||
interface Datetimepicker {
|
||||
setDate(date: any): void;
|
||||
setMinDate(date: any): void;
|
||||
setMaxDate(date: any): void;
|
||||
show(): void;
|
||||
disable(): void;
|
||||
enable(): void;
|
||||
getDate(): void;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
interface JQuery {
|
||||
|
||||
datetimepicker(): JQuery;
|
||||
datetimepicker(options: BootstrapV3DatetimePicker.DatetimepickerOptions): JQuery;
|
||||
|
||||
off(events: "dp.change", selector?: string, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery;
|
||||
off(events: "dp.change", handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery;
|
||||
|
||||
on(events: "dp.change", selector: string, data: any, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery;
|
||||
on(events: "dp.change", selector: string, handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery;
|
||||
on(events: 'dp.change', handler: (eventObject: BootstrapV3DatetimePicker.DatetimepickerChangeEventObject) => any): JQuery;
|
||||
|
||||
off(events: "dp.show", selector?: string, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
off(events: "dp.show", handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
|
||||
on(events: "dp.show", selector: string, data: any, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
on(events: "dp.show", selector: string, handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
on(events: 'dp.show', handler: (eventObject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
|
||||
off(events: "dp.hide", selector?: string, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
off(events: "dp.hide", handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
|
||||
on(events: "dp.hide", selector: string, data: any, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
on(events: "dp.hide", selector: string, handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
on(events: 'dp.hide', handler: (eventObject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
|
||||
off(events: "dp.error", selector?: string, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
off(events: "dp.error", handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
|
||||
on(events: "dp.error", selector: string, data: any, handler?: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
on(events: "dp.error", selector: string, handler: (eventobject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
on(events: 'dp.error', handler: (eventObject: BootstrapV3DatetimePicker.DatetimepickerEventObject) => any): JQuery;
|
||||
|
||||
data(key: 'DateTimePicker'): BootstrapV3DatetimePicker.Datetimepicker;
|
||||
}
|
||||
Vendored
+1
-1
@@ -1,5 +1,5 @@
|
||||
// Type definitions for buffer-equal 1.0 0
|
||||
// Project: https://github.com/chaijs/assertion-error
|
||||
// Project: https://github.com/substack/node-buffer-equal
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path="bufferstream.d.ts" />
|
||||
|
||||
import BufferStream = require('bufferstream')
|
||||
|
||||
var stream = new BufferStream({encoding:'utf8', size:'flexible'});
|
||||
stream.enable();
|
||||
stream.disable();
|
||||
stream.split('//', ':');
|
||||
stream.on('split', (chunk: any, token: any) => {
|
||||
console.log("got '%s' by '%s'", chunk.toString(), token.toString())
|
||||
});
|
||||
stream.write("buffer:stream//23");
|
||||
console.log(stream.toString());
|
||||
|
||||
Vendored
+119
@@ -0,0 +1,119 @@
|
||||
// Type definitions for bufferstream v0.6.2
|
||||
// Project: https://github.com/dodo/node-bufferstream
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../node/node.d.ts" />
|
||||
|
||||
declare module 'bufferstream' {
|
||||
import stream = require('stream');
|
||||
|
||||
export = BufferStream;
|
||||
|
||||
class BufferStream extends stream.Duplex {
|
||||
constructor(options?: BufferStream.Opts);
|
||||
|
||||
/*
|
||||
different buffer behaviors can be triggered by size:
|
||||
|
||||
none when output drains, bufferstream drains too
|
||||
flexible buffers everthing that it gets and not piping out
|
||||
<number> TODO buffer has given size. buffers everthing until buffer is full. when buffer is full then the stream will drain
|
||||
*/
|
||||
setSize(size: string): void; // can be one of ['none', 'flexible', <number>]
|
||||
setSize(size: number): void; // can be one of ['none', 'flexible', <number>]
|
||||
/*
|
||||
enables stream buffering default
|
||||
*/
|
||||
enable(): void;
|
||||
/*
|
||||
flushes buffer and disables stream buffering. BufferStream now pipes all data as long as the output accepting data. when the output is draining BufferStream will buffer all input temporary.
|
||||
|
||||
token[s] buffer splitters (should be String or Buffer)
|
||||
|
||||
disables given tokens. wont flush until no splitter tokens are left.
|
||||
*/
|
||||
disable(): void;
|
||||
disable(token: string, ...tokens: string[]): void;
|
||||
disable(tokens: string[]): void; // Array
|
||||
disable(token: Buffer, ...tokens: Buffer[]): void;
|
||||
disable(tokens: Buffer[]): void; // Array
|
||||
/*
|
||||
each time BufferStream finds a splitter token in the input data it will emit a split event. this also works for binary data.
|
||||
|
||||
token[s] buffer splitters (should be String or Buffer)
|
||||
*/
|
||||
split(token: string, ...tokens: string[]): void;
|
||||
split(tokens: string[]): void; // Array
|
||||
split(token: Buffer, ...tokens: Buffer[]): void;
|
||||
split(tokens: Buffer[]): void; // Array
|
||||
/*
|
||||
returns Buffer.
|
||||
*/
|
||||
getBuffer(): Buffer;
|
||||
/*
|
||||
returns Buffer.
|
||||
*/
|
||||
buffer: Buffer;
|
||||
/*
|
||||
shortcut for buffer.toString()
|
||||
*/
|
||||
toString(): string;
|
||||
/*
|
||||
shortcut for buffer.length
|
||||
*/
|
||||
length: number;
|
||||
}
|
||||
module BufferStream {
|
||||
|
||||
export interface Opts {
|
||||
/*
|
||||
default encoding for writing strings
|
||||
*/
|
||||
encoding?: string;
|
||||
/*
|
||||
if true and the source is a child_process the stream will block the entire process (timeouts wont work anymore, but splitting and listening on data still works, because they work sync)
|
||||
*/
|
||||
blocking?: boolean;
|
||||
/*
|
||||
defines buffer level or sets buffer to given size (see ↓setSize for more)
|
||||
*/
|
||||
size?: any;
|
||||
/*
|
||||
immediately call disable
|
||||
*/
|
||||
disabled?: boolean;
|
||||
/*
|
||||
short form for:
|
||||
split(token, function (chunk) {emit('data', chunk)})
|
||||
*/
|
||||
// String or Buffer
|
||||
split?: any;
|
||||
}
|
||||
export var fn: {warn: boolean};
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'bufferstream/postbuffer' {
|
||||
import http = require('http');
|
||||
import BufferStream = require('bufferstream');
|
||||
|
||||
class PostBuffer extends BufferStream {
|
||||
/*
|
||||
for if you want to get all the post data from a http server request and do some db reqeust before.
|
||||
|
||||
http client buffer
|
||||
*/
|
||||
constructor(req: http.ServerRequest);
|
||||
/*
|
||||
set a callback to get all post data from a http server request
|
||||
*/
|
||||
onEnd(callback: (data: any) => void): void;
|
||||
/*
|
||||
pumps data into another stream to allow incoming streams given options will be passed to Stream.pipe
|
||||
*/
|
||||
pipe(stream: NodeJS.WritableStream, options?: BufferStream.Opts): NodeJS.ReadableStream;
|
||||
}
|
||||
|
||||
export = PostBuffer;
|
||||
}
|
||||
Vendored
+4
@@ -102,6 +102,10 @@ declare module CamlBuilder {
|
||||
All(...conditions: IExpression[]): IExpression;
|
||||
/** Adds Or clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
|
||||
Any(...conditions: IExpression[]): IExpression;
|
||||
/** Adds And clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
|
||||
All(conditions: IExpression[]): IExpression;
|
||||
/** Adds Or clauses to the query. Use for creating bracket-expressions in conjuction with CamlBuilder.Expression(). */
|
||||
Any(conditions: IExpression[]): IExpression;
|
||||
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Text */
|
||||
TextField(internalName: string): ITextFieldExpression;
|
||||
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is Boolean */
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Type definitions for chai-datetime
|
||||
// Project: https://github.com/gaslight/chai-datetime.git
|
||||
// Definitions by: Cliff Burger <https://github.com/cliffburger/>
|
||||
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../chai/chai.d.ts" />
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Type definitions for chai-jquery 1.1.1
|
||||
// Project: https://github.com/chaijs/chai-jquery
|
||||
// Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid/>
|
||||
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../chai/chai.d.ts" />
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
""
|
||||
Vendored
-4
@@ -129,7 +129,3 @@ declare module chai {
|
||||
|
||||
//browser global
|
||||
declare var assert:chai.Assert;
|
||||
|
||||
declare module 'chai' {
|
||||
export = chai;
|
||||
}
|
||||
|
||||
Vendored
+5
-2
@@ -1,8 +1,7 @@
|
||||
// Type definitions for chai 1.7.2
|
||||
// Project: http://chaijs.com/
|
||||
// Definitions by: Jed Hunsaker <https://github.com/jedhunsaker/>
|
||||
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module chai {
|
||||
|
||||
@@ -163,3 +162,7 @@ declare module chai {
|
||||
(constructor: Function, expected?: RegExp, message?: string): Expect;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "chai" {
|
||||
export = chai;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
/// <reference path="chalk.d.ts" />
|
||||
|
||||
import chalk = require('chalk');
|
||||
|
||||
var str: string;
|
||||
var bool: boolean;
|
||||
|
||||
chalk.enabled = bool;
|
||||
str = chalk.stripColor(str);
|
||||
|
||||
bool = chalk.supportsColor;
|
||||
bool = chalk.hasColor(str);
|
||||
|
||||
// style a string
|
||||
console.log( chalk.blue('Hello world!') );
|
||||
|
||||
// combine styled and normal strings
|
||||
console.log( chalk.blue('Hello'), 'World' + chalk.red('!') );
|
||||
|
||||
// compose multiple styles using the chainable API
|
||||
console.log( chalk.blue.bgRed.bold('Hello world!') );
|
||||
|
||||
// pass in multiple arguments
|
||||
console.log( chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz') );
|
||||
|
||||
// nest styles
|
||||
console.log( chalk.red('Hello', chalk.underline.bgBlue('world') + '!') );
|
||||
|
||||
// nest styles of the same type even (color, underline, background)
|
||||
console.log( chalk.green('I am a green line ' + chalk.blue('with a blue substring') + ' that becomes green again!') );
|
||||
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
// Type definitions for chalk v0.4.0
|
||||
// Project: https://github.com/sindresorhus/chalk
|
||||
// Definitions by: Diullei Gomes <https://github.com/Diullei>, Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module Chalk {
|
||||
export interface ChalkModule extends ChalkStyle {
|
||||
enabled: boolean;
|
||||
supportsColor: boolean;
|
||||
styles: ChalkStyleMap;
|
||||
|
||||
stripColor(value: string): any;
|
||||
hasColor(str: string): boolean;
|
||||
}
|
||||
|
||||
export interface ChalkChain extends ChalkStyle {
|
||||
(...text: string[]): ChalkChain;
|
||||
}
|
||||
|
||||
export interface ChalkStyleElement {
|
||||
open: string;
|
||||
close: string;
|
||||
}
|
||||
|
||||
export interface ChalkStyle {
|
||||
// General
|
||||
reset: ChalkChain;
|
||||
bold: ChalkChain;
|
||||
italic: ChalkChain;
|
||||
underline: ChalkChain;
|
||||
inverse: ChalkChain;
|
||||
strikethrough: ChalkChain;
|
||||
|
||||
// Text colors
|
||||
black: ChalkChain;
|
||||
red: ChalkChain;
|
||||
green: ChalkChain;
|
||||
yellow: ChalkChain;
|
||||
blue: ChalkChain;
|
||||
magenta: ChalkChain;
|
||||
cyan: ChalkChain;
|
||||
white: ChalkChain;
|
||||
gray: ChalkChain;
|
||||
|
||||
// Background colors
|
||||
bgBlack: ChalkChain;
|
||||
bgRed: ChalkChain;
|
||||
bgGreen: ChalkChain;
|
||||
bgYellow: ChalkChain;
|
||||
bgBlue: ChalkChain;
|
||||
bgMagenta: ChalkChain;
|
||||
bgCyan: ChalkChain;
|
||||
bgWhite: ChalkChain;
|
||||
}
|
||||
|
||||
export interface ChalkStyleMap {
|
||||
// General
|
||||
reset: ChalkStyleElement;
|
||||
bold: ChalkStyleElement;
|
||||
italic: ChalkStyleElement;
|
||||
underline: ChalkStyleElement;
|
||||
inverse: ChalkStyleElement;
|
||||
strikethrough: ChalkStyleElement;
|
||||
|
||||
// Text colors
|
||||
black: ChalkStyleElement;
|
||||
red: ChalkStyleElement;
|
||||
green: ChalkStyleElement;
|
||||
yellow: ChalkStyleElement;
|
||||
blue: ChalkStyleElement;
|
||||
magenta: ChalkStyleElement;
|
||||
cyan: ChalkStyleElement;
|
||||
white: ChalkStyleElement;
|
||||
gray: ChalkStyleElement;
|
||||
|
||||
// Background colors
|
||||
bgBlack: ChalkStyleElement;
|
||||
bgRed: ChalkStyleElement;
|
||||
bgGreen: ChalkStyleElement;
|
||||
bgYellow: ChalkStyleElement;
|
||||
bgBlue: ChalkStyleElement;
|
||||
bgMagenta: ChalkStyleElement;
|
||||
bgCyan: ChalkStyleElement;
|
||||
bgWhite: ChalkStyleElement;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "chalk" {
|
||||
var ch: Chalk.ChalkModule;
|
||||
export = ch;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ $el.children().map((index, element) => {
|
||||
});
|
||||
|
||||
$el.children().filter((index) => {
|
||||
return $el.children().eq(index).find('t');
|
||||
return $el.children().eq(index).find('t').length >= 0;
|
||||
});
|
||||
|
||||
$el.filter('span').filter('li');
|
||||
@@ -60,6 +60,6 @@ $el.text('some text');
|
||||
|
||||
$el.toArray();
|
||||
$el.clone().find('a').parent();
|
||||
$el.root().find('a');
|
||||
$.root().find('a');
|
||||
|
||||
$el.dom();
|
||||
$el.data();
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
""
|
||||
Vendored
+167
-37
@@ -1,81 +1,211 @@
|
||||
// Type definitions for Cheerio
|
||||
// Project: https://github.com/MatthewMueller/cheerio
|
||||
// Type definitions for Cheerio v0.17.0
|
||||
// Project: https://github.com/cheeriojs/cheerio
|
||||
// Definitions by: Bret Little <https://github.com/blittle>
|
||||
// Definitions by: VILIC VANE <http://vilic.info>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
interface Cheerio {
|
||||
|
||||
addClass(classNames: string): Cheerio;
|
||||
hasClass(className: string): boolean;
|
||||
removeClass(className?: any): Cheerio;
|
||||
// Document References
|
||||
// Cheerio https://github.com/cheeriojs/cheerio
|
||||
// JQuery http://api.jquery.com
|
||||
|
||||
attr(attributeName: string, value: any): Cheerio;
|
||||
attr(attributeName: string): string;
|
||||
removeAttr(attributeName: any): Cheerio;
|
||||
[index: number]: CheerioElement;
|
||||
length: number;
|
||||
|
||||
// Attributes
|
||||
|
||||
attr(name: string): string;
|
||||
attr(name: string, value: any): Cheerio;
|
||||
|
||||
data(): any;
|
||||
|
||||
val(): string;
|
||||
val(value: string): Cheerio;
|
||||
|
||||
removeAttr(name: string): Cheerio;
|
||||
|
||||
hasClass(className: string): boolean;
|
||||
addClass(classNames: string): Cheerio;
|
||||
|
||||
removeClass(): Cheerio;
|
||||
removeClass(className: string): Cheerio;
|
||||
removeClass(func: (index: number, className: string) => string): Cheerio;
|
||||
|
||||
toggleClass(className: string): Cheerio;
|
||||
toggleClass(className: string, toggleSwitch: boolean): Cheerio;
|
||||
toggleClass(toggleSwitch?: boolean): Cheerio;
|
||||
toggleClass(func: (index: number, className: string, toggleSwitch: boolean) => string, toggleSwitch?: boolean): Cheerio;
|
||||
|
||||
is(selector: string): boolean;
|
||||
is(element: CheerioElement): boolean;
|
||||
is(element: CheerioElement[]): boolean;
|
||||
is(selection: Cheerio): boolean;
|
||||
is(func: (index: number, element: CheerioElement) => boolean): boolean;
|
||||
|
||||
// Traversing
|
||||
|
||||
find(selector: string): Cheerio;
|
||||
|
||||
parent(): Cheerio;
|
||||
parent(selector?: string): Cheerio;
|
||||
parents(selector?: string): Cheerio;
|
||||
parentsUntil(selector?: string, filter?: string): Cheerio;
|
||||
parentsUntil(element: CheerioElement, filter?: string): Cheerio;
|
||||
parentsUntil(element: Cheerio, filter?: string): Cheerio;
|
||||
|
||||
next(): Cheerio;
|
||||
prev(): Cheerio;
|
||||
closest(selector: string): Cheerio;
|
||||
|
||||
siblings(): Cheerio;
|
||||
next(selector?: string): Cheerio;
|
||||
nextAll(): Cheerio;
|
||||
|
||||
children(selector?: any): Cheerio;
|
||||
nextUntil(selector?: string, filter?: string): Cheerio;
|
||||
nextUntil(element: CheerioElement, filter?: string): Cheerio;
|
||||
nextUntil(element: Cheerio, filter?: string): Cheerio;
|
||||
|
||||
each(func: (index: any, elem: any) => Cheerio);
|
||||
prev(selector?: string): Cheerio;
|
||||
prevAll(): Cheerio;
|
||||
|
||||
map(callback: (index: any, domElement: Element) =>any): Cheerio;
|
||||
prevUntil(selector?: string, filter?: string): Cheerio;
|
||||
prevUntil(element: CheerioElement, filter?: string): Cheerio;
|
||||
prevUntil(element: Cheerio, filter?: string): Cheerio;
|
||||
|
||||
slice(start: number, end?: number): Cheerio;
|
||||
|
||||
siblings(selector?: string): Cheerio;
|
||||
|
||||
children(selector?: string): Cheerio;
|
||||
|
||||
each(func: (index: number, element: CheerioElement) => any): Cheerio;
|
||||
map(func: (index: number, element: CheerioElement) => any): Cheerio;
|
||||
|
||||
filter(selector: string): Cheerio;
|
||||
filter(func: (index: any) =>any): Cheerio;
|
||||
filter(selection: Cheerio): Cheerio;
|
||||
filter(element: CheerioElement): Cheerio;
|
||||
filter(elements: CheerioElement[]): Cheerio;
|
||||
filter(func: (index: number) => boolean): Cheerio;
|
||||
|
||||
first(): Cheerio;
|
||||
last(): Cheerio;
|
||||
|
||||
eq(index: number): Cheerio;
|
||||
|
||||
append(...content: any[]): Cheerio;
|
||||
prepend(...content: any[]): Cheerio;
|
||||
after(...content: any[]): Cheerio;
|
||||
before(...content: any[]): Cheerio;
|
||||
remove(selector: string): Cheerio;
|
||||
get(): Document[];
|
||||
get(index: number): Document;
|
||||
|
||||
end(): Cheerio;
|
||||
|
||||
add(selectorOrHtml: string): Cheerio;
|
||||
add(selector: string, context: Document): Cheerio;
|
||||
add(element: CheerioElement): Cheerio;
|
||||
add(elements: CheerioElement[]): Cheerio;
|
||||
add(selection: Cheerio): Cheerio;
|
||||
|
||||
// Manipulation
|
||||
|
||||
append(content: string, ...contents: any[]): Cheerio;
|
||||
append(content: Document, ...contents: any[]): Cheerio;
|
||||
append(content: Document[], ...contents: any[]): Cheerio;
|
||||
append(content: Cheerio, ...contents: any[]): Cheerio;
|
||||
|
||||
prepend(content: string, ...contents: any[]): Cheerio;
|
||||
prepend(content: Document, ...contents: any[]): Cheerio;
|
||||
prepend(content: Document[], ...contents: any[]): Cheerio;
|
||||
prepend(content: Cheerio, ...contents: any[]): Cheerio;
|
||||
|
||||
after(content: string, ...contents: any[]): Cheerio;
|
||||
after(content: Document, ...contents: any[]): Cheerio;
|
||||
after(content: Document[], ...contents: any[]): Cheerio;
|
||||
after(content: Cheerio, ...contents: any[]): Cheerio;
|
||||
|
||||
before(content: string, ...contents: any[]): Cheerio;
|
||||
before(content: Document, ...contents: any[]): Cheerio;
|
||||
before(content: Document[], ...contents: any[]): Cheerio;
|
||||
before(content: Cheerio, ...contents: any[]): Cheerio;
|
||||
|
||||
remove(selector?: string): Cheerio;
|
||||
|
||||
replaceWith(content: string): Cheerio;
|
||||
replaceWith(content: CheerioElement): Cheerio;
|
||||
replaceWith(content: CheerioElement[]): Cheerio;
|
||||
replaceWith(content: Cheerio): Cheerio;
|
||||
|
||||
empty(): Cheerio;
|
||||
|
||||
html(htmlString: string): Cheerio;
|
||||
html(): string;
|
||||
html(html: string): Cheerio;
|
||||
|
||||
text(textString: string): Cheerio;
|
||||
text(): string;
|
||||
text(text: string): Cheerio;
|
||||
|
||||
toArray(): any[];
|
||||
css(propertyName: string): string;
|
||||
css(propertyNames: string[]): string[];
|
||||
css(propertyName: string, value: string): Cheerio;
|
||||
css(propertyName: string, value: number): Cheerio;
|
||||
css(propertyName: string, func: (index: number, value: string) => string): Cheerio;
|
||||
css(propertyName: string, func: (index: number, value: string) => number): Cheerio;
|
||||
css(properties: Object): Cheerio;
|
||||
|
||||
clone() : Cheerio;
|
||||
root() : Cheerio;
|
||||
dom(): any;
|
||||
// Rendering
|
||||
|
||||
contains(container: Element, contained: Element): boolean;
|
||||
isArray(obj: any): boolean;
|
||||
inArray(value: any, array: any[], fromIndex?: number): number;
|
||||
merge(first: any[], second: any[]): any[];
|
||||
// Miscellaneous
|
||||
|
||||
clone(): Cheerio;
|
||||
|
||||
// Not Documented
|
||||
|
||||
toArray(): CheerioElement[];
|
||||
}
|
||||
|
||||
interface CheerioOptionsInterface {
|
||||
ignoreWhitespace?: boolean;
|
||||
// Document References
|
||||
// Cheerio https://github.com/cheeriojs/cheerio
|
||||
// HTMLParser2 https://github.com/fb55/htmlparser2/wiki/Parser-options
|
||||
// DomHandler https://github.com/fb55/DomHandler
|
||||
|
||||
xmlMode?: boolean;
|
||||
decodeEntities?: boolean;
|
||||
lowerCaseTags?: boolean;
|
||||
lowerCaseAttributeNames?: boolean;
|
||||
recognizeCDATA?: boolean;
|
||||
recognizeSelfClosing?: boolean;
|
||||
normalizeWhitespace?: boolean;
|
||||
}
|
||||
|
||||
interface CheerioStatic {
|
||||
(...selectors: any[]): Cheerio;
|
||||
(): Cheerio;
|
||||
// Document References
|
||||
// Cheerio https://github.com/cheeriojs/cheerio
|
||||
// JQuery http://api.jquery.com
|
||||
|
||||
(selector: string): Cheerio;
|
||||
(selector: string, context: string): Cheerio;
|
||||
(selector: string, context: CheerioElement): Cheerio;
|
||||
(selector: string, context: CheerioElement[]): Cheerio;
|
||||
(selector: string, context: Cheerio): Cheerio;
|
||||
(selector: string, context: string, root: string): Cheerio;
|
||||
(selector: string, context: CheerioElement, root: string): Cheerio;
|
||||
(selector: string, context: CheerioElement[], root: string): Cheerio;
|
||||
(selector: string, context: Cheerio, root: string): Cheerio;
|
||||
(selector: any): Cheerio;
|
||||
|
||||
xml(): string;
|
||||
root(): Cheerio;
|
||||
contains(container: CheerioElement, contained: CheerioElement): boolean;
|
||||
parseHTML(data: string, context?: Document, keepScripts?: boolean): Document[];
|
||||
}
|
||||
|
||||
interface CheerioElement {
|
||||
// Document References
|
||||
// Node Console
|
||||
|
||||
type: string;
|
||||
name: string;
|
||||
attribs: Object;
|
||||
children: CheerioElement[];
|
||||
next: CheerioElement;
|
||||
prev: CheerioElement;
|
||||
parent: CheerioElement;
|
||||
root: CheerioElement;
|
||||
}
|
||||
|
||||
declare module "cheerio" {
|
||||
export function load (html : string, options?: CheerioOptionsInterface) : CheerioStatic;
|
||||
export function load(html: string, options?: CheerioOptionsInterface): CheerioStatic;
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
""
|
||||
Vendored
+2
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Chrome packaged application development.
|
||||
// Type definitions for Chrome packaged application development
|
||||
// Project: http://developer.chrome.com/apps/
|
||||
// Definitions by: Adam Lay <https://github.com/AdamLay>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -92,4 +92,4 @@ declare module chrome.app.window {
|
||||
var onMaximized: WindowEvent;
|
||||
var onMinimized: WindowEvent;
|
||||
var onRestored: WindowEvent;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+64
-2
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Chrome extension development.
|
||||
// Type definitions for Chrome extension development
|
||||
// Project: http://developer.chrome.com/extensions/
|
||||
// Definitions by: Matthew Kimber <https://github.com/matthewkimber> and otiai10 <https://github.com/otiai10>
|
||||
// Definitions by: Matthew Kimber <https://github.com/matthewkimber>, otiai10 <https://github.com/otiai10>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
////////////////////
|
||||
@@ -1232,6 +1232,68 @@ declare module chrome.management {
|
||||
var onEnabled: ManagementEnabledEvent;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Notifications
|
||||
// https://developer.chrome.com/extensions/notifications
|
||||
////////////////////
|
||||
declare module chrome.notifications {
|
||||
interface ButtonOptions {
|
||||
title: string;
|
||||
iconUrl?: string;
|
||||
}
|
||||
|
||||
interface ItemOptions {
|
||||
title: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
interface NotificationOptions {
|
||||
type?: string;
|
||||
iconUrl?: string;
|
||||
title?: string;
|
||||
message?: string;
|
||||
contextMessage?: string;
|
||||
priority?: number;
|
||||
eventTime?: number;
|
||||
buttons?: Array<ButtonOptions>;
|
||||
items?: Array<ItemOptions>;
|
||||
progress?: number;
|
||||
isClickable?: boolean;
|
||||
}
|
||||
|
||||
interface OnClosed {
|
||||
addListener(callback: (notificationId: string, byUser: boolean) => void): void;
|
||||
}
|
||||
|
||||
interface OnClicked {
|
||||
addListener(callback: (notificationId: string) => void): void;
|
||||
}
|
||||
|
||||
interface OnButtonClicked {
|
||||
addListener(callback: (notificationId: string, buttonIndex: number) => void): void;
|
||||
}
|
||||
|
||||
interface OnPermissionLevelChanged {
|
||||
addListener(callback: (level: string) => void): void;
|
||||
}
|
||||
|
||||
interface OnShowSettings {
|
||||
addListener(callback: Function): void;
|
||||
}
|
||||
|
||||
export var onClosed: OnClosed;
|
||||
export var onClicked: OnClicked;
|
||||
export var onButtonClicked: OnButtonClicked;
|
||||
export var onPermissionLevelChanged: OnPermissionLevelChanged;
|
||||
export var onShowSettings: OnShowSettings;
|
||||
|
||||
export function create(notificationId: string, options: NotificationOptions, callback: (notificationId: string) => void): void;
|
||||
export function update(notificationId: string, options: NotificationOptions, callback: (wasUpdated: boolean) => void): void;
|
||||
export function clear(notificationId: string, callback: (wasCleared: boolean) => void): void;
|
||||
export function getAll(callback: (notifications: any) => void): void;
|
||||
export function getPermissionLevel(callback: (level: string) => void): void;
|
||||
}
|
||||
|
||||
////////////////////
|
||||
// Omnibox
|
||||
////////////////////
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="../cordova/cordova.d.ts" />
|
||||
/// <reference path="./cordova-ionic.d.ts" />
|
||||
|
||||
// Keyboard
|
||||
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
|
||||
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(false);
|
||||
cordova.plugins.Keyboard.close();
|
||||
cordova.plugins.Keyboard.disableScroll(true);
|
||||
cordova.plugins.Keyboard.disableScroll(false);
|
||||
console.log(cordova.plugins.Keyboard.isVisible);
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// Type definitions for Ionic Cordova plugins
|
||||
// Project: https://github.com/driftyco
|
||||
// Definitions by: Hendrik Maus <https://github.com/hendrikmaus>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="./plugins/keyboard.d.ts" />
|
||||
|
||||
interface Cordova {
|
||||
plugins:Plugins;
|
||||
}
|
||||
|
||||
interface Plugins {
|
||||
Keyboard:Ionic.Keyboard;
|
||||
}
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
// Type definitions for Cordova Keyboard plugin
|
||||
// Project: https://github.com/driftyco/ionic-plugins-keyboard
|
||||
// Definitions by: Hendrik Maus <https://github.com/hendrikmaus>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module Ionic {
|
||||
interface Keyboard {
|
||||
|
||||
/**
|
||||
* Hide the keyboard accessory bar with the next, previous and done buttons.
|
||||
*
|
||||
* @param hide
|
||||
*/
|
||||
hideKeyboardAccessoryBar(hide:boolean): void;
|
||||
|
||||
/**
|
||||
* Close the keyboard if it is open.
|
||||
*/
|
||||
close(): void;
|
||||
|
||||
/**
|
||||
* Disable native scrolling, useful if you are using JavaScript to scroll
|
||||
*
|
||||
* @param disbale
|
||||
*/
|
||||
disableScroll(disbale:boolean): void;
|
||||
|
||||
/**
|
||||
* Whether or not the keyboard is currently visible.
|
||||
*/
|
||||
isVisible: boolean;
|
||||
}
|
||||
}
|
||||
Vendored
+3
-3
@@ -1,6 +1,6 @@
|
||||
// Type definitions for Apache Cordova.
|
||||
// Type definitions for Apache Cordova
|
||||
// Project: http://cordova.apache.org
|
||||
// Definitions by: Microsoft Open Technologies, Inc. <http://msopentech.com>
|
||||
// Definitions by: Microsoft Open Technologies Inc. <http://msopentech.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
//
|
||||
// Copyright (c) Microsoft Open Technologies, Inc.
|
||||
@@ -57,4 +57,4 @@ interface UrlUtil {
|
||||
}
|
||||
|
||||
/** Apache Cordova instance */
|
||||
declare var cordova: Cordova;
|
||||
declare var cordova: Cordova;
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/// <reference path="cordovarduino.d.ts"/>
|
||||
|
||||
serial.requestPermission(function success() {}, function error() {});
|
||||
serial.open({}, function success() {}, function error() {});
|
||||
serial.write('data_string', function success() {}, function error() {});
|
||||
serial.read(function success() {}, function error() {});
|
||||
serial.registerReadCallback(
|
||||
function success(data:any) {
|
||||
var view = new Uint8Array(data);
|
||||
console.log(view);
|
||||
},
|
||||
function error() {
|
||||
new Error("Failed to register read callback");
|
||||
});
|
||||
serial.close(function success() {}, function error() {});
|
||||
|
||||
var errorCallback = function (message:string) {
|
||||
alert('Error: ' + message);
|
||||
};
|
||||
|
||||
serial.requestPermission(
|
||||
function (successMessage:string) {
|
||||
serial.open(
|
||||
{baudRate: 9600},
|
||||
function (successMessage:string) {
|
||||
serial.write(
|
||||
'1',
|
||||
function (successMessage:string) {
|
||||
alert(successMessage);
|
||||
},
|
||||
errorCallback
|
||||
);
|
||||
},
|
||||
errorCallback
|
||||
);
|
||||
},
|
||||
errorCallback
|
||||
);
|
||||
Vendored
+84
@@ -0,0 +1,84 @@
|
||||
// Type definitions for Cordovarduino plugin
|
||||
// Project: https://github.com/stereolux/cordovarduino
|
||||
// Definitions by: Hendrik Maus <https://github.com/hendrikmaus>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module Cordovardunio {
|
||||
interface Serial {
|
||||
/**
|
||||
* Request permission to interact with the serial port.
|
||||
*
|
||||
* @param successCallback Function to call on success
|
||||
* @param errorCallback Function to call on error
|
||||
*/
|
||||
requestPermission(successCallback:Function, errorCallback:Function): void;
|
||||
|
||||
/**
|
||||
* Open a connection.
|
||||
*
|
||||
* @param opts SerialOptions object
|
||||
* @param successCallback Function to call on success
|
||||
* @param errorCallback Function to call on error
|
||||
*/
|
||||
open(opts:SerialOptions, successCallback:Function, errorCallback:Function): void
|
||||
|
||||
/**
|
||||
* Write to the serial port.
|
||||
*
|
||||
* @param data String data to write to serial port
|
||||
* @param successCallback Function to call on success
|
||||
* @param errorCallback Function to call on error
|
||||
*/
|
||||
write(data:string, successCallback:Function, errorCallback:Function): void;
|
||||
|
||||
/**
|
||||
* Read from the serial port.
|
||||
*
|
||||
* @param successCallback Function to call on success
|
||||
* @param errorCallback Function to call on error
|
||||
*/
|
||||
read(successCallback:Function, errorCallback:Function): void;
|
||||
|
||||
/**
|
||||
* Close connection.
|
||||
*
|
||||
* @param successCallback Function to call on success
|
||||
* @param errorCallback Function to call on error
|
||||
*/
|
||||
close(successCallback:Function, errorCallback:Function): void;
|
||||
|
||||
/**
|
||||
* Register a callback for the driver reading incoming data from the serial device
|
||||
*
|
||||
* @param successCallback Function to call on success
|
||||
* @param errorCallback Function to call on error
|
||||
*/
|
||||
registerReadCallback(successCallback:Function, errorCallback:Function): void;
|
||||
}
|
||||
|
||||
interface SerialOptions {
|
||||
/**
|
||||
* @defaultValue 9600
|
||||
*/
|
||||
baudRate?: number;
|
||||
|
||||
/**
|
||||
* @defaultValue 8
|
||||
*/
|
||||
dataBits?: number;
|
||||
|
||||
/**
|
||||
* @defaultValue 1
|
||||
*/
|
||||
stopBits?: number;
|
||||
|
||||
/**
|
||||
* @defaultValue 0
|
||||
*/
|
||||
parity?: number;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Plugin will be surfaced as window.serial
|
||||
declare var serial:Cordovardunio.Serial;
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Type definitions for EaselJS 0.7.1, TweenJS 0.5.1, SoundJS 0.5.2, PreloadJS 0.4.1
|
||||
// Project: http://www.createjs.com/#!/EaselJS
|
||||
// Type definitions for CreateJS
|
||||
// Project: http://www.createjs.com/
|
||||
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>, Chris Smith <https://github.com/evilangelist>, Satoru Kimura <https://github.com/gyohk>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
Vendored
+2
-2
@@ -1,5 +1,5 @@
|
||||
// Type definitions for EaselJS 0.7.1, TweenJS 0.5.1, SoundJS 0.5.2, PreloadJS 0.4.1
|
||||
// Project: http://www.createjs.com/#!/EaselJS
|
||||
// Type definitions for CreateJS
|
||||
// Project: http://www.createjs.com/
|
||||
// Definitions by: Pedro Ferreira <https://bitbucket.org/drk4>, Chris Smith <https://github.com/evilangelist>, Satoru Kimura <https://github.com/gyohk>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Type definitions for Crossroads.js
|
||||
// Project: http://millermedeiros.github.io/crossroads.js/
|
||||
// Definitions by: Diullei Gomes <https://github.com/diullei>
|
||||
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/// <reference path="../js-signals/js-signals.d.ts" />
|
||||
|
||||
|
||||
@@ -2587,4 +2587,42 @@ function extentTest() {
|
||||
d3.extent(["20", 3], (d) => { return d; });
|
||||
d3.extent([3, "20"], (d) => { return d; });
|
||||
d3.extent(["3", 20], (d) => { return d; });
|
||||
}
|
||||
|
||||
// Tests for d3.time.format.multi
|
||||
// Adopted from http://bl.ocks.org/mbostock/4149176
|
||||
function multiTest() {
|
||||
var customTimeFormat = d3.time.format.multi([
|
||||
[".%L", function(d) { return d.getMilliseconds(); }],
|
||||
[":%S", function(d) { return d.getSeconds(); }],
|
||||
["%I:%M", function(d) { return d.getMinutes(); }],
|
||||
["%I %p", function(d) { return d.getHours(); }],
|
||||
["%a %d", function(d) { return d.getDay() && d.getDate() != 1; }],
|
||||
["%b %d", function(d) { return d.getDate() != 1; }],
|
||||
["%B", function(d) { return d.getMonth(); }],
|
||||
["%Y", function() { return true; }]
|
||||
]);
|
||||
|
||||
var margin = {top: 250, right: 40, bottom: 250, left: 40},
|
||||
width = 960 - margin.left - margin.right,
|
||||
height = 500 - margin.top - margin.bottom;
|
||||
|
||||
var x = d3.time.scale()
|
||||
.domain([new Date(2012, 0, 1), new Date(2013, 0, 1)])
|
||||
.range([0, width]);
|
||||
|
||||
var xAxis = d3.svg.axis()
|
||||
.scale(x)
|
||||
.tickFormat(customTimeFormat);
|
||||
|
||||
var svg = d3.select("body").append("svg")
|
||||
.attr("width", width + margin.left + margin.right)
|
||||
.attr("height", height + margin.top + margin.bottom)
|
||||
.append("g")
|
||||
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
||||
|
||||
svg.append("g")
|
||||
.attr("class", "x axis")
|
||||
.attr("transform", "translate(0," + height + ")")
|
||||
.call(xAxis);
|
||||
}
|
||||
+29
-8
@@ -42,14 +42,14 @@ declare module D3 {
|
||||
};
|
||||
}
|
||||
|
||||
export interface Event {
|
||||
export interface D3Event extends Event{
|
||||
dx: number;
|
||||
dy: number;
|
||||
clientX: number;
|
||||
clientY: number;
|
||||
translate: number[];
|
||||
scale: number;
|
||||
sourceEvent: Event;
|
||||
sourceEvent: D3Event;
|
||||
x: number;
|
||||
y: number;
|
||||
keyCode: number;
|
||||
@@ -65,7 +65,7 @@ declare module D3 {
|
||||
/**
|
||||
* Access the current user event for interaction
|
||||
*/
|
||||
event: Event;
|
||||
event: D3Event;
|
||||
|
||||
/**
|
||||
* Compare two values for sorting.
|
||||
@@ -751,8 +751,8 @@ declare module D3 {
|
||||
empty: () => boolean;
|
||||
|
||||
data: {
|
||||
(values: (data: any, index?: number) => any[], key?: (data: any, index?: number) => string): UpdateSelection;
|
||||
(values: any[], key?: (data: any, index?: number) => string): UpdateSelection;
|
||||
(values: (data: any, index?: number) => any[], key?: (data: any, index?: number) => any): UpdateSelection;
|
||||
(values: any[], key?: (data: any, index?: number) => any): UpdateSelection;
|
||||
(): any[];
|
||||
};
|
||||
|
||||
@@ -1003,9 +1003,29 @@ declare module D3 {
|
||||
fridays: Range;
|
||||
saturdays: Range;
|
||||
format: {
|
||||
|
||||
/**
|
||||
* Constructs a new local time formatter using the given specifier.
|
||||
*/
|
||||
(specifier: string): TimeFormat;
|
||||
utc: (specifier: string) => TimeFormat;
|
||||
/**
|
||||
* Returns a new multi-resolution time format given the specified array of predicated formats.
|
||||
*/
|
||||
multi: (formats: any[][]) => TimeFormat;
|
||||
|
||||
utc: {
|
||||
/**
|
||||
* Constructs a new local time formatter using the given specifier.
|
||||
*/
|
||||
(specifier: string): TimeFormat;
|
||||
/**
|
||||
* Returns a new multi-resolution UTC time format given the specified array of predicated formats.
|
||||
*/
|
||||
multi: (formats: any[][]) => TimeFormat;
|
||||
};
|
||||
|
||||
/**
|
||||
* The full ISO 8601 UTC time format: "%Y-%m-%dT%H:%M:%S.%LZ".
|
||||
*/
|
||||
iso: TimeFormat;
|
||||
};
|
||||
|
||||
@@ -1600,6 +1620,7 @@ declare module D3 {
|
||||
export interface Symbol {
|
||||
type: (string:string) => Symbol;
|
||||
size: (number:number) => Symbol;
|
||||
(datum:any, index:number): string;
|
||||
}
|
||||
|
||||
export interface Brush {
|
||||
@@ -2743,7 +2764,7 @@ declare module D3 {
|
||||
clamp(clamp: boolean): TimeScale;
|
||||
ticks: {
|
||||
(count: number): any[];
|
||||
(range: Range, count: number): any[];
|
||||
(range: D3.Time.Range, count: number): any[];
|
||||
};
|
||||
tickFormat(count: number): (n: number) => string;
|
||||
copy(): TimeScale;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/// <reference path="date.format.d.ts" />
|
||||
|
||||
// test dateFormat
|
||||
var now : string = dateFormat();
|
||||
var nowFullDate : string = dateFormat( dateFormat.masks.fullDate );
|
||||
|
||||
// test format() (on the prototype of Date)
|
||||
var then : Date = new Date( 2014, 1, 1 );
|
||||
var thenDefaultFormat : string = then.format();
|
||||
var thenCustomFormat : string = then.format('yyyy/m/d HH:MM');
|
||||
Vendored
+244
@@ -0,0 +1,244 @@
|
||||
// Type definitions for Date Format 1.2.3
|
||||
// Project: http://blog.stevenlevithan.com/archives/date-time-format
|
||||
// Definitions by: Rob Stutton <https://github.com/balrob>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
/*****************************************************************************
|
||||
Portions Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
||||
this file except in compliance with the License. You may obtain a copy of the
|
||||
License at http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
||||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
||||
MERCHANTABLITY OR NON-INFRINGEMENT.
|
||||
|
||||
See the Apache Version 2.0 License for specific language governing permissions
|
||||
and limitations under the License.
|
||||
***************************************************************************** */
|
||||
|
||||
/** Enables basic storage and retrieval of dates and times. */
|
||||
interface Date {
|
||||
/** Returns a string representation of a date. The format of the string depends on the locale. */
|
||||
toString(): string;
|
||||
/** Returns a date as a string value. */
|
||||
toDateString(): string;
|
||||
/** Returns a time as a string value. */
|
||||
toTimeString(): string;
|
||||
/** Returns a value as a string value appropriate to the host environment's current locale. */
|
||||
toLocaleString(): string;
|
||||
/** Returns a date as a string value appropriate to the host environment's current locale. */
|
||||
toLocaleDateString(): string;
|
||||
/** Returns a time as a string value appropriate to the host environment's current locale. */
|
||||
toLocaleTimeString(): string;
|
||||
/** Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC. */
|
||||
valueOf(): number;
|
||||
/** Gets the time value in milliseconds. */
|
||||
getTime(): number;
|
||||
/** Gets the year, using local time. */
|
||||
getFullYear(): number;
|
||||
/** Gets the year using Universal Coordinated Time (UTC). */
|
||||
getUTCFullYear(): number;
|
||||
/** Gets the month, using local time. */
|
||||
getMonth(): number;
|
||||
/** Gets the month of a Date object using Universal Coordinated Time (UTC). */
|
||||
getUTCMonth(): number;
|
||||
/** Gets the day-of-the-month, using local time. */
|
||||
getDate(): number;
|
||||
/** Gets the day-of-the-month, using Universal Coordinated Time (UTC). */
|
||||
getUTCDate(): number;
|
||||
/** Gets the day of the week, using local time. */
|
||||
getDay(): number;
|
||||
/** Gets the day of the week using Universal Coordinated Time (UTC). */
|
||||
getUTCDay(): number;
|
||||
/** Gets the hours in a date, using local time. */
|
||||
getHours(): number;
|
||||
/** Gets the hours value in a Date object using Universal Coordinated Time (UTC). */
|
||||
getUTCHours(): number;
|
||||
/** Gets the minutes of a Date object, using local time. */
|
||||
getMinutes(): number;
|
||||
/** Gets the minutes of a Date object using Universal Coordinated Time (UTC). */
|
||||
getUTCMinutes(): number;
|
||||
/** Gets the seconds of a Date object, using local time. */
|
||||
getSeconds(): number;
|
||||
/** Gets the seconds of a Date object using Universal Coordinated Time (UTC). */
|
||||
getUTCSeconds(): number;
|
||||
/** Gets the milliseconds of a Date, using local time. */
|
||||
getMilliseconds(): number;
|
||||
/** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */
|
||||
getUTCMilliseconds(): number;
|
||||
/** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */
|
||||
getTimezoneOffset(): number;
|
||||
/**
|
||||
* Sets the date and time value in the Date object.
|
||||
* @param time A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.
|
||||
*/
|
||||
setTime(time: number): void;
|
||||
/**
|
||||
* Sets the milliseconds value in the Date object using local time.
|
||||
* @param ms A numeric value equal to the millisecond value.
|
||||
*/
|
||||
setMilliseconds(ms: number): void;
|
||||
/**
|
||||
* Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).
|
||||
* @param ms A numeric value equal to the millisecond value.
|
||||
*/
|
||||
setUTCMilliseconds(ms: number): void;
|
||||
|
||||
/**
|
||||
* Sets the seconds value in the Date object using local time.
|
||||
* @param sec A numeric value equal to the seconds value.
|
||||
* @param ms A numeric value equal to the milliseconds value.
|
||||
*/
|
||||
setSeconds(sec: number, ms?: number): void;
|
||||
/**
|
||||
* Sets the seconds value in the Date object using Universal Coordinated Time (UTC).
|
||||
* @param sec A numeric value equal to the seconds value.
|
||||
* @param ms A numeric value equal to the milliseconds value.
|
||||
*/
|
||||
setUTCSeconds(sec: number, ms?: number): void;
|
||||
/**
|
||||
* Sets the minutes value in the Date object using local time.
|
||||
* @param min A numeric value equal to the minutes value.
|
||||
* @param sec A numeric value equal to the seconds value.
|
||||
* @param ms A numeric value equal to the milliseconds value.
|
||||
*/
|
||||
setMinutes(min: number, sec?: number, ms?: number): void;
|
||||
/**
|
||||
* Sets the minutes value in the Date object using Universal Coordinated Time (UTC).
|
||||
* @param min A numeric value equal to the minutes value.
|
||||
* @param sec A numeric value equal to the seconds value.
|
||||
* @param ms A numeric value equal to the milliseconds value.
|
||||
*/
|
||||
setUTCMinutes(min: number, sec?: number, ms?: number): void;
|
||||
/**
|
||||
* Sets the hour value in the Date object using local time.
|
||||
* @param hours A numeric value equal to the hours value.
|
||||
* @param min A numeric value equal to the minutes value.
|
||||
* @param sec A numeric value equal to the seconds value.
|
||||
* @param ms A numeric value equal to the milliseconds value.
|
||||
*/
|
||||
setHours(hours: number, min?: number, sec?: number, ms?: number): void;
|
||||
/**
|
||||
* Sets the hours value in the Date object using Universal Coordinated Time (UTC).
|
||||
* @param hours A numeric value equal to the hours value.
|
||||
* @param min A numeric value equal to the minutes value.
|
||||
* @param sec A numeric value equal to the seconds value.
|
||||
* @param ms A numeric value equal to the milliseconds value.
|
||||
*/
|
||||
setUTCHours(hours: number, min?: number, sec?: number, ms?: number): void;
|
||||
/**
|
||||
* Sets the numeric day-of-the-month value of the Date object using local time.
|
||||
* @param date A numeric value equal to the day of the month.
|
||||
*/
|
||||
setDate(date: number): void;
|
||||
/**
|
||||
* Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).
|
||||
* @param date A numeric value equal to the day of the month.
|
||||
*/
|
||||
setUTCDate(date: number): void;
|
||||
/**
|
||||
* Sets the month value in the Date object using local time.
|
||||
* @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
|
||||
* @param date A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used.
|
||||
*/
|
||||
setMonth(month: number, date?: number): void;
|
||||
/**
|
||||
* Sets the month value in the Date object using Universal Coordinated Time (UTC).
|
||||
* @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.
|
||||
* @param date A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used.
|
||||
*/
|
||||
setUTCMonth(month: number, date?: number): void;
|
||||
/**
|
||||
* Sets the year of the Date object using local time.
|
||||
* @param year A numeric value for the year.
|
||||
* @param month A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified.
|
||||
* @param date A numeric value equal for the day of the month.
|
||||
*/
|
||||
setFullYear(year: number, month?: number, date?: number): void;
|
||||
/**
|
||||
* Sets the year value in the Date object using Universal Coordinated Time (UTC).
|
||||
* @param year A numeric value equal to the year.
|
||||
* @param month A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied.
|
||||
* @param date A numeric value equal to the day of the month.
|
||||
*/
|
||||
setUTCFullYear(year: number, month?: number, date?: number): void;
|
||||
/** Returns a date converted to a string using Universal Coordinated Time (UTC). */
|
||||
toUTCString(): string;
|
||||
/** Returns a date as a string value in ISO format. */
|
||||
toISOString(): string;
|
||||
/** Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization. */
|
||||
toJSON(key?: any): string;
|
||||
/**
|
||||
* This is a convenience addition to the Date prototype
|
||||
* Returns a formatted version of the date.
|
||||
* The mask defaults to dateFormat.masks.default.
|
||||
* @param {string=} mask
|
||||
* @param {boolean=} utc
|
||||
*/
|
||||
format(mask?: string, utc?: boolean) : string;
|
||||
}
|
||||
|
||||
declare var Date: {
|
||||
new (): Date;
|
||||
new (value: number): Date;
|
||||
new (value: string): Date;
|
||||
new (year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): Date;
|
||||
(): string;
|
||||
prototype: Date;
|
||||
/**
|
||||
* Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970.
|
||||
* @param s A date string
|
||||
*/
|
||||
parse(s: string): number;
|
||||
/**
|
||||
* Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.
|
||||
* @param year The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.
|
||||
* @param month The month as an number between 0 and 11 (January to December).
|
||||
* @param date The date as an number between 1 and 31.
|
||||
* @param hours Must be supplied if minutes is supplied. An number from 0 to 23 (midnight to 11pm) that specifies the hour.
|
||||
* @param minutes Must be supplied if seconds is supplied. An number from 0 to 59 that specifies the minutes.
|
||||
* @param seconds Must be supplied if milliseconds is supplied. An number from 0 to 59 that specifies the seconds.
|
||||
* @param ms An number from 0 to 999 that specifies the milliseconds.
|
||||
*/
|
||||
UTC(year: number, month: number, date?: number, hours?: number, minutes?: number, seconds?: number, ms?: number): number;
|
||||
now(): number;
|
||||
};
|
||||
|
||||
// Some common format strings
|
||||
interface DateFormatMasks {
|
||||
"default": string;
|
||||
shortDate: string;
|
||||
mediumDate: string;
|
||||
longDate: string;
|
||||
fullDate: string;
|
||||
shortTime: string;
|
||||
mediumTime: string;
|
||||
longTime: string;
|
||||
isoDate: string;
|
||||
isoTime: string;
|
||||
isoDateTime: string;
|
||||
isoUtcDateTime: string;
|
||||
}
|
||||
|
||||
// Internationalization strings
|
||||
interface DateFormatI18n {
|
||||
dayNames: string[];
|
||||
monthNames: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a date, a mask, or a date and a mask.
|
||||
* Returns a formatted version of the given date.
|
||||
* The date defaults to the current date/time.
|
||||
* The mask defaults to dateFormat.masks.default.
|
||||
* @param {Date=} date
|
||||
* @param {string=} mask
|
||||
* @param {boolean=} utc
|
||||
*/
|
||||
declare var dateFormat: {
|
||||
(date?: any, mask?: string, utc?: boolean ): string;
|
||||
masks : DateFormatMasks;
|
||||
i18n : DateFormatI18n;
|
||||
};
|
||||
Vendored
+3
-2
@@ -1,7 +1,8 @@
|
||||
// Type definitions for DCJS
|
||||
// Project: https://github.com/dc-js
|
||||
// Definitions by: hans windhoff
|
||||
// Definitions by: hans windhoff <https://github.com/hansrwindhoff>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
// this makes only sense together with d3 and crossfilter so you need the d3.d.ts and crossfilter.d.ts files
|
||||
|
||||
///<reference path="../d3/d3.d.ts" />
|
||||
@@ -195,4 +196,4 @@ export interface ILegendwidget {
|
||||
export function rowChart(cssSel: string): IRowchart;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/// <reference path="deep-freeze.d.ts" />
|
||||
|
||||
import df = require('deep-freeze');
|
||||
|
||||
class Foo {
|
||||
foo: string;
|
||||
}
|
||||
var foo:Foo = df(new Foo());
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
// Type definitions for deep-freeze
|
||||
// Project: https://github.com/substack/deep-freeze
|
||||
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module 'deep-freeze' {
|
||||
function df<T>(obj: T): T;
|
||||
export = df;
|
||||
}
|
||||
+298
@@ -0,0 +1,298 @@
|
||||
# Dojo Definitions Usage Notes
|
||||
|
||||
## Overview
|
||||
Anyone that has used Dojo for any length of time has probably discovered three things:
|
||||
* Dojo is very powerful
|
||||
* Dojo can be challenging to learn
|
||||
* Dojo doesn't always play well with other
|
||||
|
||||
Having said that, there are ways that Dojo can be coerced out of its shell to work with other JavaScript technologies. This README is intended to describe some techniques for getting the full power of Dojo to work in an environment where almost everything can take advantage of TypeScript.
|
||||
|
||||
*Disclaimer*: Dojo is VERY big framework and, as such the type definitions are generated by a [tool](https://github.com/vansimke/DojoTypeDescriptionGenerator) from dojo's [API](dojotoolkit.org/api) docs. The generated files were then hand-polished to eliminate any import errors and clean up some obvious errors. This is all to say that the generated type definitions are not flawless and are not guaranteed to reflect the actual implementations.
|
||||
|
||||
## Basic Usage
|
||||
A normal dojo module might look something like this:
|
||||
|
||||
```js
|
||||
define(['dojo/request', 'dojo/request/xhr'],
|
||||
function (request, xhr) {
|
||||
...
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
When using the TypeScript, you can write the following:
|
||||
|
||||
```ts
|
||||
define(['dojo/request', 'dojo/request/xhr'],
|
||||
function (request: dojo.request,
|
||||
xhr: dojo.request.xhr) {
|
||||
...
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
Inside of the define variable, both `request` and `xhr` will work as the functions that come from Dojo, only they are strongly typed.
|
||||
|
||||
## Advanced Usage
|
||||
Dojo and TypeScript both use different and conflicting class semantics. This causes some issues when trying to create custom class modules that are strongly typed in other modules. The following technique is presented as **A** solution to the problem, but not necessarily the best one. Other ideas a welcomed!
|
||||
|
||||
Using pure JavaScript, a class that has a base class and mixins can be defined in Dojo as follows:
|
||||
|
||||
```js
|
||||
define(['dojo/_base/declare', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dojo/request'],
|
||||
function(dojoDeclare, _WidgetBase, _TemplatedMixin, request) {
|
||||
var Foo = dojoDeclare([_WidgetBase, _TemplatedMixin], {
|
||||
templateString: '<div>Hello TypeScript</div',
|
||||
|
||||
message: '',
|
||||
|
||||
sayMessage: function() {
|
||||
alert(this.message);
|
||||
},
|
||||
|
||||
getServerInfo: function() {
|
||||
request.get('http://dojoAndTypeScriptTogetherAtLast.html', function(data) {
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return Foo;
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
The goal is to be able to describe the `Foo` class in a way that TypeScript can recognize, but also works with Dojo. This requires some hacks that will be introduced and explained as the problems are discovered.
|
||||
|
||||
The first challenge that we run into is how to define the class. We will define that using standard TypeScript semantics as follows:
|
||||
|
||||
```ts
|
||||
module App {
|
||||
export class Foo extends dijit._WidgetBase implements dijit._TemplatedMixin {
|
||||
constructor(public templateString= "<div>Hello TypeScript</div>",
|
||||
public message= "") {
|
||||
super();
|
||||
}
|
||||
|
||||
sayMessage() {
|
||||
alert(this.message);
|
||||
}
|
||||
|
||||
getServerInfo() {
|
||||
request.get("http://dojoAndTypeScriptTogetherAtLast.html", (data: string) => {
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This class is identical to the standard Dojo method, except that it is declared inside of a TypeScript module and it is declared using TypeScript instead of Dojo's `declare` method. Two problems arise however:
|
||||
1. `Foo` has an error because it doesn't honor the interface declared by dijit._TemplatedMixin
|
||||
2. `request` is undefined
|
||||
|
||||
The first problem can be solved by adding the missing properties and methods, but this will only serve to clutter the code base over time. Instead, we are creating another base class that hides this requirement like so:
|
||||
|
||||
```ts
|
||||
module App {
|
||||
export class Foo extends WidgetBaseWithTemplatedMixin {
|
||||
constructor(public templateString= "<div>Hello TypeScript</div>",
|
||||
public message= "") {
|
||||
super();
|
||||
}
|
||||
|
||||
sayMessage() {
|
||||
alert(this.message);
|
||||
}
|
||||
|
||||
getServerInfo() {
|
||||
request.get("http://dojoAndTypeScriptTogetherAtLast.html", (data: string) => {
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class WidgetBaseWithTemplatedMixin extends dijit._WidgetBase implements dijit._TemplatedMixin {
|
||||
"attachScope": Object;
|
||||
"searchContainerNode": boolean;
|
||||
"templatePath": string;
|
||||
"templateString": string;
|
||||
buildRendering(): {}
|
||||
destroyRendering(): {}
|
||||
getCachedTemplate(templateString: String, alwaysUseString: boolean, doc: HTMLDocument): {}
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Now the base class meets TypeScript's requirements so it is happy. This class could easily be moved out to a general add-in file so that it can be created and forgotten since it is only here to make TypeScript happy.
|
||||
|
||||
The second problem that we had as that `request` is undefined. This is going to take a bit more trickery as shown below:
|
||||
|
||||
```ts
|
||||
module App {
|
||||
export class Foo extends WidgetBaseWithTemplatedMixin {
|
||||
constructor(public templateString= "<div>Hello TypeScript</div>",
|
||||
public message= "") {
|
||||
super();
|
||||
}
|
||||
|
||||
public request: dojo.request;
|
||||
|
||||
sayMessage() {
|
||||
alert(this.message);
|
||||
}
|
||||
|
||||
getServerInfo() {
|
||||
this.request.get("http://dojoAndTypeScriptTogetherAtLast.html").then((data: string) => {
|
||||
console.log(data);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export class WidgetBaseWithTemplatedMixin extends dijit._WidgetBase implements dijit._TemplatedMixin {
|
||||
public static getPrototype(deps: Object) {
|
||||
if (deps) {
|
||||
for (var i in deps) {
|
||||
this.prototype[i] = deps[i];
|
||||
}
|
||||
|
||||
return this.prototype;
|
||||
}
|
||||
}
|
||||
|
||||
"attachScope": Object;
|
||||
"searchContainerNode": boolean;
|
||||
"templatePath": string;
|
||||
"templateString": string;
|
||||
buildRendering(): {}
|
||||
destroyRendering(): {}
|
||||
getCachedTemplate(templateString: String, alwaysUseString: boolean, doc: HTMLDocument): {}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
define(['dojo/_base/declare', 'dijit/_WidgetBase', 'dijit/_TemplatedMixin', 'dojo/request'],
|
||||
function (dojoDeclare, _WidgetBase, _TemplatedMixin, request) {
|
||||
var deps = {
|
||||
request: request
|
||||
};
|
||||
|
||||
var Foo = dojoDeclare([_WidgetBase, _TemplatedMixin], App.Foo.getPrototype(deps));
|
||||
|
||||
return Foo;
|
||||
}
|
||||
);
|
||||
```
|
||||
|
||||
Yes, I know - pretty crazy right. But, we're getting close...
|
||||
|
||||
In the Dojo module, we are building an object that contains references to each of the dependencies. We are then passing that object into the static method `getPrototype` that we have added to the base class. This method takes an object literal and mixes it into the class's prototype. In this way, the module dependencies are made available to the TypeScript class via its prototype. The last thing we need to do is change the `getServerInfo()`'s call to `request` to be a `this.request` call since it is calling through its prototype instead of the ambient object that is used in Dojo.
|
||||
|
||||
Okay, great. TypeScript is happy. Everything should be working right? Wrong.
|
||||
|
||||
We have two more problems that are not apparent until the code is actually executed. They are both related to our usage of the `extends` keyword that we used to show that our `Foo` class extends from `dijit._WidgetBase`.
|
||||
|
||||
The first problem is that, as stated previously, TypeScript has its own implementation of a class system in JavaScript. When one class extends another, TypeScript injects the following snippet into the module:
|
||||
|
||||
```js
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
```
|
||||
|
||||
This method is called in a closure that wraps the class definition and mixes the parent's prototype and owned properties into the child class. However, this won't work in our case, because our base class is `dijit._WidgetBase` which doesn't actually exist in the global namespace (where TypeScript expects it). This is because we are still using Dojo's class system (via `declare`). This is an important, and confusing, point. Our class is actually being constructed by Dojo using declare. However, we are working with the class as if it was created in the way the TypeScript expects. In short, this means that we don't actually need the `__extends` function to work, but something needs to be there so that the constructor function doesn't die. The solve is actually relatively easy: In the main HTML page, add this function before the tag that includes `dojo.js`:
|
||||
|
||||
```js
|
||||
var __extends = function (d, b) {
|
||||
if (d && b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() {
|
||||
this.constructor = d;
|
||||
}
|
||||
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
All this does is check to see if `d` and `b` are defined before running. Since TypeScript won't override __extends, it will allow us to override the default implementation.
|
||||
|
||||
Okay, only one more thing to deal with: the call to super. This issue is also related to TypeScript's method for handling inheritance. After calling `__extends`, the generated constructor function will call the parent's constructor function. Once again, we are hit by the fact that our base class (`dijit._WidgetBase`) doesn't actually exist where TypeScript is expecting it. The only way around this is to give TypeScript something to call. This simplest thing to do is to add a no-op function for TypeScript to call. In short add this:
|
||||
|
||||
```js
|
||||
var dijit = dijit || {};
|
||||
dijit._WidgetBase = function() {}
|
||||
```
|
||||
|
||||
Into the page after Dojo bootstraps, but before our module loads. The simplest way to do this is to create a little module that does this and added it to the array of modules loaded in the `define()` call of the module.
|
||||
|
||||
Okay, so things look pretty messy right now. There are several hacks and tricks that we have to play in order to allow TypeScript and Dojo to work together. The nice thing about most of this is that it can all be shoved into a single helper module and never thought of again. Here is an example of what that module would look like:
|
||||
|
||||
```ts
|
||||
"use strict";
|
||||
|
||||
define([], function () { });
|
||||
|
||||
var __extends = function (d, b) {
|
||||
if (d && b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() {
|
||||
this.constructor = d;
|
||||
}
|
||||
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
}
|
||||
};
|
||||
|
||||
window['dojo'] = {};
|
||||
window['dijit'] = {
|
||||
_WidgetBase: function () {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
module Base {
|
||||
function getPrototype(type: Function, deps: Object): Object {
|
||||
if (deps) {
|
||||
for (var i in deps) {
|
||||
type.prototype[i] = deps[i];
|
||||
}
|
||||
|
||||
return this.prototype;
|
||||
}
|
||||
}
|
||||
export class WidgetBaseWithTemplatedMixin extends dijit._WidgetBase implements dijit._TemplatedMixin {
|
||||
public static getPrototype(deps: Object): Object {
|
||||
return getPrototype(this, deps);
|
||||
}
|
||||
|
||||
"attachScope": Object;
|
||||
"searchContainerNode": boolean;
|
||||
"templatePath": string;
|
||||
"templateString": string;
|
||||
buildRendering() { }
|
||||
destroyRendering() { }
|
||||
getCachedTemplate(templateString: String, alwaysUseString: boolean, doc: HTMLDocument) { }
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This module can then be added to whenever we have another base class / mix-in combination (e.g. dijit/_WidgetBase, dijit/_TemplatedMixin, and dijit/_WidgetsInTemplateMixin). When done this way, the only regularly visible changes that we have to do is to compose the hash of dependencies and call the `getPrototype` as the last argument to `declare`.
|
||||
|
||||
## Appendix
|
||||
|
||||
Examples:
|
||||
* https://github.com/craigstjean/typescript-dojo-sample
|
||||
|
||||
Vendored
+104749
File diff suppressed because one or more lines are too long
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user