diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 1df2749f4d..938c816189 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -34,6 +34,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](angular-wizard/angular-wizard.d.ts) [Angular Wizard](https://github.com/mgonto/angular-wizard) by [Marko Jurisic](https://github.com/mjurisic)
* [:link:](angular-bootstrap-lightbox/angular-bootstrap-lightbox.d.ts) [angular-bootstrap-lightbox](https://github.com/compact/angular-bootstrap-lightbox) by [Roland Zwaga](https://github.com/rolandzwaga)
* [:link:](angular-dynamic-locale/angular-dynamic-locale.d.ts) [angular-dynamic-locale](https://github.com/lgalfaso/angular-dynamic-locale) by [Stephen Lautier](https://github.com/stephenlautier)
+* [:link:](angular-formly/angular-formly.d.ts) [angular-formly](https://github.com/formly-js/angular-formly) by [Scott Hatcher](https://github.com/scatcher)
* [:link:](angular-hotkeys/angular-hotkeys.d.ts) [angular-hotkeys](https://github.com/chieffancypants/angular-hotkeys) by [Jason Zhao](https://github.com/jlz27), [Stefan Steinhart](https://github.com/reppners)
* [:link:](angular-http-auth/angular-http-auth.d.ts) [angular-http-auth](https://github.com/witoldsz/angular-http-auth) by [vvakame](https://github.com/vvakame)
* [:link:](angular-jwt/angular-jwt.d.ts) [angular-jwt](https://github.com/auth0/angular-jwt) by [Reto Rezzonico](https://github.com/rerezz)
@@ -50,6 +51,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](rx-angular/rx.angular.d.ts) [angularjs extensions to rxjs](http://reactivex.io) by [Mick Delaney](https://github.com/mickdelaney)
* [:link:](angularjs-toaster/angularjs-toaster.d.ts) [angularjs-toaster](https://github.com/jirikavi/AngularJS-Toaster) by [Ben Tesser](https://github.com/btesser)
* [:link:](angularLocalStorage/angularLocalStorage.d.ts) [AngularLocalStorage](https://github.com/agrublev/angularLocalStorage) by [Horiuchi_H](https://github.com/horiuchi)
+* [:link:](angulartics/angulartics.d.ts) [Angulartics](http://luisfarzati.github.io/angulartics) by [Steven Fan](https://github.com/stevenfan)
* [:link:](animation-frame/animation-frame.d.ts) [animation-frame](https://github.com/kof/animation-frame) by [Qinfeng Chen](https://github.com/qinfchen)
* [:link:](ansi-styles/ansi-styles.d.ts) [ansi-styles](https://github.com/sindresorhus/ansi-styles) by [bryn austin bellomy](https://github.com/brynbellomy)
* [:link:](ansicolors/ansicolors.d.ts) [ansicolors](https://github.com/thlorenz/ansicolors) by [rogierschouten](https://github.com/rogierschouten)
@@ -89,7 +91,9 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](backbone.paginator/backbone.paginator.d.ts) [backbone.paginator](https://github.com/backbone-paginator/backbone.paginator) by [Nyamazing](https://github.com/Nyamazing)
* [:link:](backbone.radio/backbone.radio.d.ts) [Backbone.Radio](https://github.com/marionettejs/backbone.radio) by [Peter Palotas](https://github.com/alphaleonis)
* [:link:](backgrid/backgrid.d.ts) [Backgrid](http://backgridjs.com) by [Jeremy Lujan](https://github.com/jlujan)
+* [:link:](baconjs/baconjs.d.ts) [Bacon.js](https://baconjs.github.io) by [Alexander Matsievsky](https://github.com/alexander-matsievsky)
* [:link:](bardjs/bardjs.d.ts) [bardjs](https://github.com/wardbell/bardjs) by [Andrew Archibald](https://github.com/TepigMC)
+* [:link:](batch-stream/batch-stream.d.ts) [batch-stream](https://github.com/segmentio/batch-stream) by [Nicholas Penree](http://github.com/drudge)
* [:link:](bcrypt/bcrypt.d.ts) [bcrypt](https://www.npmjs.org/package/bcrypt) by [Peter Harris](https://github.com/codeanimal)
* [:link:](bgiframe/typescript.bgiframe.d.ts) [bgiframe](https://github.com/sumegizoltan/BgiFrame) by [Zoltan Sumegi](https://github.com/sumegizoltan)
* [:link:](big.js/big.js.d.ts) [big.js](https://github.com/MikeMcl/big.js) by [Steve Ognibene](https://github.com/nycdotnet)
@@ -110,8 +114,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](bootstrap-slider/bootstrap-slider.d.ts) [bootstrap-slider.js](https://github.com/seiyria/bootstrap-slider) by [Daniel Beckwith](https://github.com/dbeckwith)
* [:link:](bootstrap.datepicker/bootstrap.datepicker.d.ts) [bootstrap.datepicker](https://github.com/eternicode/bootstrap-datepicker) by [Boris Yankov](https://github.com/borisyankov)
* [:link:](bootstrap.paginator/bootstrap.paginator.d.ts) [bootstrap.paginator](https://github.com/lyonlai/bootstrap-paginator) by [derikwhittaker](https://github.com/derikwhittaker)
-* [:link:](bootstrap.timepicker/bootstrap.timepicker.d.ts) [bootstrap.timepicker](https://github.com/jdewit/bootstrap-timepicker) by [derikwhittaker](https://github.com/derikwhittaker)
* [:link:](box2d/box2dweb.d.ts) [bootstrap.timepicker](http://code.google.com/p/box2dweb) by [jbaldwin](https://github.com/jbaldwin)
+* [:link:](bootstrap.timepicker/bootstrap.timepicker.d.ts) [bootstrap.timepicker](https://github.com/jdewit/bootstrap-timepicker) by [derikwhittaker](https://github.com/derikwhittaker)
* [:link:](breeze/breeze.d.ts) [Breeze 1.5.x](http://www.breezejs.com) by [Boris Yankov](https://github.com/borisyankov), [IdeaBlade](https://github.com/IdeaBlade/Breeze)
* [:link:](browser-harness/browser-harness.d.ts) [Browser Harness](https://github.com/scriby/browser-harness) by [Chris Scribner](https://github.com/scriby)
* [:link:](browser-sync/browser-sync.d.ts) [browser-sync](http://www.browsersync.io) by [Asana](https://asana.com)
@@ -125,6 +129,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](business-rules-engine/business-rules-engine.d.ts) [business-rules-engine](https://github.com/rsamec/form) by [Roman Samec](https://github.com/rsamec)
* [:link:](byline/byline.d.ts) [byline](https://github.com/jahewson/node-byline) by [Stefan Steinhart](https://github.com/reppners)
* [:link:](calq/calq.d.ts) [calq](https://calq.io/docs/client/javascript/reference) by [Eirik Hoem](https://github.com/eirikhm)
+* [:link:](camel-case/camel-case.d.ts) [camel-case](https://github.com/blakeembrey/camel-case) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](camljs/camljs.d.ts) [camljs](http://camljs.codeplex.com) by [Andrey Markeev](http://markeev.com)
* [:link:](canvasjs/canvasjs.d.ts) [CanvasJS](http://canvasjs.com) by [Mark Overholt](https://github.com/mover5)
* [:link:](casperjs/casperjs.d.ts) [CasperJS](http://casperjs.org) by [Jed Mao](https://github.com/jedmao)
@@ -163,8 +168,10 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](compression/compression.d.ts) [compression](https://github.com/expressjs/compression) by [Santi Albo](https://github.com/santialbo)
* [:link:](configstore/configstore.d.ts) [configstore](https://github.com/yeoman/configstore) by [Bart van der Schoor](https://github.com/Bartvds)
* [:link:](connect-flash/connect-flash.d.ts) [connect-flash](https://github.com/jaredhanson/connect-flash) by [Andreas Gassmann](https://github.com/AndreasGassmann)
+* [:link:](connect-modrewrite/connect-modrewrite.d.ts) [connect-modrewrite](https://github.com/tinganho/connect-modrewrite) by [Tingan Ho](https://github.com/tinganho)
* [:link:](connect-slashes/connect-slashes.d.ts) [connect-slashes](https://github.com/avinoamr/connect-slashes) by [Sam Herrmann](https://github.com/samherrmann)
* [:link:](consolidate/consolidate.d.ts) [consolidate](https://github.com/visionmedia/consolidate.js) by [Carlos Ballesteros Velasco](https://github.com/soywiz)
+* [:link:](constant-case/constant-case.d.ts) [constant-case](https://github.com/blakeembrey/constant-case) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](content-type/content-type.d.ts) [content-type](https://github.com/deoxxa/content-type) by [Pine Mizune](https://github.com/pine613)
* [:link:](contextjs/contextjs.d.ts) [contextjs](https://github.com/jakiestfu/Context.js) by [Kern Handa](https://github.com/kernhanda)
* [:link:](convert-source-map/convert-source-map.d.ts) [convert-source-map](https://github.com/thlorenz/convert-source-map) by [Andrew Gaspar](https://github.com/AndrewGaspar)
@@ -173,6 +180,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](cookiejs/cookiejs.d.ts) [cookie.js](https://github.com/js-coder/cookie.js) by [Boltmade](https://github.com/Boltmade)
* [:link:](cordova-ionic/plugins/keyboard.d.ts) [Cordova Keyboard plugin](https://github.com/driftyco/ionic-plugins-keyboard) by [Hendrik Maus](https://github.com/hendrikmaus)
* [:link:](cordovarduino/cordovarduino.d.ts) [Cordovarduino plugin](https://github.com/stereolux/cordovarduino) by [Hendrik Maus](https://github.com/hendrikmaus)
+* [:link:](core-js/core-js.d.ts) [core-js](https://github.com/zloirock/core-js) by [Ron Buckton](http://github.com/rbuckton)
* [:link:](couchbase/couchbase.d.ts) [Couchbase Couchnode](https://github.com/couchbase/couchnode) by [Basarat Ali Syed](https://github.com/basarat)
* [:link:](createjs/createjs.d.ts) [CreateJS](http://www.createjs.com) by [Pedro Ferreira](https://bitbucket.org/drk4), [Chris Smith](https://github.com/evilangelist), [Satoru Kimura](https://github.com/gyohk)
* [:link:](cron/cron.d.ts) [cron](https://www.npmjs.com/package/cron) by [Hiroki Horiuchi](https://github.com/horiuchi)
@@ -218,6 +226,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](domready/domready.d.ts) [domready](https://github.com/ded/domready) by [Christian Holm Nielsen](https://github.com/dotnetnerd)
* [:link:](donna/donna.d.ts) [donna](https://github.com/atom/donna) by [vvakame](https://github.com/vvakame)
* [:link:](dot/dot.d.ts) [doT](https://github.com/olado/doT) by [ZombieHunter](https://github.com/ZombieHunter)
+* [:link:](dot-case/dot-case.d.ts) [dot-case](https://github.com/blakeembrey/dot-case) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](dotdotdot/dotdotdot.d.ts) [dotdotdot](http://dotdotdot.frebsite.nl) by [Milan Jaros](https://github.com/milanjaros)
* [:link:](doublearray/doublearray.d.ts) [doublearray](https://github.com/takuyaa/doublearray) by [MIZUSHIMA Junki](https://github.com/mzsm)
* [:link:](drop/drop.d.ts) [Drop](http://github.hubspot.com/drop) by [Adi Dahiya](https://github.com/adidahiya)
@@ -249,7 +258,9 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](epiceditor/epiceditor.d.ts) [EpicEditor](http://epiceditor.com) by [Boris Yankov](https://github.com/borisyankov)
* [:link:](eq.js/eq.js.d.ts) [eq.js](https://github.com/Snugug/eq.js) by [Stephen Lautier](https://github.com/stephenlautier)
* [:link:](errorhandler/errorhandler.d.ts) [errorhandler](https://github.com/expressjs/errorhandler) by [Santi Albo](https://github.com/santialbo)
+* [:link:](es6-collections/es6-collections.d.ts) [es6-collections](https://github.com/WebReflection/es6-collections) by [Ron Buckton](http://github.com/rbuckton)
* [:link:](es6-promise/es6-promise.d.ts) [es6-promise](https://github.com/jakearchibald/ES6-Promise) by [François de Campredon](https://github.com/fdecampredon), [vvakame](https://github.com/vvakame)
+* [:link:](es6-shim/es6-shim.d.ts) [es6-shim](https://github.com/paulmillr/es6-shim) by [Ron Buckton](http://github.com/rbuckton)
* [:link:](escape-latex/escape-latex.d.ts) [escape-latex](https://github.com/dangmai/escape-latex) by [Oliver Schneider](https://github.com/olsio)
* [:link:](esprima/esprima.d.ts) [Esprima](http://esprima.org) by [teppeis](https://github.com/teppeis), [RReverser](https://github.com/RReverser)
* [:link:](estree/estree.d.ts) [ESTree AST specification](https://github.com/estree/estree) by [RReverser](https://github.com/RReverser)
@@ -318,6 +329,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](geojson/geojson.d.ts) [GeoJSON Format Specification](http://geojson.org) by [Jacob Bruun](https://github.com/cobster)
* [:link:](geometry-dom/geometry-dom.d.ts) [Geometry Format Specification](http://www.w3.org/TR/geometry-1) by [Toshiya Nakakura](https://github.com/nakakura)
* [:link:](giraffe/giraffe.d.ts) [Giraffe](https://github.com/barc/backbone.giraffe) by [Matt McCray](https://github.com/darthapo)
+* [:link:](git-config/git-config.d.ts) [git-config](https://github.com/eugeneware/git-config) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](gl-matrix/gl-matrix.d.ts) [gl-matrix](https://github.com/toji/gl-matrix) by [Tat](https://github.com/tatchx)
* [:link:](gldatepicker/gldatepicker.d.ts) [glDatePicker](http://glad.github.com/glDatePicker) by [Dániel Tar](https://github.com/qcz)
* [:link:](glidejs/glidejs.d.ts) [Glide.js](http://glide.jedrzejchalubek.com) by [Milan Jaros](https://github.com/milanjaros)
@@ -345,14 +357,14 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](greensock/greensock.d.ts) [GreenSock Animation Platform](http://www.greensock.com/get-started-js) by [Robert S](https://github.com/codebelt)
* [:link:](gridfs-stream/gridfs-stream.d.ts) [gridfs-stream](https://github.com/aheckmann/gridfs-stream) by [Lior Mualem](https://github.com/liorm)
* [:link:](gruntjs/gruntjs.d.ts) [Grunt 0.4.x](http://gruntjs.com) by [Jeff May](https://github.com/jeffmay), [Basarat Ali Syed](https://github.com/basarat)
-* [:link:](gsap/TweenLite.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io)
* [:link:](gsap/Ease.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io)
* [:link:](gsap/Core.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io)
+* [:link:](gsap/TweenLite.d.ts) [GSAP](http://greensock.com) by [VILIC VANE](https://vilic.github.io)
* [:link:](gulp/gulp.d.ts) [Gulp v3.8.x](http://gulpjs.com) by [Drew Noakes](https://drewnoakes.com)
* [:link:](gulp-autoprefixer/gulp-autoprefixer.d.ts) [gulp-autoprefixer](https://github.com/sindresorhus/gulp-autoprefixer) by [Asana](https://asana.com)
* [:link:](gulp-concat/gulp-concat.d.ts) [gulp-concat](http://github.com/wearefractal/gulp-concat) by [Keita Kagurazaka](https://github.com/k-kagurazaka)
-* [:link:](gulp-rev/gulp-rev.d.ts) [gulp-csso](https://github.com/sindresorhus/gulp-rev) by [Tanguy Krotoff](https://github.com/tkrotoff)
* [:link:](gulp-csso/gulp-csso.d.ts) [gulp-csso](https://github.com/ben-eb/gulp-csso) by [Tanguy Krotoff](https://github.com/tkrotoff)
+* [:link:](gulp-rev/gulp-rev.d.ts) [gulp-csso](https://github.com/sindresorhus/gulp-rev) by [Tanguy Krotoff](https://github.com/tkrotoff)
* [:link:](gulp-debug/gulp-debug.d.ts) [gulp-debug](https://github.com/sindresorhus/gulp-debug) by [Tanguy Krotoff](https://github.com/tkrotoff)
* [:link:](gulp-flatten/gulp-flatten.d.ts) [gulp-flatten](https://github.com/armed/gulp-flatten) by [Keita Kagurazaka](https://github.com/k-kagurazaka)
* [:link:](gulp-gh-pages/gulp-gh-pages.d.ts) [gulp-gh-pages](https://github.com/rowoot/gulp-gh-pages) by [Asana](https://asana.com)
@@ -407,8 +419,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](humane/humane.d.ts) [Humane](http://wavded.github.com/humane-js) by [jmvrbanac](https://github.com/jmvrbanac)
* [:link:](hypertext-application-language/hypertext-application-language.d.ts) [Hypertext Application Language Draft 6](https://tools.ietf.org/html/draft-kelly-json-hal-06) by [Maks3w](https://github.com/maks3w)
* [:link:](i18n-node/i18n-node.d.ts) [i18n-node](https://github.com/mashpie/i18n-node) by [Maxime LUCE](https://github.com/SomaticIT)
-* [:link:](i18next/i18next.d.ts) [i18next](http://i18next.com) by [Maarten Docter](https://github.com/mdocter)
* [:link:](ng-i18next/ng-i18next.d.ts) [i18next](https://github.com/i18next/ng-i18next) by [Cyril Schumacher](https://github.com/cyrilschumacher)
+* [:link:](i18next/i18next.d.ts) [i18next](http://i18next.com) by [Maarten Docter](https://github.com/mdocter)
* [:link:](iban/iban.d.ts) [iban.js](https://github.com/arhs/iban.js) by [Cyril Schumacher](https://github.com/cyrilschumacher)
* [:link:](icheck/icheck.d.ts) [iCheck](http://damirfoy.com/iCheck) by [Dániel Tar](https://github.com/qcz)
* [:link:](imagemagick/imagemagick.d.ts) [imagemagick](http://github.com/rsms/node-imagemagick) by [Carlos Ballesteros Velasco](https://github.com/soywiz)
@@ -425,11 +437,13 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](inversify/inversify.d.ts) [inversify](https://github.com/inversify/InversifyJS) by [inversify](https://github.com/inversify)
* [:link:](cordova-ionic/cordova-ionic.d.ts) [Ionic Cordova plugins](https://github.com/driftyco) by [Hendrik Maus](https://github.com/hendrikmaus)
* [:link:](irc/irc.d.ts) [irc](https://github.com/martynsmith/node-irc) by [phillips1012](https://github.com/phillips1012)
+* [:link:](is-lower-case/is-lower-case.d.ts) [is-lower-case](https://github.com/blakeembrey/is-lower-case) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](is_js/is_js.d.ts) [is.js](http://arasatasaygin.github.io/is.js) by [Rodrigo Cabral](https://github.com/cabralRodrigo)
* [:link:](iscroll/iscroll.d.ts) [iScroll](http://cubiq.org/iscroll-4) by [Boris Yankov](https://github.com/borisyankov), [Christiaan Rakowski](https://github.com/csrakowski)
* [:link:](iscroll/iscroll-5.d.ts) [iScroll 5](http://cubiq.org/iscroll-5-ready-for-beta-test) by [Christiaan Rakowski](https://github.com/csrakowski)
* [:link:](iscroll/iscroll-lite.d.ts) [iScroll Lite](http://cubiq.org/iscroll-4) by [Boris Yankov](https://github.com/borisyankov), [Christiaan Rakowski](https://github.com/csrakowski)
* [:link:](iscroll/iscroll-5-lite.d.ts) [iScroll Lite 5](http://cubiq.org/iscroll-5-ready-for-beta-test) by [Christiaan Rakowski](https://github.com/csrakowski)
+* [:link:](iso8601-localizer/iso8601-localizer.d.ts) [ISO8601-Localizer](https://github.com/avielfedida/ISO8601-Localizer) by [Aviel Fedida](https://github.com/avielfedida)
* [:link:](ix.js/ix.d.ts) [IxJS 1.0.6 / ix.js](https://github.com/Reactive-Extensions/IxJS) by [Igor Oleinikov](https://github.com/Igorbek)
* [:link:](ix.js/l2o.d.ts) [IxJS 1.0.6 / l2o.js](https://github.com/Reactive-Extensions/IxJS) by [Igor Oleinikov](https://github.com/Igorbek)
* [:link:](jake/jake.d.ts) [jake](https://github.com/mde/jake) by [Kon](http://phyzkit.net)
@@ -464,6 +478,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](jquery.fileupload/jquery.fileupload.d.ts) [jQuery File Upload Plugin](https://github.com/blueimp/jQuery-File-Upload) by [Rob Alarcon](https://github.com/rob-alarcon)
* [:link:](jquery.joyride/jquery.joyride.d.ts) [jQuery JoyRide Plugin](https://github.com/zurb/joyride) by [Vincent Bortone](https://github.com/vbortone)
* [:link:](jqgrid/jqgrid.d.ts) [jQuery jqgrid Plugin](https://github.com/tonytomov/jqGrid) by [Lokesh Peta](https://github.com/lokeshpeta)
+* [:link:](jquery-knob/jquery-knob.d.ts) [jQuery Knob](http://anthonyterrien.com/knob) by [Iain Buchanan](https://github.com/iain8)
* [:link:](jquerymobile/jquerymobile.d.ts) [jQuery Mobile](http://jquerymobile.com) by [Boris Yankov](https://github.com/borisyankov)
* [:link:](jquery.notifyBar/jquery.notifyBar.d.ts) [jQuery Notify Bar](http://www.whoop.ee/posts/2013-04-05-the-resurrection-of-jquery-notify-bar) by [Shunsuke Ohtani](https://github.com/zaneli)
* [:link:](jquery.base64/jquery.base64.d.ts) [jQuery Plugin - base64 codec](https://github.com/yatt/jquery.base64) by [Shinya Mochizuki](https://github.com/enrapt-mochizuki)
@@ -623,6 +638,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](luaparse/luaparse.d.ts) [luaparse](https://github.com/oxyc/luaparse) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](lunr/lunr.d.ts) [lunr.js](https://github.com/olivernn/lunr.js) by [Sebastian Lenz](https://github.com/sebastian-lenz)
* [:link:](lz-string/lz-string.d.ts) [lz-string](https://github.com/pieroxy/lz-string) by [Roman Nikitin](https://github.com/M0ns1gn0r)
+* [:link:](magic-number/magic-number.d.ts) [magic-number](https://github.com/stpettersens/node-magic-number) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](magicsuggest/magicsuggest.d.ts) [MagicSuggest](http://nicolasbize.com/magicsuggest) by [Leonardo Chaia](http://github.com/leonardochaia)
* [:link:](mailcheck/mailcheck.d.ts) [Mailcheck](https://github.com/mailcheck/mailcheck) by [Paulo Cesar](http://github.com/pocesar)
* [:link:](main-bower-files/main-bower-files.d.ts) [main-bower-files](https://github.com/ck86/main-bower-files) by [Keita Kagurazaka](https://github.com/k-kagurazaka)
@@ -672,8 +688,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](mkdirp/mkdirp.d.ts) [mkdirp](http://github.com/substack/node-mkdirp) by [Bart van der Schoor](https://github.com/Bartvds)
* [:link:](mkpath/mkpath.d.ts) [mkpath](https://www.npmjs.com/package/mkpath) by [Jared Klopper](https://github.com/optical)
* [:link:](mobile-detect/mobile-detect.d.ts) [mobile-detect](http://hgoebl.github.io/mobile-detect.js) by [Martin McWhorter](https://github.com/martinmcwhorter)
-* [:link:](mocha/mocha.d.ts) [mocha](http://mochajs.org) by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid), [otiai10](https://github.com/otiai10), [jt000](https://github.com/jt000), [Vadim Macagon](https://github.com/enlight)
* [:link:](mocha/mocha-node.d.ts) [mocha](http://mochajs.org) by [Vadim Macagon](https://github.com/enlight), [vvakame](https://github.com/vvakame)
+* [:link:](mocha/mocha.d.ts) [mocha](http://mochajs.org) by [Kazi Manzur Rashid](https://github.com/kazimanzurrashid), [otiai10](https://github.com/otiai10), [jt000](https://github.com/jt000), [Vadim Macagon](https://github.com/enlight)
* [:link:](mocha-phantomjs/mocha-phantomjs.d.ts) [mocha-phantomjs](http://metaskills.net/mocha-phantomjs) by [Erik Schierboom](https://github.com/ErikSchierboom)
* [:link:](mock-fs/mock-fs.d.ts) [mock-fs](https://github.com/tschaub/mock-fs) by [Wim Looman](https://github.com/Nemo157)
* [:link:](mockery/mockery.d.ts) [mockery](https://github.com/mfncooper/mockery) by [jt000](https://github.com/jt000)
@@ -705,6 +721,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](nedb/nedb.d.ts) [NeDB](https://github.com/louischatriot/nedb) by [Stefan Steinhart](https://github.com/reppners)
* [:link:](needle/needle.d.ts) [needle](https://github.com/tomas/needle) by [San Chen](https://github.com/bigsan)
* [:link:](nexpect/nexpect.d.ts) [nexpect](https://github.com/nodejitsu/nexpect) by [vvakame](http://github.com/vvakame)
+* [:link:](ng-command/ng-command.d.ts) [ng-command](https://github.com/stephenlautier/ng-command) by [Stephen Lautier](https://github.com/stephenlautier)
* [:link:](ng-grid/ng-grid.d.ts) [ng-grid](http://angular-ui.github.io/ng-grid) by [Ken Smith](https://github.com/smithkl42), [Roland Zwaga](https://github.com/rolandzwaga), [Kent Cooper](https://github.com/kentcooper)
* [:link:](angular-idle/angular-idle.d.ts) [ng-idle](http://hackedbychinese.github.io/ng-idle) by [mthamil](https://github.com/mthamil)
* [:link:](ngprogress/ngprogress.d.ts) [ngProgress](http://victorbjelkholm.github.io/ngProgress) by [Martin McWhorter](https://github.com/martinmcwhorter)
@@ -722,6 +739,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](node-fibers/node-fibers.d.ts) [node-fibers](https://github.com/laverdet/node-fibers) by [Cary Haynie](https://github.com/caryhaynie)
* [:link:](node-form/node-form.d.ts) [node-form](https://github.com/rsamec/form) by [Roman Samec](https://github.com/rsamec)
* [:link:](node-gcm/node-gcm.d.ts) [node-gcm](https://www.npmjs.org/package/node-gcm) by [Hiroki Horiuchi](https://github.com/horiuchi)
+* [:link:](node-getopt/node-getopt.d.ts) [node-getopt](https://github.com/jiangmiao/node-getopt) by [Karl.M.Cauchy](https://github.com/kcauchy)
* [:link:](node-git/node-git.d.ts) [node-git](https://github.com/christkv/node-git) by [vvakame](https://github.com/vvakame)
* [:link:](ip/ip.d.ts) [node-ip](https://github.com/indutny/node-ip) by [Peter Harris](https://github.com/codeanimal)
* [:link:](multiparty/multiparty.d.ts) [node-multiparty](https://github.com/andrewrk/node-multiparty) by [Ken Fukuyama](https://github.com/kenfdev)
@@ -735,25 +753,24 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](node-webkit/node-webkit.d.ts) [node-webkit](https://github.com/rogerwang/node-webkit) by [Pedro Casaubon](https://github.com/xperiments)
* [:link:](xml2js/xml2js.d.ts) [node-xml2js](https://github.com/Leonidas-from-XIV/node-xml2js) by [Michel Salib](https://github.com/michelsalib), [Jason McNeil](https://github.com/jasonrm)
* [:link:](node/node.d.ts) [Node.js](http://nodejs.org) by [Microsoft TypeScript](http://typescriptlang.org), [DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped)
+* [:link:](_debugger/_debugger.d.ts) [Node.js debugger API](http://nodejs.org) by [Basarat Ali Syed](https://github.com/basarat)
* [:link:](restify/restify.d.ts) [node.js REST framework](https://github.com/mcavage/node-restify) by [Bret Little](https://github.com/blittle)
-* [:link:](acl/acl-redisBackend.d.ts) [node_acl](https://github.com/optimalbits/node_acl) by [Qubo](https://github.com/tkQubo)
-* [:link:](acl/acl-mongodbBackend.d.ts) [node_acl](https://github.com/optimalbits/node_acl) by [Qubo](https://github.com/tkQubo)
* [:link:](acl/acl.d.ts) [node_acl](https://github.com/optimalbits/node_acl) by [Qubo](https://github.com/tkQubo)
* [:link:](mdns/mdns.d.ts) [node_mdns](https://github.com/agnat/node_mdns) by [Stefan Steinhart](https://github.com/reppners)
* [:link:](node_redis/node_redis.d.ts) [node_redis](https://github.com/mranney/node_redis) by [Boris Yankov](https://github.com/borisyankov)
* [:link:](each/each.d.ts) [NodeEach](http://www.adaltas.com/projects/node-each) by [Michael Zabka](https://github.com/misak113)
-* [:link:](nodemailer/nodemailer-types.d.ts) [Nodemailer](https://github.com/andris9/Nodemailer) by [Rogier Schouten](https://github.com/rogierschouten)
* [:link:](nodemailer/nodemailer.d.ts) [Nodemailer](https://github.com/andris9/Nodemailer) by [Rogier Schouten](https://github.com/rogierschouten)
+* [:link:](nodemailer/nodemailer-types.d.ts) [Nodemailer](https://github.com/andris9/Nodemailer) by [Rogier Schouten](https://github.com/rogierschouten)
* [:link:](nodemailer-direct-transport/nodemailer-direct-transport.d.ts) [nodemailer-direct-transport](https://github.com/andris9/nodemailer-direct-transport) by [Rogier Schouten](https://github.com/rogierschouten)
* [:link:](nodemailer-smtp-pool/nodemailer-smtp-pool.d.ts) [nodemailer-smtp-pool](https://github.com/andris9/nodemailer-smtp-pool) by [Rogier Schouten](https://github.com/rogierschouten)
* [:link:](nodemailer-smtp-transport/nodemailer-smtp-transport.d.ts) [nodemailer-smtp-transport](https://github.com/andris9/nodemailer-smtp-transport) by [Rogier Schouten](https://github.com/rogierschouten)
* [:link:](nodeunit/nodeunit.d.ts) [nodeunit](https://github.com/caolan/nodeunit) by [Jeff Goddard](https://github.com/jedigo)
* [:link:](nomnom/nomnom.d.ts) [nomnom](https://github.com/harthur/nomnom) by [Paul Vick](https://github.com/panopticoncentral)
* [:link:](nopt/nopt.d.ts) [nopt](https://github.com/npm/nopt) by [jbondc](https://github.com/jbondc)
-* [:link:](notify/notify.d.ts) [Notify.js](https://github.com/jpillora/notifyjs) by [Xiaohan Zhang](https://github.com/hellochar)
* [:link:](notifyjs/notifyjs.d.ts) [notify.js](https://github.com/alexgibson/notify.js) by [soundTricker](https://github.com/soundTricker)
-* [:link:](nouislider/nouislider.d.ts) [nouislider](https://github.com/leongersen/noUiSlider) by [Corey Jepperson](https://github.com/acoreyj)
+* [:link:](notify/notify.d.ts) [Notify.js](https://github.com/jpillora/notifyjs) by [Xiaohan Zhang](https://github.com/hellochar)
* [:link:](wnumb/wnumb.d.ts) [nouislider](https://github.com/leongersen/wnumb) by [Corey Jepperson](https://github.com/acoreyj)
+* [:link:](nouislider/nouislider.d.ts) [nouislider](https://github.com/leongersen/noUiSlider) by [Corey Jepperson](https://github.com/acoreyj)
* [:link:](noVNC/noVNC.d.ts) [noVNC](https://github.com/kanaka/noVNC) by [Ken Smith](https://github.com/smithkl42)
* [:link:](npm/npm.d.ts) [npm](https://github.com/npm/npm) by [Maxime LUCE](https://github.com/SomaticIT)
* [:link:](nprogress/NProgress.d.ts) [NProgress](https://github.com/rstacruz/nprogress) by [Judah Gabriel Himango](http://debuggerdotbreak.wordpress.com)
@@ -779,10 +796,11 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](passport/passport.d.ts) [Passport](http://passportjs.org) by [Horiuchi_H](https://github.com/horiuchi)
* [:link:](passport-strategy/passport-strategy.d.ts) [Passport Strategy module](https://github.com/jaredhanson/passport-strategy) by [Lior Mualem](https://github.com/liorm)
* [:link:](passport-twitter/passport-twitter.d.ts) [passport-facebook](https://github.com/jaredhanson/passport-facebook) by [James Roland Cabresos](https://github.com/staticfunction)
-* [:link:](passport-facebook/passport-facebook.d.ts) [passport-facebook](https://github.com/jaredhanson/passport-facebook) by [James Roland Cabresos](https://github.com/staticfunction)
* [:link:](passport-google-oauth/passport-google-oauth.d.ts) [passport-facebook](https://github.com/jaredhanson/passport-facebook) by [James Roland Cabresos](https://github.com/staticfunction)
+* [:link:](passport-facebook/passport-facebook.d.ts) [passport-facebook](https://github.com/jaredhanson/passport-facebook) by [James Roland Cabresos](https://github.com/staticfunction)
* [:link:](passport-facebook-token/passport-facebook-token.d.ts) [passport-facebook-token](https://github.com/drudge/passport-facebook-token) by [Ray Martone](https://github.com/rmartone)
* [:link:](passport-local/passport-local.d.ts) [passport-local](https://github.com/jaredhanson/passport-local) by [Maxime LUCE](https://github.com/SomaticIT)
+* [:link:](path-exists/path-exists.d.ts) [path-exists](https://github.com/sindresorhus/path-exists) by [Shogo Iwano](https://github.com/shiwano)
* [:link:](path-to-regexp/path-to-regexp.d.ts) [path-to-regexp](https://github.com/pillarjs/path-to-regexp) by [xica](https://github.com/xica)
* [:link:](pathwatcher/pathwatcher.d.ts) [pathwatcher](https://github.com/atom/node-pathwatcher) by [vvakame](https://github.com/vvakame)
* [:link:](pdf/pdf.d.ts) [PDF.js](https://github.com/mozilla/pdf.js) by [Josh Baldwin](https://github.com/jbaldwin)
@@ -795,6 +813,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](phantom/phantom.d.ts) [PhantomJS bridge for NodeJS](https://github.com/sgentle/phantomjs-node) by [horiuchi](https://github.com/horiuchi)
* [:link:](phantomjs/phantomjs.d.ts) [PhantomJS v1.9.0 API](https://github.com/ariya/phantomjs/wiki/API-Reference) by [Jed Hunsaker](https://github.com/jedhunsaker), [Mike Keesey](https://github.com/keesey)
* [:link:](phonegap/phonegap.d.ts) [PhoneGap](http://phonegap.com) by [Boris Yankov](https://github.com/borisyankov), [Dick van den Brink](https://github.com/DickvdBrink)
+* [:link:](photonui/photonui.d.ts) [PhotonUI](https://github.com/wanadev/PhotonUI) by [Florent Poujol](https://github.com/florentpoujol)
* [:link:](photoswipe/photoswipe.d.ts) [PhotoSwipe](http://photoswipe.com) by [Xiaohan Zhang](https://github.com/hellochar)
* [:link:](physijs/physijs.d.ts) [Physijs](http://chandlerprall.github.io/Physijs) by [Satoru Kimura](https://github.com/gyohk)
* [:link:](pickadate/pickadate.d.ts) [pickadate.js](https://github.com/amsul/pickadate.js) by [Theodore Brown](https://github.com/theodorejb)
@@ -924,8 +943,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](slickgrid/slick.rowselectionmodel.d.ts) [SlickGrid RowSelectionModel Plugin](https://github.com/mleibman/SlickGrid) by [Derek Cicerone](https://github.com/derekcicerone)
* [:link:](smoothie/smoothie.d.ts) [Smoothie Charts](https://github.com/joewalnes/smoothie) by [Drew Noakes](https://drewnoakes.com), [Mike H. Hawley](https://github.com/mikehhawley)
* [:link:](snapsvg/snapsvg.d.ts) [Snap-SVG](https://github.com/adobe-webplatform/Snap.svg) by [Lars Klein](https://github.com/lhk)
-* [:link:](socket.io/socket.io.d.ts) [socket.io](http://socket.io) by [PROGRE](https://github.com/progre)
-* [:link:](socket.io-client/socket.io-client.d.ts) [socket.io-client](http://socket.io) by [PROGRE](https://github.com/progre)
+* [:link:](socket.io/socket.io.d.ts) [socket.io](http://socket.io) by [PROGRE](https://github.com/progre), [Damian Connolly](https://github.com/divillysausages)
+* [:link:](socket.io-client/socket.io-client.d.ts) [socket.io-client](http://socket.io) by [PROGRE](https://github.com/progre), [Damian Connolly](https://github.com/divillysausages)
* [:link:](sockjs/sockjs.d.ts) [SockJS 0.3.x](https://github.com/sockjs/sockjs-client) by [Emil Ivanov](https://github.com/vladev)
* [:link:](sockjs-node/sockjs-node.d.ts) [sockjs-node 0.3.x](https://github.com/sockjs/sockjs-node) by [Phil McCloghry-Laing](https://github.com/pmccloghrylaing)
* [:link:](soundjs/soundjs.d.ts) [SoundJS](http://www.createjs.com/#!/SoundJS) by [Pedro Ferreira](https://bitbucket.org/drk4)
@@ -972,6 +991,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](swipeview/swipeview.d.ts) [SwipeView](http://cubiq.org/swipeview) by [Boris Yankov](https://github.com/borisyankov)
* [:link:](switchery/switchery.d.ts) [switchery](https://github.com/abpetkov/switchery) by [Bruno Grieder](https://github.com/bgrieder)
* [:link:](swiz/swiz.d.ts) [swiz](https://github.com/racker/node-swiz) by [Jeff Goddard](https://github.com/jedigo)
+* [:link:](systemjs/systemjs.d.ts) [System.js](https://github.com/systemjs/systemjs) by [Ludovic HENIN](https://github.com/ludohenin), [Nathan Walker](https://github.com/NathanWalker)
* [:link:](tabtab/tabtab.d.ts) [tabtab](https://github.com/mklabs/node-tabtab) by [Vojtěch Habarta](https://github.com/vojtechhabarta)
* [:link:](tape/tape.d.ts) [tape](https://github.com/substack/tape) by [Bart van der Schoor](https://github.com/Bartvds)
* [:link:](tar/tar.d.ts) [tar](https://github.com/npm/node-tar) by [Maxime LUCE](https://github.com/SomaticIT)
@@ -1008,6 +1028,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](titanium/titanium.d.ts) [Titanium Mobile](http://www.appcelerator.com) by [Craig Younkins](https://github.com/cyounkins)
* [:link:](title-case/title-case.d.ts) [title-case](https://github.com/blakeembrey/title-case) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](tmp/tmp.d.ts) [tmp](https://www.npmjs.com/package/tmp) by [Jared Klopper](https://github.com/optical)
+* [:link:](to-title-case-gouch/to-title-case-gouch.d.ts) [to-title-case](https://github.com/gouch/to-title-case) by [Sam Saint-Pettersen](https://github.com/stpettersens)
* [:link:](toastr/toastr.d.ts) [Toastr](https://github.com/CodeSeven/toastr) by [Boris Yankov](https://github.com/borisyankov)
* [:link:](sencha_touch/SenchaTouch.d.ts) [Touch](http://www.sencha.com/products/touch) by [Brian Kotek](https://github.com/brian428)
* [:link:](traceback/traceback.d.ts) [Traceback](http://github.com/iriscouch/traceback) by [Michael Zabka](https://github.com/misak113)
@@ -1024,6 +1045,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](type-detect/type-detect.d.ts) [type-detect](https://github.com/chaijs/type-detect) by [Bart van der Schoor](https://github.com/Bartvds)
* [:link:](type-name/type-name.d.ts) [type-name](https://github.com/twada/type-name) by [OKUNOKENTARO](https://github.com/armorik83)
* [:link:](typeahead/typeahead.d.ts) [typeahead.js](http://twitter.github.io/typeahead.js) by [Ivaylo Gochkov](https://github.com/igochkov), [Gidon Junge](https://github.com/gjunge)
+* [:link:](webfontloader/webfontloader.d.ts) [typekit-webfontloader](https://github.com/typekit/webfontloader) by [doskallemaskin](https://github.com/doskallemaskin)
* [:link:](typescript/typescript.d.ts) [TypeScript API](http://www.typescriptlang.org) by [Microsoft TypeScript](http://typescriptlang.org)
* [:link:](typescript-deferred/typescript-deferred.d.ts) [typescript-deferred](https://github.com/DirtyHairy/typescript-deferred) by [Christian Speckner](https://github.com/DirtyHairy)
* [:link:](typescript-services/typescriptServices.d.ts) [TypeScript-Services](https://www.npmjs.org/package/typescript-services) by [Basarat Ali Syed](http://github.com/basarat)
@@ -1060,7 +1082,6 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](watch/watch.d.ts) [watch](https://github.com/mikeal/watch) by [Carlos Ballesteros Velasco](https://github.com/soywiz)
* [:link:](jquery.watermark/jquery.watermark.d.ts) [Watermark plugin for jQuery](http://jquery-watermark.googlecode.com) by [Anwar Javed](https://github.com/anwarjaved)
* [:link:](webaudioapi/waa.d.ts) [Web Audio API](http://www.w3.org/TR/webaudio) by [Baruch Berger](https://github.com/bbss), [Kon](http://phyzkit.net), [kubosho](https://github.com/kubosho)
-* [:link:](webaudioapi/waa-nightly.d.ts) [Web Audio API (nightly)](http://www.w3.org/TR/2012/WD-webaudio-20120802) by [Baruch Berger](https://github.com/bbss)
* [:link:](webmidi/webmidi.d.ts) [Web MIDI API](http://www.w3.org/TR/webmidi) by [Toshiya Nakakura](https://github.com/nakakura)
* [:link:](webspeechapi/webspeechapi.d.ts) [Web Speech API](https://dvcs.w3.org/hg/speech-api/raw-file/tip/speechapi.html) by [SaschaNaz](https://github.com/saschanaz)
* [:link:](webcola/webcola.d.ts) [webcola](https://github.com/tgdwyer/WebCola) by [Qinfeng Chen](https://github.com/qinfchen)
diff --git a/angular-formly/angular-formly-tests.ts b/angular-formly/angular-formly-tests.ts
new file mode 100644
index 0000000000..ef6a384637
--- /dev/null
+++ b/angular-formly/angular-formly-tests.ts
@@ -0,0 +1,108 @@
+///
+
+var app = angular.module('app', ['formly']);
+
+interface IScope extends ng.IScope {
+ to: { label: string; }
+}
+
+class FormConfig {
+ constructor(formlyConfig: AngularFormly.IFormlyConfig, formlyValidationMessages: AngularFormly.IValidationMessages) {
+ formlyConfig.setWrapper({
+ name: 'validation',
+ types: ['input', 'customInput'],
+ templateUrl: 'my-messages.html'
+ });
+
+ formlyValidationMessages.addStringMessage('required', 'This field is required');
+
+ formlyConfig.setType({
+ name: 'customInput',
+ extends: 'input'
+ });
+ }
+}
+
+class AppController {
+ fields: AngularFormly.IFieldConfigurationObject[];
+ constructor() {
+ var vm = this;
+ vm.fields = [
+ {
+ key: 'firstName',
+ type: 'customInput',
+ templateOptions: {
+ required: true,
+ label: 'First Name',
+ foo: 'hi'
+ }
+ },
+ {
+ key: 'email',
+ type: 'input',
+ templateOptions: {
+ label: 'Email',
+ required: true,
+ type: 'email',
+ maxlength: 10,
+ minlength: 6,
+ placeholder: 'example@example.com'
+ }
+ },
+ {
+ key: 'ip',
+ type: 'input',
+ validators: {
+ ipAddress: {
+ expression: function(viewValue, modelValue) {
+ var value = modelValue || viewValue;
+ return /(\d{1,3}\.){3}\d{1,3}/.test(value);
+ },
+ message: '$viewValue + " is not a valid IP Address"'
+ }
+ },
+ templateOptions: {
+ label: 'IP Address',
+ required: true,
+ type: 'text',
+ placeholder: '127.0.0.1',
+ },
+ validation: {
+ messages: {
+ required: function($viewValue: any, $modelValue: any, scope: AngularFormly.ITemplateScope) {
+ return scope.to.label + ' is required'
+ }
+ }
+ }
+ },
+ {
+ key: 'mac',
+ type: 'input',
+ templateOptions: {
+ label: 'MAC Address',
+ required: true,
+ placeholder: '49-8A-BD-4E-00-1D',
+ pattern: '([0-9A-F]{2}[:-]){5}([0-9A-F]{2})'
+ }
+ },
+ {
+ type: 'checkbox',
+ key: 'checked',
+ templateOptions: {
+ label: 'Check this'
+ }
+ },
+ {
+ key: 'checked2',
+ type: 'checkbox',
+ wrapper: null,
+ templateOptions: {
+ label: 'no wrapper here...'
+ }
+ }
+ ]
+ }
+}
+
+app.controller("AppController", AppController);
+
diff --git a/angular-formly/angular-formly.d.ts b/angular-formly/angular-formly.d.ts
new file mode 100644
index 0000000000..8f76b3ccf9
--- /dev/null
+++ b/angular-formly/angular-formly.d.ts
@@ -0,0 +1,574 @@
+// Type definitions for angular-formly 6.18.0
+// Project: https://github.com/formly-js/angular-formly
+// Definitions by: Scott Hatcher
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module 'AngularFormly' {
+ export = AngularFormly;
+}
+
+declare module AngularFormly {
+
+
+ interface IFieldGroup {
+ data?: Object;
+ className?: string;
+ elementAttributes?: { [key: string]: string };
+ fieldGroup: IFieldConfigurationObject[];
+ form?: Object;
+ hide?: boolean;
+ hideExpression?: string | IExpresssionFunction;
+ key?: string | number;
+ model?: string | Object;
+ options?: IFormOptionsAPI
+ }
+
+
+ interface IFormOptionsAPI {
+ data?: Object;
+ fieldTransform?: Function;
+ formState?: Object;
+ removeChromeAutoComplete?: boolean;
+ resetModel?: Function;
+ templateManipulators?: ITemplateManipulators;
+ updateInitialValue?: Function;
+ wrapper?: string | string[];
+ }
+
+
+ /**
+ * see http://docs.angular-formly.com/docs/formly-expressions#expressionproperties-validators--messages
+ */
+ interface IExpresssionFunction {
+ ($viewValue: any, $modelValue: any, scope: ITemplateScope): any;
+ }
+
+
+ interface IModelOptions {
+ updateOn?: string;
+ debounce?: number;
+ allowInvalid?: boolean;
+ getterSetter?: string;
+ timezone?: string;
+ }
+
+
+ interface ITemplateManipulator {
+ (template: string | HTMLElement, options: Object, scope: ITemplateScope): string | HTMLElement;
+ }
+
+
+ interface ITemplateManipulators {
+ preWrapper?: ITemplateManipulator[];
+ postWrapper?: ITemplateManipulator[];
+ }
+
+
+ /**
+ * see http://docs.angular-formly.com/docs/ngmodelattrstemplatemanipulator
+ */
+ interface ITemplateOptions {
+
+ // both attribute or regular attribute
+ disabled?: boolean;
+ maxlength?: number;
+ minlength?: number;
+ pattern?: string;
+ required?: boolean;
+
+ //attribute only
+ max?: number;
+ min?: number;
+ placeholder?: number | string;
+ tabindex?: number;
+ type?: string;
+
+ //expression types
+ onBlur?: string;
+ onChange?: string;
+ onClick?: string;
+ onFocus?: string;
+ onKeydown?: string;
+ onKeypress?: string;
+ onKeyup?: string;
+
+ //Bootstrap types
+ label?: string;
+ description?: string;
+ [key: string]: any;
+
+ }
+
+
+ /**
+ * see http://docs.angular-formly.com/docs/field-configuration-object#validators-object
+ */
+ interface IValidator {
+ expression: string | IExpresssionFunction;
+ message?: string | IExpresssionFunction;
+ }
+
+
+ /**
+ * An object which has at least two properties called expression and listener. The watch.expression
+ * is added to the formly-form directive's scope (to allow it to run even when hide is true). You
+ * can specify a type ($watchCollection or $watchGroup) via the watcher.type property (defaults to
+ * $watch) and whether you want it to be a deep watch via the watcher.deep property (defaults to false).
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#watcher-objectarray-of-watches
+ */
+ interface IWatcher {
+ deep?: boolean; //Defaults to false
+ expression?: string | { (field: string, scope: ITemplateScope): boolean };
+ listener: (field: string, newValue: any, oldValue: any, scope: ITemplateScope, stopWatching: Function) => void;
+ type?: string; //Defaults to $watch but can be set to $watchCollection or $watchGroup
+ }
+
+
+ // see http://docs.angular-formly.com/docs/field-configuration-object
+ interface IFieldConfigurationObject {
+
+
+ /**
+ * Added in 6.18.0
+ *
+ * Demo
+ * see http://angular-formly.com/#/example/other/unique-value-async-validation
+ */
+ asyncValidators?: {
+ [key: string]: string | IExpresssionFunction | IValidator;
+ }
+
+ /**
+ * This is a great way to add custom behavior to a specific field. It is injectable with the $scope of the
+ * field, and anything else you have in your injector.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#controller-controller-name-as-string--controller-f
+ */
+ controller?: string | Function;
+
+
+ /**
+ * This is reserved for the developer. You have our guarantee to be able to use this and not worry about
+ * future versions of formly overriding your usage and preventing you from upgrading :-)
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#data-object
+ */
+ data?: Object;
+
+
+ /**
+ * Use defaultValue to initialize it the model. If this is provided and the value of the
+ * model at compile-time is undefined, then the value of the model will be assigned to defaultValue.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#defaultvalue-any
+ */
+ defaultValue?: any;
+
+
+ /**
+ * You can specify your own class that will be applied to the formly-field directive (or ng-form of
+ * a fieldGroup).
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#classname-string
+ */
+ className?: string;
+
+
+ elementAttributes?: string;
+
+
+ /**
+ * An object where the key is a property to be set on the main field config and the value is an
+ * expression used to assign that property. The value is a formly expressions. The returned value is
+ * wrapped in $q.when so you can return a promise from your function :-)
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#expressionproperties-object
+ */
+ expressionProperties?: {
+ [key: string]: string | IExpresssionFunction | IValidator;
+ }
+
+
+ /**
+ * Uses ng-if. Whether to hide the field. Defaults to false. If you wish this to be conditional, use
+ * hideExpression. See below.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#hide-boolean
+ */
+ hide?: boolean
+
+
+ /**
+ * This is similar to expressionProperties with a slight difference. You should (hopefully) never
+ * notice the difference with the most common use case. This is available due to limitations with
+ * expressionProperties and ng-if not working together very nicely.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#hideexpression-string--function
+ */
+ hideExpression?: string | IExpresssionFunction;
+
+
+ /**
+ * This allows you to specify the id of your field (which will be used for its name as well unless
+ * a name is provided). Note, you can also override the id generation code using the formlyConfig
+ * extra called getFieldId.
+ *
+ * AVOID THIS
+ * If you don't have to do this, don't. Specifying IDs makes it harder to re-use things and it's
+ * just extra work. Part of the beauty that angular-formly provides is the fact that you don't need
+ * to concern yourself with making sure that this is unique.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#id-string
+ */
+ id?: string;
+
+
+ initialValue?: any;
+
+
+ /**
+ * Can be set instead of type or template to use a custom html template form field. Works
+ * just like a directive templateUrl and uses the $templateCache
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#key-string
+ */
+ key?: string | number;
+
+
+ /**
+ * This allows you to specify a link function. It is invoked after your template has finished compiling.
+ * You are passed the normal arguments for a normal link function.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#link-link-function
+ */
+ link?: ng.IDirectiveLinkFn;
+
+
+ /**
+ * By default, the model passed to the formly-field directive is the same as the model passed to the
+ * formly-form. However, if the field has a model specified, then it is used for that field (and that
+ * field only). In addition, a deep watch is added to the formly-field directive's scope to run the
+ * expressionProperties when the specified model changes.
+ *
+ * Note, the formly-form directive will allow you to specify a string which is an (almost) formly
+ * expression which allows you to define the model as relative to the scope of the form.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#model-object--string
+ */
+ model?: Object | string;
+
+
+ /**
+ * Allows you to take advantage of ng-model-options directive. Formly's built-in templateManipulator (see
+ * below) will add this attribute to your ng-model element automatically if this property exists. Note,
+ * if you use the getter/setter option, formly's templateManipulator will change the value of ng-model
+ * to options.value which is a getterSetter that formly adds to field options.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#modeloptions
+ */
+ modelOptions?: IModelOptions;
+
+
+ /**
+ * If you wish to, you can specify a specific name for your ng-model. This is useful if you're posting
+ * the form to a server using techniques of yester-year.
+ *
+ * AVOID THIS
+ * If you don't have to do this, don't. It's just extra work. Part of the beauty that angular-formly
+ * provides is the fact that you don't need to concern yourself with stuff like this.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#name-string
+ */
+ name?: string;
+
+
+ /**
+ * This is used by ngModelAttrsTemplateManipulator to automatically add attributes to the ng-model element
+ * of field templates. You will likely not use this often. This object is a little complex, but extremely
+ * powerful. It's best to explain this api via an example. For more information, see the guide on ngModelAttrs.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#ngmodelattrs-object
+ */
+ ngModelAttrs?: {
+ attribute?: any;
+ bound?: any;
+ expression?: any;
+ value?: any;
+ };
+
+
+ /**
+ * Used to tell angular-formly to not attempt to add the formControl property to your object. This is useful
+ * for things like validation, but not necessary if your "field" doesn't use ng-model (if it's just a horizontal
+ * line for example). Defaults to undefined.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#noformcontrol-boolean
+ */
+ noFormControl?: boolean;
+
+
+ /**
+ * Allows you to specify extra types to get options from. Duplicate options are overridden in later priority
+ * (index 1 will override index 0 properties). Also, these are applied after the type's defaultOptions and
+ * hence will override any duplicates of those properties as well.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#optionstypes-string--array-of-strings
+ */
+ optionsTypes?: string | string[];
+
+
+ /**
+ * Can be set instead of type or templateUrl to use a custom html
+ * template form field. Recommended to be used with one-liners mostly
+ * (like a directive), or if you're using webpack with the ability to require templates :-)
+ *
+ * If a function is passed, it is invoked with the field configuration object and can return
+ * either a string for the template or a promise that resolves to a string.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#template-string--function
+ */
+ template?: string | { (fieldConfiguration: IFieldConfigurationObject): string | ng.IPromise };
+
+
+ /**
+ * Allows you to specify custom template manipulators for this specific field. (use defaultOptions in a
+ * type configuration if you want it to apply to all fields of a certain type).
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#templatemanipulator-object-of-arrays-of-functions
+ */
+ templateManipulators?: ITemplateManipulators;
+
+
+ /**
+ * This is reserved for the templates. Any template-specific options go in here. Look at your specific
+ * template implementation to know the options required for this.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#templateoptions-object
+ */
+ templateOptions?: ITemplateOptions;
+
+
+ /**
+ * Can be set instead of type or template to use a custom html template form field. Works
+ * just like a directive templateUrl and uses the $templateCache
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#templateurl-string--function
+ */
+ templateUrl?: string | { (fieldConfiguration: IFieldConfigurationObject): string | ng.IPromise };
+
+
+ /**
+ * The type of field to be rendered. This is the recommended method
+ * for defining fields. Types must be pre-defined using formlyConfig.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#type-string
+ */
+ type?: string;
+
+
+ /**
+ * An object with a few useful properties mostly handy when used in combination with ng-messages
+ */
+ validation?: {
+
+ /**
+ * This is set by angular-formly. This is a boolean indicating whether an error message should be shown. Because
+ * you generally only want to show error messages when the user has interacted with a specific field, this value
+ * is set to true based on this rule: field invalid && (field touched || validation.show) (with slight difference
+ * for pre-angular 1.3 because it doesn't have touched support).
+ */
+ errorExistsAndShouldBeVisible?: boolean;
+
+
+ /**
+ * A map of Formly Expressions mapped to message names. This is really useful when you're using ng-messages
+ * like in this example.
+ */
+ messages?: {
+ [key: string]: IExpresssionFunction | string;
+ }
+
+
+ /**
+ * A boolean you as the developer can set to specify to force options.validation.errorExistsAndShouldBeVisible
+ * to be set to true when there are $errors. This is useful when you're trying to call the user's attention to
+ * some fields for some reason.
+ */
+ show?: boolean;
+
+ }
+
+
+ /**
+ * An object where the keys are the name of the validator and the values are Formly Expressions;
+ *
+ * Async Validation
+ * All function validators can return true/false/Promise. A validator passes if it returns true or a promise
+ * that is resolved. A validator fails if it returns false or a promise that is rejected.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#validators-object
+ */
+ validators?: {
+ [key: string]: string | IExpresssionFunction | IValidator;
+ }
+
+
+ /**
+ * This is a getter/setter function for the value that your field is representing. Useful when using getterSetter: true
+ * in the modelOptions (in fact, if you don't disable the ngModelAttrsTemplateManipulator that comes built-in with formly,
+ * it will automagically change your field's ng-model attribute to use options.value.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#value-gettersetter-function
+ */
+ value?(): any; //Getter
+ value?(val: any): void; //Setter
+
+
+ /**
+ * An object which has at least two properties called expression and listener. The watch.expression is added
+ * to the formly-form directive's scope (to allow it to run even when hide is true). You can specify a type
+ * ($watchCollection or $watchGroup) via the watcher.type property (defaults to $watch) and whether you want
+ * it to be a deep watch via the watcher.deep property (defaults to false).
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#watcher-objectarray-of-watches
+ */
+ watcher?: IWatcher | IWatcher[];
+
+
+ /**
+ * This makes reference to setWrapper in formlyConfig. It is expected to be the name of the wrapper. If
+ * given an array, the formly field template will be wrapped by the first wrapper, then the second, then
+ * the third, etc. You can also specify these as part of a type (which is the recommended approach).
+ * Specifying this property will override the wrappers for the type for this field.
+ *
+ * http://docs.angular-formly.com/docs/field-configuration-object#wrapper-string--array-of-strings
+ */
+ wrapper?: string | string[];
+
+
+ //ALL PROPERTIES BELOW ARE ADDED (So you should not be setting them yourself.)
+
+
+ /**
+ * This is the NgModelController for the field. It provides you with awesome stuff like $errors :-)
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#formcontrol-ngmodelcontroller
+ */
+ formControl?: ng.IFormController | ng.IFormController[];
+
+
+ /**
+ * Will reset the field's model and the field control to the last initialValue. This is used by the
+ * formly-form's options.resetModel function.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#resetmodel-function
+ */
+ resetModel?: () => void;
+
+
+ /**
+ * It is not likely that you'll ever want to invoke this function. It simply runs the expressionProperties expressions.
+ * It is used internally and you shouldn't have to use it, but you can if you want to, and any breaking changes to the
+ * way it works will result in a major version change, so you can rely on its api.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#runexpressions-function
+ */
+ runExpressions?: () => void;
+
+
+ /**
+ * Will reset the field's initialValue to the current state of the model. Useful if you load the model asynchronously.
+ * Invoke this when the model gets set. This is used by the formly-form's options.updateInitialValue function.
+ *
+ * see http://docs.angular-formly.com/docs/field-configuration-object#updateinitialvalue-function
+ */
+ updateInitialValue?: () => void;
+
+ }
+
+ /**
+ *
+ *
+ * see http://docs.angular-formly.com/docs/custom-templates#section-formlyconfig-settype-options
+ */
+ interface ITypeOptions {
+ apiCheck?: { [key: string]: Function };
+ apiCheckFunction?: string; //'throw' or 'warn
+ apiCheckInstance?: any;
+ apiCheckOptions?: Object;
+ defaultOptions?: IFieldConfigurationObject | Function;
+ controller?: Function | string | any[];
+ data?: Object;
+ extends?: string;
+ link?: ng.IDirectiveLinkFn;
+ overwriteOk?: boolean;
+ name: string;
+ template?: Function | string;
+ templateUrl?: Function | string;
+ validateOptions?: Function;
+ wrapper?: string | string[];
+ }
+
+ interface IWrapperOptions {
+ apiCheck?: { [key: string]: Function };
+ apiCheckFunction?: string; //'throw' or 'warn
+ apiCheckInstance?: any;
+ apiCheckOptions?: Object;
+ overwriteOk?: boolean;
+ name?: string;
+ template?: string;
+ templateUrl?: string;
+ types?: string[];
+ validateOptions?: Function;
+ }
+
+ interface IFormlyConfig {
+ setType(typeOptions: ITypeOptions): void;
+ setWrapper(wrapperOptions: IWrapperOptions): void;
+
+ }
+
+ interface ITemplateScopeOptions {
+ formControl: ng.IFormController | ng.IFormController[];
+ templateOptions: ITemplateOptions;
+ validation: Object;
+ }
+
+ /**
+ * see http://docs.angular-formly.com/docs/custom-templates#templates-scope
+ */
+ interface ITemplateScope {
+ options: ITemplateScopeOptions;
+ //Shortcut to options.formControl
+ fc: ng.IFormController | ng.IFormController[];
+ //all the fields for the form
+ fields: IFieldConfigurationObject[];
+ //the form controller the field is in
+ form: any;
+ //The object passed as options.formState to the formly-form directive. Use this to share state between fields.
+ formState: Object;
+ //The id of the field. You shouldn't have to use this.
+ id: string;
+ //The index of the field the form is on (in ng-repeat)
+ index: number;
+ //the model of the form (or the model specified by the field if it was specified).
+ model: Object | string;
+ //Shortcut to options.validation.errorExistsAndShouldBeVisible
+ showError: boolean;
+ //Shortcut to options.templateOptions
+ to: ITemplateOptions;
+ }
+
+ /**
+ * see http://docs.angular-formly.com/docs/formlyvalidationmessages#addtemplateoptionvaluemessage
+ */
+ interface IValidationMessages {
+ addTemplateOptionValueMessage(name: string, prop: string, prefix: string, suffix: string, alternate: string): void;
+ addStringMessage(name: string, string: string): void;
+ messages: { [key: string]: ($viewValue: any, $modelValue: any, scope: ITemplateScope) => string };
+ }
+
+}
\ No newline at end of file
diff --git a/angular-odata-resources/angular-odata-resources-tests.ts b/angular-odata-resources/angular-odata-resources-tests.ts
index 0149533fab..5b8dbcc52b 100644
--- a/angular-odata-resources/angular-odata-resources-tests.ts
+++ b/angular-odata-resources/angular-odata-resources-tests.ts
@@ -186,4 +186,14 @@ var combination2 = Predicate.and([combination1, predicate2]);
var predicate = new Predicate("FirstName", "John")
.or(new Predicate("LastName", '!=', "Doe"))
- .and(new Predicate("Age", '>', 10));
\ No newline at end of file
+ .and(new Predicate("Age", '>', 10));
+
+
+users = odataResourceClass.odata()
+ .withInlineCount()
+ .query();
+
+
+var countResult = odataResourceClass.odata().count();
+var total = countResult.result;
+
diff --git a/angular-odata-resources/angular-odata-resources.d.ts b/angular-odata-resources/angular-odata-resources.d.ts
index 87b89687fa..0a83df2c3c 100644
--- a/angular-odata-resources/angular-odata-resources.d.ts
+++ b/angular-odata-resources/angular-odata-resources.d.ts
@@ -264,6 +264,11 @@ declare module OData {
(queryString: string, success: () => any, error: () => any): T[];
(queryString: string, success: () => any, error: () => any, isSingleElement?: boolean, forceSingleElement?: boolean): T;
}
+
+ interface ICountResult{
+ result: number;
+ }
+
class Provider {
private callback;
private filters;
@@ -281,6 +286,8 @@ declare module OData {
single(success?: any, error?: any): T;
get(data: any, success?: any, error?: any): T;
expand(params: any, otherParam1?: any, otherParam2?: any, otherParam3?: any, otherParam4?: any, otherParam5?: any, otherParam6?: any, otherParam7?: any): Provider;
+ count(success?: (result: ICountResult) => any, error?: () => any):ICountResult;
+ withInlineCount(): Provider;
}
interface ValueFactory {
diff --git a/angular-protractor/angular-protractor-tests.ts b/angular-protractor/angular-protractor-tests.ts
index b8b9585f47..45a5d7edc4 100644
--- a/angular-protractor/angular-protractor-tests.ts
+++ b/angular-protractor/angular-protractor-tests.ts
@@ -374,7 +374,7 @@ function TestElementArrayFinder() {
var b: boolean = elementArrayFinder.isPending();
var locator: webdriver.Locator = elementArrayFinder.locator();
- var findersArray: protractor.ElementFinder[] = elementArrayFinder.asElementFinders_();
+ var findersArrayPromise: protractor.promise.Promise = elementArrayFinder.asElementFinders_();
var driverElementArray: webdriver.WebElement[] = elementArrayFinder.getWebElements();
var elementFinder: protractor.ElementFinder = elementArrayFinder.get(42);
diff --git a/angular-protractor/angular-protractor.d.ts b/angular-protractor/angular-protractor.d.ts
index 76f0b5f10c..2b86864cd3 100644
--- a/angular-protractor/angular-protractor.d.ts
+++ b/angular-protractor/angular-protractor.d.ts
@@ -927,7 +927,7 @@ declare module protractor {
* @return {Array.} Return a promise, which resolves to a list
* of ElementFinders specified by the locator.
*/
- asElementFinders_(): ElementFinder[];
+ asElementFinders_(): webdriver.promise.Promise;
/**
* Create a shallow copy of ElementArrayFinder.
diff --git a/angular2/angular2-2.0.0-alpha.32.d.ts b/angular2/angular2-2.0.0-alpha.32.d.ts
index 596db9287c..ff5661650f 100644
--- a/angular2/angular2-2.0.0-alpha.32.d.ts
+++ b/angular2/angular2-2.0.0-alpha.32.d.ts
@@ -23,7 +23,7 @@ declare module ng {
type SetterFn = typeof Function;
type int = number;
interface Type extends Function {
- new (...args: any[]): Type;
+ new (...args: any[]): any;
}
// See https://github.com/Microsoft/TypeScript/issues/1168
diff --git a/angular2/angular2.d.ts b/angular2/angular2.d.ts
index 596db9287c..ff5661650f 100644
--- a/angular2/angular2.d.ts
+++ b/angular2/angular2.d.ts
@@ -23,7 +23,7 @@ declare module ng {
type SetterFn = typeof Function;
type int = number;
interface Type extends Function {
- new (...args: any[]): Type;
+ new (...args: any[]): any;
}
// See https://github.com/Microsoft/TypeScript/issues/1168
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index 746fbb0e0d..5ad9895b04 100755
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -238,7 +238,7 @@ declare module angular {
fromJson(json: string): any;
identity(arg?: any): any;
- injector(modules?: any[]): auto.IInjectorService;
+ injector(modules?: any[], strictDi?: boolean): auto.IInjectorService;
isArray(value: any): boolean;
isDate(value: any): boolean;
isDefined(value: any): boolean;
@@ -421,9 +421,9 @@ declare module angular {
/**
* Converts an attribute name (e.g. dash/colon/underscore-delimited string, optionally prefixed with x- or data-) to its normalized, camelCase form.
- *
+ *
* Also there is special case for Moz prefix starting with upper case letter.
- *
+ *
* For further information check out the guide on @see https://docs.angularjs.org/guide/directive#matching-directives
*/
$normalize(name: string): void;
diff --git a/angulartics/angulartics-tests.ts b/angulartics/angulartics-tests.ts
new file mode 100644
index 0000000000..cc816a2ab5
--- /dev/null
+++ b/angulartics/angulartics-tests.ts
@@ -0,0 +1,25 @@
+///
+///
+
+module Analytics {
+ angular.module("angulartics.app", ["angulartics"])
+ .config(["$analyticsProvider", ($analyticsProvider: Angulartics.IAnalyticsServiceProvider) => {
+ angulartics.waitForVendorApi("location", 1000, (message: string) => {
+ console.log(message);
+ });
+
+ $analyticsProvider.virtualPageviews(false);
+ $analyticsProvider.firstPageview(false);
+ $analyticsProvider.withAutoBase(true);
+ $analyticsProvider.developerMode(true);
+
+ $analyticsProvider.registerEventTrack((action: string, properties?: any) => {
+ console.log(action);
+ });
+
+ $analyticsProvider.registerPageTrack((path: string, locationObj: ng.ILocationService) => {
+ console.log("viewed " + path);
+ });
+ }]);
+}
+
diff --git a/angulartics/angulartics.d.ts b/angulartics/angulartics.d.ts
new file mode 100644
index 0000000000..8c89575698
--- /dev/null
+++ b/angulartics/angulartics.d.ts
@@ -0,0 +1,39 @@
+// Type definitions for Angulartics v0.19.2
+// Project: http://luisfarzati.github.io/angulartics/
+// Definitions by: Steven Fan
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+interface Angulartics {
+ waitForVendorApi(objectName: string, delay: number, containsField?: any, registerFn?: any, onTimeout?: boolean): void;
+}
+
+declare module Angulartics {
+
+ interface IAnalyticsService {
+ eventTrack(eventName: string, properties?: any): any;
+ pageTrack(path: string, location?: ng.ILocationService): any;
+ setAlias(alias: string): any;
+ setUsername(username: string): any;
+ setUserProperties(properties: any): any;
+ setSuperProperties(properties: any): any;
+ }
+
+ interface IAnalyticsServiceProvider extends angular.IServiceProvider {
+ virtualPageviews(value: boolean): void;
+ firstPageview(value: boolean): void;
+ withBase(value: boolean): void;
+ withAutoBase(value: boolean): void;
+ developerMode(value: boolean): void;
+
+ registerPageTrack(callback: (path: string, location?: ng.ILocationService) => any): void;
+ registerEventTrack(callback: (eventName: string, properties?: any) => any): void;
+ registerSetAlias(callback: (alias: string) => any): void
+ registerSetUsername(callback: (username: string) => any): void
+ registerSetUserProperties(callback: (userProperties: any) => any): void
+ registerSetSuperProperties(callback: (superProperties: any) => any): void
+ }
+}
+
+declare var angulartics:Angulartics;
diff --git a/baconjs/.editorconfig b/baconjs/.editorconfig
new file mode 100644
index 0000000000..8649cc5c38
--- /dev/null
+++ b/baconjs/.editorconfig
@@ -0,0 +1,9 @@
+root = true
+
+[*.ts]
+indent_style = space
+indent_size = 4
+end_of_line = lf
+charset = utf-8
+trim_trailing_whitespace = true
+insert_final_newline = true
diff --git a/baconjs/baconjs-tests.ts b/baconjs/baconjs-tests.ts
index 5d5998b708..9557e37cdf 100644
--- a/baconjs/baconjs-tests.ts
+++ b/baconjs/baconjs-tests.ts
@@ -1,389 +1,464 @@
///
function CreatingStreams() {
- $("#my-div").asEventStream("click");
- $("#my-div").asEventStream("click", ".more-specific-selector");
- $("#my-div").asEventStream("click", (event, args) => args[0]);
- $("#my-div").asEventStream("click", ".more-specific-selector", (event, args) => args[0]);
+ $("#my-div").asEventStream("click");
+ $("#my-div").asEventStream("click", ".more-specific-selector");
+ $("#my-div").asEventStream("click", (event, args) => args[0]);
+ $("#my-div").asEventStream("click", ".more-specific-selector", (event, args) => args[0]);
- Bacon.fromPromise($.ajax("https://baconjs.github.io/"));
- Bacon.fromPromise(Promise.resolve(1));
+ Bacon.fromPromise($.ajax("https://baconjs.github.io/"));
+ Bacon.fromPromise(Promise.resolve(1));
- Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true);
- Bacon.fromPromise(Promise.resolve(1), false);
+ Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true);
+ Bacon.fromPromise(Promise.resolve(1), false);
- Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true, (n:string) => {
- return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
- });
- Bacon.fromPromise(Promise.resolve(1), false, n => {
- return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
- });
-
- Bacon.fromEvent(document.body, "click").onValue(() => {
- alert("Bacon!");
- });
- Bacon.fromEvent(document.body, "click", (event:MouseEvent) => event.clientX).onValue(clientX => {
- alert("Bacon!");
- });
- Bacon.fromEvent(process.stdin, "readable", () => {
- alert("Bacon!");
- });
- Bacon.fromEvent($("body"), "click").onValue(() => {
- alert("Bacon!");
- });
-
- // This would create a stream that outputs a single value "Bacon!" and ends after that. The use of setTimeout causes the value to be delayed by 1 second.
- Bacon.fromCallback(callback => {
- setTimeout(() => {
- callback("Bacon!");
- }, 1000);
- });
-
- // You can also give any number of arguments to `fromCallback`, which will be passed to the function. These arguments can be simple variables, Bacon EventStreams or Properties. For example the following will output "Bacon rules":
- Bacon.fromCallback((a, b, callback) => {
- callback(a + " " + b);
- }, Bacon.constant("bacon"), "rules").log();
-
- {
- var fs = require("fs"),
- read = Bacon.fromNodeCallback(fs.readFile, "input.txt");
- read.onError(error => {
- console.log("Reading failed: " + error);
+ Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true, (n:string) => {
+ return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
});
- read.onValue(value => {
- console.log("Read contents: " + value);
+ Bacon.fromPromise(Promise.resolve(1), false, n => {
+ return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
});
- }
- Bacon.once(new Bacon.Error("fail"));
+ Bacon.fromEvent(document.body, "click").onValue(() => {
+ alert("Bacon!");
+ });
+ Bacon.fromEvent(document.body, "click", (event:MouseEvent) => event.clientX).onValue(clientX => {
+ alert("Bacon!");
+ });
+ Bacon.fromEvent(process.stdin, "readable", () => {
+ alert("Bacon!");
+ });
+ Bacon.fromEvent($("body"), "click").onValue(() => {
+ alert("Bacon!");
+ });
- // The following would lead to `1,2,3,1,2,3...` to be repeated indefinitely:
- Bacon.fromArray([1, new Bacon.Error("")]);
+ // This would create a stream that outputs a single value "Bacon!" and ends after that. The use of setTimeout causes the value to be delayed by 1 second.
+ Bacon.fromCallback(callback => {
+ setTimeout(() => {
+ callback("Bacon!");
+ }, 1000);
+ });
- Bacon.repeatedly(10, [1, 2, 3]);
+ // You can also give any number of arguments to `fromCallback`, which will be passed to the function. These arguments can be simple variables, Bacon EventStreams or Properties. For example the following will output "Bacon rules":
+ Bacon.fromCallback((a, b, callback) => {
+ callback(a + " " + b);
+ }, Bacon.constant("bacon"), "rules").log();
- // The following will produce values `0,1,2`.
- Bacon.repeat(i => {
- if (i < 3) {
- return Bacon.once(i);
- } else {
- return false;
+ {
+ var fs = require("fs"),
+ read = Bacon.fromNodeCallback(fs.readFile, "input.txt");
+ read.onError(error => {
+ console.log("Reading failed: " + error);
+ });
+ read.onValue(value => {
+ console.log("Read contents: " + value);
+ });
}
- }).log();
- {
- var stream = Bacon.fromBinder(sink => {
- sink("first value");
- sink([new Bacon.Next("2nd"), new Bacon.Next("3rd")]);
- sink(new Bacon.Next(() => {
- return "This one will be evaluated lazily"
- }));
- sink(new Bacon.Error("oops, an error"));
- sink(new Bacon.End());
- return () => {
- // unsub functionality here, this one's a no-op
- };
- });
- stream.log();
- }
+ Bacon.once(new Bacon.Error("fail"));
- new Bacon.Next("value");
- new Bacon.Next(() => "value");
+ // The following would lead to `1,2,3,1,2,3...` to be repeated indefinitely:
+ Bacon.fromArray([1, new Bacon.Error("")]);
+
+ Bacon.repeatedly(10, [1, 2, 3]);
+
+ // The following will produce values `0,1,2`.
+ Bacon.repeat(i => {
+ if (i < 3) {
+ return Bacon.once(i);
+ } else {
+ return false;
+ }
+ }).log();
+
+ {
+ var stream = Bacon.fromBinder(sink => {
+ sink("first value");
+ sink([new Bacon.Next("2nd"), new Bacon.Next("3rd")]);
+ sink(new Bacon.Next(() => {
+ return "This one will be evaluated lazily"
+ }));
+ sink(new Bacon.Error("oops, an error"));
+ sink(new Bacon.End());
+ return () => {
+ // unsub functionality here, this one's a no-op
+ };
+ });
+ stream.log();
+ }
+
+ new Bacon.Next("value");
+ new Bacon.Next(() => "value");
}
function CommonMethodsInEventStreamsAndProperties() {
- // Converting strings to integers, skipping empty values:
- Bacon.once("").flatMap(text => {
- return text != "" ? parseInt(text) : Bacon.never();
- });
+ // Converting strings to integers, skipping empty values:
+ Bacon.once("").flatMap(text => {
+ return text != "" ? parseInt(text) : Bacon.never();
+ });
- Bacon.sequentially(1, [1, 2, 3]).scan(0, (a, b) => a + b);
+ Bacon.sequentially(1, [1, 2, 3]).scan(0, (a, b) => a + b);
- Bacon.sequentially(1, [1, 2, 3]).diff(0, (a, b) => Math.abs(b - a));
+ Bacon.sequentially(1, [1, 2, 3]).diff(0, (a, b) => Math.abs(b - a));
- // If you have a EventStream `s` with a value sequence `1,2,3,4,5`, the respective values in `s.slidingWindow(2)` would be `[],[1],[1,2],[2,3],[3,4],[4,5]`:
- Bacon.fromArray([1, 2, 3, 4, 5]).slidingWindow(2);
- // The values of `s.slidingWindow(2,2)`would be `[1,2],[2,3],[3,4],[4,5]`:
- Bacon.fromArray([1, 2, 3, 4, 5]).slidingWindow(2, 2);
+ // If you have a EventStream `s` with a value sequence `1,2,3,4,5`, the respective values in `s.slidingWindow(2)` would be `[],[1],[1,2],[2,3],[3,4],[4,5]`:
+ Bacon.fromArray([1, 2, 3, 4, 5]).slidingWindow(2);
+ // The values of `s.slidingWindow(2,2)`would be `[1,2],[2,3],[3,4],[4,5]`:
+ Bacon.fromArray([1, 2, 3, 4, 5]).slidingWindow(2, 2);
- {
- var x = Bacon.fromArray([1, 2]), y = Bacon.fromArray([3, 4]);
- x.zip(y, (x, y) => x + y);
- }
-
- {
- var stream = Bacon.fromArray([1, 2]);
- stream.log("New event in myStream");
- stream.log();
- }
-
- Bacon.fromArray([1, 2, 3]).withStateMachine(0, (sum, event) => {
- if (event.hasValue()) {
- // had to cast to `number` because event:Bacon.Next|Bacon.Error<{}>
- return [sum + event.value(), []];
+ {
+ var x = Bacon.fromArray([1, 2]), y = Bacon.fromArray([3, 4]);
+ x.zip(y, (x, y) => x + y);
}
- else if (event.isEnd()) {
- return [undefined, [new Bacon.Next(sum), event]];
+
+ {
+ var stream = Bacon.fromArray([1, 2]);
+ stream.log("New event in myStream");
+ stream.log();
}
- else {
- return [sum, [event]];
+
+ Bacon.fromArray([1, 2, 3]).withStateMachine(0, (sum, event) => {
+ if (event.hasValue()) {
+ // had to cast to `number` because event:Bacon.Next|Bacon.Error<{}>
+ return [sum + event.value(), []];
+ }
+ else if (event.isEnd()) {
+ return [undefined, [new Bacon.Next(sum), event]];
+ }
+ else {
+ return [sum, [event]];
+ }
+ });
+
+ {
+ var property = Bacon.fromArray([1, 2, 3]).toProperty(),
+ who = Bacon.fromArray(["A", "B", "C"]).toProperty();
+ property.decode({1: "mike", 2: who});
+
+ property.decode({1: {type: "mike"}, 2: {type: "other", whoThen: who}});
}
- });
- {
- var property = Bacon.fromArray([1, 2, 3]).toProperty(),
- who = Bacon.fromArray(["A", "B", "C"]).toProperty();
- property.decode({1: "mike", 2: who});
-
- property.decode({1: {type: "mike"}, 2: {type: "other", whoThen: who}});
- }
-
- {
- // This is handy for keeping track whether we are currently awaiting an AJAX response:
- var ajaxRequest = >{},
- ajaxResponse = >{},
- showAjaxIndicator = ajaxRequest.awaiting(ajaxResponse);
- }
-
- Bacon.fromArray([1, 2, -3, 3]).withHandler(function (event) {
- if (event.hasValue() && event.value() < 0) {
- this.push(new Bacon.Error("Value below zero"));
- return this.push(new Bacon.End());
- } else {
- return this.push(event);
+ {
+ // This is handy for keeping track whether we are currently awaiting an AJAX response:
+ var ajaxRequest = >{},
+ ajaxResponse = >{},
+ showAjaxIndicator = ajaxRequest.awaiting(ajaxResponse);
}
- });
- {
- var src = Bacon.once(1),
- obs = src.map(x => -x);
- console.log(obs.toString()); // > "Bacon.once(1).map(function)"
+ Bacon.fromArray([1, 2, -3, 3]).withHandler(function (event) {
+ if (event.hasValue() && event.value() < 0) {
+ this.push(new Bacon.Error("Value below zero"));
+ return this.push(new Bacon.End());
+ } else {
+ return this.push(event);
+ }
+ });
- obs.withDescription(src, "times", -1);
- console.log(obs.toString()); // > "Bacon.once(1).times(-1)"
- }
+ {
+ var src = Bacon.once(1),
+ obs = src.map(x => -x);
+ console.log(obs.toString()); // > "Bacon.once(1).map(function)"
- {
- // Calculator for grouped consecutive values until group is cancelled:
- var events = [
- {id: 1, type: "add", val: 3},
- {id: 2, type: "add", val: -1},
- {id: 1, type: "add", val: 2},
- {id: 2, type: "cancel"},
- {id: 3, type: "add", val: 2},
- {id: 3, type: "cancel"},
- {id: 1, type: "add", val: 1},
- {id: 1, type: "add", val: 2},
- {id: 1, type: "cancel"}
- ],
- keyF = (event:{id:number}) => event.id,
- limitF = (groupedStream:Bacon.EventStream) => {
- var cancel = groupedStream.filter(x => x.type === "cancel").take(1),
- adds = groupedStream.filter(x => x.type === "add");
- return adds.takeUntil(cancel).map(x => x.val);
- };
+ obs.withDescription(src, "times", -1);
+ console.log(obs.toString()); // > "Bacon.once(1).times(-1)"
+ }
- Bacon.sequentially(2, events)
- .groupBy(keyF, limitF)
- .flatMap(groupedStream => groupedStream.fold(0, (acc, x) => acc + x))
- .onValue(sum => {
- console.log(sum); // returns [-1, 2, 8] in an order
- });
- }
+ {
+ // Calculator for grouped consecutive values until group is cancelled:
+ var events = [
+ {id: 1, type: "add", val: 3},
+ {id: 2, type: "add", val: -1},
+ {id: 1, type: "add", val: 2},
+ {id: 2, type: "cancel"},
+ {id: 3, type: "add", val: 2},
+ {id: 3, type: "cancel"},
+ {id: 1, type: "add", val: 1},
+ {id: 1, type: "add", val: 2},
+ {id: 1, type: "cancel"}
+ ],
+ keyF = (event:{id:number}) => event.id,
+ limitF = (groupedStream:Bacon.EventStream) => {
+ var cancel = groupedStream.filter(x => x.type === "cancel").take(1),
+ adds = groupedStream.filter(x => x.type === "add");
+ return adds.takeUntil(cancel).map(x => x.val);
+ };
+
+ Bacon.sequentially(2, events)
+ .groupBy(keyF, limitF)
+ .flatMap(groupedStream => groupedStream.fold(0, (acc, x) => acc + x))
+ .onValue(sum => {
+ console.log(sum); // returns [-1, 2, 8] in an order
+ });
+ }
}
function EventStream() {
- // This creates the stream which doesn't produce any events and never ends:
- Bacon.interval(1e1, 0).last();
+ // This creates the stream which doesn't produce any events and never ends:
+ Bacon.interval(1e1, 0).last();
- Bacon.fromArray([1, 2, 2, 1])
- .skipDuplicates().log(); // > returns [1, 2, 1] in an order
+ Bacon.fromArray([1, 2, 2, 1])
+ .skipDuplicates().log(); // > returns [1, 2, 1] in an order
- // You might get two events containing [1,2,3,4] and [5,6,7] respectively, given that the flush occurs between numbers 4 and 5:
- Bacon.fromArray([1, 2, 3, 4, 5, 6, 7]).bufferWithTime(0);
+ // You might get two events containing [1,2,3,4] and [5,6,7] respectively, given that the flush occurs between numbers 4 and 5:
+ Bacon.fromArray([1, 2, 3, 4, 5, 6, 7]).bufferWithTime(0);
- // Here's an equivalent to `stream.bufferWithTime(10)`:
- {
- var stream = Bacon.fromArray([1, 2, 3, 4, 5, 6, 7]);
- stream.bufferWithTime(f => {
- setTimeout(f, 10);
- });
- }
+ // Here's an equivalent to `stream.bufferWithTime(10)`:
+ {
+ var stream = Bacon.fromArray([1, 2, 3, 4, 5, 6, 7]);
+ stream.bufferWithTime(f => {
+ setTimeout(f, 10);
+ });
+ }
- // You will get output events with values `[1, 2]`, `[3, 4]` and `[5]`.
- Bacon.fromArray([1, 2, 3, 4, 5]).bufferWithCount(2);
+ // You will get output events with values `[1, 2]`, `[3, 4]` and `[5]`.
+ Bacon.fromArray([1, 2, 3, 4, 5]).bufferWithCount(2);
}
function Property() {
- // This creates the property which doesn't produce any events and never ends:
- Bacon.interval(1e1, 0).toProperty().last();
+ // This creates the property which doesn't produce any events and never ends:
+ Bacon.interval(1e1, 0).toProperty().last();
- {
- var property = Bacon.fromArray([1, 2, 3, 4, 5]).toProperty();
- // If you want to assign your Property to the "disabled" attribute of a JQuery object, you can do this:
- property.assign($("#my-button"), "attr", "disabled");
+ {
+ var property = Bacon.fromArray([1, 2, 3, 4, 5]).toProperty();
+ // If you want to assign your Property to the "disabled" attribute of a JQuery object, you can do this:
+ property.assign($("#my-button"), "attr", "disabled");
- // A simpler example would be to toggle the visibility of an element based on a Property:
- property.assign($("#my-button"), "toggle");
- }
+ // A simpler example would be to toggle the visibility of an element based on a Property:
+ property.assign($("#my-button"), "toggle");
+ }
- Bacon.fromArray([1, 2, 2, 1]).toProperty()
- .skipDuplicates().log(); // > returns [1, 2, 1] in an order
+ Bacon.fromArray([1, 2, 2, 1]).toProperty()
+ .skipDuplicates().log(); // > returns [1, 2, 1] in an order
}
function CombiningMultipleStreamsAndProperties() {
- {
- var property = Bacon.constant(1),
- stream = Bacon.once(2),
- constant = 3;
- Bacon.combineAsArray(property, stream, constant)
- .log(); // > returns [1, 2, 3]
- }
+ {
+ var property = Bacon.constant(1),
+ stream = Bacon.once(2),
+ constant = 3;
+ Bacon.combineAsArray(property, stream, constant)
+ .log(); // > returns [1, 2, 3]
+ }
- {
- // To calculate the current sum of three numeric Properties, you can do:
- var property = Bacon.constant(1),
- stream = Bacon.once(2),
- constant = 3;
- // NOTE: had to explicitly specify the typing for `x:number, y:number, z:number`
- Bacon.combineWith((x:number, y:number, z:number) => x + y + z, property, stream, constant);
- }
+ {
+ // To calculate the current sum of three numeric Properties, you can do:
+ var property = Bacon.constant(1),
+ stream = Bacon.once(2),
+ constant = 3;
+ // NOTE: had to explicitly specify the typing for `x:number, y:number, z:number`
+ Bacon.combineWith((x:number, y:number, z:number) => x + y + z, property, stream, constant);
+ }
- {
- // Assuming you've got streams or properties named `password`, `username`, `firstname` and `lastname`, you can do:
- var password = Bacon.constant("easy"),
- username = Bacon.constant("juha"),
- firstname = Bacon.constant("juha"),
- lastname = Bacon.constant("paananen"),
- // NOTE: you should provide `combineTemplate` typing explicitly!
- loginInfo = Bacon.combineTemplate({
- magicNumber: 3,
- userid: username,
- passwd: password,
- name: {first: firstname, last: lastname}
- }).onValue(loginInfo => {
- // and your new `loginInfo` property will combine values from all these streams using that template, whenever any of the streams/properties get a new value. It would yield a value:
- console.log("`loginInfo` expected", {
- magicNumber: 3,
- userid: "juha",
- passwd: "easy",
- name: {first: "juha", last: "paananen"}
- });
- console.log("`loginInfo` actual", loginInfo);
- });
+ {
+ // Assuming you've got streams or properties named `password`, `username`, `firstname` and `lastname`, you can do:
+ var password = Bacon.constant("easy"),
+ username = Bacon.constant("juha"),
+ firstname = Bacon.constant("juha"),
+ lastname = Bacon.constant("paananen"),
+ // NOTE: you should provide `combineTemplate` typing explicitly!
+ loginInfo = Bacon.combineTemplate({
+ magicNumber: 3,
+ userid: username,
+ passwd: password,
+ name: {first: firstname, last: lastname}
+ }).onValue(loginInfo => {
+ // and your new `loginInfo` property will combine values from all these streams using that template, whenever any of the streams/properties get a new value. It would yield a value:
+ console.log("`loginInfo` expected", {
+ magicNumber: 3,
+ userid: "juha",
+ passwd: "easy",
+ name: {first: "juha", last: "paananen"}
+ });
+ console.log("`loginInfo` actual", loginInfo);
+ });
- // Note that all Bacon.combine* methods produce a `Property` instead of an `EventStream`. If you need the result as an `EventStream` you might want to use `property.changes()`:
- Bacon.combineWith((firstname, lastname) => `${firstname} ${lastname}`, firstname, lastname).changes();
- }
+ // Note that all Bacon.combine* methods produce a `Property` instead of an `EventStream`. If you need the result as an `EventStream` you might want to use `property.changes()`:
+ Bacon.combineWith((firstname, lastname) => `${firstname} ${lastname}`, firstname, lastname).changes();
+ }
- {
- var x = Bacon.fromArray([1, 2, 3]),
- y = Bacon.fromArray([10, 20, 30]),
- z = Bacon.fromArray([100, 200, 300]);
- Bacon.zipAsArray(x, y, z)
- .log(); // > returns values `[1, 10, 100]`, `[2, 20, 200]` and `[3, 30, 300]`
- }
+ {
+ var x = Bacon.fromArray([1, 2, 3]),
+ y = Bacon.fromArray([10, 20, 30]),
+ z = Bacon.fromArray([100, 200, 300]);
+ Bacon.zipAsArray(x, y, z)
+ .log(); // > returns values `[1, 10, 100]`, `[2, 20, 200]` and `[3, 30, 300]`
+ }
- // The following example would log the number 3.
- // NOTE: had to explicitly specify the typing for `a:number, b:number`
- Bacon.onValues(Bacon.constant(1), Bacon.constant(2), (a:number, b:number) => {
- console.log(a + b);
- });
+ // The following example would log the number 3.
+ // NOTE: had to explicitly specify the typing for `a:number, b:number`
+ Bacon.onValues(Bacon.constant(1), Bacon.constant(2), (a:number, b:number) => {
+ console.log(a + b);
+ });
}
function $Event() {
- new Bacon.Next("value");
- new Bacon.Next(() => "value");
+ new Bacon.Next("value");
+ new Bacon.Next(() => "value");
}
function Errors() {
- // In case you want to convert (some) value events into Error events, you may use `flatMap` like this:
- // NOTE: had to explicitly specify the typing for `flatMap`
- Bacon.fromArray([1, 2, 3, 4]).flatMap(x => {
- return x > 2 ? new Bacon.Error("too big") : x;
- });
+ // In case you want to convert (some) value events into Error events, you may use `flatMap` like this:
+ // NOTE: had to explicitly specify the typing for `flatMap`
+ Bacon.fromArray([1, 2, 3, 4]).flatMap(x => {
+ return x > 2 ? new Bacon.Error("too big") : x;
+ });
- // Conversely, if you want to convert some Error events into value events, you may use `flatMapError`:
- Bacon.fromArray([1, 2, 3, 4]).flatMapError(error => {
- var isNonCriticalError = (error:string) => Math.random() < .5,
- handleNonCriticalError = (error:string) => 42;
- return isNonCriticalError(error) ? handleNonCriticalError(error) : new Bacon.Error(error);
- });
+ // Conversely, if you want to convert some Error events into value events, you may use `flatMapError`:
+ Bacon.fromArray([1, 2, 3, 4]).flatMapError(error => {
+ var isNonCriticalError = (error:string) => Math.random() < .5,
+ handleNonCriticalError = (error:string) => 42;
+ return isNonCriticalError(error) ? handleNonCriticalError(error) : new Bacon.Error(error);
+ });
- // Note also that Bacon.js combinators do not catch errors that are thrown. Especially `map` doesn't do so. If you want to map things and wrap caught errors into Error events, you can do the following:
- Bacon.fromArray([1, 2, 3, 4]).flatMap(x => {
- var dangerousFunction = (x:number) => {
- throw new Error("dangerous function!");
- };
- try {
- return dangerousFunction(x);
- } catch (e) {
- return new Bacon.Error(e);
- }
- });
+ // Note also that Bacon.js combinators do not catch errors that are thrown. Especially `map` doesn't do so. If you want to map things and wrap caught errors into Error events, you can do the following:
+ Bacon.fromArray([1, 2, 3, 4]).flatMap(x => {
+ var dangerousFunction = (x:number) => {
+ throw new Error("dangerous function!");
+ };
+ try {
+ return dangerousFunction(x);
+ } catch (e) {
+ return new Bacon.Error(e);
+ }
+ });
- Bacon.once("https://baconjs.github.io/").flatMap(url => {
- // `ajaxCall` gives `Error`s on network or server `Error`s.
- var ajaxCall = (url:string) => {
- return Bacon.fromPromise($.ajax(url));
- };
- return Bacon.retry({
- source: () => ajaxCall(url),
- retries: 5,
- isRetryable: (error:JQueryXHR) => error.status !== 404,
- delay: context => 100 // Just use the same delay always
+ Bacon.once("https://baconjs.github.io/").flatMap(url => {
+ // `ajaxCall` gives `Error`s on network or server `Error`s.
+ var ajaxCall = (url:string) => {
+ return Bacon.fromPromise($.ajax(url));
+ };
+ return Bacon.retry({
+ source: () => ajaxCall(url),
+ retries: 5,
+ isRetryable: (error:JQueryXHR) => error.status !== 404,
+ delay: context => 100 // Just use the same delay always
+ });
});
- });
}
function JoinPatterns() {
- {
- // Consider implementing a game with discrete time ticks. We want to handle key-events synchronized on tick-events, with at most one key event handled per tick. If there are no key events, we want to just process a tick:
- var tick = Bacon.interval(1e2, 0),
- keyEvent = Bacon.fromEvent(document.body, "click", _ => Date.now()),
- handleTick = (_:number) => `timestamp: NONE`,
- handleKeyEvent = (timestamp:number) => `timestamp: ${timestamp}`;
- Bacon.when(
- [tick, keyEvent], (_:number, timestamp:number) => handleKeyEvent(timestamp),
- [tick], handleTick
- );
- // Order is important here. If the [tick] patterns had been written first, this would have been tried first, and preferred at each tick.
- }
+ {
+ // Consider implementing a game with discrete time ticks. We want to handle key-events synchronized on tick-events, with at most one key event handled per tick. If there are no key events, we want to just process a tick:
+ var tick = Bacon.interval(1e2, 0),
+ keyEvent = Bacon.fromEvent(document.body, "click", _ => Date.now()),
+ handleTick = (_:number) => `timestamp: NONE`,
+ handleKeyEvent = (timestamp:number) => `timestamp: ${timestamp}`;
+ Bacon.when(
+ [tick, keyEvent], (_:number, timestamp:number) => handleKeyEvent(timestamp),
+ [tick], handleTick
+ );
+ // Order is important here. If the [tick] patterns had been written first, this would have been tried first, and preferred at each tick.
+ }
- {
- // Join patterns are indeed a generalization of `zip`, and `zip` is equivalent to a single-rule join pattern. The following `Observable`s have the same output:
- var a = Bacon.once("a"),
- b = Bacon.once("b"),
- c = Bacon.once("c"),
- f = (a:string, b:string, c:string) => `a = ${a}; b = ${b}; c = ${c}.`;
- Bacon.zipWith(f, a, b, c);
- Bacon.when([a, b, c], f);
- }
- {
- // The inputs to `Bacon.update` are defined like this:
- var initial = 0,
- x = Bacon.interval(1e3, 1),
- y = Bacon.interval(2e3, 1),
- z = Bacon.interval(1.5e3, 1);
- // NOTE: had to explicitly specify the typing for `previous:number`
- Bacon.update(initial,
- [x, y, z], (previous:number, x:number, y:number, z:number) => previous + x + y + z,
- [x, y], (previous:number, x:number, y:number) => previous + x + y
- );
- // As input, each function above will get the previous value of the `result` Property, along with values from the listed Observables. The value returned by the function will be used as the next value of `result`. Just like in `Bacon.when`, only EventStreams will trigger an update, while Properties will be just sampled. So, if you list a single EventStream and several Properties, the value will be updated only when an event occurs in the EventStream.
- }
- {
- // Here's a simple gaming example:
- var scoreMultiplier = Bacon.constant(1),
- hitUfo = new Bacon.Bus(),
- hitMotherShip = new Bacon.Bus(),
- score = Bacon.update(0,
- [hitUfo, scoreMultiplier], (score:number, _:number, multiplier:number) => score + 100 * multiplier,
- [hitMotherShip], (score:number, _:number) => score + 2000
- );
- // In the example, the `score` property is updated when either `hitUfo` or `hitMotherShip` occur. The `scoreMultiplier` Property is sampled to take multiplier into account when `hitUfo` occurs.
- }
+ {
+ // Join patterns are indeed a generalization of `zip`, and `zip` is equivalent to a single-rule join pattern. The following `Observable`s have the same output:
+ var a = Bacon.once("a"),
+ b = Bacon.once("b"),
+ c = Bacon.once("c"),
+ f = (a:string, b:string, c:string) => `a = ${a}; b = ${b}; c = ${c}.`;
+ Bacon.zipWith(f, a, b, c);
+ Bacon.when([a, b, c], f);
+ }
+ {
+ // The inputs to `Bacon.update` are defined like this:
+ var initial = 0,
+ x = Bacon.interval(1e3, 1),
+ y = Bacon.interval(2e3, 1),
+ z = Bacon.interval(1.5e3, 1);
+ // NOTE: had to explicitly specify the typing for `previous:number`
+ Bacon.update(initial,
+ [x, y, z], (previous:number, x:number, y:number, z:number) => previous + x + y + z,
+ [x, y], (previous:number, x:number, y:number) => previous + x + y
+ );
+ // As input, each function above will get the previous value of the `result` Property, along with values from the listed Observables. The value returned by the function will be used as the next value of `result`. Just like in `Bacon.when`, only EventStreams will trigger an update, while Properties will be just sampled. So, if you list a single EventStream and several Properties, the value will be updated only when an event occurs in the EventStream.
+ }
+ {
+ // Here's a simple gaming example:
+ var scoreMultiplier = Bacon.constant(1),
+ hitUfo = new Bacon.Bus(),
+ hitMotherShip = new Bacon.Bus(),
+ score = Bacon.update(0,
+ [hitUfo, scoreMultiplier], (score:number, _:number, multiplier:number) => score + 100 * multiplier,
+ [hitMotherShip], (score:number, _:number) => score + 2000
+ );
+ // In the example, the `score` property is updated when either `hitUfo` or `hitMotherShip` occur. The `scoreMultiplier` Property is sampled to take multiplier into account when `hitUfo` occurs.
+ }
+ {
+ // Join patterns as a "chemical machine". A quick way to get some intuition for join patterns is to understand them through an analogy in terms of atoms and molecules. A join pattern can here be regarded as a recipe for a chemical reaction. Lets say we have observables `oxygen`, `carbon` and `hydrogen`, where an event in these spawns an 'atom' of that type into a mixture. We can state reactions:
+ let oxygen = Bacon.interval(1e3, "O"),
+ hydrogen = Bacon.interval(2e3, "H"),
+ carbon = Bacon.interval(1.5e3, "C"),
+ makeWater = (oxygen:string, hydrogen1:string, hydrogen2:string) => `${hydrogen1}${[hydrogen1, hydrogen2].length}${oxygen}`,
+ makeCarbonMonoxide = (oxygen:string, carbon:string) => `${carbon}${oxygen}`;
+
+ Bacon.when(
+ [oxygen, hydrogen, hydrogen], makeWater,
+ [oxygen, carbon], makeCarbonMonoxide
+ );
+ // Now, every time a new 'atom' is spawned from one of the observables, this atom is added to the mixture. If at any time there are two hydrogen atoms, and an oxygen atom, the corresponding atoms are *consumed*, and output is produced via `makeWater`. The same semantics apply for the second rule to create carbon monoxide. The rules are tried at each point from top to bottom.
+ }
+}
+
+function JoinPatternsAndProperties() {
+ {
+ // Join patterns and properties
+ //Properties are not part of the synchronization pattern, but are instead just sampled. The following example take three input streams `$price`, `$quantity` and `$total`, e.g. coming from input fields, and defines mutally recursive behaviours in properties `price`, `quantity` and `total` such that
+ // -- updating price sets total to price * quantity;
+ // -- updating quantity sets total to price * quantity;
+ // -- updating total sets price to total / quantity.
+ let random = (x:number) => Math.round(x * Math.random()),
+ id = (x:A):A => x;
+ let $quantity = Bacon.interval(1e3, 10).map(random),
+ $price = Bacon.interval(2e3, 100).map(random),
+ $total = Bacon.interval(1.5e3, 1000).map(random);
+ let quantity = $quantity.toProperty(1),
+ price = Bacon.when(
+ [$price], id,
+ [$total, quantity], (x, y) => x / y
+ ).toProperty(0),
+ total = Bacon.when(
+ [$total], id,
+ [$price, quantity], (x, y) => x * y,
+ [price, $quantity], (x, y) => x * y
+ ).toProperty(0);
+ }
+}
+
+function JoinPatternsAndBaconBus() {
+ {
+ // Join patterns and `Bacon.Bus`
+ // The result functions of join patterns are allowed to push values onto a `Bus` that may in turn be in one of its patterns. For instance, an implementation of the dining philosophers problem can be written as follows:
+ // Availability of chopsticks are implemented using bus.
+ let chopsticks = [new Bacon.Bus(), new Bacon.Bus(), new Bacon.Bus()],
+ // Hungry could be any type of observable, but we'll use bus here.
+ hungry = [new Bacon.Bus(), new Bacon.Bus(), new Bacon.Bus()],
+ // A philosopher eats for one second, then makes the chopsticks available again by pushing values onto their bus.
+ eat = (i:number) => () => {
+ setTimeout(() => {
+ console.log("done!");
+ chopsticks[i].push({});
+ chopsticks[(i + 1) % 3].push({});
+ }, 1e3);
+ return `philosopher ${i} eating`;
+ },
+ // We use Bacon.when to make sure a hungry philosopher can eat only when both his chopsticks are available.
+ dining = Bacon.when(
+ [hungry[0], chopsticks[0], chopsticks[1]], eat(0),
+ [hungry[1], chopsticks[1], chopsticks[2]], eat(1),
+ [hungry[2], chopsticks[2], chopsticks[0]], eat(2)
+ ).log("dining");
+ // Make all chopsticks initially available.
+ chopsticks[0].push({});
+ chopsticks[1].push({});
+ chopsticks[2].push({});
+ // Make philosophers hungry in some way, in this case we just push to their bus.
+ for (var i = 0; i < 3; i++) {
+ hungry[0].push({});
+ hungry[1].push({});
+ hungry[2].push({});
+ }
+ }
}
diff --git a/baconjs/baconjs.d.ts b/baconjs/baconjs.d.ts
index 2021b3dd7b..4717d0e956 100644
--- a/baconjs/baconjs.d.ts
+++ b/baconjs/baconjs.d.ts
@@ -4,2070 +4,2074 @@
// Definitions: https://github.com/borisyankov/DefinitelyTyped
///
-///
+///
///
interface JQuery {
- /**
- * @method
- * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object.
- * @param {string} eventName
- * @returns {EventStream}
- * @example
- * $("#my-div").asEventStream("click");
- */
- asEventStream(eventName:string):Bacon.EventStream;
+ /**
+ * @method
+ * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object.
+ * @param {string} eventName
+ * @returns {EventStream}
+ * @example
+ * $("#my-div").asEventStream("click");
+ */
+ asEventStream(eventName:string):Bacon.EventStream;
- /**
- * @method
- * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a jQuery live `selector`.
- * @param {string} eventName
- * @param {string} selector
- * @returns {EventStream}
- * @example
- * $("#my-div").asEventStream("click", ".more-specific-selector");
- */
- asEventStream(eventName:string, selector:string):Bacon.EventStream;
+ /**
+ * @method
+ * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a jQuery live `selector`.
+ * @param {string} eventName
+ * @param {string} selector
+ * @returns {EventStream}
+ * @example
+ * $("#my-div").asEventStream("click", ".more-specific-selector");
+ */
+ asEventStream(eventName:string, selector:string):Bacon.EventStream;
- /**
- * @callback JQuery#asEventStream1~f
- * @param {JQueryEventObject} event
- * @param {*[]} args
- * @returns {A}
- */
- /**
- * @method JQuery#asEventStream1
- * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a function `f` that processes the jQuery event and its parameters.
- * @param {string} eventName
- * @param {JQuery#asEventStream1~f} f
- * @returns {EventStream}
- * @example
- * $("#my-div").asEventStream("click", (event, args) => args[0]);
- */
- asEventStream(eventName:string, f:(event:JQueryEventObject, args:any[]) => A):Bacon.EventStream;
+ /**
+ * @callback JQuery#asEventStream1~f
+ * @param {JQueryEventObject} event
+ * @param {*[]} args
+ * @returns {A}
+ */
+ /**
+ * @method JQuery#asEventStream1
+ * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a function `f` that processes the jQuery event and its parameters.
+ * @param {string} eventName
+ * @param {JQuery#asEventStream1~f} f
+ * @returns {EventStream}
+ * @example
+ * $("#my-div").asEventStream("click", (event, args) => args[0]);
+ */
+ asEventStream(eventName:string, f:(event:JQueryEventObject, args:any[]) => A):Bacon.EventStream;
- /**
- * @callback JQuery#asEventStream2~f
- * @param {JQueryEventObject} event
- * @param {*[]} args
- * @returns {A}
- */
- /**
- * @method JQuery#asEventStream2
- * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a jQuery live `selector` and a function `f` that processes the jQuery event and its parameters.
- * @param {string} eventName
- * @param {string} selector
- * @param {JQuery#asEventStream2~f} f
- * @returns {Bacon.EventStream}
- * @example
- * $("#my-div").asEventStream("click", ".more-specific-selector", (event, args) => args[0]);
- */
- asEventStream(eventName:string, selector:string, f:(event:JQueryEventObject, args:any[]) => A):Bacon.EventStream;
+ /**
+ * @callback JQuery#asEventStream2~f
+ * @param {JQueryEventObject} event
+ * @param {*[]} args
+ * @returns {A}
+ */
+ /**
+ * @method JQuery#asEventStream2
+ * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a jQuery or Zepto.js object. You can pass an argument to add a jQuery live `selector` and a function `f` that processes the jQuery event and its parameters.
+ * @param {string} eventName
+ * @param {string} selector
+ * @param {JQuery#asEventStream2~f} f
+ * @returns {Bacon.EventStream}
+ * @example
+ * $("#my-div").asEventStream("click", ".more-specific-selector", (event, args) => args[0]);
+ */
+ asEventStream(eventName:string, selector:string, f:(event:JQueryEventObject, args:any[]) => A):Bacon.EventStream;
}
/** @module Bacon */
declare module Bacon {
- /**
- * @function
- * @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the optional `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream.
- * @param {Promise|JQueryXHR} promise
- * @param {boolean} [abort]
- * @returns {EventStream}
- * @example
- * Bacon.fromPromise($.ajax("https://baconjs.github.io/"));
- * Bacon.fromPromise(Promise.resolve(1));
- * Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true);
- * Bacon.fromPromise(Promise.resolve(1), false);
- */
- function fromPromise(promise:Promise|JQueryXHR, abort?:boolean):EventStream;
-
- /**
- * @callback Bacon.fromPromise~eventTransformer
- * @param {A} value
- * @returns {(Initial|Next|End|Error)[]}
- */
- /**
- * @function Bacon.fromPromise
- * @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream, and also pass a function `eventTransformer` that transforms the promise value into Events. The default is to transform the value into `[new Bacon.Next(value), new Bacon.End()]`.
- * @param {Promise|JQueryXHR} promise
- * @param {boolean} abort
- * @param {Bacon.fromPromise~eventTransformer} eventTransformer
- * @returns {EventStream}
- * @example
- * Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true, (n:string) => {
- * return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
- * });
- * Bacon.fromPromise(Promise.resolve(1), false, n => {
- * return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
- * });
- */
- function fromPromise(promise:Promise|JQueryXHR, abort:boolean, eventTransformer:(value:A) => (Initial|Next|End|Error)[]):EventStream;
-
- /**
- * @function
- * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a DOM EventTarget or Node.JS EventEmitter object, or an object that supports event listeners using `on`/`off` methods.
- * @param {EventTarget|NodeJS.EventEmitter|JQuery} target
- * @param {string} eventName
- * @returns {EventStream}
- * @example
- * Bacon.fromEvent(document.body, "click").onValue(() => {
- * alert("Bacon!");
- * });
- * Bacon.fromEvent(process.stdin, "readable", () => {
- * alert("Bacon!");
- * });
- * Bacon.fromEvent($("body"), "click").onValue(() => {
- * alert("Bacon!");
- * });
- */
- function fromEvent(target:EventTarget|NodeJS.EventEmitter|JQuery, eventName:string):EventStream;
-
- /**
- * @callback Bacon.fromEvent~eventTransformer
- * @param {A} event
- * @returns {B}
- */
- /**
- * @function Bacon.fromEvent
- * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a DOM EventTarget or Node.JS EventEmitter object, or an object that supports event listeners using `on`/`off` methods. You can pass a function `eventTransformer` that transforms the emitted events' parameters.
- * @param {EventTarget|NodeJS.EventEmitter|JQuery} target
- * @param {string} eventName
- * @param {Bacon.fromEvent~eventTransformer} eventTransformer
- * @returns {EventStream}
- * @example
- * Bacon.fromEvent(document.body, "click", (event:MouseEvent) => event.clientX).onValue(clientX => {
- * alert("Bacon!");
- * });
- */
- function fromEvent(target:EventTarget|NodeJS.EventEmitter|JQuery, eventName:string, eventTransformer:(event:A) => B):EventStream;
-
- /**
- * @callback Bacon.fromCallback1~f
- * @param {Bacon.fromCallback1~callback} callback
- * @returns {void}
- */
- /**
- * @callback Bacon.fromCallback1~callback
- * @param {...*} args
- * @returns {void}
- */
- /**
- * @function Bacon.fromCallback1
- * @description Creates an [EventStream]{@link Bacon.EventStream} from a function `f` that accepts a `callback`. The function is supposed to call its callback just once.
- * @param {Bacon.fromCallback1~f} f
- * @returns {EventStream}
- * @example
- * // This would create a stream that outputs a single value "Bacon!" and ends after that. The use of setTimeout causes the value to be delayed by 1 second.
- * Bacon.fromCallback(callback => {
- * setTimeout(() => {
- * callback("Bacon!");
- * }, 1000);
- * });
- */
- function fromCallback(f:(callback:(...args:any[]) => void) => void):EventStream;
-
- /**
- * @callback Bacon.fromCallback2~f
- * @param {...*} args
- * @returns {void}
- */
- /**
- * @function Bacon.fromCallback2
- * @description Creates an [EventStream]{@link Bacon.EventStream} from a function `f` that accepts a `callback`. The function is supposed to call its callback just once.
- * @param {Bacon.fromCallback2~f} f
- * @param {...*} args
- * @returns {EventStream}
- * @example
- * // You can also give any number of arguments to `fromCallback`, which will be passed to the function. These arguments can be simple variables, Bacon EventStreams or Properties. For example the following will output "Bacon rules":
- * Bacon.fromCallback((a, b, callback) => {
- * callback(a + " " + b);
- * }, Bacon.constant("bacon"), "rules").log();
- */
- function fromCallback(f:(...args:any[]) => void, ...args:any[]):EventStream;
-
- /**
- * @function
- * @description Creates an [EventStream]{@link Bacon.EventStream} from a `methodName` method of a given `object`. The function is supposed to call its callback just once.
- * @param {Object} object
- * @param {string} methodName
- * @param {...*} args
- * @returns {EventStream}
- */
- function fromCallback(object:Object, methodName:string, ...args:any[]):EventStream;
-
- /**
- * @callback Bacon.fromNodeCallback~f
- * @param {Bacon.fromNodeCallback~callback} callback
- * @returns {void}
- */
- /**
- * @callback Bacon.fromNodeCallback~callback
- * @param {E} error
- * @param {A} data
- * @returns {void}
- */
- /**
- * @function Bacon.fromNodeCallback
- * @description Creates an [EventStream]{@link Bacon.EventStream} from a function `f` that accepts a Node.js `callback`: callback(error, data), where error is `null` if everything is fine. The function is supposed to call its callback just once.
- * @param {Bacon.fromNodeCallback~f} f
- * @param {...*} args
- * @returns {EventStream}
- * @example
- * {
- * let fs = require("fs"),
- * read = Bacon.fromNodeCallback(fs.readFile, "input.txt");
- * read.onError(error => {
- * console.log("Reading failed: " + error);
- * });
- * read.onValue(value => {
- * console.log("Read contents: " + value);
- * });
- * }
- */
- function fromNodeCallback(f:(callback:(error:E, data:A) => void) => void, ...args:any[]):EventStream;
-
- /**
- * @function
- * @description Creates an [EventStream]{@link Bacon.EventStream} from a `methodName` method of a given `object`.
- * @param {Object} object
- * @param {string} methodName
- * @param {...*} args
- * @returns {EventStream}
- */
- function fromNodeCallback(object:Object, methodName:string, ...args:any[]):EventStream;
-
- /**
- * @callback Bacon.fromPoll~f
- * @returns {Next|End}
- */
- /**
- * @function Bacon.fromPoll
- * @description Polls given function `f` with given `interval`. Function should return events: either [Next]{@link Bacon.Next} or [End]{@link Bacon.End}. Polling occurs only when there are subscribers to the stream. Polling ends permanently when `f` returns [End]{@link Bacon.End}.
- * @param {number} interval
- * @param {Bacon.fromPoll~f} f
- * @returns {EventStream}
- */
- function fromPoll(interval:number, f:() => Next|End):EventStream;
-
- /**
- * @function Bacon.once
- * @description Creates an [EventStream]{@link Bacon.EventStream} that delivers the given single `value` for the first subscriber. The stream will end immediately after this value. You can also send an [Error]{@link Bacon.Error} event instead of a `value`.
- * @param {A|Error} value
- * @returns {EventStream}
- * @example
- * Bacon.once(new Bacon.Error("fail"));
- */
- function once(value:A|Error):EventStream;
-
- /**
- * @function
- * @description Creates an [EventStream]{@link Bacon.EventStream} that delivers the given series of `values` (given as array) to the first subscriber. The stream ends after these values have been delivered. You can also send [Error]{@link Bacon.Error} events, or any combination of pure values and error events.
- * @param {(A|Error)[]} values
- * @returns {EventStream}
- * @example
- * Bacon.fromArray([1, new Bacon.Error("")]);
- */
- function fromArray(values:(A|Error)[]):EventStream;
-
- /**
- * @function
- * @description Repeats the single `value` indefinitely with the given `interval` (in milliseconds).
- * @param {number} interval
- * @param {A} value
- * @returns {EventStream}
- */
- function interval(interval:number, value:A):EventStream;
-
- /**
- * @function
- * @description Creates a [EventStream]{@link Bacon.EventStream} containing given `values` (given as array) with the given `interval` (in milliseconds).
- * @param {number} interval
- * @param {A[]} values
- * @returns {EventStream}
- */
- function sequentially(interval:number, values:A[]):EventStream;
-
- /**
- * @function
- * @description Repeats given `values` indefinitely with then given `interval` (in milliseconds).
- * @param {number} interval
- * @param {A[]} values
- * @returns {EventStream}
- * @example
- * // The following would lead to `1,2,3,1,2,3...` to be repeated indefinitely:
- * Bacon.fromArray([1, new Bacon.Error("")]);
- */
- function repeatedly(interval:number, values:A[]):EventStream;
-
- /**
- * @callback Bacon.repeat~f
- * @param {number} iteration
- * @returns {boolean|Observable}
- */
- /**
- * @function Bacon.repeat
- * @description Calls generator function `f` which is expected to return an [Observable]{@link Bacon.Observable}. The returned [EventStream]{@link Bacon.EventStream} contains values and errors from the spawned observable. When the spawned Observable ends, the generator `f` is called again to spawn a new Observable. This is repeated until the generator `f` returns a falsy value (such as `undefined` or `false`). The generator `f` is called with one argument — `iteration` number starting from `0`.
- * @param {Bacon.repeat~f} f
- * @returns {EventStream}
- * @example
- * // The following will produce values `0,1,2`.
- * Bacon.repeat(i => {
- * if (i < 3) {
- * return Bacon.once(i);
- * } else {
- * return false;
- * }
- * }).log();
- */
- function repeat(f:(iteration:number) => boolean|Observable):EventStream;
-
- /**
- * @function Bacon.never
- * @description Creates an [EventStream]{@link Bacon.EventStream} that immediately ends.
- * @returns {EventStream}
- */
- function never():EventStream;
-
- /**
- * @function
- * @description Creates a single-element [EventStream]{@link Bacon.EventStream} that produces given `value` after a given `delay` (in milliseconds).
- * @param {number} delay
- * @param {A} value
- * @returns {EventStream}
- */
- function later(delay:number, value:A):EventStream;
-
- /**
- * @function
- * @description Creates a constant [Property]{@link Bacon.Property} with value `x`.
- * @param {A} x
- * @returns {Property}
- */
- function constant(x:A):Property;
-
- /**
- * @callback Bacon.fromBinder~subscribe
- * @param {Bacon.fromBinder~sink} sink
- * @returns {Bacon.fromBinder~unsubscribe}
- */
- /**
- * @callback Bacon.fromBinder~sink
- * @param {More|NoMore|(A|Initial|Next|End|Error)|(A|Initial|Next|End|Error)[]} value
- * @returns {void}
- */
- /**
- * @callback Bacon.fromBinder~unsubscribe
- * @returns {void}
- */
- /**
- * @function Bacon.fromBinder
- * @description Creates an [EventStream]{@link Bacon.EventStream} with the given [subscribe]{@link Bacon.fromBinder~subscribe} function. The parameter `subscribe` is a function that accepts a [sink]{@link Bacon.fromBinder~sink} which is a function that your `subscribe` function can "push" events to. You can push: a plain value, like `"first value"`; an [Event]{@link Bacon.Event} object including [Error]{@link Bacon.Error} (wraps an error) and [End]{@link Bacon.End} (indicates stream end); an array of event objects at once. The `subscribe` function must return a function. Let's call that function [unsubscribe]{@link Bacon.fromBinder~unsubscribe}. The returned function can be used by the subscriber (directly or indirectly) to unsubscribe from the EventStream. It should release all resources that the `subscribe` function reserved. The `sink` function may return [noMore]{@link Bacon.noMore} (as well as [more]{@link Bacon.more} or any other value). If it returns `noMore`, no further events will be consumed by the subscriber. The `subscribe` function may choose to clean up all resources at this point (e.g., by calling `unsubscribe`). This is usually not necessary, because further calls to `sink` are ignored, but doing so can increase performance in rare cases. The EventStream will wrap your `subscribe` function so that it will only be called when the first stream listener is added, and the `unsubscribe` function is called only after the last listener has been removed. The subscribe-unsubscribe cycle may of course be repeated indefinitely, so prepare for multiple calls to the `subscribe` function.
- * @param {Bacon.fromBinder~subscribe} subscribe
- * @returns {EventStream}
- * @example
- * let stream = Bacon.fromBinder(sink => {
- * sink("first value");
- * sink([new Bacon.Next("2nd"), new Bacon.Next("3rd")]);
- * sink(new Bacon.Next(() => {
- * return "This one will be evaluated lazily"
- * }));
- * sink(new Bacon.Error("oops, an error"));
- * sink(new Bacon.End());
- * return () => {
- * // unsub functionality here, this one's a no-op
- * };
- * });
- * stream.log();
- */
- function fromBinder(subscribe:(sink:(value:More|NoMore|(A|Initial|Next|End|Error)|(A|Initial|Next|End|Error)[]) => void) => (() => void)):EventStream;
-
- /**
- * @interface
- * @see Bacon.more
- */
- interface More {
- }
- /**
- * @property more
- * @constant
- * @description The opaque value `sink` function may return. See [Bacon.fromBinder]{@link Bacon.fromBinder}.
- */
- var more:More;
-
- /**
- * @interface
- * @see Bacon.noMore
- */
- interface NoMore {
- }
- /**
- * @property noMore
- * @constant
- * @description The opaque value `sink` function may return. See [Bacon.fromBinder]{@link Bacon.fromBinder}.
- */
- var noMore:NoMore;
-
- /**
- * @class Observable
- * @description A superclass for [EventStream]{@link Bacon.EventStream} and [Property]{@link Bacon.Property}.
- * */
- interface Observable {
/**
- * @callback Observable#onValue~f
- * @param {A} value
- * @returns {void}
- */
- /**
- * @callback Observable#onValue~unsubscribe
- * @returns {void}
- */
- /**
- * @method Observable#onValue
- * @description Subscribes a given handler function `f` to the [Observable]{@link Bacon.Observable}. Function will be called for each new value. This is the simplest way to assign a side-effect to an Observable. The difference to the [EventStream.subscribe]{@link Bacon.EventStream#subscribe} and [Property.subscribe]{@link Bacon.Property#subscribe} methods is that the actual stream `value`s are received, instead of [Event]{@link Bacon.Event} objects. [EventStream.onValue]{@link Bacon.EventStream#onValue} and [Property.onValue]{@link Bacon.Property#onValue} behave similarly, except that the latter also pushes the initial value of the Property, in case there is one.
- * @param {Observable#onValue~f} f
- * @returns {Observable#onValue~unsubscribe}
- */
- onValue(f:(value:A) => void):() => void;
-
- /**
- * @callback Observable#onError~f
- * @param {E} error
- * @returns {void}
- */
- /**
- * @callback Observable#onError~unsubscribe
- * @returns {void}
- */
- /**
- * @method Observable#onError
- * @description Subscribes a given handler function `f` to [Error]{@link Bacon.Error} events. The function `f` will be called for each error in the [Observable]{@link Bacon.Observable}.
- * @param {Observable#onError~f} f
- * @returns {Observable#onError~unsubscribe}
- */
- onError(f:(error:E) => void):() => void;
-
- /**
- * @callback Observable#onEnd~f
- * @returns {void}
- */
- /**
- * @callback Observable#onEnd~unsubscribe
- * @returns {void}
- */
- /**
- * @method Observable#onEnd
- * @description Subscribes a given handler function `f` to [End]{@link Bacon.End} event. The function `f` will be called when the [Observable]{@link Bacon.Observable} ends. Just like [EventStream.subscribe]{@link Bacon.EventStream#subscribe} and [Property.subscribe]{@link Bacon.Property#subscribe}, this method returns a function for `unsubscribe`ing.
- * @param {Observable#onEnd~f} f
- * @returns {Observable#onEnd~unsubscribe}
- */
- onEnd(f:() => void):() => void;
-
- /**
- * @callback Observable#toPromise~promiseCtr
- * @param {A} value
- * @returns {Promise}
- */
- /**
- * @method Observable#toPromise
- * @description Returns a Promise which will be resolved with the last event coming from an [Observable]{@link Bacon.Observable}. The global ES6 promise implementation will be used unless a promise constructor `promiseCtr` is given. Use a shim if you need to support legacy browsers or platforms.
- * @param {Observable#toPromise~promiseCtr} [promiseCtr]
- * @returns {Promise}
- */
- toPromise(promiseCtr?:(value:A) => Promise):Promise;
-
- /**
- * @callback Observable#firstToPromise~promiseCtr
- * @param {A} value
- * @returns {Promise}
- */
- /**
- * @method Observable#firstToPromise
- * @description Returns a Promise which will be resolved with the first event coming from an [Observable]{@link Bacon.Observable}. Like [Observable.toPromise]{@link Bacon.Observable#toPromise}, the global ES6 promise implementation will be used unless a promise constructor `promiseCtr` is given.
- * @param {Observable#firstToPromise~promiseCtr} [promiseCtr]
- * @returns {Promise}
- */
- firstToPromise(promiseCtr?:(value:A) => Promise):Promise;
-
- /**
- * @method
- * @description Throttles the [Observable]{@link Bacon.Observable} using a buffer so that at most one value event in `minimumInteval` is issued. Unlike [EventStream.throttle]{@link Bacon.EventStream#throttle} and [Property.throttle]{@link Bacon.Property#throttle}, it doesn't discard the excessive events but buffers them instead, outputting them with a rate of at most one value per `minimumInterval`.
- * @param {number} minimumInterval
+ * @function
+ * @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the optional `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream.
+ * @param {Promise|JQueryXHR} promise
+ * @param {boolean} [abort]
* @returns {EventStream}
+ * @example
+ * Bacon.fromPromise($.ajax("https://baconjs.github.io/"));
+ * Bacon.fromPromise(Promise.resolve(1));
+ * Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true);
+ * Bacon.fromPromise(Promise.resolve(1), false);
*/
- bufferingThrottle(minimumInterval:number):EventStream;
+ function fromPromise(promise:Promise|JQueryXHR, abort?:boolean):EventStream;
/**
- * @callback Observable#flatMap~f
+ * @callback Bacon.fromPromise~eventTransformer
* @param {A} value
- * @returns {B|Initial|Next|End|Error|Observable}
+ * @returns {(Initial|Next|End|Error)[]}
*/
/**
- * @method Observable#flatMap
- * @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of [flatMap]{@link Bacon.Observable#flatMap} is always an EventStream. The "Function Construction rules" apply here. `flatMap` can be used conveniently with [Bacon.once]{@link Bacon.once} and [Bacon.never]{@link Bacon.never} for converting and filtering at the same time, including only some of the results.
- * @param {Observable#flatMap~f} f
+ * @function Bacon.fromPromise
+ * @description Creates an [EventStream]{@link Bacon.EventStream} from a `promise` Promise object such as JQuery Ajax. This stream will contain a single value or an error, followed immediately by stream end. You can use the `abort` flag (i.e. ´Bacon.fromPromise(p, true)´ to have the `abort` method of the given promise be called when all subscribers have been removed from the created stream, and also pass a function `eventTransformer` that transforms the promise value into Events. The default is to transform the value into `[new Bacon.Next(value), new Bacon.End()]`.
+ * @param {Promise|JQueryXHR} promise
+ * @param {boolean} abort
+ * @param {Bacon.fromPromise~eventTransformer} eventTransformer
* @returns {EventStream}
* @example
- * // Converting strings to integers, skipping empty values:
- * Bacon.once("").flatMap(text => {
- * return text != "" ? parseInt(text) : Bacon.never();
+ * Bacon.fromPromise($.ajax("https://baconjs.github.io/"), true, (n:string) => {
+ * return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
+ * });
+ * Bacon.fromPromise(Promise.resolve(1), false, n => {
+ * return [new Bacon.Next(n), new Bacon.Next(() => n), new Bacon.End()];
* });
*/
- flatMap(f:(value:A) => B|Initial|Next|End|Error|Observable):EventStream;
+ function fromPromise(promise:Promise|JQueryXHR, abort:boolean, eventTransformer:(value:A) => (Initial|Next|End|Error)[]):EventStream;
/**
- * @callback Observable#flatMapLatest~f
- * @param {A} value
- * @returns {B|Initial|Next|End|Error|Observable}
- */
- /**
- * @method Observable#flatMapLatest
- * @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, but instead of including events from all spawned streams, only includes them from the latest spawned stream into the result [EventStream]{@link Bacon.EventStream}. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of [flatMapLatest]{@link Bacon.Observable#flatMapLatest} is always an EventStream.
- * @param {Observable#flatMapLatest~f} f
- * @returns {EventStream}
- */
- flatMapLatest(f:(value:A) => B|Initial|Next|End|Error|Observable):EventStream;
-
- /**
- * @callback Observable#flatMapFirst~f
- * @param {A} value
- * @returns {B|Initial|Next|End|Error|Observable}
- */
- /**
- * @method Observable#flatMapFirst
- * @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f` only if the previously spawned stream has ended, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of [flatMapFirst]{@link Bacon.Observable#flatMapFirst} is always an EventStream.
- * @param {Observable#flatMapFirst~f} f
- * @returns {EventStream}
- */
- flatMapFirst(f:(value:A) => B|Initial|Next|End|Error|Observable):EventStream;
-
- /**
- * @callback Observable#flatMapError~f
- * @param {E} error
- * @returns {B|Initial|Next|End|Error|Observable}
- */
- /**
- * @method Observable#flatMapError
- * @description For each [Error]{@link Bacon.Error} event in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of [flatMapError]{@link Bacon.Observable#flatMapError} is always an EventStream.
- * @param {Observable#flatMapError~f} f
- * @returns {EventStream}
- */
- flatMapError(f:(error:E) => B|Initial|Next|End|Error|Observable):EventStream;
-
- /**
- * @callback Observable#flatMapWithConcurrencyLimit~f
- * @param {A} value
- * @returns {B|Initial|Next|End|Error|Observable}
- */
- /**
- * @method Observable#flatMapWithConcurrencyLimit
- * @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}, but limit the number of open spawned streams and buffers incoming events by `limit` amount. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. [flatMapConcat]{@link Bacon.Observable#flatMapConcat} is [flatMapWithConcurrencyLimit]{@link Bacon.Observable#flatMapWithConcurrencyLimit}(1) (only one input active), and [flatMap]{@link Bacon.Observable#flatMap} is [flatMapWithConcurrencyLimit]{@link Bacon.Observable#flatMapWithConcurrencyLimit}(∞) (all inputs are piped to output). The result of `flatMapWithConcurrencyLimit` is always an EventStream.
- * @param {number} limit
- * @param {Observable#flatMapWithConcurrencyLimit~f} f
- * @returns {EventStream}
- */
- flatMapWithConcurrencyLimit(limit:number, f:(value:A) => B|Initial|Next|End|Error|Observable):EventStream;
-
- /**
- * @callback Observable#flatMapConcat~f
- * @param {A} value
- * @returns {B|Initial|Next|End|Error|Observable}
- */
- /**
- * @method Observable#flatMapConcat
- * @description For each element in the source [Observable]{@link Bacon.Observable}, spawn a new stream using the function `f`, and collect events from each of the spawned streams into the result [EventStream]{@link Bacon.EventStream}, but limit the number of open spawned streams and buffers incoming events to 1. The return value of function `f` can be either an Observable (EventStream/[Property]{@link Bacon.Property}) or a constant value. The result of `flatMapConcat` is always an EventStream.
- * @param {Observable#flatMapConcat~f} f
- * @returns {EventStream}
- */
- flatMapConcat(f:(value:A) => B|Initial|Next|End|Error|Observable):EventStream;
-
- /**
- * @callback Observable#scan~f
- * @param {B} acc
- * @param {A} next
- * @returns {B}
- */
- /**
- * @method Observable#scan
- * @description Scans [Observable]{@link Bacon.Observable} with given `seed` value and accumulator function `f`, resulting to a [Property]{@link Bacon.Property}. For example, you might use zero as `seed` and a "plus" function as the accumulator to create an "integral" Property. When applied to a Property as in `r = p.scan(seed, f)`, there's a (hopefully insignificant) catch: the starting value for `r` depends on whether `p` has an initial value when `scan` is applied. If there's no initial value, this works identically to `[EventStream]{@link Bacon.EventStream}.scan`: the `seed` will be the initial value of `r`. However, if `r` already has a current/initial value `x`, the seed won't be output as is. Instead, the initial value of `r` will be `f(seed, x)`. This makes sense, because there can only be 1 initial value for a Property at a time.
- * @param {B} seed
- * @param {Observable#scan~f} f
- * @returns {Property}
+ * @function
+ * @description Creates an [EventStream]{@link Bacon.EventStream} from events on a DOM EventTarget or Node.JS EventEmitter object, or an object that supports event listeners using `on`/`off` methods.
+ * @param {EventTarget|NodeJS.EventEmitter|JQuery} target
+ * @param {string} eventName
+ * @returns {EventStream}
* @example
- * Bacon.sequentially(1, [1, 2, 3]).scan(0, (a, b) => a + b);
- */
- scan(seed:B, f:(acc:B, next:A) => B):Property;
-
- /**
- * @callback Observable#fold~f
- * @param {B} acc
- * @param {A} next
- * @returns {B}
- */
- /**
- * @method Observable#fold
- * @description Scans [Observable]{@link Bacon.Observable} with given `seed` value and accumulator function `f`, but only emits the final value, i.e. the value just before the Observable ends. Returns a [Property]{@link Bacon.Property}.
- * @param {B} seed
- * @param {Observable#fold~f} f
- * @returns {Property}
- */
- fold(seed:B, f:(acc:B, next:A) => B):Property;
-
- /**
- * @callback Observable#reduce~f
- * @param {B} acc
- * @param {A} next
- * @returns {B}
- */
- /**
- * @method Observable#reduce
- * @description Scans [Observable]{@link Bacon.Observable} with given `seed` value and accumulator function `f`, but only emits the final value, i.e. the value just before the Observable ends. Returns a [Property]{@link Bacon.Property}.
- * @param {B} seed
- * @param {Observable#reduce~f} f
- * @returns {Property}
- */
- reduce(seed:B, f:(acc:B, next:A) => B):Property;
-
- /**
- * @callback Observable#diff~f
- * @param {A} a
- * @param {B} b
- * @returns {B}
- */
- /**
- * @method Observable#diff
- * @description Returns a [Property]{@link Bacon.Property} that represents the result of a comparison `f` between the previous and current value of the [Observable]{@link Bacon.Observable}. For the initial value of the Observable, the previous value will be the given `start`.
- * @param {A} start
- * @param {Observable#diff~f} f
- * @returns {Property}
- * @example
- * Bacon.sequentially(1, [1, 2, 3]).diff(0, (a, b) => Math.abs(b - a));
- */
- diff(start:A, f:(a:A, b:A) => B):Property;
-
- /**
- * @callback Observable#zip~f
- * @param {A} a
- * @param {B} b
- * @returns {C}
- */
- /**
- * @method Observable#zip
- * @description Returns an [EventStream]{@link Bacon.EventStream} with elements pair-wise lined up with events from this and the `other` EventStream. A zipped EventStream will publish only when it has a value from each EventStream and will only produce values up to when any single EventStream ends. The given function `f` is used to create the result value from value in the two source EventStream. If no function `f` is given, the values are zipped into an array. Be careful not to have too much "drift" between streams. If one stream produces many more values than some other excessive buffering will occur inside the zipped observable.
- * @param {EventStream