diff --git a/.gitignore b/.gitignore
index 2a52c95e0..35dd5a667 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,37 +1,37 @@
-*.dll
-*.exe
-*.cmd
-*.pdb
-*.suo
-*.js
-*.user
-*.cache
-*.cs
-*.sln
-*.csproj
-*.txt
-*.map
-*.swp
-.DS_Store
-npm-debug.log
-
-_Resharper.DefinitelyTyped
-bin
-obj
-Properties
-
-# VIM backup files
-*~
-
-# test folder
-_infrastructure/tests/build
-
-.idea
-*.iml
-*.js.map
-!*.js/
-
-node_modules
-
-.sublimets
-.settings/launch.json
+*.dll
+*.exe
+*.cmd
+*.pdb
+*.suo
+*.js
+*.user
+*.cache
+*.cs
+*.sln
+*.csproj
+*.txt
+*.map
+*.swp
+.DS_Store
+npm-debug.log
+
+_Resharper.DefinitelyTyped
+bin
+obj
+Properties
+
+# VIM backup files
+*~
+
+# test folder
+_infrastructure/tests/build
+
+.idea
+*.iml
+*.js.map
+!*.js/
+
+node_modules
+
+.sublimets
+.settings/launch.json
diff --git a/Finch/Finch-tests.ts b/Finch/Finch-tests.ts
index 28aeb6b66..ec15bcb88 100644
--- a/Finch/Finch-tests.ts
+++ b/Finch/Finch-tests.ts
@@ -1,368 +1,368 @@
-///
-
-function test_Finch() {
-
-
- Finch.route("Hello/Route", function() {
- return console.log("Well hello there! How you doin'?!");
- });
-
- Finch.route("Hello/Route/:someId", function(bindings) {
- return console.log("Hey! Here's Some Id: " + bindings.someId);
- });
-
- Finch.route("Hello/Route/:someId", function(bindings, childCallback) {
- console.log("Hey! Here's Some Id: " + bindings.someId);
- return childCallback();
- });
-
- Finch.route("some/route", {
- setup: function(bindings) {
- return console.log("Some Route has been setup! :)");
- },
- load: function(bindings) {
- return console.log("Some Route has been loaed! :D");
- },
- unload: function(bindings) {
- return console.log("Some Route has been loaed! :(");
- },
- teardown: function(bindings) {
- return console.log("Some Route has been torndown! :'(");
- }
- });
-
- Finch.route("some/route", {
- setup: function(bindings, childCallback) {
- console.log("Some Route has been setup! :)");
- return childCallback();
- },
- load: function(bindings, childCallback) {
- console.log("Some Route has been loaed! :D");
- return childCallback();
- },
- unload: function(bindings, childCallback) {
- console.log("Some Route has been loaed! :(");
- return childCallback();
- },
- teardown: function(bindings, childCallback) {
- console.log("Some Route has been torndown! :'(");
- return childCallback();
- }
- });
-
- Finch.call("Some/Route");
-
- Finch.route("Some/Route", function() {
- return Finch.observe("hello", "foo", function(hello: any, foo: string) {
- return console.log("" + hello + " and " + foo);
- });
- });
-
- Finch.route("Some/Route", function() {
- return Finch.observe(["hello", "foo"], function(hello: any, foo: any) {
- return console.log("" + hello + " and " + foo);
- });
- });
-
- Finch.route("Some/Route", function(bindings) {
- return Finch.observe(function(params) {
- });
- });
-
- Finch.navigate("Some/Route");
-
- Finch.navigate("Some/Route", {
- hello: 'world',
- foo: 'bar'
- });
-
- Finch.navigate("Some/Route", {
- foo: 'bar'
- }, true);
-
- Finch.navigate("Some/Route", true);
-
- Finch.navigate({
- hello: 'world2',
- wow: 'wee'
- });
-
- Finch.navigate({
- foo: 'bar',
- wow: 'wee!!!'
- });
-
- Finch.navigate({
- hello: 'world2'
- }, true);
-
- Finch.listen();
- Finch.ignore();
- Finch.abort();
-
-
- //test from Finch
- Finch.call("/foo/bar");
- Finch.call("/foo/bar/123");
- Finch.call("/foo/bar/123");
- Finch.call("/foo/bar/123?x=Hello&y=World");
- Finch.call("/foo/baz/456");
- Finch.call("/quux/789?band=Sunn O)))&genre=Post-Progressive Fridgecore");
- Finch.call("/foo/bar/baz");
- Finch.call("/foo/bar/quux");
- Finch.call("/foo");
- Finch.call("/foo/bar");
- Finch.call("/foo");
- Finch.call("/foo");
- Finch.call("/");
- Finch.call("/");
- Finch.call("/foo");
- Finch.call("/foo/bar");
- Finch.call("/foo/bar?baz=quux");
- Finch.call("/foo/bar?baz=xyzzy");
-
- var cb: any;
- Finch.route("foo", {
- setup: cb.setup_foo = this.stub(),
- load: cb.load_foo = this.stub(),
- unload: cb.unload_foo = this.stub(),
- teardown: cb.teardown_foo = this.stub()
- });
- Finch.route("[foo]/bar", {
- setup: cb.setup_foo_bar = this.stub(),
- load: cb.load_foo_bar = this.stub(),
- unload: cb.unload_foo_bar = this.stub(),
- teardown: cb.teardown_foo_bar = this.stub()
- });
- Finch.route("[foo/bar]/:id", {
- setup: cb.setup_foo_bar_id = this.stub(),
- load: cb.load_foo_bar_id = this.stub(),
- unload: cb.unload_foo_bar_id = this.stub(),
- teardown: cb.teardown_foo_bar_id = this.stub()
- });
- Finch.route("[foo]/baz", {
- setup: cb.setup_foo_baz = this.stub(),
- load: cb.load_foo_baz = this.stub(),
- unload: cb.unload_foo_baz = this.stub(),
- teardown: cb.teardown_foo_baz = this.stub()
- });
- Finch.route("[foo/baz]/:id", {
- setup: cb.setup_foo_baz_id = this.stub(),
- load: cb.load_foo_baz_id = this.stub(),
- unload: cb.unload_foo_baz_id = this.stub(),
- teardown: cb.teardown_foo_baz_id = this.stub()
- });
- Finch.call("/foo");
- Finch.call("/foo/bar");
- Finch.call("/foo");
- Finch.call("/foo/bar/123?x=abc");
- Finch.call("/foo/bar/456?x=aaa&y=zzz");
- Finch.call("/foo/bar/456?x=bbb&y=zzz");
- Finch.call("/foo/bar/456?y=zzz&x=bbb");
- Finch.call("/foo/baz/789");
- Finch.call("/foo/baz/abc?term=Hello");
- Finch.call("/foo/baz/abc?term=World");
- Finch.route("bar", this.stub());
- Finch.call("/foo");
- Finch.call("/bar");
- Finch.route("/", function() {
- });
- Finch.route("[/]home", function() {
- });
- Finch.route("[/home]/news", {
- setup: function() {
- },
- load: function() {
- },
- unload: function() {
- return true;
- },
- teardown: function() {
- return false;
- }
- });
- Finch.route("/foo", {
- setup: function() {
- return true;
- },
- load: function() {
- return true;
- },
- unload: function() {
- },
- teardown: function() {
- }
- });
- Finch.route("[/]bar", {
- setup: function() {
- },
- load: function() {
- },
- unload: function() {
- },
- teardown: function() {
- }
- });
- Finch.call("/bar");
- Finch.call("/home/news");
- Finch.call("/foo");
- Finch.call("/home/news");
- Finch.call("/bar");
- Finch.route("baz", this.stub());
- Finch.call("/foo");
- Finch.call("/foo/bar");
- Finch.call("/baz");
- Finch.route("/home", {
- setup: function(bindings, next) {
- return next();
- },
- load: function(bindings, next) {
- return next();
- },
- unload: function(bindings, next) {
- return next();
- },
- teardown: function(bindings, next) {
- return next();
- }
- });
- Finch.route("[/home]/news", {
- setup: function(bindings, next) {
- return next();
- },
- load: function(bindings, next) {
- return next();
- },
- unload: function(bindings, next) {
- return next();
- },
- teardown: function(bindings, next) {
- return next();
- }
- });
- Finch.call("/home");
- Finch.call("/home/news");
- Finch.call("/foo");
-
- Finch.route("/", function(bindings) {
- return Finch.observe(["x"], function(x) {
- });
- });
- Finch.call("/?x=123");
- Finch.call("/?x=123.456");
- Finch.call("/?x=true");
- Finch.call("/?x=false");
- Finch.call("/?x=stuff");
- Finch.options({
- CoerceParameterTypes: true
- });
- Finch.call("/?x=123");
- Finch.call("/?x=123.456");
- Finch.call("/?x=true");
- Finch.call("/?x=false");
- Finch.call("/?x=stuff");
- Finch.route("/:x", function(_arg) {
- });
- Finch.call("/123");
- Finch.call("/123.456");
- Finch.call("/true");
- Finch.call("/false");
- Finch.call("/stuff");
- Finch.options({
- CoerceParameterTypes: true
- });
- Finch.call("/123");
- Finch.call("/123.456");
- Finch.call("/true");
- Finch.call("/false");
- Finch.call("/stuff");
-
- Finch.navigate("/home");
- Finch.navigate("/home/news");
- Finch.navigate("/home");
- Finch.navigate("/home", {
- foo: "bar"
- });
- Finch.navigate("/home", {
- hello: "world"
- });
- Finch.navigate({
- foos: "bars"
- });
- Finch.navigate({
- foos: "baz"
- });
- Finch.navigate({
- hello: "world"
- }, true);
- Finch.navigate({
- foos: null
- }, true);
- Finch.navigate("/home/news", true);
- Finch.navigate("/hello world", {});
- Finch.navigate("/hello world", {
- foo: "bar bar"
- });
- Finch.navigate({
- foo: "baz baz"
- });
- Finch.navigate({
- hello: 'world world'
- }, true);
- Finch.navigate("/home?foo=bar", {
- hello: "world"
- });
- Finch.navigate("/home?foo=bar", {
- hello: "world",
- foo: "baz"
- });
- Finch.navigate("/home?foo=bar", {
- hello: "world",
- free: "bird"
- });
- Finch.navigate("#/home", true);
- Finch.navigate("#/home");
- Finch.navigate("#/home/news", {
- free: "birds",
- hello: "worlds"
- });
- Finch.navigate("#/home/news", {
- foo: "bar"
- }, true);
- Finch.navigate("/home/news");
- Finch.navigate("../");
- Finch.navigate("./");
- Finch.navigate("./news");
- Finch.navigate("/home/news/article");
- Finch.navigate("../../account");
-
- Finch.listen();
- Finch.ignore();
- Finch.route("/home", function(bindings, continuation) {
- });
- Finch.route("/foo", function(bindings, continuation) {
- });
- Finch.call("home");
- Finch.call("foo");
- Finch.abort();
- Finch.call("foo");
- Finch.route("/", {
- 'setup': cb.slash_setup = this.stub(),
- 'load': cb.slash_load = this.stub(),
- 'unload': cb.slash_unload = this.stub(),
- 'teardown': cb.slash_teardown = this.stub()
- });
- Finch.route("[/]users/profile", {
- 'setup': cb.profile_setup = this.stub(),
- 'load': cb.profile_load = this.stub(),
- 'unload': cb.profile_unload = this.stub(),
- 'teardown': cb.profile_teardown = this.stub()
- });
- Finch.route("[/]:page", {
- 'setup': cb.page_setup = this.stub(),
- 'load': cb.page_load = this.stub(),
- 'unload': cb.page_unload = this.stub(),
- 'teardown': cb.page_teardown = this.stub()
- });
- Finch.call("/users");
-}
+///
+
+function test_Finch() {
+
+
+ Finch.route("Hello/Route", function() {
+ return console.log("Well hello there! How you doin'?!");
+ });
+
+ Finch.route("Hello/Route/:someId", function(bindings) {
+ return console.log("Hey! Here's Some Id: " + bindings.someId);
+ });
+
+ Finch.route("Hello/Route/:someId", function(bindings, childCallback) {
+ console.log("Hey! Here's Some Id: " + bindings.someId);
+ return childCallback();
+ });
+
+ Finch.route("some/route", {
+ setup: function(bindings) {
+ return console.log("Some Route has been setup! :)");
+ },
+ load: function(bindings) {
+ return console.log("Some Route has been loaed! :D");
+ },
+ unload: function(bindings) {
+ return console.log("Some Route has been loaed! :(");
+ },
+ teardown: function(bindings) {
+ return console.log("Some Route has been torndown! :'(");
+ }
+ });
+
+ Finch.route("some/route", {
+ setup: function(bindings, childCallback) {
+ console.log("Some Route has been setup! :)");
+ return childCallback();
+ },
+ load: function(bindings, childCallback) {
+ console.log("Some Route has been loaed! :D");
+ return childCallback();
+ },
+ unload: function(bindings, childCallback) {
+ console.log("Some Route has been loaed! :(");
+ return childCallback();
+ },
+ teardown: function(bindings, childCallback) {
+ console.log("Some Route has been torndown! :'(");
+ return childCallback();
+ }
+ });
+
+ Finch.call("Some/Route");
+
+ Finch.route("Some/Route", function() {
+ return Finch.observe("hello", "foo", function(hello: any, foo: string) {
+ return console.log("" + hello + " and " + foo);
+ });
+ });
+
+ Finch.route("Some/Route", function() {
+ return Finch.observe(["hello", "foo"], function(hello: any, foo: any) {
+ return console.log("" + hello + " and " + foo);
+ });
+ });
+
+ Finch.route("Some/Route", function(bindings) {
+ return Finch.observe(function(params) {
+ });
+ });
+
+ Finch.navigate("Some/Route");
+
+ Finch.navigate("Some/Route", {
+ hello: 'world',
+ foo: 'bar'
+ });
+
+ Finch.navigate("Some/Route", {
+ foo: 'bar'
+ }, true);
+
+ Finch.navigate("Some/Route", true);
+
+ Finch.navigate({
+ hello: 'world2',
+ wow: 'wee'
+ });
+
+ Finch.navigate({
+ foo: 'bar',
+ wow: 'wee!!!'
+ });
+
+ Finch.navigate({
+ hello: 'world2'
+ }, true);
+
+ Finch.listen();
+ Finch.ignore();
+ Finch.abort();
+
+
+ //test from Finch
+ Finch.call("/foo/bar");
+ Finch.call("/foo/bar/123");
+ Finch.call("/foo/bar/123");
+ Finch.call("/foo/bar/123?x=Hello&y=World");
+ Finch.call("/foo/baz/456");
+ Finch.call("/quux/789?band=Sunn O)))&genre=Post-Progressive Fridgecore");
+ Finch.call("/foo/bar/baz");
+ Finch.call("/foo/bar/quux");
+ Finch.call("/foo");
+ Finch.call("/foo/bar");
+ Finch.call("/foo");
+ Finch.call("/foo");
+ Finch.call("/");
+ Finch.call("/");
+ Finch.call("/foo");
+ Finch.call("/foo/bar");
+ Finch.call("/foo/bar?baz=quux");
+ Finch.call("/foo/bar?baz=xyzzy");
+
+ var cb: any;
+ Finch.route("foo", {
+ setup: cb.setup_foo = this.stub(),
+ load: cb.load_foo = this.stub(),
+ unload: cb.unload_foo = this.stub(),
+ teardown: cb.teardown_foo = this.stub()
+ });
+ Finch.route("[foo]/bar", {
+ setup: cb.setup_foo_bar = this.stub(),
+ load: cb.load_foo_bar = this.stub(),
+ unload: cb.unload_foo_bar = this.stub(),
+ teardown: cb.teardown_foo_bar = this.stub()
+ });
+ Finch.route("[foo/bar]/:id", {
+ setup: cb.setup_foo_bar_id = this.stub(),
+ load: cb.load_foo_bar_id = this.stub(),
+ unload: cb.unload_foo_bar_id = this.stub(),
+ teardown: cb.teardown_foo_bar_id = this.stub()
+ });
+ Finch.route("[foo]/baz", {
+ setup: cb.setup_foo_baz = this.stub(),
+ load: cb.load_foo_baz = this.stub(),
+ unload: cb.unload_foo_baz = this.stub(),
+ teardown: cb.teardown_foo_baz = this.stub()
+ });
+ Finch.route("[foo/baz]/:id", {
+ setup: cb.setup_foo_baz_id = this.stub(),
+ load: cb.load_foo_baz_id = this.stub(),
+ unload: cb.unload_foo_baz_id = this.stub(),
+ teardown: cb.teardown_foo_baz_id = this.stub()
+ });
+ Finch.call("/foo");
+ Finch.call("/foo/bar");
+ Finch.call("/foo");
+ Finch.call("/foo/bar/123?x=abc");
+ Finch.call("/foo/bar/456?x=aaa&y=zzz");
+ Finch.call("/foo/bar/456?x=bbb&y=zzz");
+ Finch.call("/foo/bar/456?y=zzz&x=bbb");
+ Finch.call("/foo/baz/789");
+ Finch.call("/foo/baz/abc?term=Hello");
+ Finch.call("/foo/baz/abc?term=World");
+ Finch.route("bar", this.stub());
+ Finch.call("/foo");
+ Finch.call("/bar");
+ Finch.route("/", function() {
+ });
+ Finch.route("[/]home", function() {
+ });
+ Finch.route("[/home]/news", {
+ setup: function() {
+ },
+ load: function() {
+ },
+ unload: function() {
+ return true;
+ },
+ teardown: function() {
+ return false;
+ }
+ });
+ Finch.route("/foo", {
+ setup: function() {
+ return true;
+ },
+ load: function() {
+ return true;
+ },
+ unload: function() {
+ },
+ teardown: function() {
+ }
+ });
+ Finch.route("[/]bar", {
+ setup: function() {
+ },
+ load: function() {
+ },
+ unload: function() {
+ },
+ teardown: function() {
+ }
+ });
+ Finch.call("/bar");
+ Finch.call("/home/news");
+ Finch.call("/foo");
+ Finch.call("/home/news");
+ Finch.call("/bar");
+ Finch.route("baz", this.stub());
+ Finch.call("/foo");
+ Finch.call("/foo/bar");
+ Finch.call("/baz");
+ Finch.route("/home", {
+ setup: function(bindings, next) {
+ return next();
+ },
+ load: function(bindings, next) {
+ return next();
+ },
+ unload: function(bindings, next) {
+ return next();
+ },
+ teardown: function(bindings, next) {
+ return next();
+ }
+ });
+ Finch.route("[/home]/news", {
+ setup: function(bindings, next) {
+ return next();
+ },
+ load: function(bindings, next) {
+ return next();
+ },
+ unload: function(bindings, next) {
+ return next();
+ },
+ teardown: function(bindings, next) {
+ return next();
+ }
+ });
+ Finch.call("/home");
+ Finch.call("/home/news");
+ Finch.call("/foo");
+
+ Finch.route("/", function(bindings) {
+ return Finch.observe(["x"], function(x) {
+ });
+ });
+ Finch.call("/?x=123");
+ Finch.call("/?x=123.456");
+ Finch.call("/?x=true");
+ Finch.call("/?x=false");
+ Finch.call("/?x=stuff");
+ Finch.options({
+ CoerceParameterTypes: true
+ });
+ Finch.call("/?x=123");
+ Finch.call("/?x=123.456");
+ Finch.call("/?x=true");
+ Finch.call("/?x=false");
+ Finch.call("/?x=stuff");
+ Finch.route("/:x", function(_arg) {
+ });
+ Finch.call("/123");
+ Finch.call("/123.456");
+ Finch.call("/true");
+ Finch.call("/false");
+ Finch.call("/stuff");
+ Finch.options({
+ CoerceParameterTypes: true
+ });
+ Finch.call("/123");
+ Finch.call("/123.456");
+ Finch.call("/true");
+ Finch.call("/false");
+ Finch.call("/stuff");
+
+ Finch.navigate("/home");
+ Finch.navigate("/home/news");
+ Finch.navigate("/home");
+ Finch.navigate("/home", {
+ foo: "bar"
+ });
+ Finch.navigate("/home", {
+ hello: "world"
+ });
+ Finch.navigate({
+ foos: "bars"
+ });
+ Finch.navigate({
+ foos: "baz"
+ });
+ Finch.navigate({
+ hello: "world"
+ }, true);
+ Finch.navigate({
+ foos: null
+ }, true);
+ Finch.navigate("/home/news", true);
+ Finch.navigate("/hello world", {});
+ Finch.navigate("/hello world", {
+ foo: "bar bar"
+ });
+ Finch.navigate({
+ foo: "baz baz"
+ });
+ Finch.navigate({
+ hello: 'world world'
+ }, true);
+ Finch.navigate("/home?foo=bar", {
+ hello: "world"
+ });
+ Finch.navigate("/home?foo=bar", {
+ hello: "world",
+ foo: "baz"
+ });
+ Finch.navigate("/home?foo=bar", {
+ hello: "world",
+ free: "bird"
+ });
+ Finch.navigate("#/home", true);
+ Finch.navigate("#/home");
+ Finch.navigate("#/home/news", {
+ free: "birds",
+ hello: "worlds"
+ });
+ Finch.navigate("#/home/news", {
+ foo: "bar"
+ }, true);
+ Finch.navigate("/home/news");
+ Finch.navigate("../");
+ Finch.navigate("./");
+ Finch.navigate("./news");
+ Finch.navigate("/home/news/article");
+ Finch.navigate("../../account");
+
+ Finch.listen();
+ Finch.ignore();
+ Finch.route("/home", function(bindings, continuation) {
+ });
+ Finch.route("/foo", function(bindings, continuation) {
+ });
+ Finch.call("home");
+ Finch.call("foo");
+ Finch.abort();
+ Finch.call("foo");
+ Finch.route("/", {
+ 'setup': cb.slash_setup = this.stub(),
+ 'load': cb.slash_load = this.stub(),
+ 'unload': cb.slash_unload = this.stub(),
+ 'teardown': cb.slash_teardown = this.stub()
+ });
+ Finch.route("[/]users/profile", {
+ 'setup': cb.profile_setup = this.stub(),
+ 'load': cb.profile_load = this.stub(),
+ 'unload': cb.profile_unload = this.stub(),
+ 'teardown': cb.profile_teardown = this.stub()
+ });
+ Finch.route("[/]:page", {
+ 'setup': cb.page_setup = this.stub(),
+ 'load': cb.page_load = this.stub(),
+ 'unload': cb.page_unload = this.stub(),
+ 'teardown': cb.page_teardown = this.stub()
+ });
+ Finch.call("/users");
+}
diff --git a/Finch/Finch.d.ts b/Finch/Finch.d.ts
index e3dd86c70..ca896570f 100644
--- a/Finch/Finch.d.ts
+++ b/Finch/Finch.d.ts
@@ -1,47 +1,47 @@
-// Type definitions for Finch 0.5.13
-// Project: https://github.com/stoodder/finchjs
-// Definitions by: David Sichau
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-
-interface FinchCallback {
- (bindings?: any, childCallback? : () => void): any;
-}
-
-interface ExpandedCallback {
- setup?: FinchCallback;
- load?: FinchCallback;
- unload?: FinchCallback;
- teardown?: FinchCallback;
-}
-
-interface ObserveCallback {
- (...args: any[]): string;
-}
-interface FinchOptions {
- CoerceParameterTypes?: boolean;
-}
-
-
-interface FinchStatic {
- route(route: string, callback: FinchCallback): void;
- route(route: string, callbacks: ExpandedCallback): void;
- call( uri: string ): void;
-
- observe(argN: string[], callback: (params: ObserveCallback ) => void): void;
- observe(callback: (params: ObserveCallback) => void): void;
- observe(...args: any[]): void;
- navigate(uri:string, queryParams?:any, doUpdate?:boolean ): void;
- navigate(uri:string, doUpdate:boolean ): void;
- navigate(queryParams:any, doUpdate?:boolean ): void;
- listen(): boolean;
- ignore(): boolean;
- abort(): void;
- options(options: FinchOptions): void;
-}
-
-
-declare var Finch: FinchStatic;
-declare module "finch" {
- export = Finch;
-}
+// Type definitions for Finch 0.5.13
+// Project: https://github.com/stoodder/finchjs
+// Definitions by: David Sichau
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+interface FinchCallback {
+ (bindings?: any, childCallback? : () => void): any;
+}
+
+interface ExpandedCallback {
+ setup?: FinchCallback;
+ load?: FinchCallback;
+ unload?: FinchCallback;
+ teardown?: FinchCallback;
+}
+
+interface ObserveCallback {
+ (...args: any[]): string;
+}
+interface FinchOptions {
+ CoerceParameterTypes?: boolean;
+}
+
+
+interface FinchStatic {
+ route(route: string, callback: FinchCallback): void;
+ route(route: string, callbacks: ExpandedCallback): void;
+ call( uri: string ): void;
+
+ observe(argN: string[], callback: (params: ObserveCallback ) => void): void;
+ observe(callback: (params: ObserveCallback) => void): void;
+ observe(...args: any[]): void;
+ navigate(uri:string, queryParams?:any, doUpdate?:boolean ): void;
+ navigate(uri:string, doUpdate:boolean ): void;
+ navigate(queryParams:any, doUpdate?:boolean ): void;
+ listen(): boolean;
+ ignore(): boolean;
+ abort(): void;
+ options(options: FinchOptions): void;
+}
+
+
+declare var Finch: FinchStatic;
+declare module "finch" {
+ export = Finch;
+}
diff --git a/README.md b/README.md
index 7e1d60d87..47c56482c 100644
--- a/README.md
+++ b/README.md
@@ -22,7 +22,7 @@ Please see the [contribution guide](http://definitelytyped.org/guides/contributi
## How to get the definitions
-* Directly from the Github repos
+* Directly from the GitHub repos
* [NuGet packages](http://nuget.org/packages?q=DefinitelyTyped)
* [TypeScript Definition manager](https://github.com/DefinitelyTyped/tsd)
diff --git a/accounting/accounting-tests.ts b/accounting/accounting-tests.ts
index a00f2fefc..bc9b74eaa 100644
--- a/accounting/accounting-tests.ts
+++ b/accounting/accounting-tests.ts
@@ -1,107 +1,107 @@
-///
-
-// formatMoney
-
-// Default usage:
-accounting.formatMoney(12345678); // $12,345,678.00
-
-// European formatting (custom symbol and separators), could also use options object as second param:
-accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99
-
-// Negative values are formatted nicely, too:
-accounting.formatMoney(-500000, "£ ", 0); // £ -500,000
-
-// Simple `format` string allows control of symbol position [%v = value, %s = symbol]:
-accounting.formatMoney(5318008, { symbol: "GBP", format: "%v %s" }); // 5,318,008.00 GBP
-
-// Example usage with options object:
-accounting.formatMoney(5318008, {
- symbol: "GBP",
- precision: 0,
- thousand: "·",
- format: {
- pos: "%s %v",
- neg: "%s (%v)",
- zero: "%s --"
- }
-});
-
-// Will recursively format an array of values:
-accounting.formatMoney([123, 456, [78, 9]], "$", 0); // ["$123", "$456", ["$78", "$9"]]
-
-
-
-// formatColumn
-
-// Format list of numbers for display:
-accounting.formatColumn([123.5, 3456.49, 777888.99, 12345678, -5432], "$ ");
-
-// Example usage (NB. use a space after the symbol to add arbitrary padding to all values):
-accounting.formatColumn([123, 12345], "$ ", 0); // ["$ 123", "$ 12,345"]
-
-// List of numbers can be a multi-dimensional array (formatColumn is applied recursively):
-accounting.formatColumn([[1, 100], [900, 9]]); // [["$ 1.00", "$100.00"], ["$900.00", "$ 9.00"]]
-
-
-
-// formatNumber
-
-// Example usage:
-accounting.formatNumber(5318008); // 5,318,008
-accounting.formatNumber(9876543.21, 3, " "); // 9 876 543.210
-accounting.formatNumber(4999.99, 2, ".", ","); // 4.999,99
-
-// Example usage with options object:
-accounting.formatNumber(5318008, {
- precision: 3,
- thousand: " "
-});
-
-// Will recursively format an array of values:
-accounting.formatNumber([123456, [7890, 123]]); // ["123,456", ["7,890", "123"]]
-
-
-
-// toFixed
-
-(0.615).toFixed(2); // "0.61"
-accounting.toFixed(0.615, 2); // "0.62"
-
-
-
-
-// unformat
-
-// Example usage:
-accounting.unformat("£ 12,345,678.90 GBP"); // 12345678.9
-accounting.unformat("GBP £ 12,345,678.90"); // 12345678.9
-
-// If a non-standard decimal separator was used (eg. a comma) unformat() will need it in order to work out
-// which part of the number is a decimal/float:
-accounting.unformat("€ 1.000.000,00", ","); // 1000000
-
-// Settings object that controls default parameters for library methods:
-accounting.settings = {
- currency: {
- symbol: "$", // default currency symbol is '$'
- format: "%s%v", // controls output: %s = symbol, %v = value/number (can be object: see below)
- decimal: ".", // decimal point separator
- thousand: ",", // thousands separator
- precision: 2 // decimal places
- },
- number: {
- precision: 0, // default precision on numbers is 0
- thousand: ",",
- decimal: "."
- }
-};
-
-// These can be changed externally to edit the library's defaults:
-accounting.settings.currency.format = "%s %v";
-
-// Format can be an object, with `pos`, `neg` and `zero`:
-accounting.settings.currency.format = {
- pos: "%s %v", // for positive values, eg. "$ 1.00" (required)
- neg: "%s (%v)", // for negative values, eg. "$ (1.00)" [optional]
- zero: "%s -- " // for zero values, eg. "$ --" [optional]
-};
\ No newline at end of file
+///
+
+// formatMoney
+
+// Default usage:
+accounting.formatMoney(12345678); // $12,345,678.00
+
+// European formatting (custom symbol and separators), could also use options object as second param:
+accounting.formatMoney(4999.99, "€", 2, ".", ","); // €4.999,99
+
+// Negative values are formatted nicely, too:
+accounting.formatMoney(-500000, "£ ", 0); // £ -500,000
+
+// Simple `format` string allows control of symbol position [%v = value, %s = symbol]:
+accounting.formatMoney(5318008, { symbol: "GBP", format: "%v %s" }); // 5,318,008.00 GBP
+
+// Example usage with options object:
+accounting.formatMoney(5318008, {
+ symbol: "GBP",
+ precision: 0,
+ thousand: "·",
+ format: {
+ pos: "%s %v",
+ neg: "%s (%v)",
+ zero: "%s --"
+ }
+});
+
+// Will recursively format an array of values:
+accounting.formatMoney([123, 456, [78, 9]], "$", 0); // ["$123", "$456", ["$78", "$9"]]
+
+
+
+// formatColumn
+
+// Format list of numbers for display:
+accounting.formatColumn([123.5, 3456.49, 777888.99, 12345678, -5432], "$ ");
+
+// Example usage (NB. use a space after the symbol to add arbitrary padding to all values):
+accounting.formatColumn([123, 12345], "$ ", 0); // ["$ 123", "$ 12,345"]
+
+// List of numbers can be a multi-dimensional array (formatColumn is applied recursively):
+accounting.formatColumn([[1, 100], [900, 9]]); // [["$ 1.00", "$100.00"], ["$900.00", "$ 9.00"]]
+
+
+
+// formatNumber
+
+// Example usage:
+accounting.formatNumber(5318008); // 5,318,008
+accounting.formatNumber(9876543.21, 3, " "); // 9 876 543.210
+accounting.formatNumber(4999.99, 2, ".", ","); // 4.999,99
+
+// Example usage with options object:
+accounting.formatNumber(5318008, {
+ precision: 3,
+ thousand: " "
+});
+
+// Will recursively format an array of values:
+accounting.formatNumber([123456, [7890, 123]]); // ["123,456", ["7,890", "123"]]
+
+
+
+// toFixed
+
+(0.615).toFixed(2); // "0.61"
+accounting.toFixed(0.615, 2); // "0.62"
+
+
+
+
+// unformat
+
+// Example usage:
+accounting.unformat("£ 12,345,678.90 GBP"); // 12345678.9
+accounting.unformat("GBP £ 12,345,678.90"); // 12345678.9
+
+// If a non-standard decimal separator was used (eg. a comma) unformat() will need it in order to work out
+// which part of the number is a decimal/float:
+accounting.unformat("€ 1.000.000,00", ","); // 1000000
+
+// Settings object that controls default parameters for library methods:
+accounting.settings = {
+ currency: {
+ symbol: "$", // default currency symbol is '$'
+ format: "%s%v", // controls output: %s = symbol, %v = value/number (can be object: see below)
+ decimal: ".", // decimal point separator
+ thousand: ",", // thousands separator
+ precision: 2 // decimal places
+ },
+ number: {
+ precision: 0, // default precision on numbers is 0
+ thousand: ",",
+ decimal: "."
+ }
+};
+
+// These can be changed externally to edit the library's defaults:
+accounting.settings.currency.format = "%s %v";
+
+// Format can be an object, with `pos`, `neg` and `zero`:
+accounting.settings.currency.format = {
+ pos: "%s %v", // for positive values, eg. "$ 1.00" (required)
+ neg: "%s (%v)", // for negative values, eg. "$ (1.00)" [optional]
+ zero: "%s -- " // for zero values, eg. "$ --" [optional]
+};
diff --git a/accounting/accounting.d.ts b/accounting/accounting.d.ts
index ea861612b..675104047 100644
--- a/accounting/accounting.d.ts
+++ b/accounting/accounting.d.ts
@@ -3,28 +3,28 @@
// Definitions by: Sergey Gerasimov
// Definitions: https://github.com/borisyankov/DefinitelyTyped
-interface IAccountingCurrencyFormat {
- pos: string; // for positive values, eg. "$ 1.00"
- neg?: string; // for negative values, eg. "$ (1.00)"
+interface IAccountingCurrencyFormat {
+ pos: string; // for positive values, eg. "$ 1.00"
+ neg?: string; // for negative values, eg. "$ (1.00)"
zero?: string; // for zero values, eg. "$ --"
}
-interface IAccountingCurrencySettings {
- symbol?: string; // default currency symbol is '$'
- format?: TFormat; // controls output: %s = symbol, %v = value/number
- decimal?: string; // decimal point separator
- thousand?: string; // thousands separator
+interface IAccountingCurrencySettings {
+ symbol?: string; // default currency symbol is '$'
+ format?: TFormat; // controls output: %s = symbol, %v = value/number
+ decimal?: string; // decimal point separator
+ thousand?: string; // thousands separator
precision?: number // decimal places
}
-interface IAccountingNumberSettings {
- precision?: number; // default precision on numbers is 0
- thousand?: string;
- decimal?: string;
+interface IAccountingNumberSettings {
+ precision?: number; // default precision on numbers is 0
+ thousand?: string;
+ decimal?: string;
}
-interface IAccountingSettings {
- currency: IAccountingCurrencySettings; // IAccountingCurrencySettings or IAccountingCurrencySettings
+interface IAccountingSettings {
+ currency: IAccountingCurrencySettings; // IAccountingCurrencySettings or IAccountingCurrencySettings
number: IAccountingNumberSettings;
}
@@ -76,4 +76,4 @@ declare var accounting: IAccountingStatic;
declare module "accounting" {
export = accounting;
-}
\ No newline at end of file
+}
diff --git a/ace/all-tests.ts.tscparams b/ace/all-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/all-tests.ts.tscparams
+++ b/ace/all-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-anchor-tests.ts.tscparams b/ace/tests/ace-anchor-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-anchor-tests.ts.tscparams
+++ b/ace/tests/ace-anchor-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-background_tokenizer-tests.ts.tscparams b/ace/tests/ace-background_tokenizer-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-background_tokenizer-tests.ts.tscparams
+++ b/ace/tests/ace-background_tokenizer-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-default-tests.ts.tscparams b/ace/tests/ace-default-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-default-tests.ts.tscparams
+++ b/ace/tests/ace-default-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-document-tests.ts.tscparams b/ace/tests/ace-document-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-document-tests.ts.tscparams
+++ b/ace/tests/ace-document-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-edit_session-tests.ts.tscparams b/ace/tests/ace-edit_session-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-edit_session-tests.ts.tscparams
+++ b/ace/tests/ace-edit_session-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-editor1-tests.ts.tscparams b/ace/tests/ace-editor1-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-editor1-tests.ts.tscparams
+++ b/ace/tests/ace-editor1-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams b/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams
+++ b/ace/tests/ace-editor_highlight_selected_word-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-editor_navigation-tests.ts.tscparams b/ace/tests/ace-editor_navigation-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-editor_navigation-tests.ts.tscparams
+++ b/ace/tests/ace-editor_navigation-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-multi_select-tests.ts.tscparams b/ace/tests/ace-multi_select-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-multi_select-tests.ts.tscparams
+++ b/ace/tests/ace-multi_select-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-placeholder-tests.ts.tscparams b/ace/tests/ace-placeholder-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-placeholder-tests.ts.tscparams
+++ b/ace/tests/ace-placeholder-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-range_list-tests.ts.tscparams b/ace/tests/ace-range_list-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-range_list-tests.ts.tscparams
+++ b/ace/tests/ace-range_list-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-selection-tests.ts.tscparams b/ace/tests/ace-selection-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-selection-tests.ts.tscparams
+++ b/ace/tests/ace-selection-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-token_iterator-tests.ts.tscparams b/ace/tests/ace-token_iterator-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-token_iterator-tests.ts.tscparams
+++ b/ace/tests/ace-token_iterator-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ace/tests/ace-virtual_renderer-tests.ts.tscparams b/ace/tests/ace-virtual_renderer-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/ace/tests/ace-virtual_renderer-tests.ts.tscparams
+++ b/ace/tests/ace-virtual_renderer-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/amcharts/AmCharts.d.ts.tscparams b/amcharts/AmCharts.d.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/amcharts/AmCharts.d.ts.tscparams
+++ b/amcharts/AmCharts.d.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/amplifyjs/amplifyjs-tests.ts.tscparams b/amplifyjs/amplifyjs-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/amplifyjs/amplifyjs-tests.ts.tscparams
+++ b/amplifyjs/amplifyjs-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/amqplib/amqplib.d.ts b/amqplib/amqplib.d.ts
index d03c46ed7..fd74a48c0 100644
--- a/amqplib/amqplib.d.ts
+++ b/amqplib/amqplib.d.ts
@@ -38,6 +38,7 @@ declare module "amqplib/properties" {
messageTtl?: number;
expires?: number;
deadLetterExchange?: string;
+ deadLetterRoutingKey?: string;
maxLength?: number;
}
interface DeleteQueue {
diff --git a/angular-growl-v2/angular-growl-v2-tests.ts b/angular-growl-v2/angular-growl-v2-tests.ts
index c03e0725a..13c7cad2e 100644
--- a/angular-growl-v2/angular-growl-v2-tests.ts
+++ b/angular-growl-v2/angular-growl-v2-tests.ts
@@ -1,65 +1,65 @@
-///
-
-var app = angular.module("ag", ["pascalprecht.translate", "$httpProvider"]);
-
-app.config((growlProvider:angular.growl.IGrowlProvider, $httpProvider:angular.IHttpProvider) => {
- var ttl:angular.growl.IGrowlTTLConfig = {
- success: 5000,
- error: 4000
- };
-
- growlProvider.globalTimeToLive(ttl)
- .globalTimeToLive(5000)
- .globalDisableCloseButton(true)
- .globalDisableIcons(true)
- .globalReversedOrder(false)
- .globalDisableCountDown(true)
- .messageVariableKey("someKey")
- .globalInlineMessages(false)
- .globalPosition("top-center")
- .messagesKey("someKey")
- .messageTextKey("someKey")
- .messageTitleKey("someKey")
- .messageSeverityKey("someKey")
- .onlyUniqueMessages(false);
-
- $httpProvider.interceptors.push(growlProvider.serverMessagesInterceptor);
-});
-
-app.controller("Ctrl", ($scope:angular.IScope,
- growl:angular.growl.IGrowlService,
- growlMessages:angular.growl.IGrowlMessagesService) => {
- var config:angular.growl.IGrowlMessageConfig = {
- ttl: 5000,
- disableCountDown: true,
- disableCloseButton: true
- };
-
- var message = "Some message";
-
- growl.warning(message);
- growl.warning(message, config);
- growl.error(message);
- growl.error(message, config);
- growl.info(message);
- growl.info(message, config);
- growl.success(message);
- growl.success(message, config);
- growl.general(message);
- growl.general(message, config);
- growl.general(message, config, "error");
- growl.onlyUnique();
- growl.reverseOrder();
- growl.inlineMessages();
- growl.position();
-
- growlMessages.initDirective(1, 10);
- var messages:angular.growl.IGrowlMessage[] = growlMessages.getAllMessages(2);
- growlMessages.destroyAllMessages(0);
- growlMessages.addMessage(messages[0]);
- growlMessages.deleteMessage(messages[1]);
-
- var testMessage = growl.warning(message);
- testMessage.setText("Some other message");
- testMessage.destroy();
-});
+///
+
+var app = angular.module("ag", ["pascalprecht.translate", "$httpProvider"]);
+
+app.config((growlProvider:angular.growl.IGrowlProvider, $httpProvider:angular.IHttpProvider) => {
+ var ttl:angular.growl.IGrowlTTLConfig = {
+ success: 5000,
+ error: 4000
+ };
+
+ growlProvider.globalTimeToLive(ttl)
+ .globalTimeToLive(5000)
+ .globalDisableCloseButton(true)
+ .globalDisableIcons(true)
+ .globalReversedOrder(false)
+ .globalDisableCountDown(true)
+ .messageVariableKey("someKey")
+ .globalInlineMessages(false)
+ .globalPosition("top-center")
+ .messagesKey("someKey")
+ .messageTextKey("someKey")
+ .messageTitleKey("someKey")
+ .messageSeverityKey("someKey")
+ .onlyUniqueMessages(false);
+
+ $httpProvider.interceptors.push(growlProvider.serverMessagesInterceptor);
+});
+
+app.controller("Ctrl", ($scope:angular.IScope,
+ growl:angular.growl.IGrowlService,
+ growlMessages:angular.growl.IGrowlMessagesService) => {
+ var config:angular.growl.IGrowlMessageConfig = {
+ ttl: 5000,
+ disableCountDown: true,
+ disableCloseButton: true
+ };
+
+ var message = "Some message";
+
+ growl.warning(message);
+ growl.warning(message, config);
+ growl.error(message);
+ growl.error(message, config);
+ growl.info(message);
+ growl.info(message, config);
+ growl.success(message);
+ growl.success(message, config);
+ growl.general(message);
+ growl.general(message, config);
+ growl.general(message, config, "error");
+ growl.onlyUnique();
+ growl.reverseOrder();
+ growl.inlineMessages();
+ growl.position();
+
+ growlMessages.initDirective(1, 10);
+ var messages:angular.growl.IGrowlMessage[] = growlMessages.getAllMessages(2);
+ growlMessages.destroyAllMessages(0);
+ growlMessages.addMessage(messages[0]);
+ growlMessages.deleteMessage(messages[1]);
+
+ var testMessage = growl.warning(message);
+ testMessage.setText("Some other message");
+ testMessage.destroy();
+});
diff --git a/angular-growl-v2/angular-growl-v2.d.ts b/angular-growl-v2/angular-growl-v2.d.ts
index 07c0dbe37..594e45c42 100644
--- a/angular-growl-v2/angular-growl-v2.d.ts
+++ b/angular-growl-v2/angular-growl-v2.d.ts
@@ -1,259 +1,259 @@
-// Type definitions for Angular Growl 2 v.0.7.5
-// Project: http://janstevens.github.io/angular-growl-2
-// Definitions by: Tadeusz Hucal
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-///
-
-declare module angular.growl {
-
- /**
- * Global Time-To-Leave configuration.
- */
- interface IGrowlTTLConfig {
- success?: number;
- error?: number;
- warning?: number;
- info?: number;
- }
-
- /**
- * Custom configuration used in single message call.
- */
- interface IGrowlMessageConfig {
- title?: string;
- ttl?: number;
- disableCountDown?: boolean;
- disableIcons?: boolean;
- disableCloseButton?: boolean;
- onclose?: Function;
- onopen?: Function;
- position?: string;
- referenceId?: number;
- translateMessage?: boolean;
- variables?: { [variable: string]: any; };
- }
-
- /**
- * Growl message with configuration.
- */
- interface IGrowlMessage extends IGrowlMessageConfig {
- text: string;
-
- /**
- * Destroy the message.
- */
- destroy(): void;
- /**
- * Update the message body.
- * @param newText new message body
- */
- setText(newText: string): void;
- }
-
- /**
- * Growl service provider.
- */
- interface IGrowlProvider extends angular.IServiceProvider {
- /**
- * Pre-defined server error interceptor.
- */
- serverMessagesInterceptor: (string|IHttpInterceptorFactory)[];
-
- /**
- * Set default TTL settings.
- * @param ttl configuration of TTL for different type of message
- */
- globalTimeToLive(ttl: IGrowlTTLConfig): IGrowlProvider;
- /**
- * Set default TTL settings.
- * @param ttl ttl in milliseconds
- */
- globalTimeToLive(ttl: number): IGrowlProvider;
- /**
- * Set default setting for disabling close button.
- * @param disableCloseButton
- */
- globalDisableCloseButton(disableCloseButton: boolean): IGrowlProvider;
- /**
- * Set default setting for disabling icons.
- * @param disableIcons
- */
- globalDisableIcons(disableIcons: boolean): IGrowlProvider;
- /**
- * Set reversing order of displaying new messages.
- * @param reverseOrder
- */
- globalReversedOrder(reverseOrder: boolean): IGrowlProvider;
- /**
- * Set default setting for displaying message disappear countdown.
- * @param disableCountDown
- */
- globalDisableCountDown(disableCountDown: boolean): IGrowlProvider;
- /**
- * Set default allowance for inline messages.
- * @param inline
- */
- globalInlineMessages(inline: boolean): IGrowlProvider;
- /**
- * Set default message position.
- * @param position
- */
- globalPosition(position: string): IGrowlProvider;
- /**
- * Enable/disable displaying only unique messages.
- * @param onlyUniqueMessages
- */
- onlyUniqueMessages(onlyUniqueMessages: boolean): IGrowlProvider;
-
- /**
- * Set key where messages are stored (for http interceptor).
- * @param messageVariableKey
- */
- messagesKey(messageKey: string): IGrowlProvider;
- /**
- * Set key where message text is stored (for http interceptor).
- * @param messageVariableKey
- */
- messageTextKey(messageTextKey: string): IGrowlProvider;
- /**
- * Set key where title of message is stored (for http interceptor).
- * @param messageVariableKey
- */
- messageTitleKey(messageTitleKey: string): IGrowlProvider;
- /**
- * Set key where severity of message is stored (for http interceptor).
- * @param messageVariableKey
- */
- messageSeverityKey(messageSeverityKey: string): IGrowlProvider;
- /**
- * Set key where variables for message are stored (for http interceptor).
- * @param messageVariableKey
- */
- messageVariableKey(messageVariableKey: string): IGrowlProvider;
- }
-
- /**
- * Growl service.
- */
- interface IGrowlService {
- /**
- * Show warning message.
- * @param message text to display (or code for angular-translate)
- */
- warning(message: string): IGrowlMessage;
- /**
- * Show warning message.
- * @param message text to display (or code for angular-translate)
- * @param config additional message configuration
- */
- warning(message: string, config: IGrowlMessageConfig): IGrowlMessage;
-
- /**
- * Show error message.
- * @param message text to display (or code for angular-translate)
- */
- error(message: string): IGrowlMessage;
- /**
- * Show error message.
- * @param message text to display (or code for angular-translate)
- * @param config additional message configuration
- */
- error(message: string, config: IGrowlMessageConfig): IGrowlMessage;
-
- /**
- * Show information message.
- * @param message text to display (or code for angular-translate)
- */
- info(message: string): IGrowlMessage;
- /**
- * Show information message.
- * @param message text to display (or code for angular-translate)
- * @param config additional message configuration
- */
- info(message: string, config: IGrowlMessageConfig): IGrowlMessage;
-
- /**
- * Show success message.
- * @param message text to display (or code for angular-translate)
- * @param config additional message configuration
- */
- success(message: string): IGrowlMessage;
- /**
- * Show success message.
- * @param message text to display (or code for angular-translate)
- */
- success(message: string, config: IGrowlMessageConfig): IGrowlMessage;
-
- /**
- * Show message (generic).
- * @param message text to display (or code for angular-translate)
- */
- general(message: string): IGrowlMessage;
- /**
- * Show message (generic).
- * @param message text to display (or code for angular-translate)
- * @param config additional message configuration
- */
- general(message: string, config: IGrowlMessageConfig): IGrowlMessage;
- /**
- * Show message (generic).
- * @param message text to display (or code for angular-translate)
- * @param config additional message configuration
- * @param severity message severity (error, warning, success, info).
- */
- general(message: string, config: IGrowlMessageConfig, severity: string): IGrowlMessage;
-
- /**
- * Get current setting for displaying only unique messages.
- */
- onlyUnique(): boolean;
- /**
- * Get current setting for reversing messages order.
- */
- reverseOrder(): boolean;
- /**
- * Get current allowance for inline messages.
- */
- inlineMessages(): boolean;
- /**
- * Get current messages position.
- */
- position(): string;
- }
-
- /**
- * GrowlMessages service.
- */
- interface IGrowlMessagesService {
- /**
- * Initialize a directive
- * We look at the preloaded directive and use this else we
- * create a new blank object
- * @param referenceId
- * @param limitMessages
- */
- initDirective(referenceId: number, limitMessages: number): angular.IDirective;
-
- /**
- * Get current messages
- */
- getAllMessages(referenceId?: number): IGrowlMessage[];
-
- /**
- * Destroy all messages
- */
- destroyAllMessages(referenceId?: number): void;
-
- /**
- * Add a message
- */
- addMessage(message: IGrowlMessage): IGrowlMessage;
-
- /**
- * Delete a message
- */
- deleteMessage(message: IGrowlMessage): void;
-
- }
-}
+// Type definitions for Angular Growl 2 v.0.7.5
+// Project: http://janstevens.github.io/angular-growl-2
+// Definitions by: Tadeusz Hucal
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module angular.growl {
+
+ /**
+ * Global Time-To-Leave configuration.
+ */
+ interface IGrowlTTLConfig {
+ success?: number;
+ error?: number;
+ warning?: number;
+ info?: number;
+ }
+
+ /**
+ * Custom configuration used in single message call.
+ */
+ interface IGrowlMessageConfig {
+ title?: string;
+ ttl?: number;
+ disableCountDown?: boolean;
+ disableIcons?: boolean;
+ disableCloseButton?: boolean;
+ onclose?: Function;
+ onopen?: Function;
+ position?: string;
+ referenceId?: number;
+ translateMessage?: boolean;
+ variables?: { [variable: string]: any; };
+ }
+
+ /**
+ * Growl message with configuration.
+ */
+ interface IGrowlMessage extends IGrowlMessageConfig {
+ text: string;
+
+ /**
+ * Destroy the message.
+ */
+ destroy(): void;
+ /**
+ * Update the message body.
+ * @param newText new message body
+ */
+ setText(newText: string): void;
+ }
+
+ /**
+ * Growl service provider.
+ */
+ interface IGrowlProvider extends angular.IServiceProvider {
+ /**
+ * Pre-defined server error interceptor.
+ */
+ serverMessagesInterceptor: (string|IHttpInterceptorFactory)[];
+
+ /**
+ * Set default TTL settings.
+ * @param ttl configuration of TTL for different type of message
+ */
+ globalTimeToLive(ttl: IGrowlTTLConfig): IGrowlProvider;
+ /**
+ * Set default TTL settings.
+ * @param ttl ttl in milliseconds
+ */
+ globalTimeToLive(ttl: number): IGrowlProvider;
+ /**
+ * Set default setting for disabling close button.
+ * @param disableCloseButton
+ */
+ globalDisableCloseButton(disableCloseButton: boolean): IGrowlProvider;
+ /**
+ * Set default setting for disabling icons.
+ * @param disableIcons
+ */
+ globalDisableIcons(disableIcons: boolean): IGrowlProvider;
+ /**
+ * Set reversing order of displaying new messages.
+ * @param reverseOrder
+ */
+ globalReversedOrder(reverseOrder: boolean): IGrowlProvider;
+ /**
+ * Set default setting for displaying message disappear countdown.
+ * @param disableCountDown
+ */
+ globalDisableCountDown(disableCountDown: boolean): IGrowlProvider;
+ /**
+ * Set default allowance for inline messages.
+ * @param inline
+ */
+ globalInlineMessages(inline: boolean): IGrowlProvider;
+ /**
+ * Set default message position.
+ * @param position
+ */
+ globalPosition(position: string): IGrowlProvider;
+ /**
+ * Enable/disable displaying only unique messages.
+ * @param onlyUniqueMessages
+ */
+ onlyUniqueMessages(onlyUniqueMessages: boolean): IGrowlProvider;
+
+ /**
+ * Set key where messages are stored (for http interceptor).
+ * @param messageVariableKey
+ */
+ messagesKey(messageKey: string): IGrowlProvider;
+ /**
+ * Set key where message text is stored (for http interceptor).
+ * @param messageVariableKey
+ */
+ messageTextKey(messageTextKey: string): IGrowlProvider;
+ /**
+ * Set key where title of message is stored (for http interceptor).
+ * @param messageVariableKey
+ */
+ messageTitleKey(messageTitleKey: string): IGrowlProvider;
+ /**
+ * Set key where severity of message is stored (for http interceptor).
+ * @param messageVariableKey
+ */
+ messageSeverityKey(messageSeverityKey: string): IGrowlProvider;
+ /**
+ * Set key where variables for message are stored (for http interceptor).
+ * @param messageVariableKey
+ */
+ messageVariableKey(messageVariableKey: string): IGrowlProvider;
+ }
+
+ /**
+ * Growl service.
+ */
+ interface IGrowlService {
+ /**
+ * Show warning message.
+ * @param message text to display (or code for angular-translate)
+ */
+ warning(message: string): IGrowlMessage;
+ /**
+ * Show warning message.
+ * @param message text to display (or code for angular-translate)
+ * @param config additional message configuration
+ */
+ warning(message: string, config: IGrowlMessageConfig): IGrowlMessage;
+
+ /**
+ * Show error message.
+ * @param message text to display (or code for angular-translate)
+ */
+ error(message: string): IGrowlMessage;
+ /**
+ * Show error message.
+ * @param message text to display (or code for angular-translate)
+ * @param config additional message configuration
+ */
+ error(message: string, config: IGrowlMessageConfig): IGrowlMessage;
+
+ /**
+ * Show information message.
+ * @param message text to display (or code for angular-translate)
+ */
+ info(message: string): IGrowlMessage;
+ /**
+ * Show information message.
+ * @param message text to display (or code for angular-translate)
+ * @param config additional message configuration
+ */
+ info(message: string, config: IGrowlMessageConfig): IGrowlMessage;
+
+ /**
+ * Show success message.
+ * @param message text to display (or code for angular-translate)
+ * @param config additional message configuration
+ */
+ success(message: string): IGrowlMessage;
+ /**
+ * Show success message.
+ * @param message text to display (or code for angular-translate)
+ */
+ success(message: string, config: IGrowlMessageConfig): IGrowlMessage;
+
+ /**
+ * Show message (generic).
+ * @param message text to display (or code for angular-translate)
+ */
+ general(message: string): IGrowlMessage;
+ /**
+ * Show message (generic).
+ * @param message text to display (or code for angular-translate)
+ * @param config additional message configuration
+ */
+ general(message: string, config: IGrowlMessageConfig): IGrowlMessage;
+ /**
+ * Show message (generic).
+ * @param message text to display (or code for angular-translate)
+ * @param config additional message configuration
+ * @param severity message severity (error, warning, success, info).
+ */
+ general(message: string, config: IGrowlMessageConfig, severity: string): IGrowlMessage;
+
+ /**
+ * Get current setting for displaying only unique messages.
+ */
+ onlyUnique(): boolean;
+ /**
+ * Get current setting for reversing messages order.
+ */
+ reverseOrder(): boolean;
+ /**
+ * Get current allowance for inline messages.
+ */
+ inlineMessages(): boolean;
+ /**
+ * Get current messages position.
+ */
+ position(): string;
+ }
+
+ /**
+ * GrowlMessages service.
+ */
+ interface IGrowlMessagesService {
+ /**
+ * Initialize a directive
+ * We look at the preloaded directive and use this else we
+ * create a new blank object
+ * @param referenceId
+ * @param limitMessages
+ */
+ initDirective(referenceId: number, limitMessages: number): angular.IDirective;
+
+ /**
+ * Get current messages
+ */
+ getAllMessages(referenceId?: number): IGrowlMessage[];
+
+ /**
+ * Destroy all messages
+ */
+ destroyAllMessages(referenceId?: number): void;
+
+ /**
+ * Add a message
+ */
+ addMessage(message: IGrowlMessage): IGrowlMessage;
+
+ /**
+ * Delete a message
+ */
+ deleteMessage(message: IGrowlMessage): void;
+
+ }
+}
diff --git a/angular-meteor/angular-meteor-tests.ts b/angular-meteor/angular-meteor-tests.ts
index 9ce0a33e9..cc2a62c8d 100644
--- a/angular-meteor/angular-meteor-tests.ts
+++ b/angular-meteor/angular-meteor-tests.ts
@@ -1,255 +1,255 @@
-///
-
-interface ITodo {
- _id?: string;
- name: string;
- public?: boolean;
- sticky?: boolean;
-}
-
-interface TodoAngularMeteorObject extends ITodo, angular.meteor.AngularMeteorObject {}
-
-interface CustomScope extends angular.meteor.IScope {
- sticky: boolean;
-
- todos: angular.meteor.AngularMeteorCollection;
- stickyTodos: angular.meteor.AngularMeteorCollection;
- notAutoTodos: angular.meteor.AngularMeteorCollection;
-
- todo: ITodo;
- todoNotAuto: TodoAngularMeteorObject;
- todoSubscribed: TodoAngularMeteorObject;
-
- save: (todo: ITodo) => void;
- saveAll: () =>void;
- autoSave: (todo: ITodo) => void;
- remove: (todoId: string) => void;
- removeAll: () => void;
- removeAuto: (todo: ITodo) => void;
- toSticky: (todo: ITodo) => void;
-}
-
-var Todos = new Mongo.Collection('todos');
-
-var app = angular.module('angularMeteorTestApp');
-
-app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor: angular.meteor.IMeteorService) => {
- // Bind all the todos to $scope.todos
- $scope.todos = $meteor.collection(Todos);
-
- $scope.sticky = true;
- // Bind all sticky todos to $scope.stickyTodos
- // Binds the query to $scope.sticky so that if it changes, Meteor will re-run the query and bind it
- // to $scope.stickyTodos
- $scope.stickyTodos = $meteor.collection(function(){
- return Todos.find({sticky: $scope.getReactively('sticky')});
- });
-
- // Bind without auto-save all todos to $scope.notAutoTodos
- $scope.notAutoTodos = $meteor.collection(Todos, false).subscribe("publicTodos");
-
- $scope.todoNotAuto = $meteor.object(Todos, 'TodoID', false);
- $scope.todoSubscribed = $meteor.object(Todos, 'TodoID').subscribe('todos');
- $scope.todo = $scope.todoNotAuto.getRawObject();
- $scope.todoNotAuto.reset();
- $scope.todoNotAuto.save($scope.todo).then((data) => { return data == 1; });;
-
- // todo might be an object like this {text: "Learn Angular", sticky: false}
- // or an array like this:
- // [{text: "Learn Angular", sticky: false}, {text: "Hello World", sticky: true}]
-
- $scope.save = function(todo) {
- $scope.notAutoTodos.save(todo);
- };
-
- $scope.saveAll = function() {
- $scope.notAutoTodos.save();
- };
-
- $scope.autoSave = function(todo) {
- $scope.todos.push(todo);
- };
-
- // todoId might be an string like this "WhrnEez5yBRgo4yEm"
- // or an array like this ["WhrnEez5yBRgo4yEm","gH6Fa4DXA3XxQjXNS"]
- $scope.remove = function(todoId) {
- $scope.notAutoTodos.remove(todoId);
- };
-
- $scope.removeAll = function() {
- $scope.notAutoTodos.remove();
- };
-
- $scope.removeAuto = function(todo) {
- $scope.todos.splice( $scope.todos.indexOf(todo), 1 );
- }
-
- $scope.toSticky = function(todo) {
- if (angular.isArray(todo)){
- angular.forEach(todo, function(object) {
- object.sticky = true;
- });
- } else {
- todo.sticky = true;
- }
-
- $scope.stickyTodos.save(todo);
- };
-
- var todoObject = {name:'first todo'};
- var todosArray = [{name:'second todo'}, {name:'third todo'}];
- var todoSecondObject = {name:'forth todo'};
-
- $scope.todos.save(todoObject); // todos equals [{name:'first todo'}]
-
- $scope.todos.save(todosArray); // todos equals [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
-
- $scope.todos.push(todoSecondObject); // The scope variable equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
- // but the collection still equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
-
- $scope.todos.save(); // Now the collection also equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
-
- $scope.todos.remove('firstTodoId'); // scope and collection equals to [{name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
-
- var todoIdsArray = ['secondTodoId', 'thirdTodoId'];
- $scope.todos.remove(todoIdsArray); // removes everything matches the array of IDs both in scope and in collection
-
- $scope.todos.pop(); // removes only in scope
-
- $scope.todos.remove(); // syncs also in Meteor collection
-
- // Subscribe ->
-
- $meteor.subscribe('todos').then((subscriptionHandle) => {
- // Bind all the todos to $scope.todos
- $scope.todos = $meteor.collection(Todos);
-
- console.log($scope.todos + ' is ready');
-
- // You can use the subscription handle to stop the subscription if you want
- subscriptionHandle.stop();
- });
-
- $scope.subscribe('todos').then((subscriptionHandle) => {
- // Bind all the todos to $scope.books
- $scope.todos = $meteor.collection(Todos);
-
- console.log($scope.todos + ' is ready');
-
- // No need to stop the subscription, it will automatically close on scope destroy
- });
-
- $meteor.call('subscribe', $scope.todo._id, $scope.currentUser._id).then((data) => {
- // Handle success
- console.log('success subscribing', data.name);
- }, (err) => {
- // Handle error
- console.log('failed', err);
- });
-
- if (!$scope.loggingIn) {
- $meteor.waitForUser();
-
- $meteor.requireUser();
-
- $meteor.requireValidUser(user => {
- return user.username == 'admin';
- });
-
- $meteor.loginWithPassword('user', 'password').then(() => {
- console.log('Login success');
- }, err => {
- console.log('Login error - ', err);
- });
-
- $meteor.createUser({
- username:'moma',
- email:'example@gmail.com',
- password: 'Bksd@asdf',
- profile: {expertize: 'Developer'}
- }).then(() => {
- console.log('Login success');
- }, err => {
- console.log('Login error - ', err);
- });
-
- $meteor.changePassword('old', 'new232f3').then(() => {
- console.log('Change password success');
- }, err => {
- console.log('Error changing password - ', err);
- });
-
- $meteor.forgotPassword({email: 'sample@gmail.com'}).then(() => {
- console.log('Success sending forgot password email');
- }, err => {
- console.log('Error sending forgot password email - ', err);
- });
-
- $meteor.resetPassword('tokenID', 'new232f3').then(() => {
- console.log('Reset password success');
- }, err => {
- console.log('Error resetting password - ', err);
- });
-
- $meteor.verifyEmail('tokenID').then(() => {
- console.log('Success verifying password ');
- }, err => {
- console.log('Error verifying password - ', err);
- });
-
- $meteor.logout().then(() => {
- console.log('Logout success');
- }, err => {
- console.log('logout error - ', err);
- });
-
- $meteor.logoutOtherClients().then(() => {
- console.log('Logout success');
- }, err => {
- console.log('logout error - ', err);
- });
-
- var loginWithOptions = {requestPermissions: ['email']};
-
- $meteor.loginWithFacebook({requestPermissions: ['email']}).then(() => {
- console.log('Login success');
- }, err => {
- console.log('Login error - ', err);
- });
- $meteor.loginWithGithub({requestPermissions: ['email']}).then(() => {
- console.log('Login success');
- }, err => {
- console.log('Login error - ', err);
- });
- $meteor.loginWithGoogle({requestPermissions: ['email']}).then(() => {
- console.log('Login success');
- }, err => {
- console.log('Login error - ', err);
- });
- $meteor.loginWithMeetup({requestPermissions: ['email']}).then(() => {
- console.log('Login success');
- }, err => {
- console.log('Login error - ', err);
- });
- $meteor.loginWithTwitter({requestPermissions: ['email']}).then(() => {
- console.log('Login success');
- }, err => {
- console.log('Login error - ', err);
- });
- $meteor.loginWithWeibo({requestPermissions: ['email']}).then(() => {
- console.log('Login success');
- }, err => {
- console.log('Login error - ', err);
- });
- }
-
- $meteor.autorun($scope, () => { console.log("Aurorun triggered."); });
- $meteor.getCollectionByName('collectionName');
-
- // requires meteor add mdg:camera
- $meteor.getPicture().then(function(data){
- $scope['picture'] = data;
- });
-
- $meteor.session('counter').bind($scope, 'counter');
-}]);
+///
+
+interface ITodo {
+ _id?: string;
+ name: string;
+ public?: boolean;
+ sticky?: boolean;
+}
+
+interface TodoAngularMeteorObject extends ITodo, angular.meteor.AngularMeteorObject {}
+
+interface CustomScope extends angular.meteor.IScope {
+ sticky: boolean;
+
+ todos: angular.meteor.AngularMeteorCollection;
+ stickyTodos: angular.meteor.AngularMeteorCollection;
+ notAutoTodos: angular.meteor.AngularMeteorCollection;
+
+ todo: ITodo;
+ todoNotAuto: TodoAngularMeteorObject;
+ todoSubscribed: TodoAngularMeteorObject;
+
+ save: (todo: ITodo) => void;
+ saveAll: () =>void;
+ autoSave: (todo: ITodo) => void;
+ remove: (todoId: string) => void;
+ removeAll: () => void;
+ removeAuto: (todo: ITodo) => void;
+ toSticky: (todo: ITodo) => void;
+}
+
+var Todos = new Mongo.Collection('todos');
+
+var app = angular.module('angularMeteorTestApp');
+
+app.controller("mainCtrl", ['$scope', '$meteor', ($scope: CustomScope, $meteor: angular.meteor.IMeteorService) => {
+ // Bind all the todos to $scope.todos
+ $scope.todos = $meteor.collection(Todos);
+
+ $scope.sticky = true;
+ // Bind all sticky todos to $scope.stickyTodos
+ // Binds the query to $scope.sticky so that if it changes, Meteor will re-run the query and bind it
+ // to $scope.stickyTodos
+ $scope.stickyTodos = $meteor.collection(function(){
+ return Todos.find({sticky: $scope.getReactively('sticky')});
+ });
+
+ // Bind without auto-save all todos to $scope.notAutoTodos
+ $scope.notAutoTodos = $meteor.collection(Todos, false).subscribe("publicTodos");
+
+ $scope.todoNotAuto = $meteor.object(Todos, 'TodoID', false);
+ $scope.todoSubscribed = $meteor.object(Todos, 'TodoID').subscribe('todos');
+ $scope.todo = $scope.todoNotAuto.getRawObject();
+ $scope.todoNotAuto.reset();
+ $scope.todoNotAuto.save($scope.todo).then((data) => { return data == 1; });;
+
+ // todo might be an object like this {text: "Learn Angular", sticky: false}
+ // or an array like this:
+ // [{text: "Learn Angular", sticky: false}, {text: "Hello World", sticky: true}]
+
+ $scope.save = function(todo) {
+ $scope.notAutoTodos.save(todo);
+ };
+
+ $scope.saveAll = function() {
+ $scope.notAutoTodos.save();
+ };
+
+ $scope.autoSave = function(todo) {
+ $scope.todos.push(todo);
+ };
+
+ // todoId might be an string like this "WhrnEez5yBRgo4yEm"
+ // or an array like this ["WhrnEez5yBRgo4yEm","gH6Fa4DXA3XxQjXNS"]
+ $scope.remove = function(todoId) {
+ $scope.notAutoTodos.remove(todoId);
+ };
+
+ $scope.removeAll = function() {
+ $scope.notAutoTodos.remove();
+ };
+
+ $scope.removeAuto = function(todo) {
+ $scope.todos.splice( $scope.todos.indexOf(todo), 1 );
+ }
+
+ $scope.toSticky = function(todo) {
+ if (angular.isArray(todo)){
+ angular.forEach(todo, function(object) {
+ object.sticky = true;
+ });
+ } else {
+ todo.sticky = true;
+ }
+
+ $scope.stickyTodos.save(todo);
+ };
+
+ var todoObject = {name:'first todo'};
+ var todosArray = [{name:'second todo'}, {name:'third todo'}];
+ var todoSecondObject = {name:'forth todo'};
+
+ $scope.todos.save(todoObject); // todos equals [{name:'first todo'}]
+
+ $scope.todos.save(todosArray); // todos equals [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
+
+ $scope.todos.push(todoSecondObject); // The scope variable equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
+ // but the collection still equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}]
+
+ $scope.todos.save(); // Now the collection also equals to [{name:'first todo'}, {name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
+
+ $scope.todos.remove('firstTodoId'); // scope and collection equals to [{name:'second todo'}, {name:'third todo'}, {name:'forth todo'}]
+
+ var todoIdsArray = ['secondTodoId', 'thirdTodoId'];
+ $scope.todos.remove(todoIdsArray); // removes everything matches the array of IDs both in scope and in collection
+
+ $scope.todos.pop(); // removes only in scope
+
+ $scope.todos.remove(); // syncs also in Meteor collection
+
+ // Subscribe ->
+
+ $meteor.subscribe('todos').then((subscriptionHandle) => {
+ // Bind all the todos to $scope.todos
+ $scope.todos = $meteor.collection(Todos);
+
+ console.log($scope.todos + ' is ready');
+
+ // You can use the subscription handle to stop the subscription if you want
+ subscriptionHandle.stop();
+ });
+
+ $scope.subscribe('todos').then((subscriptionHandle) => {
+ // Bind all the todos to $scope.books
+ $scope.todos = $meteor.collection(Todos);
+
+ console.log($scope.todos + ' is ready');
+
+ // No need to stop the subscription, it will automatically close on scope destroy
+ });
+
+ $meteor.call('subscribe', $scope.todo._id, $scope.currentUser._id).then((data) => {
+ // Handle success
+ console.log('success subscribing', data.name);
+ }, (err) => {
+ // Handle error
+ console.log('failed', err);
+ });
+
+ if (!$scope.loggingIn) {
+ $meteor.waitForUser();
+
+ $meteor.requireUser();
+
+ $meteor.requireValidUser(user => {
+ return user.username == 'admin';
+ });
+
+ $meteor.loginWithPassword('user', 'password').then(() => {
+ console.log('Login success');
+ }, err => {
+ console.log('Login error - ', err);
+ });
+
+ $meteor.createUser({
+ username:'moma',
+ email:'example@gmail.com',
+ password: 'Bksd@asdf',
+ profile: {expertize: 'Developer'}
+ }).then(() => {
+ console.log('Login success');
+ }, err => {
+ console.log('Login error - ', err);
+ });
+
+ $meteor.changePassword('old', 'new232f3').then(() => {
+ console.log('Change password success');
+ }, err => {
+ console.log('Error changing password - ', err);
+ });
+
+ $meteor.forgotPassword({email: 'sample@gmail.com'}).then(() => {
+ console.log('Success sending forgot password email');
+ }, err => {
+ console.log('Error sending forgot password email - ', err);
+ });
+
+ $meteor.resetPassword('tokenID', 'new232f3').then(() => {
+ console.log('Reset password success');
+ }, err => {
+ console.log('Error resetting password - ', err);
+ });
+
+ $meteor.verifyEmail('tokenID').then(() => {
+ console.log('Success verifying password ');
+ }, err => {
+ console.log('Error verifying password - ', err);
+ });
+
+ $meteor.logout().then(() => {
+ console.log('Logout success');
+ }, err => {
+ console.log('logout error - ', err);
+ });
+
+ $meteor.logoutOtherClients().then(() => {
+ console.log('Logout success');
+ }, err => {
+ console.log('logout error - ', err);
+ });
+
+ var loginWithOptions = {requestPermissions: ['email']};
+
+ $meteor.loginWithFacebook({requestPermissions: ['email']}).then(() => {
+ console.log('Login success');
+ }, err => {
+ console.log('Login error - ', err);
+ });
+ $meteor.loginWithGithub({requestPermissions: ['email']}).then(() => {
+ console.log('Login success');
+ }, err => {
+ console.log('Login error - ', err);
+ });
+ $meteor.loginWithGoogle({requestPermissions: ['email']}).then(() => {
+ console.log('Login success');
+ }, err => {
+ console.log('Login error - ', err);
+ });
+ $meteor.loginWithMeetup({requestPermissions: ['email']}).then(() => {
+ console.log('Login success');
+ }, err => {
+ console.log('Login error - ', err);
+ });
+ $meteor.loginWithTwitter({requestPermissions: ['email']}).then(() => {
+ console.log('Login success');
+ }, err => {
+ console.log('Login error - ', err);
+ });
+ $meteor.loginWithWeibo({requestPermissions: ['email']}).then(() => {
+ console.log('Login success');
+ }, err => {
+ console.log('Login error - ', err);
+ });
+ }
+
+ $meteor.autorun($scope, () => { console.log("Aurorun triggered."); });
+ $meteor.getCollectionByName('collectionName');
+
+ // requires meteor add mdg:camera
+ $meteor.getPicture().then(function(data){
+ $scope['picture'] = data;
+ });
+
+ $meteor.session('counter').bind($scope, 'counter');
+}]);
diff --git a/angular-meteor/angular-meteor.d.ts b/angular-meteor/angular-meteor.d.ts
index e536e3203..e3e66bf34 100644
--- a/angular-meteor/angular-meteor.d.ts
+++ b/angular-meteor/angular-meteor.d.ts
@@ -1,352 +1,352 @@
-// Type definitions for Angular JS Meteor v0.8.8 (angular.meteor module)
-// Project: https://github.com/Urigo/angular-meteor
-// Definitions by: Peter Grman
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-///
-///
-
-declare module angular.meteor {
- interface IRootScopeService extends angular.IRootScopeService {
- /**
- * The current logged in user and it's data. it is null if the user is not logged in. A reactive data source.
- */
- currentUser: Meteor.User;
-
- /**
- * True if a login method (such as Meteor.loginWithPassword, Meteor.loginWithFacebook, or Accounts.createUser) is currently in progress.
- * A reactive data source. Can be use to display animation while user is logging in.
- */
- loggingIn: boolean;
- }
-
- interface IScope extends angular.IScope, IRootScopeService {
- /**
- * A method to get a $scope variable and watch it reactivly
- *
- * @param scopeVariableName - The name of the scope's variable to bind to
- * @param [objectEquality=false] - Watch the object equality using angular.equals instead of comparing for reference equality, deeper watch but also slower
- */
- getReactively(scopeVariableName: string, objectEquality?: boolean): ReactiveResult;
-
- /**
- * A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready.
- * Calling $scope.subscribe will automatically stop the subscription when the scope is destroyed.
- *
- * @param name - Name of the subscription. Matches the name of the server's publish() call.
- * @param publisherArguments - Optional arguments passed to publisher function on server.
- *
- * @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle.
- */
- subscribe(name: string, ...publisherArguments: any[]): angular.IPromise;
-
- /**
- * The helpers method is part of the ReactiveContext, and available on every context and $scope.
- * These method are defined as Object, where each key is the name of the variable that will be available on the context we run, and each value is a function with a return value.
- * Under the hood, each helper starts a new Tracker.autorun. When its reactive dependencies change, the helper is rerun.
- * To trigger a rerun every time an specific Angular variable change, use getReactively](/api/1.3.1/get-reactively) to make your Angular variable reactive inside the helper its used in.
- * Each helper function should return a MongoDB Cursor and the helpers will expose it as a normal array to the context.
- *
- * @param definitions - Object containing `name` => `function` definition, where each name is a string and each function is the helper function. Should return a [MongoDB Cursor](http://docs.meteor.com/#/full/mongo_cursor)
- * @return This method returns this, which the the reactive context, in order to provide the ability to chain the logic.
- */
- helpers(definitions : { [helperName : string] : () => Mongo.Cursor }): IScope;
-
- /**
- * This method is a wrapper of Tracker.autorun and shares exactly the same API.
- * The autorun method is part of the ReactiveContext, and available on every context and $scope.
- * The argument of this method is a callback, which will be called each time Autorun will be used.
- * The Autorun will stop automatically when when it's context ($scope) is destroyed.
- *
- * @param runFunc - The function to run. It receives one argument: the Computation object that will be returned.
- */
- autorun(runFunc : () => void) : Tracker.Computation;
- }
-
- /**
- * $meteor in angularjs
- */
- interface IMeteorService {
- /**
- * A service that wraps the Meteor collections to enable reactivity within AngularJS.
- *
- * @param collection - A Meteor Collection or a reactive function to bind to.
- * - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor.
- * @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection.
- * - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.
- */
- collection(collection: Mongo.Collection|ReactiveResult|Function|(()=>T), autoClientSave?: boolean): AngularMeteorCollection;
-
- /**
- * A service that wraps the Meteor collections to enable reactivity within AngularJS.
- *
- * @param collection - A Meteor Collection or a reactive function to bind to.
- * - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor.
- * @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection.
- * - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.
- * @param [updateCollection] - A collection object which will be used for updates (insert, update, delete).
- */
- collection(collection: Mongo.Collection|ReactiveResult|Function|(()=>T), autoClientSave: boolean, updateCollection: Mongo.Collection): AngularMeteorCollection2;
-
- /**
- * A service that wraps a Meteor object to enable reactivity within AngularJS.
- * Finds the first document that matches the selector, as ordered by sort and skip options. Wraps collection.findOne
- *
- * @param collection - A Meteor Collection to bind to.
- * @param selector - A query describing the documents to find or just the ID of the document.
- * - $meteor.object will find the first document that matches the selector,
- * - as ordered by sort and skip options, exactly like Meteor's collection.findOne
- * @param [autoClientSave=true] - By default, changes in the Angular object will automatically update the Meteor object.
- * - However if set to false, changes in the client won't be automatically propagated back to the Meteor object.
- */
- object(collection: Mongo.Collection, selector: Mongo.Selector|Mongo.ObjectID|string, autoClientSave?: boolean): AngularMeteorObject;
-
- /**
- * A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready.
- *
- * @param name - Name of the subscription. Matches the name of the server's publish() call.
- * @param publisherArguments - Optional arguments passed to publisher function on server.
- *
- * @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle.
- */
- subscribe(name: string, ...publisherArguments: any[]): angular.IPromise;
-
- /**
- * A service service which wraps up Meteor.methods with AngularJS promises.
- *
- * @param name - Name of method to invoke
- * @param methodArguments - Optional method arguments
- *
- * @return The promise solves successfully with the return value of the method or return reject with the error from the method.
- */
- call(name: string, ...methodArguments: any[]): angular.IPromise;
-
- // User Authentication BEGIN ->
-
- /**
- * Returns a promise fulfilled with the currentUser when the user subscription is ready.
- * This is useful when you want to grab the current user before the route is rendered.
- * If there is no logged in user, it will return null.
- * See the “Authentication with Routers” section of our tutorial for more information and a full example.
- */
- waitForUser(): angular.IPromise;
-
- /**
- * Resolves the promise successfully if a user is authenticated and rejects otherwise.
- * This is useful in cases where you want to require a route to have an authenticated user.
- * You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page.
- * See the “Authentication with Routers” section of our tutorial for more information and a full example.
- */
- requireUser(): angular.IPromise;
-
- /**
- * Resolves the promise successfully if a user is authenticated and the validatorFn returns true; rejects otherwise.
- * This is useful in cases where you want to require a route to have an authenticated user and do extra validation like the user's role or group.
- * You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page.
- * See the “Authentication with Routers” section of our tutorial for more information and a full example.
- *
- * The mandatory validator function will be called with the authenticated user as the single param and it's expected to return true in order to resolve.
- * If it returns a string, the promise will be rejected using said string as the reason.
- * Any other return (false, null, undefined) will be rejected with the default "FORBIDDEN" reason.
- */
- requireValidUser(validatorFn: (user: Meteor.User) => boolean|string): angular.IPromise;
-
- /**
- * Log the user in with a password.
- *
- * @param user - Either a string interpreted as a username or an email; or an object with a single key: email, username or id.
- * @param password - The user's password.
- */
- loginWithPassword(user: string|{email: string}|{username: string}|{id: string}, password: string): angular.IPromise;
-
- /**
- * Create a new user. More information: http://docs.meteor.com/#/full/accounts_createuser
- *
- * @param options.username - A unique name for this user. Either this, or email is required.
- * @param options.email - The user's email address. Either this, or username is required.
- * @param options.password - The user's password. This is not sent in plain text over the wire.
- * @param options.profile - The user's profile, typically including the name field.
- */
- createUser(options: {username?: string; email?: string; password: string; profile?: Object}): angular.IPromise;
-
- /**
- * Change the current user's password. Must be logged in.
- *
- * @param oldPassword - The user's current password. This is not sent in plain text over the wire.
- * @param newPassword - A new password for the user. This is not sent in plain text over the wire.
- */
- changePassword(oldPassword: string, newPassword: string): angular.IPromise;
-
- /**
- * Request a forgot password email.
- *
- * @param options.email - The email address to send a password reset link.
- */
- forgotPassword(options: {email: string}): angular.IPromise;
-
- /**
- * Reset the password for a user using a token received in email. Logs the user in afterwards.
- *
- * @param token - The token retrieved from the reset password URL.
- * @param newPassword - A new password for the user. This is not sent in plain text over the wire.
- */
- resetPassword(token: string, newPassword: string): angular.IPromise;
-
- /**
- * Marks the user's email address as verified. Logs the user in afterwards.
- *
- * @param token - The token retrieved from the reset password URL.
- */
- verifyEmail(token: string): angular.IPromise;
-
- loginWithFacebook: ILoginWithExternalService;
- loginWithTwitter: ILoginWithExternalService;
- loginWithGoogle: ILoginWithExternalService;
- loginWithGithub: ILoginWithExternalService;
- loginWithMeetup: ILoginWithExternalService;
- loginWithWeibo: ILoginWithExternalService;
-
- /**
- * Log the user out.
- *
- * @return Resolves with no arguments on success, or reject with a Error argument on failure.
- */
- logout(): angular.IPromise;
-
- /**
- * Log out other clients logged in as the current user, but does not log out the client that calls this function.
- * For example, when called in a user's browser, connections in that browser remain logged in,
- * but any other browsers or DDP clients logged in as that user will be logged out.
- *
- * @return Resolves with no arguments on success, or reject with a Error argument on failure.
- */
- logoutOtherClients(): angular.IPromise;
-
- // <- User Authentication END
- // $meteorUtils BEGIN ->
-
- /**
- * @param scope - The AngularJS scope you use the autorun on.
- * @param fn - The function that will re-run every time a reactive variable changes inside it.
- */
- autorun(scope: angular.IScope, fn: Function): void;
-
- /**
- * @param collectionName - The name of the collection you want to get back
- */
- getCollectionByName(collectionName: string): Mongo.Collection;
-
- // <- $meteorUtils END
- // $meteorCamera BEGIN ->
-
- /**
- * A helper service for taking pictures across platforms.
- * Must add mdg:camera package to use! (meteor add mdg:camera)
- *
- * @param [options] - options is an optional argument that is an Object with the following possible keys:
- * @param options.width - An integer that specifies the minimum width of the returned photo.
- * @param options.height - An integer that specifies the minimum height of the returned photo.
- * @param options.quality - A number from 0 to 100 specifying the desired quality of JPEG encoding.
- *
- * @return The promise solved successfully when the picture is taken with the data as a parameter or rejected with an error as a parameter in case of error.
- */
- getPicture(options?: {width?: number; height?: number; quality?: number}): angular.IPromise;
-
- // <- $meteorCamera END
-
- /**
- * A service that binds a scope variable to a Meteor Session variable.
- *
- * @param sessionKey - The name of the session variable
- * @return An object with a single function bind - to bind to that variable.
- */
- session(sessionKey: string): {
- /**
- * @param scope - The scope the document will be bound to.
- * @param model - The name of the scope's model variable that the document will be bound to.
- */
- bind: (scope: IScope, model: string) => void;
- };
- }
-
- /**
- * An object that connects a Meteor Object to an AngularJS scope variable.
- *
- * The object contains also all the properties from the generic type T,
- * unfortunately TypeScript doesn't at the moment allow to extend a generic type (see https://github.com/Microsoft/TypeScript/issues/2225 for details and updates).
- * For a workaround, you'll need to implement an interface which will merge AngularMeteorObject together with T and cast it, like this:
- *
- * interface TodoAngularMeteorObject extends ITodo, AngularMeteorObject { }
- * var todo = $meteor.object(TodoCollection, 'TodoID');
- */
- interface AngularMeteorObject {
- /**
- * @param [doc] - The doc to save to the Meteor Object. If nothing is passed, the method saves everything in the AngularMeteorObject as is.
- * - Unchanged properties will be overridden with their existing values, which may trigger hooks.
- * - If doc is passed, the method only updates the Meteor Object with the properties passed, and no other changes will be saved.
- *
- * @return Returns a promise with an error in case for an error or a number of successful docs changed in case of success.
- */
- save(doc?: T): angular.IPromise;
-
- /**
- * Reset the current value of the object to the one in the server.
- */
- reset(): void;
-
- /**
- * Returns a copy of the AngularMeteorObject with all the AngularMeteor-specific internal properties removed.
- * The returned object is then safe to use as a parameter for method calls, or anywhere else where the data needs to be converted to JSON.
- */
- getRawObject(): T;
-
- /**
- * A shorten (Syntactic sugar) function for the $meteor.subscribe function.
- * Takes only one parameter and not returns a promise like $meteor.subscribe does.
- *
- * @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service.
- */
- subscribe(subscriptionName:string): AngularMeteorObject;
- }
-
- /**
- * An object that connects a Meteor Collection to an AngularJS scope variable
- */
- interface AngularMeteorCollection extends AngularMeteorCollection2 { }
-
- /**
- * An object that connects a Meteor Collection to an AngularJS scope variable,
- * but can use a differen type for updates.
- */
- interface AngularMeteorCollection2 extends Array {
- /**
- * @param [docs] - The docs to save to the Meteor Collection.
- * - If the docs parameter is empty, the method saves everything in the AngularMeteorCollection as is.
- * - If an object is passed, the method pushes that object into the AngularMeteorCollection.
- * - If an array is passed, the method pushes all objects in the array into the AngularMeteorCollection.
- */
- save(docs?: U|U[]): void;
-
- /**
- * @param [keys] - The keys of the object to remove from the Meteor Collection.
- * - If nothing is passed, the method removes all the documents from the AngularMeteorCollection.
- * - If an object is passed, the method removes the object with that key from the AngularMeteorCollection.
- * - If an array is passed, the method removes all objects that matches the keys in the array from the AngularMeteorCollection.
- */
- remove(keys?: U|string|number|string[]|number[]): void;
-
- /**
- * A shorten (Syntactic sugar) function for the $meteor.subscribe function.
- * Takes only one parameter and not returns a promise like $meteor.subscribe does.
- *
- * @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service.
- */
- subscribe(subscriptionName:string): AngularMeteorCollection2;
- }
-
- interface ILoginWithExternalService {
- (options: Meteor.LoginWithExternalServiceOptions): angular.IPromise;
- }
-
- interface ReactiveResult { }
-}
+// Type definitions for Angular JS Meteor v0.8.8 (angular.meteor module)
+// Project: https://github.com/Urigo/angular-meteor
+// Definitions by: Peter Grman
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+///
+
+declare module angular.meteor {
+ interface IRootScopeService extends angular.IRootScopeService {
+ /**
+ * The current logged in user and it's data. it is null if the user is not logged in. A reactive data source.
+ */
+ currentUser: Meteor.User;
+
+ /**
+ * True if a login method (such as Meteor.loginWithPassword, Meteor.loginWithFacebook, or Accounts.createUser) is currently in progress.
+ * A reactive data source. Can be use to display animation while user is logging in.
+ */
+ loggingIn: boolean;
+ }
+
+ interface IScope extends angular.IScope, IRootScopeService {
+ /**
+ * A method to get a $scope variable and watch it reactivly
+ *
+ * @param scopeVariableName - The name of the scope's variable to bind to
+ * @param [objectEquality=false] - Watch the object equality using angular.equals instead of comparing for reference equality, deeper watch but also slower
+ */
+ getReactively(scopeVariableName: string, objectEquality?: boolean): ReactiveResult;
+
+ /**
+ * A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready.
+ * Calling $scope.subscribe will automatically stop the subscription when the scope is destroyed.
+ *
+ * @param name - Name of the subscription. Matches the name of the server's publish() call.
+ * @param publisherArguments - Optional arguments passed to publisher function on server.
+ *
+ * @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle.
+ */
+ subscribe(name: string, ...publisherArguments: any[]): angular.IPromise;
+
+ /**
+ * The helpers method is part of the ReactiveContext, and available on every context and $scope.
+ * These method are defined as Object, where each key is the name of the variable that will be available on the context we run, and each value is a function with a return value.
+ * Under the hood, each helper starts a new Tracker.autorun. When its reactive dependencies change, the helper is rerun.
+ * To trigger a rerun every time an specific Angular variable change, use getReactively](/api/1.3.1/get-reactively) to make your Angular variable reactive inside the helper its used in.
+ * Each helper function should return a MongoDB Cursor and the helpers will expose it as a normal array to the context.
+ *
+ * @param definitions - Object containing `name` => `function` definition, where each name is a string and each function is the helper function. Should return a [MongoDB Cursor](http://docs.meteor.com/#/full/mongo_cursor)
+ * @return This method returns this, which the the reactive context, in order to provide the ability to chain the logic.
+ */
+ helpers(definitions : { [helperName : string] : () => Mongo.Cursor }): IScope;
+
+ /**
+ * This method is a wrapper of Tracker.autorun and shares exactly the same API.
+ * The autorun method is part of the ReactiveContext, and available on every context and $scope.
+ * The argument of this method is a callback, which will be called each time Autorun will be used.
+ * The Autorun will stop automatically when when it's context ($scope) is destroyed.
+ *
+ * @param runFunc - The function to run. It receives one argument: the Computation object that will be returned.
+ */
+ autorun(runFunc : () => void) : Tracker.Computation;
+ }
+
+ /**
+ * $meteor in angularjs
+ */
+ interface IMeteorService {
+ /**
+ * A service that wraps the Meteor collections to enable reactivity within AngularJS.
+ *
+ * @param collection - A Meteor Collection or a reactive function to bind to.
+ * - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor.
+ * @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection.
+ * - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.
+ */
+ collection(collection: Mongo.Collection|ReactiveResult|Function|(()=>T), autoClientSave?: boolean): AngularMeteorCollection;
+
+ /**
+ * A service that wraps the Meteor collections to enable reactivity within AngularJS.
+ *
+ * @param collection - A Meteor Collection or a reactive function to bind to.
+ * - Reactive function can be used with $scope.getReactively to add $scope variable as reactive variable to the cursor.
+ * @param [autoClientSave=true] - By default, changes in the Angular collection will automatically update the Meteor collection.
+ * - However if set to false, changes in the client won't be automatically propagated back to the Meteor collection.
+ * @param [updateCollection] - A collection object which will be used for updates (insert, update, delete).
+ */
+ collection(collection: Mongo.Collection|ReactiveResult|Function|(()=>T), autoClientSave: boolean, updateCollection: Mongo.Collection): AngularMeteorCollection2;
+
+ /**
+ * A service that wraps a Meteor object to enable reactivity within AngularJS.
+ * Finds the first document that matches the selector, as ordered by sort and skip options. Wraps collection.findOne
+ *
+ * @param collection - A Meteor Collection to bind to.
+ * @param selector - A query describing the documents to find or just the ID of the document.
+ * - $meteor.object will find the first document that matches the selector,
+ * - as ordered by sort and skip options, exactly like Meteor's collection.findOne
+ * @param [autoClientSave=true] - By default, changes in the Angular object will automatically update the Meteor object.
+ * - However if set to false, changes in the client won't be automatically propagated back to the Meteor object.
+ */
+ object(collection: Mongo.Collection, selector: Mongo.Selector|Mongo.ObjectID|string, autoClientSave?: boolean): AngularMeteorObject;
+
+ /**
+ * A service which is a wrapper for Meteor.subscribe. It subscribes to a Meteor.publish method in the client and returns a AngularJS promise when ready.
+ *
+ * @param name - Name of the subscription. Matches the name of the server's publish() call.
+ * @param publisherArguments - Optional arguments passed to publisher function on server.
+ *
+ * @return The promise solved successfully when subscription is ready. The success promise holds the subscription handle.
+ */
+ subscribe(name: string, ...publisherArguments: any[]): angular.IPromise;
+
+ /**
+ * A service service which wraps up Meteor.methods with AngularJS promises.
+ *
+ * @param name - Name of method to invoke
+ * @param methodArguments - Optional method arguments
+ *
+ * @return The promise solves successfully with the return value of the method or return reject with the error from the method.
+ */
+ call(name: string, ...methodArguments: any[]): angular.IPromise;
+
+ // User Authentication BEGIN ->
+
+ /**
+ * Returns a promise fulfilled with the currentUser when the user subscription is ready.
+ * This is useful when you want to grab the current user before the route is rendered.
+ * If there is no logged in user, it will return null.
+ * See the “Authentication with Routers” section of our tutorial for more information and a full example.
+ */
+ waitForUser(): angular.IPromise;
+
+ /**
+ * Resolves the promise successfully if a user is authenticated and rejects otherwise.
+ * This is useful in cases where you want to require a route to have an authenticated user.
+ * You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page.
+ * See the “Authentication with Routers” section of our tutorial for more information and a full example.
+ */
+ requireUser(): angular.IPromise;
+
+ /**
+ * Resolves the promise successfully if a user is authenticated and the validatorFn returns true; rejects otherwise.
+ * This is useful in cases where you want to require a route to have an authenticated user and do extra validation like the user's role or group.
+ * You can catch the rejected promise and redirect the unauthenticated user to a different page, such as the login page.
+ * See the “Authentication with Routers” section of our tutorial for more information and a full example.
+ *
+ * The mandatory validator function will be called with the authenticated user as the single param and it's expected to return true in order to resolve.
+ * If it returns a string, the promise will be rejected using said string as the reason.
+ * Any other return (false, null, undefined) will be rejected with the default "FORBIDDEN" reason.
+ */
+ requireValidUser(validatorFn: (user: Meteor.User) => boolean|string): angular.IPromise;
+
+ /**
+ * Log the user in with a password.
+ *
+ * @param user - Either a string interpreted as a username or an email; or an object with a single key: email, username or id.
+ * @param password - The user's password.
+ */
+ loginWithPassword(user: string|{email: string}|{username: string}|{id: string}, password: string): angular.IPromise;
+
+ /**
+ * Create a new user. More information: http://docs.meteor.com/#/full/accounts_createuser
+ *
+ * @param options.username - A unique name for this user. Either this, or email is required.
+ * @param options.email - The user's email address. Either this, or username is required.
+ * @param options.password - The user's password. This is not sent in plain text over the wire.
+ * @param options.profile - The user's profile, typically including the name field.
+ */
+ createUser(options: {username?: string; email?: string; password: string; profile?: Object}): angular.IPromise;
+
+ /**
+ * Change the current user's password. Must be logged in.
+ *
+ * @param oldPassword - The user's current password. This is not sent in plain text over the wire.
+ * @param newPassword - A new password for the user. This is not sent in plain text over the wire.
+ */
+ changePassword(oldPassword: string, newPassword: string): angular.IPromise;
+
+ /**
+ * Request a forgot password email.
+ *
+ * @param options.email - The email address to send a password reset link.
+ */
+ forgotPassword(options: {email: string}): angular.IPromise;
+
+ /**
+ * Reset the password for a user using a token received in email. Logs the user in afterwards.
+ *
+ * @param token - The token retrieved from the reset password URL.
+ * @param newPassword - A new password for the user. This is not sent in plain text over the wire.
+ */
+ resetPassword(token: string, newPassword: string): angular.IPromise;
+
+ /**
+ * Marks the user's email address as verified. Logs the user in afterwards.
+ *
+ * @param token - The token retrieved from the reset password URL.
+ */
+ verifyEmail(token: string): angular.IPromise;
+
+ loginWithFacebook: ILoginWithExternalService;
+ loginWithTwitter: ILoginWithExternalService;
+ loginWithGoogle: ILoginWithExternalService;
+ loginWithGithub: ILoginWithExternalService;
+ loginWithMeetup: ILoginWithExternalService;
+ loginWithWeibo: ILoginWithExternalService;
+
+ /**
+ * Log the user out.
+ *
+ * @return Resolves with no arguments on success, or reject with a Error argument on failure.
+ */
+ logout(): angular.IPromise;
+
+ /**
+ * Log out other clients logged in as the current user, but does not log out the client that calls this function.
+ * For example, when called in a user's browser, connections in that browser remain logged in,
+ * but any other browsers or DDP clients logged in as that user will be logged out.
+ *
+ * @return Resolves with no arguments on success, or reject with a Error argument on failure.
+ */
+ logoutOtherClients(): angular.IPromise;
+
+ // <- User Authentication END
+ // $meteorUtils BEGIN ->
+
+ /**
+ * @param scope - The AngularJS scope you use the autorun on.
+ * @param fn - The function that will re-run every time a reactive variable changes inside it.
+ */
+ autorun(scope: angular.IScope, fn: Function): void;
+
+ /**
+ * @param collectionName - The name of the collection you want to get back
+ */
+ getCollectionByName(collectionName: string): Mongo.Collection;
+
+ // <- $meteorUtils END
+ // $meteorCamera BEGIN ->
+
+ /**
+ * A helper service for taking pictures across platforms.
+ * Must add mdg:camera package to use! (meteor add mdg:camera)
+ *
+ * @param [options] - options is an optional argument that is an Object with the following possible keys:
+ * @param options.width - An integer that specifies the minimum width of the returned photo.
+ * @param options.height - An integer that specifies the minimum height of the returned photo.
+ * @param options.quality - A number from 0 to 100 specifying the desired quality of JPEG encoding.
+ *
+ * @return The promise solved successfully when the picture is taken with the data as a parameter or rejected with an error as a parameter in case of error.
+ */
+ getPicture(options?: {width?: number; height?: number; quality?: number}): angular.IPromise;
+
+ // <- $meteorCamera END
+
+ /**
+ * A service that binds a scope variable to a Meteor Session variable.
+ *
+ * @param sessionKey - The name of the session variable
+ * @return An object with a single function bind - to bind to that variable.
+ */
+ session(sessionKey: string): {
+ /**
+ * @param scope - The scope the document will be bound to.
+ * @param model - The name of the scope's model variable that the document will be bound to.
+ */
+ bind: (scope: IScope, model: string) => void;
+ };
+ }
+
+ /**
+ * An object that connects a Meteor Object to an AngularJS scope variable.
+ *
+ * The object contains also all the properties from the generic type T,
+ * unfortunately TypeScript doesn't at the moment allow to extend a generic type (see https://github.com/Microsoft/TypeScript/issues/2225 for details and updates).
+ * For a workaround, you'll need to implement an interface which will merge AngularMeteorObject together with T and cast it, like this:
+ *
+ * interface TodoAngularMeteorObject extends ITodo, AngularMeteorObject { }
+ * var todo = $meteor.object(TodoCollection, 'TodoID');
+ */
+ interface AngularMeteorObject {
+ /**
+ * @param [doc] - The doc to save to the Meteor Object. If nothing is passed, the method saves everything in the AngularMeteorObject as is.
+ * - Unchanged properties will be overridden with their existing values, which may trigger hooks.
+ * - If doc is passed, the method only updates the Meteor Object with the properties passed, and no other changes will be saved.
+ *
+ * @return Returns a promise with an error in case for an error or a number of successful docs changed in case of success.
+ */
+ save(doc?: T): angular.IPromise;
+
+ /**
+ * Reset the current value of the object to the one in the server.
+ */
+ reset(): void;
+
+ /**
+ * Returns a copy of the AngularMeteorObject with all the AngularMeteor-specific internal properties removed.
+ * The returned object is then safe to use as a parameter for method calls, or anywhere else where the data needs to be converted to JSON.
+ */
+ getRawObject(): T;
+
+ /**
+ * A shorten (Syntactic sugar) function for the $meteor.subscribe function.
+ * Takes only one parameter and not returns a promise like $meteor.subscribe does.
+ *
+ * @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service.
+ */
+ subscribe(subscriptionName:string): AngularMeteorObject;
+ }
+
+ /**
+ * An object that connects a Meteor Collection to an AngularJS scope variable
+ */
+ interface AngularMeteorCollection extends AngularMeteorCollection2 { }
+
+ /**
+ * An object that connects a Meteor Collection to an AngularJS scope variable,
+ * but can use a differen type for updates.
+ */
+ interface AngularMeteorCollection2 extends Array {
+ /**
+ * @param [docs] - The docs to save to the Meteor Collection.
+ * - If the docs parameter is empty, the method saves everything in the AngularMeteorCollection as is.
+ * - If an object is passed, the method pushes that object into the AngularMeteorCollection.
+ * - If an array is passed, the method pushes all objects in the array into the AngularMeteorCollection.
+ */
+ save(docs?: U|U[]): void;
+
+ /**
+ * @param [keys] - The keys of the object to remove from the Meteor Collection.
+ * - If nothing is passed, the method removes all the documents from the AngularMeteorCollection.
+ * - If an object is passed, the method removes the object with that key from the AngularMeteorCollection.
+ * - If an array is passed, the method removes all objects that matches the keys in the array from the AngularMeteorCollection.
+ */
+ remove(keys?: U|string|number|string[]|number[]): void;
+
+ /**
+ * A shorten (Syntactic sugar) function for the $meteor.subscribe function.
+ * Takes only one parameter and not returns a promise like $meteor.subscribe does.
+ *
+ * @param subscriptionName - The subscription name to subscribe to. Exactly like the first parameter in $meteor.subscribe service.
+ */
+ subscribe(subscriptionName:string): AngularMeteorCollection2;
+ }
+
+ interface ILoginWithExternalService {
+ (options: Meteor.LoginWithExternalServiceOptions): angular.IPromise;
+ }
+
+ interface ReactiveResult { }
+}
diff --git a/angular-touchspin/angular-touchspin-tests.ts b/angular-touchspin/angular-touchspin-tests.ts
new file mode 100644
index 000000000..c6e229c7f
--- /dev/null
+++ b/angular-touchspin/angular-touchspin-tests.ts
@@ -0,0 +1,29 @@
+///
+///
+
+angular
+ .module('touchspin-tests', ['lm.touchspin'])
+ .config(function(touchspinConfigProvider: angularTouchSpin.ITouchSpinConfigProvider) {
+ touchspinConfigProvider.defaults({
+ min: 0,
+ max: 0,
+ step: 0,
+ decimals: 0,
+ stepInterval: 0,
+ forceStepDivisibility: '', // none | floor | round | ceil
+ stepIntervalDelay: 0,
+ verticalButtons: true,
+ verticalUpClass: '',
+ verticalDownClass: '',
+ initVal: 0,
+ prefix: '',
+ postfix: '',
+ prefixExtraClass: '',
+ postfixExtraClass: '',
+ mousewheel: true,
+ buttonDownClass: '',
+ buttonUpClass: '',
+ buttonDownTxt: '',
+ buttonUpTxt: ''
+ });
+ });
diff --git a/angular-touchspin/angular-touchspin.d.ts b/angular-touchspin/angular-touchspin.d.ts
new file mode 100644
index 000000000..08cc353a3
--- /dev/null
+++ b/angular-touchspin/angular-touchspin.d.ts
@@ -0,0 +1,43 @@
+// Type definitions for Angular Touchspin v1.0.0
+// Project: https://github.com/nkovacic/angular-touchspin
+// Definitions by: Niko Kovačič
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+////
+
+
+declare module "angular-touchspin" {
+ let _: string;
+ export = _;
+}
+
+declare module angularTouchSpin {
+ interface ITouchSpinOptions {
+ min?: number;
+ max?: number;
+ step?: number;
+ decimals?: number;
+ stepInterval?: number;
+ forceStepDivisibility?: string; // none | floor | round | ceil
+ stepIntervalDelay?: number;
+ verticalButtons?: boolean;
+ verticalUpClass?: string;
+ verticalDownClass?: string;
+ initVal?: number;
+ prefix?: string;
+ postfix?: string;
+ prefixExtraClass?: string;
+ postfixExtraClass?: string;
+ mousewheel?: boolean;
+ buttonDownClass?: string;
+ buttonUpClass?: string;
+ buttonDownTxt?: string;
+ buttonUpTxt?: string;
+ }
+
+ interface ITouchSpinConfig extends ITouchSpinOptions { }
+
+ interface ITouchSpinConfigProvider {
+ defaults(touchSpinOptions: ITouchSpinOptions): void;
+ }
+}
\ No newline at end of file
diff --git a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts
index 8ebfdb6c2..5b9d09d46 100644
--- a/angular-ui-bootstrap/angular-ui-bootstrap.d.ts
+++ b/angular-ui-bootstrap/angular-ui-bootstrap.d.ts
@@ -6,7 +6,15 @@
///
// Support for AMD require
-declare module 'angular-bootstrap' {}
+declare module 'angular-bootstrap' {
+ let _: string;
+ export = _;
+}
+
+declare module 'angular-ui-bootstrap' {
+ let _: string;
+ export = _;
+}
declare module angular.ui.bootstrap {
diff --git a/angularjs/README.md b/angularjs/README.md
index e1256e905..cdd952454 100644
--- a/angularjs/README.md
+++ b/angularjs/README.md
@@ -1,230 +1,230 @@
-# AngularJS Definitions Usage Notes
-
-## Referencing AngularJS definition files in your code
-
-To do that, simply add `/// ` at the top of your code.
-
-That will make available to your code all interfaces AngularJS' main module **ng** implements, as well as the **AUTO** module.
-
-If you are including other AngularJS' modules in your code, like **ngResource**, just like you needed to include the additional module implementation file in your code, _angular-resource.js_, you will also need to reference the definitions file related to that module. Your code would then have the following definitions files reference:
-
- ///
- ///
-
-Having these modules in separated files is actually good because they sometimes either augment or modify some of **ng**'s interfaces, and thus those differences should only be available to you when you really need them. Also, it forces you to explicit what you're going to be using.
-
-The following extra definition files are available for referencing:
-
-* angular-resource.d.ts (for the **ngResource** module)
-* angular-route.d.ts (for the **ngRoute** module)
-* angular-cookies.d.ts (for the **ngCookies** module)
-* angular-sanitize.d.ts (for the **ngSanitize** module)
-* angular-mocks.d.ts (for the **ngMock** and **ngMockE2E** modules)
-
-(postfix with version number for specific verion, eg. angular-resource-1.0.d.ts)
-
-## The Angular Static
-
-The definitions declare the AngularJS static variable `angular` as ambient. That means that, after referencing the AngularJS definition, you will be able to get type checks and code assistance for the global `angular` member.
-
-
-## Definitions modularized
-
-To avoid cluttering the list of suggestions as you type in your IDE, all interfaces reside in their respective module namespace:
-
-* `ng` for AngularJS' **ng** module
-* `ng.auto` for **AUTO**
-* `ng.cookies` for **ngCookies**
-* `ng.mock` for **ngMock**
-* `ng.resource` for **ngResource**
-* `ng.route` for **ngRoute**
-* `ng.sanitize` for **ngSanitize**
-
-**ngMockE2E** does not define a new namespace, but rather modifies some of **ng**'s interfaces.
-
-Below is an example of how to use the interfaces:
-```ts
-function MainController($scope: ng.IScope, $http: ng.IHttpService) {
- // code assistance will now be available for $scope and $http
-}
-```
-
-## Services and other injectables
-
-AngularJS makes vast use of what it calls "injectable" functions. To put it simple, in AngularJS you are constantly annotating your functions and constructors with their dependencies, services that are going to be provided as arguments automagically during invocation.
-
-All known services interfaces have been defined, and were named using the following convention:
-
-**I + 'ServiceName' + 'Service'**
-
-So, for instance, the **$parse** service has it's interface defined as **ng.IParseService**.
-
-Service providers, by the same logic, follow this convention:
-
-**I + 'ServiceName' + 'Provider'**
-
-The **$httpProvider**, thus, is defined by **ng.IHttpProvider**.
-
-
-## A word on $scope and assigning new members
-
-TypeScript allows for static checking. Among other obvious things, that means you're gonna have to extend interfaces when you need to augment an object whose interface has been defined, because otherwise the compiler will see it as an error to try to assign a value to a unspecified member.
-
-Consider the following ordinary code:
-```ts
-function Controller($scope) {
- $scope.$broadcast('myEvent');
- $scope.title = 'Yabadabadu';
-}
-```
-That will not produce any compilation error because the compiler does not know the first thing about $scope to do any checking. For that same reason, you will not get any assistance either.
-
-Now consider this:
-```ts
-function Controller($scope: ng.IScope) {
- $scope.$broadcast('myEvent');
- $scope.title = 'Yabadabadu';
-}
-```
-
-Now we annotated `$scope` with the interface `ng.IScope`. The compiler now knows that, among other members, `$scope` has a method called `$broadcast`. That interface, however, does not define a `title` property. The compiler will complain about it.
-
-Since you are augmenting the $scope object, you should let the compiler know what to expect then:
-```ts
-interface ICustomScope extends ng.IScope {
- title: string;
-}
-
-function Controller($scope: ICustomScope) {
- $scope.$broadcast('myEvent');
- $scope.title = 'Yabadabadu';
-}
-```
-
-## Examples
-
-### Working with $resource
-```ts
-///
-///
-
-// We have the option to define arguments for a custom resource
-interface IArticleParameters {
- id: number;
-}
-
-interface IArticleResource extends ng.resource.IResource {
- title: string;
- text: string;
- date: Date;
- author: number;
-
- // Although all actions defined on IArticleResourceClass are avaiable with
- // the '$' prefix, we have the choice to expose only what we will use
- $publish(): IArticleResource;
- $unpublish(): IArticleResource;
-}
-
-// Let's define a custom resource
-interface IArticleResourceClass extends ng.resource.IResourceClass {
- // Overload get to accept our custom parameters
- get(): ng.resource.IResource;
- get(params: IArticleParameters, onSuccess: Function): IArticleResource;
-
- // Add our custom resource actions
- publish(): IArticleResource;
- publish(params: IArticleParameters): IArticleResource;
- unpublish(params: IArticleParameters): IArticleResource;
-}
-
-function MainController($resource: ng.resource.IResourceService) {
-
- // IntelliSense will provide IActionDescriptor interface and will validate
- // your assignment against it
- var publishDescriptor: ng.resource.IActionDescriptor;
- publishDescriptor = {
- method: 'GET',
- isArray: false
- };
-
- // I could still create a descriptor without the interface...
- var unpublishDescriptor = {
- method: 'POST'
- }
-
- // A call to the $resource service returns a IResourceClass. Since
- // our own IArticleResourceClass defines 2 more actions, we cast the return
- // value to make the compiler aware of that
- var articleResource = $resource('/articles/:id', null, {
- publish : publishDescriptor,
- unpublish : unpublishDescriptor
- });
-
- // Now we can do this
- articleResource.unpublish({ id: 1 });
-
- // IResourceClass.get() will be automatically available here
- var article: IArticleResource = articleResource.get({id: 1}, function success() {
- // Again, default + custom action here...
- article.title = 'New Title';
- article.$save();
- article.$publish();
- });
-}
-```
-
-### Working with $resource in angular-1.0 definitions
-```ts
-///
-///
-
-// Let's define a custom resource
-interface IArticleResourceClass extends ng.resource.IResourceClass {
- publish: ng.resource.IActionCall;
- unpublish: ng.resource.IActionCall;
-}
-interface IArticleResource extends ng.resource.IResource {
- title: string;
- text: string;
- date: Date;
- author: number;
- $publish: ng.resource.IActionCall;
- $unpublish: ng.resource.IActionCall;
-}
-
-function MainController($resource: ng.resource.IResourceService) {
-
- // IntelliSense will provide IActionDescriptor interface and will validate
- // your assignment against it
- var publishDescriptor: ng.resource.IActionDescriptor;
- publishDescriptor = {
- method: 'GET',
- isArray: false
- };
-
- // I could still create a descriptor without the interface...
- var unpublishDescriptor = {
- method: 'POST'
- }
-
- // A call to the $resource service returns a IResourceClass. Since
- // our own IArticleResourceClass defines 2 more actions, we cast the return
- // value to make the compiler aware of that
- var articles = $resource('/articles/:id', null, {
- publish : publishDescriptor,
- unpublish : unpublishDescriptor
- });
-
- // Now we can do this
- articles.unpublish({ id: 1 });
-
- // IResourceClass.get() will be automatically available here
- var article = articles.get({id: 1});
-
- // Again, default + custom action here...
- article.title = 'New Title';
- article.$save();
- article.$publish();
-
-}
-```
+# AngularJS Definitions Usage Notes
+
+## Referencing AngularJS definition files in your code
+
+To do that, simply add `/// ` at the top of your code.
+
+That will make available to your code all interfaces AngularJS' main module **ng** implements, as well as the **AUTO** module.
+
+If you are including other AngularJS' modules in your code, like **ngResource**, just like you needed to include the additional module implementation file in your code, _angular-resource.js_, you will also need to reference the definitions file related to that module. Your code would then have the following definitions files reference:
+
+ ///
+ ///
+
+Having these modules in separated files is actually good because they sometimes either augment or modify some of **ng**'s interfaces, and thus those differences should only be available to you when you really need them. Also, it forces you to explicit what you're going to be using.
+
+The following extra definition files are available for referencing:
+
+* angular-resource.d.ts (for the **ngResource** module)
+* angular-route.d.ts (for the **ngRoute** module)
+* angular-cookies.d.ts (for the **ngCookies** module)
+* angular-sanitize.d.ts (for the **ngSanitize** module)
+* angular-mocks.d.ts (for the **ngMock** and **ngMockE2E** modules)
+
+(postfix with version number for specific verion, eg. angular-resource-1.0.d.ts)
+
+## The Angular Static
+
+The definitions declare the AngularJS static variable `angular` as ambient. That means that, after referencing the AngularJS definition, you will be able to get type checks and code assistance for the global `angular` member.
+
+
+## Definitions modularized
+
+To avoid cluttering the list of suggestions as you type in your IDE, all interfaces reside in their respective module namespace:
+
+* `ng` for AngularJS' **ng** module
+* `ng.auto` for **AUTO**
+* `ng.cookies` for **ngCookies**
+* `ng.mock` for **ngMock**
+* `ng.resource` for **ngResource**
+* `ng.route` for **ngRoute**
+* `ng.sanitize` for **ngSanitize**
+
+**ngMockE2E** does not define a new namespace, but rather modifies some of **ng**'s interfaces.
+
+Below is an example of how to use the interfaces:
+```ts
+function MainController($scope: ng.IScope, $http: ng.IHttpService) {
+ // code assistance will now be available for $scope and $http
+}
+```
+
+## Services and other injectables
+
+AngularJS makes vast use of what it calls "injectable" functions. To put it simple, in AngularJS you are constantly annotating your functions and constructors with their dependencies, services that are going to be provided as arguments automagically during invocation.
+
+All known services interfaces have been defined, and were named using the following convention:
+
+**I + 'ServiceName' + 'Service'**
+
+So, for instance, the **$parse** service has it's interface defined as **ng.IParseService**.
+
+Service providers, by the same logic, follow this convention:
+
+**I + 'ServiceName' + 'Provider'**
+
+The **$httpProvider**, thus, is defined by **ng.IHttpProvider**.
+
+
+## A word on $scope and assigning new members
+
+TypeScript allows for static checking. Among other obvious things, that means you're gonna have to extend interfaces when you need to augment an object whose interface has been defined, because otherwise the compiler will see it as an error to try to assign a value to a unspecified member.
+
+Consider the following ordinary code:
+```ts
+function Controller($scope) {
+ $scope.$broadcast('myEvent');
+ $scope.title = 'Yabadabadu';
+}
+```
+That will not produce any compilation error because the compiler does not know the first thing about $scope to do any checking. For that same reason, you will not get any assistance either.
+
+Now consider this:
+```ts
+function Controller($scope: ng.IScope) {
+ $scope.$broadcast('myEvent');
+ $scope.title = 'Yabadabadu';
+}
+```
+
+Now we annotated `$scope` with the interface `ng.IScope`. The compiler now knows that, among other members, `$scope` has a method called `$broadcast`. That interface, however, does not define a `title` property. The compiler will complain about it.
+
+Since you are augmenting the $scope object, you should let the compiler know what to expect then:
+```ts
+interface ICustomScope extends ng.IScope {
+ title: string;
+}
+
+function Controller($scope: ICustomScope) {
+ $scope.$broadcast('myEvent');
+ $scope.title = 'Yabadabadu';
+}
+```
+
+## Examples
+
+### Working with $resource
+```ts
+///
+///
+
+// We have the option to define arguments for a custom resource
+interface IArticleParameters {
+ id: number;
+}
+
+interface IArticleResource extends ng.resource.IResource {
+ title: string;
+ text: string;
+ date: Date;
+ author: number;
+
+ // Although all actions defined on IArticleResourceClass are avaiable with
+ // the '$' prefix, we have the choice to expose only what we will use
+ $publish(): IArticleResource;
+ $unpublish(): IArticleResource;
+}
+
+// Let's define a custom resource
+interface IArticleResourceClass extends ng.resource.IResourceClass {
+ // Overload get to accept our custom parameters
+ get(): ng.resource.IResource;
+ get(params: IArticleParameters, onSuccess: Function): IArticleResource;
+
+ // Add our custom resource actions
+ publish(): IArticleResource;
+ publish(params: IArticleParameters): IArticleResource;
+ unpublish(params: IArticleParameters): IArticleResource;
+}
+
+function MainController($resource: ng.resource.IResourceService) {
+
+ // IntelliSense will provide IActionDescriptor interface and will validate
+ // your assignment against it
+ var publishDescriptor: ng.resource.IActionDescriptor;
+ publishDescriptor = {
+ method: 'GET',
+ isArray: false
+ };
+
+ // I could still create a descriptor without the interface...
+ var unpublishDescriptor = {
+ method: 'POST'
+ }
+
+ // A call to the $resource service returns a IResourceClass. Since
+ // our own IArticleResourceClass defines 2 more actions, we cast the return
+ // value to make the compiler aware of that
+ var articleResource = $resource('/articles/:id', null, {
+ publish : publishDescriptor,
+ unpublish : unpublishDescriptor
+ });
+
+ // Now we can do this
+ articleResource.unpublish({ id: 1 });
+
+ // IResourceClass.get() will be automatically available here
+ var article: IArticleResource = articleResource.get({id: 1}, function success() {
+ // Again, default + custom action here...
+ article.title = 'New Title';
+ article.$save();
+ article.$publish();
+ });
+}
+```
+
+### Working with $resource in angular-1.0 definitions
+```ts
+///
+///
+
+// Let's define a custom resource
+interface IArticleResourceClass extends ng.resource.IResourceClass {
+ publish: ng.resource.IActionCall;
+ unpublish: ng.resource.IActionCall;
+}
+interface IArticleResource extends ng.resource.IResource {
+ title: string;
+ text: string;
+ date: Date;
+ author: number;
+ $publish: ng.resource.IActionCall;
+ $unpublish: ng.resource.IActionCall;
+}
+
+function MainController($resource: ng.resource.IResourceService) {
+
+ // IntelliSense will provide IActionDescriptor interface and will validate
+ // your assignment against it
+ var publishDescriptor: ng.resource.IActionDescriptor;
+ publishDescriptor = {
+ method: 'GET',
+ isArray: false
+ };
+
+ // I could still create a descriptor without the interface...
+ var unpublishDescriptor = {
+ method: 'POST'
+ }
+
+ // A call to the $resource service returns a IResourceClass. Since
+ // our own IArticleResourceClass defines 2 more actions, we cast the return
+ // value to make the compiler aware of that
+ var articles = $resource('/articles/:id', null, {
+ publish : publishDescriptor,
+ unpublish : unpublishDescriptor
+ });
+
+ // Now we can do this
+ articles.unpublish({ id: 1 });
+
+ // IResourceClass.get() will be automatically available here
+ var article = articles.get({id: 1});
+
+ // Again, default + custom action here...
+ article.title = 'New Title';
+ article.$save();
+ article.$publish();
+
+}
+```
diff --git a/angularjs/angular-cookies.d.ts b/angularjs/angular-cookies.d.ts
index 25efc42de..3a5f53504 100644
--- a/angularjs/angular-cookies.d.ts
+++ b/angularjs/angular-cookies.d.ts
@@ -1,91 +1,91 @@
-// Type definitions for Angular JS 1.4 (ngCookies module)
-// Project: http://angularjs.org
-// Definitions by: Diego Vilar , Anthony Ciccarello
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-
-///
-
-declare module "angular-cookies" {
- var _: string;
- export = _;
-}
-
-/**
- * ngCookies module (angular-cookies.js)
- */
-declare module angular.cookies {
-
- /**
- * Cookies options
- * see https://docs.angularjs.org/api/ngCookies/provider/$cookiesProvider#defaults
- */
- interface ICookiesOptions {
- /**
- * The cookie will be available only for this path and its sub-paths.
- * By default, this would be the URL that appears in your base tag.
- */
- path?: string;
- /**
- * The cookie will be available only for this domain and its sub-domains.
- * For obvious security reasons the user agent will not accept the cookie if the
- * current domain is not a sub domain or equals to the requested domain.
- */
- domain?: string;
- /**
- * String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object
- * indicating the exact date/time this cookie will expire.
- */
- expires?: string|Date;
- /**
- * The cookie will be available only in secured connection.
- */
- secure?: boolean;
- }
-
- /**
- * CookieService
- * see http://docs.angularjs.org/api/ngCookies.$cookies
- */
- interface ICookiesService {
- [index: string]: any;
- }
-
- /**
- * CookieStoreService
- * see http://docs.angularjs.org/api/ngCookies.$cookieStore
- */
- interface ICookiesService {
- get(key: string): string;
- getObject(key: string): any;
- getObject(key: string): T;
- getAll(): any;
- put(key: string, value: string, options?: ICookiesOptions): void;
- putObject(key: string, value: any, options?: ICookiesOptions): void;
- remove(key: string, options?: ICookiesOptions): void;
- }
-
- /**
- * CookieStoreService DEPRECATED
- * see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookieStore
- */
- interface ICookieStoreService {
- /**
- * Returns the value of given cookie key
- * @param key Id to use for lookup
- */
- get(key: string): any;
- /**
- * Sets a value for given cookie key
- * @param key Id for the value
- * @param value Value to be stored
- */
- put(key: string, value: any): void;
- /**
- * Remove given cookie
- * @param key Id of the key-value pair to delete
- */
- remove(key: string): void;
- }
-
-}
+// Type definitions for Angular JS 1.4 (ngCookies module)
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar , Anthony Ciccarello
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+///
+
+declare module "angular-cookies" {
+ var _: string;
+ export = _;
+}
+
+/**
+ * ngCookies module (angular-cookies.js)
+ */
+declare module angular.cookies {
+
+ /**
+ * Cookies options
+ * see https://docs.angularjs.org/api/ngCookies/provider/$cookiesProvider#defaults
+ */
+ interface ICookiesOptions {
+ /**
+ * The cookie will be available only for this path and its sub-paths.
+ * By default, this would be the URL that appears in your base tag.
+ */
+ path?: string;
+ /**
+ * The cookie will be available only for this domain and its sub-domains.
+ * For obvious security reasons the user agent will not accept the cookie if the
+ * current domain is not a sub domain or equals to the requested domain.
+ */
+ domain?: string;
+ /**
+ * String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object
+ * indicating the exact date/time this cookie will expire.
+ */
+ expires?: string|Date;
+ /**
+ * The cookie will be available only in secured connection.
+ */
+ secure?: boolean;
+ }
+
+ /**
+ * CookieService
+ * see http://docs.angularjs.org/api/ngCookies.$cookies
+ */
+ interface ICookiesService {
+ [index: string]: any;
+ }
+
+ /**
+ * CookieStoreService
+ * see http://docs.angularjs.org/api/ngCookies.$cookieStore
+ */
+ interface ICookiesService {
+ get(key: string): string;
+ getObject(key: string): any;
+ getObject(key: string): T;
+ getAll(): any;
+ put(key: string, value: string, options?: ICookiesOptions): void;
+ putObject(key: string, value: any, options?: ICookiesOptions): void;
+ remove(key: string, options?: ICookiesOptions): void;
+ }
+
+ /**
+ * CookieStoreService DEPRECATED
+ * see https://code.angularjs.org/1.2.26/docs/api/ngCookies/service/$cookieStore
+ */
+ interface ICookieStoreService {
+ /**
+ * Returns the value of given cookie key
+ * @param key Id to use for lookup
+ */
+ get(key: string): any;
+ /**
+ * Sets a value for given cookie key
+ * @param key Id for the value
+ * @param value Value to be stored
+ */
+ put(key: string, value: any): void;
+ /**
+ * Remove given cookie
+ * @param key Id of the key-value pair to delete
+ */
+ remove(key: string): void;
+ }
+
+}
diff --git a/angularjs/angular-mocks.d.ts b/angularjs/angular-mocks.d.ts
index d94337273..311388186 100644
--- a/angularjs/angular-mocks.d.ts
+++ b/angularjs/angular-mocks.d.ts
@@ -1,318 +1,318 @@
-// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module)
-// Project: http://angularjs.org
-// Definitions by: Diego Vilar , Tony Curtis
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-///
-
-declare module "angular-mocks/ngMock" {
- var _: string;
- export = _;
-}
-
-declare module "angular-mocks/ngMockE2E" {
- var _: string;
- export = _;
-}
-
-declare module "angular-mocks/ngAnimateMock" {
- var _: string;
- export = _;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ngMock module (angular-mocks.js)
-///////////////////////////////////////////////////////////////////////////////
-declare module angular {
-
- ///////////////////////////////////////////////////////////////////////////
- // AngularStatic
- // We reopen it to add the MockStatic definition
- ///////////////////////////////////////////////////////////////////////////
- interface IAngularStatic {
- mock: IMockStatic;
- }
-
- // see https://docs.angularjs.org/api/ngMock/function/angular.mock.inject
- interface IInjectStatic {
- (...fns: Function[]): any;
- (...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
- strictDi(val?: boolean): void;
- }
-
- interface IMockStatic {
- // see https://docs.angularjs.org/api/ngMock/function/angular.mock.dump
- dump(obj: any): string;
-
- inject: IInjectStatic
-
- // see https://docs.angularjs.org/api/ngMock/function/angular.mock.module
- module(...modules: any[]): any;
-
- // see https://docs.angularjs.org/api/ngMock/type/angular.mock.TzDate
- TzDate(offset: number, timestamp: number): Date;
- TzDate(offset: number, timestamp: string): Date;
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // ExceptionHandlerService
- // see https://docs.angularjs.org/api/ngMock/service/$exceptionHandler
- // see https://docs.angularjs.org/api/ngMock/provider/$exceptionHandlerProvider
- ///////////////////////////////////////////////////////////////////////////
- interface IExceptionHandlerProvider extends IServiceProvider {
- mode(mode: string): void;
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // TimeoutService
- // see https://docs.angularjs.org/api/ngMock/service/$timeout
- // Augments the original service
- ///////////////////////////////////////////////////////////////////////////
- interface ITimeoutService {
- flush(delay?: number): void;
- flushNext(expectedDelay?: number): void;
- verifyNoPendingTasks(): void;
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // IntervalService
- // see https://docs.angularjs.org/api/ngMock/service/$interval
- // Augments the original service
- ///////////////////////////////////////////////////////////////////////////
- interface IIntervalService {
- flush(millis?: number): number;
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // LogService
- // see https://docs.angularjs.org/api/ngMock/service/$log
- // Augments the original service
- ///////////////////////////////////////////////////////////////////////////
- interface ILogService {
- assertEmpty(): void;
- reset(): void;
- }
-
- interface ILogCall {
- logs: string[];
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // HttpBackendService
- // see https://docs.angularjs.org/api/ngMock/service/$httpBackend
- ///////////////////////////////////////////////////////////////////////////
- interface IHttpBackendService {
- /**
- * Flushes all pending requests using the trained responses.
- * @param count Number of responses to flush (in the order they arrived). If undefined, all pending requests will be flushed.
- */
- flush(count?: number): void;
-
- /**
- * Resets all request expectations, but preserves all backend definitions.
- */
- resetExpectations(): void;
-
- /**
- * Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception.
- */
- verifyNoOutstandingExpectation(): void;
-
- /**
- * Verifies that there are no outstanding requests that need to be flushed.
- */
- verifyNoOutstandingRequest(): void;
-
- /**
- * Creates a new request expectation.
- * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param method HTTP method.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- expect(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)) :mock.IRequestHandler;
-
- /**
- * Creates a new request expectation for DELETE requests.
- * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
- * @param headers HTTP headers object to be compared with the HTTP headers in the request.
- */
- expectDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
-
- /**
- * Creates a new request expectation for GET requests.
- * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param headers HTTP headers object to be compared with the HTTP headers in the request.
- */
- expectGET(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
-
- /**
- * Creates a new request expectation for HEAD requests.
- * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param headers HTTP headers object to be compared with the HTTP headers in the request.
- */
- expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
-
- /**
- * Creates a new request expectation for JSONP requests.
- * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- */
- expectJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
-
- /**
- * Creates a new request expectation for PATCH requests.
- * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
-
- /**
- * Creates a new request expectation for POST requests.
- * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
-
- /**
- * Creates a new request expectation for PUT requests.
- * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
-
- /**
- * Creates a new backend definition.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param method HTTP method.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
-
- /**
- * Creates a new backend definition for DELETE requests.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
-
- /**
- * Creates a new backend definition for GET requests.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
-
- /**
- * Creates a new backend definition for HEAD requests.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
-
- /**
- * Creates a new backend definition for JSONP requests.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- whenJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
-
- /**
- * Creates a new backend definition for PATCH requests.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
-
- /**
- * Creates a new backend definition for POST requests.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
-
- /**
- * Creates a new backend definition for PUT requests.
- * Returns an object with respond method that controls how a matched request is handled.
- * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
- * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
- * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
- */
- whenPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
- }
-
- export module mock {
- // returned interface by the the mocked HttpBackendService expect/when methods
- interface IRequestHandler {
-
- /**
- * Controls the response for a matched request using a function to construct the response.
- * Returns the RequestHandler object for possible overrides.
- * @param func Function that receives the request HTTP method, url, data, and headers and returns an array containing response status (number), data, headers, and status text.
- */
- respond(func: ((method: string, url: string, data: string | Object, headers: Object) => [number, string | Object, Object, string])): IRequestHandler;
-
- /**
- * Controls the response for a matched request using supplied static data to construct the response.
- * Returns the RequestHandler object for possible overrides.
- * @param status HTTP status code to add to the response.
- * @param data Data to add to the response.
- * @param headers Headers object to add to the response.
- * @param responseText Response text to add to the response.
- */
- respond(status: number, data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
-
- /**
- * Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
- * Returns the RequestHandler object for possible overrides.
- * @param data Data to add to the response.
- * @param headers Headers object to add to the response.
- * @param responseText Response text to add to the response.
- */
- respond(data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
-
- // Available when ngMockE2E is loaded
- /**
- * Any request matching a backend definition or expectation with passThrough handler will be passed through to the real backend (an XHR request will be made to the server.)
- */
- passThrough(): IRequestHandler;
- }
-
- }
-
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// functions attached to global object (window)
-///////////////////////////////////////////////////////////////////////////////
-//Use `angular.mock.module` instead of `module`, as `module` conflicts with commonjs.
-//declare var module: (...modules: any[]) => any;
-declare var inject: angular.IInjectStatic;
+// Type definitions for Angular JS 1.3 (ngMock, ngMockE2E module)
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar , Tony Curtis
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module "angular-mocks/ngMock" {
+ var _: string;
+ export = _;
+}
+
+declare module "angular-mocks/ngMockE2E" {
+ var _: string;
+ export = _;
+}
+
+declare module "angular-mocks/ngAnimateMock" {
+ var _: string;
+ export = _;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// ngMock module (angular-mocks.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module angular {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // AngularStatic
+ // We reopen it to add the MockStatic definition
+ ///////////////////////////////////////////////////////////////////////////
+ interface IAngularStatic {
+ mock: IMockStatic;
+ }
+
+ // see https://docs.angularjs.org/api/ngMock/function/angular.mock.inject
+ interface IInjectStatic {
+ (...fns: Function[]): any;
+ (...inlineAnnotatedConstructor: any[]): any; // this overload is undocumented, but works
+ strictDi(val?: boolean): void;
+ }
+
+ interface IMockStatic {
+ // see https://docs.angularjs.org/api/ngMock/function/angular.mock.dump
+ dump(obj: any): string;
+
+ inject: IInjectStatic
+
+ // see https://docs.angularjs.org/api/ngMock/function/angular.mock.module
+ module(...modules: any[]): any;
+
+ // see https://docs.angularjs.org/api/ngMock/type/angular.mock.TzDate
+ TzDate(offset: number, timestamp: number): Date;
+ TzDate(offset: number, timestamp: string): Date;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // ExceptionHandlerService
+ // see https://docs.angularjs.org/api/ngMock/service/$exceptionHandler
+ // see https://docs.angularjs.org/api/ngMock/provider/$exceptionHandlerProvider
+ ///////////////////////////////////////////////////////////////////////////
+ interface IExceptionHandlerProvider extends IServiceProvider {
+ mode(mode: string): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // TimeoutService
+ // see https://docs.angularjs.org/api/ngMock/service/$timeout
+ // Augments the original service
+ ///////////////////////////////////////////////////////////////////////////
+ interface ITimeoutService {
+ flush(delay?: number): void;
+ flushNext(expectedDelay?: number): void;
+ verifyNoPendingTasks(): void;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // IntervalService
+ // see https://docs.angularjs.org/api/ngMock/service/$interval
+ // Augments the original service
+ ///////////////////////////////////////////////////////////////////////////
+ interface IIntervalService {
+ flush(millis?: number): number;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // LogService
+ // see https://docs.angularjs.org/api/ngMock/service/$log
+ // Augments the original service
+ ///////////////////////////////////////////////////////////////////////////
+ interface ILogService {
+ assertEmpty(): void;
+ reset(): void;
+ }
+
+ interface ILogCall {
+ logs: string[];
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // HttpBackendService
+ // see https://docs.angularjs.org/api/ngMock/service/$httpBackend
+ ///////////////////////////////////////////////////////////////////////////
+ interface IHttpBackendService {
+ /**
+ * Flushes all pending requests using the trained responses.
+ * @param count Number of responses to flush (in the order they arrived). If undefined, all pending requests will be flushed.
+ */
+ flush(count?: number): void;
+
+ /**
+ * Resets all request expectations, but preserves all backend definitions.
+ */
+ resetExpectations(): void;
+
+ /**
+ * Verifies that all of the requests defined via the expect api were made. If any of the requests were not made, verifyNoOutstandingExpectation throws an exception.
+ */
+ verifyNoOutstandingExpectation(): void;
+
+ /**
+ * Verifies that there are no outstanding requests that need to be flushed.
+ */
+ verifyNoOutstandingRequest(): void;
+
+ /**
+ * Creates a new request expectation.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param method HTTP method.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ expect(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)) :mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for DELETE requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url is as expected.
+ * @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ */
+ expectDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for GET requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ */
+ expectGET(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for HEAD requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object to be compared with the HTTP headers in the request.
+ */
+ expectHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for JSONP requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ */
+ expectJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for PATCH requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ expectPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for POST requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ expectPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new request expectation for PUT requests.
+ * Throws a preformatted error if expectation(s) don't match supplied string, regular expression, object, or if function returns false.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ expectPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param method HTTP method.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ when(method: string, url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for DELETE requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenDELETE(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for GET requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenGET(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for HEAD requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenHEAD(url: string | RegExp | ((url: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for JSONP requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenJSONP(url: string | RegExp | ((url: string) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for PATCH requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenPATCH(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for POST requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenPOST(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+
+ /**
+ * Creates a new backend definition for PUT requests.
+ * Returns an object with respond method that controls how a matched request is handled.
+ * @param url HTTP url string, regular expression or function that receives a url and returns true if the url matches the current expctation.
+ * @param data HTTP request body string, json object, regular expression or function that receives the data and returns true if the data matches the current expectation.
+ * @param headers HTTP headers object or function that receives the headers and returns true if the headers match the current expectation.
+ */
+ whenPUT(url: string | RegExp | ((url: string) => boolean), data?: string | RegExp | Object | ((data: string) => boolean), headers?: Object | ((object: Object) => boolean)): mock.IRequestHandler;
+ }
+
+ export module mock {
+ // returned interface by the the mocked HttpBackendService expect/when methods
+ interface IRequestHandler {
+
+ /**
+ * Controls the response for a matched request using a function to construct the response.
+ * Returns the RequestHandler object for possible overrides.
+ * @param func Function that receives the request HTTP method, url, data, and headers and returns an array containing response status (number), data, headers, and status text.
+ */
+ respond(func: ((method: string, url: string, data: string | Object, headers: Object) => [number, string | Object, Object, string])): IRequestHandler;
+
+ /**
+ * Controls the response for a matched request using supplied static data to construct the response.
+ * Returns the RequestHandler object for possible overrides.
+ * @param status HTTP status code to add to the response.
+ * @param data Data to add to the response.
+ * @param headers Headers object to add to the response.
+ * @param responseText Response text to add to the response.
+ */
+ respond(status: number, data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
+
+ /**
+ * Controls the response for a matched request using the HTTP status code 200 and supplied static data to construct the response.
+ * Returns the RequestHandler object for possible overrides.
+ * @param data Data to add to the response.
+ * @param headers Headers object to add to the response.
+ * @param responseText Response text to add to the response.
+ */
+ respond(data: string | Object, headers?: Object, responseText?: string): IRequestHandler;
+
+ // Available when ngMockE2E is loaded
+ /**
+ * Any request matching a backend definition or expectation with passThrough handler will be passed through to the real backend (an XHR request will be made to the server.)
+ */
+ passThrough(): IRequestHandler;
+ }
+
+ }
+
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// functions attached to global object (window)
+///////////////////////////////////////////////////////////////////////////////
+//Use `angular.mock.module` instead of `module`, as `module` conflicts with commonjs.
+//declare var module: (...modules: any[]) => any;
+declare var inject: angular.IInjectStatic;
diff --git a/angularjs/angular-route-tests.ts b/angularjs/angular-route-tests.ts
index 0260359fb..ab5fba0b6 100644
--- a/angularjs/angular-route-tests.ts
+++ b/angularjs/angular-route-tests.ts
@@ -1,3 +1,4 @@
+///
///
/**
@@ -32,6 +33,14 @@ $routeProvider
return "I return a string"
}
})
+ .when('/projects/:projectId/dashboard5', {
+ controller: ['$log',function($log:ng.ILogService){
+ $log.info('I am array')
+ }],
+ templateUrl: function ($routeParams?: ng.route.IRouteParamsService) {
+ return "I return a string"
+ }
+ })
.otherwise({ redirectTo: '/' })
.otherwise({ redirectTo: ($routeParams?: ng.route.IRouteParamsService, $locationPath?: string, $locationSearch?: any) => "" });
diff --git a/angularjs/angular-route.d.ts b/angularjs/angular-route.d.ts
index eafdf714c..ec49b3cd9 100644
--- a/angularjs/angular-route.d.ts
+++ b/angularjs/angular-route.d.ts
@@ -47,6 +47,7 @@ declare module angular.route {
}
+ type InlineAnnotatedFunction = Function|Array
/**
* see http://docs.angularjs.org/api/ngRoute/provider/$routeProvider#when for API documentation
@@ -56,7 +57,7 @@ declare module angular.route {
* {(string|function()=}
* Controller fn that should be associated with newly created scope or the name of a registered controller if passed as a string.
*/
- controller?: string|Function;
+ controller?: string|InlineAnnotatedFunction;
/**
* A controller alias name. If present the controller will be published to scope under the controllerAs name.
*/
diff --git a/angularjs/angular-sanitize.d.ts b/angularjs/angular-sanitize.d.ts
index c8ab8e266..d5d541f4e 100644
--- a/angularjs/angular-sanitize.d.ts
+++ b/angularjs/angular-sanitize.d.ts
@@ -1,40 +1,40 @@
-// Type definitions for Angular JS 1.3 (ngSanitize module)
-// Project: http://angularjs.org
-// Definitions by: Diego Vilar
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-
-///
-
-declare module "angular-sanitize" {
- var _: string;
- export = _;
-}
-
-///////////////////////////////////////////////////////////////////////////////
-// ngSanitize module (angular-sanitize.js)
-///////////////////////////////////////////////////////////////////////////////
-declare module angular.sanitize {
-
- ///////////////////////////////////////////////////////////////////////////
- // SanitizeService
- // see http://docs.angularjs.org/api/ngSanitize.$sanitize
- ///////////////////////////////////////////////////////////////////////////
- interface ISanitizeService {
- (html: string): string;
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // Filters included with the ngSanitize
- // see https://github.com/angular/angular.js/tree/v1.2.0/src/ngSanitize/filter
- ///////////////////////////////////////////////////////////////////////////
- export module filter {
-
- // Finds links in text input and turns them into html links.
- // Supports http/https/ftp/mailto and plain email address links.
- // see http://code.angularjs.org/1.2.0/docs/api/ngSanitize.filter:linky
- interface ILinky {
- (text: string, target?: string): string;
- }
- }
-}
+// Type definitions for Angular JS 1.3 (ngSanitize module)
+// Project: http://angularjs.org
+// Definitions by: Diego Vilar
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+
+///
+
+declare module "angular-sanitize" {
+ var _: string;
+ export = _;
+}
+
+///////////////////////////////////////////////////////////////////////////////
+// ngSanitize module (angular-sanitize.js)
+///////////////////////////////////////////////////////////////////////////////
+declare module angular.sanitize {
+
+ ///////////////////////////////////////////////////////////////////////////
+ // SanitizeService
+ // see http://docs.angularjs.org/api/ngSanitize.$sanitize
+ ///////////////////////////////////////////////////////////////////////////
+ interface ISanitizeService {
+ (html: string): string;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////
+ // Filters included with the ngSanitize
+ // see https://github.com/angular/angular.js/tree/v1.2.0/src/ngSanitize/filter
+ ///////////////////////////////////////////////////////////////////////////
+ export module filter {
+
+ // Finds links in text input and turns them into html links.
+ // Supports http/https/ftp/mailto and plain email address links.
+ // see http://code.angularjs.org/1.2.0/docs/api/ngSanitize.filter:linky
+ interface ILinky {
+ (text: string, target?: string): string;
+ }
+ }
+}
diff --git a/angularjs/angular.d.ts b/angularjs/angular.d.ts
index 67b3eb488..656e62865 100644
--- a/angularjs/angular.d.ts
+++ b/angularjs/angular.d.ts
@@ -1685,7 +1685,7 @@ declare module angular {
* Controller constructor function that should be associated with newly created scope or the name of a registered
* controller if passed as a string. Empty function by default.
*/
- controller?: string | Function;
+ controller?: any;
/**
* An identifier name for a reference to the controller. If present, the controller will be published to scope under
* the controllerAs name. If not present, this will default to be the same as the component name.
@@ -1715,15 +1715,7 @@ declare module angular {
* Whether transclusion is enabled. Enabled by default.
*/
transclude?: boolean;
- /**
- * Whether the new scope is isolated. Isolated by default.
- */
- isolate?: boolean;
- /**
- * String of subset of EACM which restricts the component to specific directive declaration style. If omitted,
- * this defaults to 'E'.
- */
- restrict?: string;
+ require? : Object;
$canActivate?: () => boolean;
$routeConfig?: RouteDefinition[];
}
@@ -1774,12 +1766,12 @@ declare module angular {
name?: string;
priority?: number;
replace?: boolean;
- require?: any;
+ require? : any;
restrict?: string;
scope?: any;
- template?: any;
+ template?: string | Function;
templateNamespace?: string;
- templateUrl?: any;
+ templateUrl?: string | Function;
terminal?: boolean;
transclude?: any;
}
diff --git a/angularjs/legacy/angular-1.0-tests.ts.tscparams b/angularjs/legacy/angular-1.0-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/angularjs/legacy/angular-1.0-tests.ts.tscparams
+++ b/angularjs/legacy/angular-1.0-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/angularjs/legacy/angular-scenario-1.0.d.ts.tscparams b/angularjs/legacy/angular-scenario-1.0.d.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/angularjs/legacy/angular-scenario-1.0.d.ts.tscparams
+++ b/angularjs/legacy/angular-scenario-1.0.d.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/ansicolors/ansicolors.d.ts b/ansicolors/ansicolors.d.ts
index 2f61b0435..ec5f0af85 100644
--- a/ansicolors/ansicolors.d.ts
+++ b/ansicolors/ansicolors.d.ts
@@ -1,9 +1,9 @@
-// Type definitions for ansicolors
-// Project: https://github.com/thlorenz/ansicolors
-// Definitions by: rogierschouten
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-declare module "ansicolors" {
- var colors: {[index: string]: (s: string) => string;};
- export = colors;
-}
+// Type definitions for ansicolors
+// Project: https://github.com/thlorenz/ansicolors
+// Definitions by: rogierschouten
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+declare module "ansicolors" {
+ var colors: {[index: string]: (s: string) => string;};
+ export = colors;
+}
diff --git a/any-db-transaction/any-db-transaction-tests.ts b/any-db-transaction/any-db-transaction-tests.ts
index 55ca53bdc..8e38fe5a3 100644
--- a/any-db-transaction/any-db-transaction-tests.ts
+++ b/any-db-transaction/any-db-transaction-tests.ts
@@ -1,29 +1,29 @@
-
-///
-///
-
-"use strict";
-
-import anyDB = require("any-db");
-import begin = require("any-db-transaction");
-
-var conn: anyDB.Connection = anyDB.createConnection("mysql://user:password@localhost/testdb");
-
-
-var transaction = begin(conn);
-var transaction2 = begin(transaction);
-
-begin(conn, { autoRollback: true });
-begin(conn, (error: Error, result: begin.Transaction): void => {
-});
-
-transaction.query("SELECT * FROM MyTable");
-
-transaction.commit();
-transaction.commit((error: Error): void => {
-});
-
-transaction.rollback();
-transaction.rollback((error: Error): void => {
-});
-
+
+///
+///
+
+"use strict";
+
+import anyDB = require("any-db");
+import begin = require("any-db-transaction");
+
+var conn: anyDB.Connection = anyDB.createConnection("mysql://user:password@localhost/testdb");
+
+
+var transaction = begin(conn);
+var transaction2 = begin(transaction);
+
+begin(conn, { autoRollback: true });
+begin(conn, (error: Error, result: begin.Transaction): void => {
+});
+
+transaction.query("SELECT * FROM MyTable");
+
+transaction.commit();
+transaction.commit((error: Error): void => {
+});
+
+transaction.rollback();
+transaction.rollback((error: Error): void => {
+});
+
diff --git a/any-db-transaction/any-db-transaction.d.ts b/any-db-transaction/any-db-transaction.d.ts
index ca5bc84b0..8b4bccfaf 100644
--- a/any-db-transaction/any-db-transaction.d.ts
+++ b/any-db-transaction/any-db-transaction.d.ts
@@ -1,94 +1,94 @@
-// Type definitions for any-db-transaction 2.2.1
-// Project: https://github.com/grncdr/node-any-db-transaction
-// Definitions by: Rogier Schouten
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-///
-///
-
-declare module "any-db-transaction" {
- import anyDB = require("any-db");
-
- module begin {
- /**
- * Transaction objects are are simple wrappers around a Connection that also implement the Queryable API,
- * but guarantee that all queries take place within a single database transaction or not at all. Note that
- * begin also understands how to acquire (and release) a connection from a ConnectionPool as well, so you
- * can simply pass a pool to it: var tx = begin(pool)
- *
- * By default, any queries that error during a transaction will cause an automatic rollback. If a query has
- * no callback, the transaction will also handle (and re-emit) 'error' events for the Query instance.
- * This enables handling errors for an entire transaction in a single place.
- *
- * Transactions may also be nested by passing a Transaction to begin and these nested transactions can
- * safely error and rollback without rolling back their parent transaction
- *
- * Transaction events:
- * 'query', query - emitted immediately after .query is called on a connection via tx.query. The argument is a query object.
- * 'commit:start' - Emitted when .commit() is called.
- * 'commit:complete' - Emitted after the transaction has committed.
- * 'rollback:start' - Emitted when .rollback() is called.
- * 'rollback:complete' - Emitted after the transaction has rolled back.
- * 'close' - Emitted after rollback or commit completes.
- * 'error', err - Emitted under three conditions:
- * There was an error acquiring a connection.
- * Any query performed in this transaction emits an error that would otherwise go unhandled.
- * Any of query, begin, commit, or rollback are called after the connection has already been committed or rolled back.
- * Note that the 'error' event may be emitted multiple times! depending on the callback you are registering, you way want to wrap it using [once][].
- */
- interface Transaction extends anyDB.Queryable {
-
- /**
- * Issue a COMMIT (or RELEASE ... in the case of nested transactions) statement to the database.
- * If a continuation is provided it will be called (possibly with an error) after the COMMIT
- * statement completes. The transaction object itself will be unusable after calling commit().
- */
- commit(callback?: (error: Error) => void): void;
-
- /**
- * The same as Transaction.commit but issues a ROLLBACK. Again, the transaction will be unusable after calling this method.
- */
- rollback(callback?: (error: Error) => void): void;
- }
-
- interface TransactionOptions {
- /**
- * Adapter name e.g. 'mysql'
- */
- adapter?: anyDB.Adapter;
- /**
- * SQL statement for beginning a transaction, default 'BEGIN'
- */
- begin?: string;
- /**
- * SQL statement for committing a transaction, default 'COMMIT'
- */
- commit?: string;
- /**
- * SQL statement for rolling back a transaction, default 'ROLLBACK'
- */
- rollback?: string;
- /**
- * Callback for transaction
- */
- callback?: (error: Error, transaction: Transaction) => void;
- /**
- * Rollback automatically on error, default true
- */
- autoRollback?: boolean;
- }
- }
-
- /**
- * Start a transaction
- */
- function begin(q: anyDB.Queryable, options?: begin.TransactionOptions, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
- function begin(q: anyDB.Queryable, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
- function begin(q: anyDB.Queryable, beginStatement?: string, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
- function begin(q: anyDB.Queryable, options?: begin.TransactionOptions, beginStatement?: string, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
-
- export = begin;
-}
-
-
-
+// Type definitions for any-db-transaction 2.2.1
+// Project: https://github.com/grncdr/node-any-db-transaction
+// Definitions by: Rogier Schouten
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+///
+
+declare module "any-db-transaction" {
+ import anyDB = require("any-db");
+
+ module begin {
+ /**
+ * Transaction objects are are simple wrappers around a Connection that also implement the Queryable API,
+ * but guarantee that all queries take place within a single database transaction or not at all. Note that
+ * begin also understands how to acquire (and release) a connection from a ConnectionPool as well, so you
+ * can simply pass a pool to it: var tx = begin(pool)
+ *
+ * By default, any queries that error during a transaction will cause an automatic rollback. If a query has
+ * no callback, the transaction will also handle (and re-emit) 'error' events for the Query instance.
+ * This enables handling errors for an entire transaction in a single place.
+ *
+ * Transactions may also be nested by passing a Transaction to begin and these nested transactions can
+ * safely error and rollback without rolling back their parent transaction
+ *
+ * Transaction events:
+ * 'query', query - emitted immediately after .query is called on a connection via tx.query. The argument is a query object.
+ * 'commit:start' - Emitted when .commit() is called.
+ * 'commit:complete' - Emitted after the transaction has committed.
+ * 'rollback:start' - Emitted when .rollback() is called.
+ * 'rollback:complete' - Emitted after the transaction has rolled back.
+ * 'close' - Emitted after rollback or commit completes.
+ * 'error', err - Emitted under three conditions:
+ * There was an error acquiring a connection.
+ * Any query performed in this transaction emits an error that would otherwise go unhandled.
+ * Any of query, begin, commit, or rollback are called after the connection has already been committed or rolled back.
+ * Note that the 'error' event may be emitted multiple times! depending on the callback you are registering, you way want to wrap it using [once][].
+ */
+ interface Transaction extends anyDB.Queryable {
+
+ /**
+ * Issue a COMMIT (or RELEASE ... in the case of nested transactions) statement to the database.
+ * If a continuation is provided it will be called (possibly with an error) after the COMMIT
+ * statement completes. The transaction object itself will be unusable after calling commit().
+ */
+ commit(callback?: (error: Error) => void): void;
+
+ /**
+ * The same as Transaction.commit but issues a ROLLBACK. Again, the transaction will be unusable after calling this method.
+ */
+ rollback(callback?: (error: Error) => void): void;
+ }
+
+ interface TransactionOptions {
+ /**
+ * Adapter name e.g. 'mysql'
+ */
+ adapter?: anyDB.Adapter;
+ /**
+ * SQL statement for beginning a transaction, default 'BEGIN'
+ */
+ begin?: string;
+ /**
+ * SQL statement for committing a transaction, default 'COMMIT'
+ */
+ commit?: string;
+ /**
+ * SQL statement for rolling back a transaction, default 'ROLLBACK'
+ */
+ rollback?: string;
+ /**
+ * Callback for transaction
+ */
+ callback?: (error: Error, transaction: Transaction) => void;
+ /**
+ * Rollback automatically on error, default true
+ */
+ autoRollback?: boolean;
+ }
+ }
+
+ /**
+ * Start a transaction
+ */
+ function begin(q: anyDB.Queryable, options?: begin.TransactionOptions, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
+ function begin(q: anyDB.Queryable, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
+ function begin(q: anyDB.Queryable, beginStatement?: string, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
+ function begin(q: anyDB.Queryable, options?: begin.TransactionOptions, beginStatement?: string, callback?: (error: Error, transaction: begin.Transaction) => void): begin.Transaction;
+
+ export = begin;
+}
+
+
+
diff --git a/any-db/any-db-tests.ts b/any-db/any-db-tests.ts
index 15dc6c7e6..41744c452 100644
--- a/any-db/any-db-tests.ts
+++ b/any-db/any-db-tests.ts
@@ -1,38 +1,38 @@
-
-///
-
-"use strict";
-
-import anyDB = require("any-db");
-
-var conn: anyDB.Connection = anyDB.createConnection("mysql://user:password@localhost/testdb");
-var sql: string = "SELECT * FROM questions";
-
-conn.query(sql, [1, "boo"]);
-
-conn.query(sql).on("data", (row: Object[]): void => {
-// nothing
-});
-
-conn.query(sql, [1, "s"], (error: Error, result: anyDB.ResultSet): void => {
- result.rows.length;
- result.fields.length;
-});
-
-conn.end();
-
-
-var poolConfig: anyDB.PoolConfig = {
- min: 1,
- max: 200
-};
-
-var pool: anyDB.ConnectionPool = anyDB.createPool("mysql://user:password@localhost/testdb", poolConfig);
-
-pool.query(sql).on("data", (row: Object[]): void => {
-// nothing
-});
-
-pool.close((error: Error): void => {
-});
-
+
+///
+
+"use strict";
+
+import anyDB = require("any-db");
+
+var conn: anyDB.Connection = anyDB.createConnection("mysql://user:password@localhost/testdb");
+var sql: string = "SELECT * FROM questions";
+
+conn.query(sql, [1, "boo"]);
+
+conn.query(sql).on("data", (row: Object[]): void => {
+// nothing
+});
+
+conn.query(sql, [1, "s"], (error: Error, result: anyDB.ResultSet): void => {
+ result.rows.length;
+ result.fields.length;
+});
+
+conn.end();
+
+
+var poolConfig: anyDB.PoolConfig = {
+ min: 1,
+ max: 200
+};
+
+var pool: anyDB.ConnectionPool = anyDB.createPool("mysql://user:password@localhost/testdb", poolConfig);
+
+pool.query(sql).on("data", (row: Object[]): void => {
+// nothing
+});
+
+pool.close((error: Error): void => {
+});
+
diff --git a/any-db/any-db.d.ts b/any-db/any-db.d.ts
index f14befb20..8bdd9d706 100644
--- a/any-db/any-db.d.ts
+++ b/any-db/any-db.d.ts
@@ -1,303 +1,303 @@
-// Type definitions for any-db 2.1.0
-// Project: https://github.com/grncdr/node-any-db
-// Definitions by: Rogier Schouten
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-///
-
-declare module "any-db" {
- import events = require("events");
- import stream = require("stream");
-
- export interface ConnectOpts {
- adapter: string;
- }
-
- export interface Adapter {
- name: string;
- /**
- * Create a new connection object. In common usage, config will be created by parse-db-url and passed to the adapter by any-db.
- * If a continuation is given, it must be called, either with an error or the established connection.
- */
- createConnection(opts: ConnectOpts, callback?: (error: Error, result: Connection) => void): Connection;
-
- /**
- * Create a Query that may eventually be executed later on by a Connection. While this function is rarely needed by user code,
- * it makes it possible for ConnectionPool.query and Transaction.query to fulfill the Queryable.query contract
- * by synchronously returning a Query stream
- */
- createQuery(text: string, params?: any[], callback?: (error: Error, result: ResultSet) => void): Query;
- createQuery(query: Query): Query;
- }
- /**
- * Other properties are driver specific
- */
- export interface Field {
- name: string;
- }
-
- /**
- * ResultSet objects are just plain data that collect results of a query when a continuation
- * is provided to Queryable.query. The lastInsertId is optional, and currently supported by
- * sqlite3 and mysql but not postgres, because it is not supported by Postgres itself.
- */
- export interface ResultSet {
- /**
- * Affected rows. Note e.g. for INSERT queries the rows property is not filled even
- * though rowCount is non-zero.
- */
- rowCount: number;
- /**
- * Result rows
- */
- rows: any[];
- /**
- * Result field descriptions
- */
- fields: Field[];
-
- /**
- * Not supported by all drivers.
- */
- fieldCount?: number;
- /**
- * Not supported by all drivers.
- */
- lastInsertId?: any;
- /**
- * Not supported by all drivers.
- */
- affectedRows?: number;
- /**
- * Not supported by all drivers.
- */
- changedRows?: number;
- }
-
- /**
- * Query objects are returned by the Queryable.query method, available on connections,
- * pools, and transactions. Queries are instances of Readable, and as such can be piped
- * through transforms and support backpressure for more efficient memory-usage on very
- * large results sets. (Note: at this time the sqlite3 driver does not support backpressure)
- *
- * Internally, Query instances are created by a database Adapter and may have more methods,
- * properties, and events than are described here. Consult the documentation for your
- * specific adapter to find out about any extensions.
- *
- * Events:
- *
- * Error event
- * The 'error' event is emitted at most once per query. Note that this event will be
- * emitted for errors even if a callback was provided, the callback will
- * simply be subscribed to the 'error' event.
- * One argument is passed to event listeners:
- * error - the error object.
- *
- * Fields event
- * A 'fields' event is emmitted before any 'data' events.
- * One argument is passed to event listeners:
- * fields - an array of [Field][ResultSet] objects.
- *
- * The following events are part of the stream.Readable interface which is implemented by Query:
- *
- * Data event
- * A 'data' event is emitted for each row in the query result set.
- * One argument is passed to event listeners:
- * row contains the contents of a single row in the query result
- *
- * Close event
- * A 'close' event is emitted when the query completes.
- * No arguments are passed to event listeners.
- *
- * End event
- * An 'end' event is emitted after all query results have been consumed.
- * No arguments are passed to event listeners.
- */
- export interface Query extends stream.Readable {
- /**
- * The SQL query as a string. If you are using MySQL this will contain
- * interpolated values after the query has been enqueued by a connection.
- */
- text: string;
-
- /**
- * The array of parameter values.
- */
- values: any[];
-
- /**
- * The callback (if any) that was provided to Queryable.query. Note that
- * Query objects must not use a closed over reference to their callback,
- * as other any-db libraries may rely on modifying the callback property
- * of a Query they did not create.
- */
- callback: (error: Error, results: ResultSet) => void;
- }
-
- /**
- * Events:
- * The 'query' event is emitted immediately before a query is executed. One argument is passed to event handlers:
- * - query: a Query object
- */
- export interface Queryable extends events.EventEmitter {
- /**
- * The Adapter instance that will be used by this Queryable for creating Query instances and/or connections.
- */
- adapter: Adapter;
-
- /**
- * Execute a SQL statement using bound parameters (if they are provided) and return a Query object
- * that is a Readable stream of the resulting rows. If a Continuation is provided the rows
- * returned by the database will be aggregated into a [ResultSet][] which will be passed to the
- * continuation after the query has completed.
- * The second form is not needed for normal use, but must be implemented by adapters to work correctly
- * with ConnectionPool and Transaction. See Adapter.createQuery for more details.
- */
- query(text: string, params?: any[], callback?: (error: Error, results: ResultSet) => void): Query
-
- /**
- * The second form is not needed for normal use, but must be implemented by adapters to work correctly
- * with ConnectionPool and Transaction. See Adapter.createQuery for more details.
- */
- // query(query: Query): Query;
- }
-
- /**
- * Connection objects are obtained using createConnection from Any-DB or ConnectionPool.acquire,
- * both of which delegate to the createConnection implementation of the specified adapter.
- * While all Connection objects implement the Queryable interface, the implementations in
- * each adapter may add additional methods or emit additional events. If you need to access a
- * feature of your database that is not described here (such as Postgres' server-side prepared
- * statements), consult the documentation for your adapter.
- *
- * Events:
- * Error event
- * The 'error' event is emitted when there is a connection-level error.
- * No arguments are passed to event listeners.
- *
- * Open event
- * The 'open' event is emitted when the connection has been established and is ready to query.
- * No arguments are passed to event listeners.
- *
- * Close event
- * The 'close' event is emitted when the connection has been closed.
- * No arguments are passed to event listeners.
- */
- export interface Connection extends Queryable {
- /**
- * Close the database connection. If a continuation is provided it
- * will be called after the connection has closed.
- */
- end(callback?: (error: Error) => void): void;
- }
-
- export interface ConnectionStatic {
- new(): Connection;
-
- name: string;
- createConnection(): void;
- createPool(): void;
- }
-
- /**
- * ConnectionPool events
- * 'acquire' - emitted whenever pool.acquire is called
- * 'release' - emitted whenever pool.release is called
- * 'query', query - emitted immediately after .query is called on a
- * connection via pool.query. The argument is a Query object.
- * 'close' - emitted when the connection pool has closed all of it
- * connections after a call to close().
- */
- export interface ConnectionPool extends Queryable {
- /**
- * Implements Queryable.query by automatically acquiring a connection
- * and releasing it when the query completes.
- */
- query(text: string, params?: any[], callback?: (error: Error, results: ResultSet) => void): Query;
-
- /**
- * Remove a connection from the pool. If you use this method you must
- * return the connection back to the pool using ConnectionPool.release
- */
- acquire(callback: (error: Error, result: Connection) => void): void;
-
- /**
- * Return a connection to the pool. This should only be called with connections
- * you've manually acquired. You must not continue to use the connection after releasing it.
- */
- release(connection: Connection): void;
-
- /**
- * Stop giving out new connections, and close all existing database connections as they
- * are returned to the pool.
- */
- close(callback?: (error: Error) => void): void;
- }
-
- /**
- * A PoolConfig is generally a plain object with any of the following properties (they are all optional):
- */
- export interface PoolConfig {
- /**
- * min (default 0) The minimum number of connections to keep open in the pool.
- */
- min?: number;
- /**
- * max (default 10) The maximum number of connections to keep open in the pool.
- * When this limit is reached further requests for connections will queue waiting
- * for an existing connection to be released back into the pool.
- */
- max?: number;
- /**
- * (default 30000) The maximum amount of time a connection can sit idle in the pool before being reaped
- */
- idleTimeout?: number;
- /**
- * (default 1000) How frequently the pool should check for connections that are old enough to be reaped.
- */
- reapInterval?: number;
- /**
- * (default true) When this is true, the pool will reap connections that
- * have been idle for more than idleTimeout milliseconds.
- */
- refreshIdle?: boolean;
- /**
- * Called immediately after a connection is first established. Use this to do one-time setup of new connections.
- * The supplied Connection will not be added to the pool until you pass it to the done continuation.
- */
- onConnect?: (connection: Connection, ready: (error: Error, result: Connection) => void) => void;
- /**
- * Called each time a connection is returned to the pool. Use this to restore a connection to
- * it's original state (e.g. rollback transactions, set the database session vars). If reset
- * fails to call the done continuation the connection will be lost in limbo.
- */
- reset?: (connection: Connection, done: (error: Error) => void) => void;
- /**
- * (default function (err) { return true }) - Called when an error is encountered
- * by pool.query or emitted by an idle connection. If shouldDestroyConnection(error)
- * is truthy the connection will be destroyed, otherwise it will be reset.
- */
- shouldDestroyConnection?: (error: Error) => boolean;
- }
-
- /**
- * Create a database connection.
- * @param url String of the form adapter://user:password@host/database
- * @param callback
- * @returns Connection object.
- */
- export function createConnection(url: string, callback?: (error: Error, connection: Connection) => void): Connection;
-
- /**
- * Create a database connection.
- * @param opts Object with adapter name and any properties that the given adapter requires
- * @param callback
- * @returns Connection object.
- */
- export function createConnection(opts: ConnectOpts, callback?: (error: Error, connection: Connection) => void): Connection;
-
-
- export function createPool(url: string, config: PoolConfig): ConnectionPool;
- export function createPool(opts: ConnectOpts, config: PoolConfig): ConnectionPool;
-
-}
+// Type definitions for any-db 2.1.0
+// Project: https://github.com/grncdr/node-any-db
+// Definitions by: Rogier Schouten
+// Definitions: https://github.com/borisyankov/DefinitelyTyped
+
+///
+
+declare module "any-db" {
+ import events = require("events");
+ import stream = require("stream");
+
+ export interface ConnectOpts {
+ adapter: string;
+ }
+
+ export interface Adapter {
+ name: string;
+ /**
+ * Create a new connection object. In common usage, config will be created by parse-db-url and passed to the adapter by any-db.
+ * If a continuation is given, it must be called, either with an error or the established connection.
+ */
+ createConnection(opts: ConnectOpts, callback?: (error: Error, result: Connection) => void): Connection;
+
+ /**
+ * Create a Query that may eventually be executed later on by a Connection. While this function is rarely needed by user code,
+ * it makes it possible for ConnectionPool.query and Transaction.query to fulfill the Queryable.query contract
+ * by synchronously returning a Query stream
+ */
+ createQuery(text: string, params?: any[], callback?: (error: Error, result: ResultSet) => void): Query;
+ createQuery(query: Query): Query;
+ }
+ /**
+ * Other properties are driver specific
+ */
+ export interface Field {
+ name: string;
+ }
+
+ /**
+ * ResultSet objects are just plain data that collect results of a query when a continuation
+ * is provided to Queryable.query. The lastInsertId is optional, and currently supported by
+ * sqlite3 and mysql but not postgres, because it is not supported by Postgres itself.
+ */
+ export interface ResultSet {
+ /**
+ * Affected rows. Note e.g. for INSERT queries the rows property is not filled even
+ * though rowCount is non-zero.
+ */
+ rowCount: number;
+ /**
+ * Result rows
+ */
+ rows: any[];
+ /**
+ * Result field descriptions
+ */
+ fields: Field[];
+
+ /**
+ * Not supported by all drivers.
+ */
+ fieldCount?: number;
+ /**
+ * Not supported by all drivers.
+ */
+ lastInsertId?: any;
+ /**
+ * Not supported by all drivers.
+ */
+ affectedRows?: number;
+ /**
+ * Not supported by all drivers.
+ */
+ changedRows?: number;
+ }
+
+ /**
+ * Query objects are returned by the Queryable.query method, available on connections,
+ * pools, and transactions. Queries are instances of Readable, and as such can be piped
+ * through transforms and support backpressure for more efficient memory-usage on very
+ * large results sets. (Note: at this time the sqlite3 driver does not support backpressure)
+ *
+ * Internally, Query instances are created by a database Adapter and may have more methods,
+ * properties, and events than are described here. Consult the documentation for your
+ * specific adapter to find out about any extensions.
+ *
+ * Events:
+ *
+ * Error event
+ * The 'error' event is emitted at most once per query. Note that this event will be
+ * emitted for errors even if a callback was provided, the callback will
+ * simply be subscribed to the 'error' event.
+ * One argument is passed to event listeners:
+ * error - the error object.
+ *
+ * Fields event
+ * A 'fields' event is emmitted before any 'data' events.
+ * One argument is passed to event listeners:
+ * fields - an array of [Field][ResultSet] objects.
+ *
+ * The following events are part of the stream.Readable interface which is implemented by Query:
+ *
+ * Data event
+ * A 'data' event is emitted for each row in the query result set.
+ * One argument is passed to event listeners:
+ * row contains the contents of a single row in the query result
+ *
+ * Close event
+ * A 'close' event is emitted when the query completes.
+ * No arguments are passed to event listeners.
+ *
+ * End event
+ * An 'end' event is emitted after all query results have been consumed.
+ * No arguments are passed to event listeners.
+ */
+ export interface Query extends stream.Readable {
+ /**
+ * The SQL query as a string. If you are using MySQL this will contain
+ * interpolated values after the query has been enqueued by a connection.
+ */
+ text: string;
+
+ /**
+ * The array of parameter values.
+ */
+ values: any[];
+
+ /**
+ * The callback (if any) that was provided to Queryable.query. Note that
+ * Query objects must not use a closed over reference to their callback,
+ * as other any-db libraries may rely on modifying the callback property
+ * of a Query they did not create.
+ */
+ callback: (error: Error, results: ResultSet) => void;
+ }
+
+ /**
+ * Events:
+ * The 'query' event is emitted immediately before a query is executed. One argument is passed to event handlers:
+ * - query: a Query object
+ */
+ export interface Queryable extends events.EventEmitter {
+ /**
+ * The Adapter instance that will be used by this Queryable for creating Query instances and/or connections.
+ */
+ adapter: Adapter;
+
+ /**
+ * Execute a SQL statement using bound parameters (if they are provided) and return a Query object
+ * that is a Readable stream of the resulting rows. If a Continuation is provided the rows
+ * returned by the database will be aggregated into a [ResultSet][] which will be passed to the
+ * continuation after the query has completed.
+ * The second form is not needed for normal use, but must be implemented by adapters to work correctly
+ * with ConnectionPool and Transaction. See Adapter.createQuery for more details.
+ */
+ query(text: string, params?: any[], callback?: (error: Error, results: ResultSet) => void): Query
+
+ /**
+ * The second form is not needed for normal use, but must be implemented by adapters to work correctly
+ * with ConnectionPool and Transaction. See Adapter.createQuery for more details.
+ */
+ // query(query: Query): Query;
+ }
+
+ /**
+ * Connection objects are obtained using createConnection from Any-DB or ConnectionPool.acquire,
+ * both of which delegate to the createConnection implementation of the specified adapter.
+ * While all Connection objects implement the Queryable interface, the implementations in
+ * each adapter may add additional methods or emit additional events. If you need to access a
+ * feature of your database that is not described here (such as Postgres' server-side prepared
+ * statements), consult the documentation for your adapter.
+ *
+ * Events:
+ * Error event
+ * The 'error' event is emitted when there is a connection-level error.
+ * No arguments are passed to event listeners.
+ *
+ * Open event
+ * The 'open' event is emitted when the connection has been established and is ready to query.
+ * No arguments are passed to event listeners.
+ *
+ * Close event
+ * The 'close' event is emitted when the connection has been closed.
+ * No arguments are passed to event listeners.
+ */
+ export interface Connection extends Queryable {
+ /**
+ * Close the database connection. If a continuation is provided it
+ * will be called after the connection has closed.
+ */
+ end(callback?: (error: Error) => void): void;
+ }
+
+ export interface ConnectionStatic {
+ new(): Connection;
+
+ name: string;
+ createConnection(): void;
+ createPool(): void;
+ }
+
+ /**
+ * ConnectionPool events
+ * 'acquire' - emitted whenever pool.acquire is called
+ * 'release' - emitted whenever pool.release is called
+ * 'query', query - emitted immediately after .query is called on a
+ * connection via pool.query. The argument is a Query object.
+ * 'close' - emitted when the connection pool has closed all of it
+ * connections after a call to close().
+ */
+ export interface ConnectionPool extends Queryable {
+ /**
+ * Implements Queryable.query by automatically acquiring a connection
+ * and releasing it when the query completes.
+ */
+ query(text: string, params?: any[], callback?: (error: Error, results: ResultSet) => void): Query;
+
+ /**
+ * Remove a connection from the pool. If you use this method you must
+ * return the connection back to the pool using ConnectionPool.release
+ */
+ acquire(callback: (error: Error, result: Connection) => void): void;
+
+ /**
+ * Return a connection to the pool. This should only be called with connections
+ * you've manually acquired. You must not continue to use the connection after releasing it.
+ */
+ release(connection: Connection): void;
+
+ /**
+ * Stop giving out new connections, and close all existing database connections as they
+ * are returned to the pool.
+ */
+ close(callback?: (error: Error) => void): void;
+ }
+
+ /**
+ * A PoolConfig is generally a plain object with any of the following properties (they are all optional):
+ */
+ export interface PoolConfig {
+ /**
+ * min (default 0) The minimum number of connections to keep open in the pool.
+ */
+ min?: number;
+ /**
+ * max (default 10) The maximum number of connections to keep open in the pool.
+ * When this limit is reached further requests for connections will queue waiting
+ * for an existing connection to be released back into the pool.
+ */
+ max?: number;
+ /**
+ * (default 30000) The maximum amount of time a connection can sit idle in the pool before being reaped
+ */
+ idleTimeout?: number;
+ /**
+ * (default 1000) How frequently the pool should check for connections that are old enough to be reaped.
+ */
+ reapInterval?: number;
+ /**
+ * (default true) When this is true, the pool will reap connections that
+ * have been idle for more than idleTimeout milliseconds.
+ */
+ refreshIdle?: boolean;
+ /**
+ * Called immediately after a connection is first established. Use this to do one-time setup of new connections.
+ * The supplied Connection will not be added to the pool until you pass it to the done continuation.
+ */
+ onConnect?: (connection: Connection, ready: (error: Error, result: Connection) => void) => void;
+ /**
+ * Called each time a connection is returned to the pool. Use this to restore a connection to
+ * it's original state (e.g. rollback transactions, set the database session vars). If reset
+ * fails to call the done continuation the connection will be lost in limbo.
+ */
+ reset?: (connection: Connection, done: (error: Error) => void) => void;
+ /**
+ * (default function (err) { return true }) - Called when an error is encountered
+ * by pool.query or emitted by an idle connection. If shouldDestroyConnection(error)
+ * is truthy the connection will be destroyed, otherwise it will be reset.
+ */
+ shouldDestroyConnection?: (error: Error) => boolean;
+ }
+
+ /**
+ * Create a database connection.
+ * @param url String of the form adapter://user:password@host/database
+ * @param callback
+ * @returns Connection object.
+ */
+ export function createConnection(url: string, callback?: (error: Error, connection: Connection) => void): Connection;
+
+ /**
+ * Create a database connection.
+ * @param opts Object with adapter name and any properties that the given adapter requires
+ * @param callback
+ * @returns Connection object.
+ */
+ export function createConnection(opts: ConnectOpts, callback?: (error: Error, connection: Connection) => void): Connection;
+
+
+ export function createPool(url: string, config: PoolConfig): ConnectionPool;
+ export function createPool(opts: ConnectOpts, config: PoolConfig): ConnectionPool;
+
+}
diff --git a/asciify/asciify.ts.tscparams b/asciify/asciify.ts.tscparams
index d68b297cb..85542607d 100644
--- a/asciify/asciify.ts.tscparams
+++ b/asciify/asciify.ts.tscparams
@@ -1 +1 @@
---noImplicitAny --module commonjs
+--noImplicitAny --module commonjs
diff --git a/async/async-tests.ts b/async/async-tests.ts
index a6dff0af8..037481b6f 100644
--- a/async/async-tests.ts
+++ b/async/async-tests.ts
@@ -1,443 +1,443 @@
-///
-
-var fs, path;
-
-function callback() {}
-
-async.map(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
-async.mapSeries(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
-async.mapLimit(['file1', 'file2', 'file3'], 2, fs.stat, function (err, results) { });
-
-async.filter(['file1', 'file2', 'file3'], path.exists, function (results) { });
-async.filterSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
-async.filterLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
-async.select(['file1', 'file2', 'file3'], path.exists, function (results) { });
-async.selectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
-async.selectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
-
-async.reject(['file1', 'file2', 'file3'], path.exists, function (results) { });
-async.rejectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
-async.rejectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
-
-async.parallel([
- function () { },
- function () { }
-], callback);
-
-async.series([
- function () { },
- function () { }
-]);
-
-var data = [];
-function asyncProcess(item, callback) { }
-async.map(data, asyncProcess, function (err, results) {
- console.log(results);
-});
-
-var openFiles = ['file1', 'file2'];
-var openFilesObj = {
- file1: "fileOne",
- file2: "fileTwo"
-}
-
-var saveFile = function () { }
-async.each(openFiles, saveFile, function (err) { });
-async.eachSeries(openFiles, saveFile, function (err) { });
-
-var documents, requestApi;
-async.eachLimit(documents, 20, requestApi, function (err) { });
-
-// forEachOf* functions. May accept array or object.
-function forEachOfIterator(item, key, forEachOfIteratorCallback) {
- console.log("ForEach: item=" + item + ", key=" + key);
- forEachOfIteratorCallback();
-}
-async.forEachOf(openFiles, forEachOfIterator, function (err) { });
-async.forEachOf(openFilesObj, forEachOfIterator, function (err) { });
-async.forEachOfSeries(openFiles, forEachOfIterator, function (err) { });
-async.forEachOfSeries(openFilesObj, forEachOfIterator, function (err) { });
-async.forEachOfLimit(openFiles, 2, forEachOfIterator, function (err) { });
-async.forEachOfLimit(openFilesObj, 2, forEachOfIterator, function (err) { });
-
-var process;
-var numArray = [1, 2, 3];
-function reducer(memo, item, callback) {
- process.nextTick(function () {
- callback(null, memo + item)
- });
-}
-async.reduce(numArray, 0, reducer, function (err, result) { });
-async.inject(numArray, 0, reducer, function (err, result) { });
-async.foldl(numArray, 0, reducer, function (err, result) { });
-async.reduceRight(numArray, 0, reducer, function (err, result) { });
-async.foldr(numArray, 0, reducer, function (err, result) { });
-
-async.detect(['file1', 'file2', 'file3'], path.exists, function (result) { });
-async.detectSeries(['file1', 'file2', 'file3'], path.exists, function (result) { });
-async.detectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
-
-async.sortBy(['file1', 'file2', 'file3'], function (file, callback) {
- fs.stat(file, function (err, stats) {
- callback(err, stats.mtime);
- });
-}, function (err, results) { });
-
-async.some(['file1', 'file2', 'file3'], path.exists, function (result) { });
-async.someLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
-async.any(['file1', 'file2', 'file3'], path.exists, function (result) { });
-
-async.every(['file1', 'file2', 'file3'], path.exists, function (result) { });
-async.everyLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
-async.all(['file1', 'file2', 'file3'], path.exists, function (result) { });
-
-async.concat(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { });
-async.concatSeries(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { });
-
-
-// Control Flow //
-
-async.series([
- function (callback) {
- callback(null, 'one');
- },
- function (callback) {
- callback(null, 'two');
- },
-],
-function (err, results) { });
-
-async.series([
- function (callback) {
- callback(null, 'one');
- },
- function (callback) {
- callback(null, 'two');
- },
-],
-function (err, results) { });
-
-async.series({
- one: function (callback) {
- setTimeout(function () {
- callback(null, 1);
- }, 200);
- },
- two: function (callback) {
- setTimeout(function () {
- callback(null, 2);
- }, 100);
- },
-},
-function (err, results) { });
-
-async.series({
- one: function (callback) {
- setTimeout(function () {
- callback(null, 1);
- }, 200);
- },
- two: function (callback) {
- setTimeout(function () {
- callback(null, 2);
- }, 100);
- },
-},
-function (err, results) { });
-
-async.times(5, function(n, next) {
- next(null, n)
-}, function(err, results) {
- console.log(results)
-})
-
-async.timesSeries(5, function(n, next) {
- next(null, n)
-}, function(err, results) {
- console.log(results)
-})
-
-async.parallel([
- function (callback) {
- setTimeout(function () {
- callback(null, 'one');
- }, 200);
- },
- function (callback) {
- setTimeout(function () {
- callback(null, 'two');
- }, 100);
- },
-],
-function (err, results) { });
-
-async.parallel([
- function (callback) {
- setTimeout(function () {
- callback(null, 'one');
- }, 200);
- },
- function (callback) {
- setTimeout(function () {
- callback(null, 'two');
- }, 100);
- },
-],
-function (err, results) { });
-
-
-async.parallel({
- one: function (callback) {
- setTimeout(function () {
- callback(null, 1);
- }, 200);
- },
- two: function (callback) {
- setTimeout(function () {
- callback(null, 2);
- }, 100);
- },
-},
-function (err, results) { });
-
-async.parallel({
- one: function (callback) {
- setTimeout(function () {
- callback(null, 1);
- }, 200);
- },
- two: function (callback) {
- setTimeout(function () {
- callback(null, 2);
- }, 100);
- },
-},
- function (err, results) { });
-
-async.parallelLimit({
- one: function (callback) {
- setTimeout(function () {
- callback(null, 1);
- }, 200);
- },
- two: function (callback) {
- setTimeout(function () {
- callback(null, 2);
- }, 100);
- },
-},
- 2,
- function (err, results) { }
-);
-
-
-function whileFn(callback) {
- count++;
- setTimeout(callback, 1000);
-}
-
-function whileTest() { return count < 5; }
-var count = 0;
-async.whilst(whileTest, whileFn, function (err) { });
-async.until(whileTest, whileFn, function (err) { });
-async.doWhilst(whileFn, whileTest, function (err) { });
-async.doUntil(whileFn, whileTest, function (err) { });
-
-async.during(function (testCallback) { testCallback(new Error(), false); }, function (callback) { callback() }, function (error) { console.log(error) });
-async.doDuring(function (callback) { callback() }, function (testCallback) { testCallback(new Error(), false); }, function (error) { console.log(error) });
-async.forever(function (errBack) {
- errBack(new Error("Not going on forever."));
-},
- function (error) {
- console.log(error);
- }
-);
-
-async.waterfall([
- function (callback) {
- callback(null, 'one', 'two');
- },
- function (arg1, arg2, callback) {
- callback(null, 'three');
- },
- function (arg1, callback) {
- callback(null, 'done');
- }
-], function (err, result) { });
-
-
-var q = async.queue(function (task: any, callback) {
- console.log('hello ' + task.name);
- callback();
-}, 2);
-
-
-q.drain = function () {
- console.log('all items have been processed');
-}
-
-q.push({ name: 'foo' });
-
-q.push({ name: 'bar' }, function (err) {
- console.log('finished processing bar');
-});
-
-q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
- console.log('finished processing bar');
-});
-
-q.unshift({ name: 'foo' });
-
-q.unshift({ name: 'bar' }, function (err) {
- console.log('finished processing bar');
-});
-
-q.unshift([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
- console.log('finished processing bar');
-});
-
-var qLength : number = q.length();
-var qStarted : boolean = q.started;
-var qPaused : boolean = q.paused;
-var qProcessingCount : number = q.running();
-var qIsIdle : boolean = q.idle();
-
-q.saturated = function() {
- console.log('queue is saturated.');
-}
-
-q.empty = function() {
- console.log('queue is empty.');
-}
-
-q.drain = function() {
- console.log('queue was drained.');
-}
-
-q.pause();
-q.resume();
-q.kill();
-
-// tests for strongly typed tasks
-var q2 = async.queue(function (task: string, callback) {
- console.log('Task: ' + task);
- callback();
-}, 1);
-
-q2.push('task1');
-
-q2.push('task2', function (error) {
- console.log('Finished tasks');
-});
-
-q2.push(['task3', 'task4', 'task5'], function (error) {
- console.log('Finished tasks');
-});
-
-q2.unshift('task1');
-
-q2.unshift('task2', function (error) {
- console.log('Finished tasks');
-});
-
-q2.unshift(['task3', 'task4', 'task5'], function (error) {
- console.log('Finished tasks');
-});
-
-// create a cargo object with payload 2
-var cargo = async.cargo(function (tasks, callback) {
- for (var i = 0; i < tasks.length; i++) {
- console.log('hello ' + tasks[i].name);
- }
- callback();
-}, 2);
-
-
-// add some items
-cargo.push({ name: 'foo' }, function (err) {
- console.log('finished processing foo');
-});
-cargo.push({ name: 'bar' }, function (err) {
- console.log('finished processing bar');
-});
-cargo.push({ name: 'baz' }, function (err) {
- console.log('finished processing baz');
-});
-
-var filename = '';
-async.auto({
- get_data: function (callback) { },
- make_folder: function (callback) { },
- //arrays with different types are not accepted by TypeScript.
- write_file: ['get_data', 'make_folder', function (callback) {
- callback(null, filename);
- }],
- //arrays with different types are not accepted by TypeScript.
- email_link: ['write_file', function (callback, results) { }]
-});
-
-async.retry(3, function (callback, results) { }, function (err, result) { });
-async.retry({ times: 3, interval: 200 }, function (callback, results) { }, function (err, result) { });
-
-
-async.parallel([
- function (callback) { },
- function (callback) { }
-],
-function (results) {
- async.series([
- function (callback) { },
- function email_link(callback) { }
- ]);
-});
-
-var sys;
-var iterator = async.iterator([
- function () { sys.p('one'); },
- function () { sys.p('two'); },
- function () { sys.p('three'); }
-]);
-
-async.parallel([
- async.apply(fs.writeFile, 'testfile1', 'test1'),
- async.apply(fs.writeFile, 'testfile2', 'test2'),
-]);
-
-
-async.parallel([
- function (callback) {
- fs.writeFile('testfile1', 'test1', callback);
- },
- function (callback) {
- fs.writeFile('testfile2', 'test2', callback);
- },
-]);
-
-var call_order = [];
-async.nextTick(function () {
- call_order.push('two');
-});
-call_order.push('one');
-
-var slow_fn = function (name, callback) {
- callback(null, 123);
-};
-var fn = async.memoize(slow_fn);
-fn('some name', function () {});
-async.unmemoize(fn);
-async.ensureAsync(function () { });
-async.constant(42);
-async.asyncify(function () { });
-
-async.log(function (name, callback) {
- setTimeout(function () {
- callback(null, 'hello ' + name);
- }, 0);
-}, "world"
- );
-
-async.dir(function (name, callback) {
- setTimeout(function () {
- callback(null, { hello: name });
- }, 1000);
-}, "world");
+///
+
+var fs, path;
+
+function callback() {}
+
+async.map(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
+async.mapSeries(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
+async.mapLimit(['file1', 'file2', 'file3'], 2, fs.stat, function (err, results) { });
+
+async.filter(['file1', 'file2', 'file3'], path.exists, function (results) { });
+async.filterSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
+async.filterLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
+async.select(['file1', 'file2', 'file3'], path.exists, function (results) { });
+async.selectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
+async.selectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
+
+async.reject(['file1', 'file2', 'file3'], path.exists, function (results) { });
+async.rejectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
+async.rejectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
+
+async.parallel([
+ function () { },
+ function () { }
+], callback);
+
+async.series([
+ function () { },
+ function () { }
+]);
+
+var data = [];
+function asyncProcess(item, callback) { }
+async.map(data, asyncProcess, function (err, results) {
+ console.log(results);
+});
+
+var openFiles = ['file1', 'file2'];
+var openFilesObj = {
+ file1: "fileOne",
+ file2: "fileTwo"
+}
+
+var saveFile = function () { }
+async.each(openFiles, saveFile, function (err) { });
+async.eachSeries(openFiles, saveFile, function (err) { });
+
+var documents, requestApi;
+async.eachLimit(documents, 20, requestApi, function (err) { });
+
+// forEachOf* functions. May accept array or object.
+function forEachOfIterator(item, key, forEachOfIteratorCallback) {
+ console.log("ForEach: item=" + item + ", key=" + key);
+ forEachOfIteratorCallback();
+}
+async.forEachOf(openFiles, forEachOfIterator, function (err) { });
+async.forEachOf(openFilesObj, forEachOfIterator, function (err) { });
+async.forEachOfSeries(openFiles, forEachOfIterator, function (err) { });
+async.forEachOfSeries(openFilesObj, forEachOfIterator, function (err) { });
+async.forEachOfLimit(openFiles, 2, forEachOfIterator, function (err) { });
+async.forEachOfLimit(openFilesObj, 2, forEachOfIterator, function (err) { });
+
+var process;
+var numArray = [1, 2, 3];
+function reducer(memo, item, callback) {
+ process.nextTick(function () {
+ callback(null, memo + item)
+ });
+}
+async.reduce(numArray, 0, reducer, function (err, result) { });
+async.inject(numArray, 0, reducer, function (err, result) { });
+async.foldl(numArray, 0, reducer, function (err, result) { });
+async.reduceRight(numArray, 0, reducer, function (err, result) { });
+async.foldr(numArray, 0, reducer, function (err, result) { });
+
+async.detect(['file1', 'file2', 'file3'], path.exists, function (result) { });
+async.detectSeries(['file1', 'file2', 'file3'], path.exists, function (result) { });
+async.detectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
+
+async.sortBy(['file1', 'file2', 'file3'], function (file, callback) {
+ fs.stat(file, function (err, stats) {
+ callback(err, stats.mtime);
+ });
+}, function (err, results) { });
+
+async.some(['file1', 'file2', 'file3'], path.exists, function (result) { });
+async.someLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
+async.any(['file1', 'file2', 'file3'], path.exists, function (result) { });
+
+async.every(['file1', 'file2', 'file3'], path.exists, function (result) { });
+async.everyLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
+async.all(['file1', 'file2', 'file3'], path.exists, function (result) { });
+
+async.concat(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { });
+async.concatSeries(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { });
+
+
+// Control Flow //
+
+async.series([
+ function (callback) {
+ callback(null, 'one');
+ },
+ function (callback) {
+ callback(null, 'two');
+ },
+],
+function (err, results) { });
+
+async.series([
+ function (callback) {
+ callback(null, 'one');
+ },
+ function (callback) {
+ callback(null, 'two');
+ },
+],
+function (err, results) { });
+
+async.series({
+ one: function (callback) {
+ setTimeout(function () {
+ callback(null, 1);
+ }, 200);
+ },
+ two: function (callback) {
+ setTimeout(function () {
+ callback(null, 2);
+ }, 100);
+ },
+},
+function (err, results) { });
+
+async.series({
+ one: function (callback) {
+ setTimeout(function () {
+ callback(null, 1);
+ }, 200);
+ },
+ two: function (callback) {
+ setTimeout(function () {
+ callback(null, 2);
+ }, 100);
+ },
+},
+function (err, results) { });
+
+async.times(5, function(n, next) {
+ next(null, n)
+}, function(err, results) {
+ console.log(results)
+})
+
+async.timesSeries(5, function(n, next) {
+ next(null, n)
+}, function(err, results) {
+ console.log(results)
+})
+
+async.parallel([
+ function (callback) {
+ setTimeout(function () {
+ callback(null, 'one');
+ }, 200);
+ },
+ function (callback) {
+ setTimeout(function () {
+ callback(null, 'two');
+ }, 100);
+ },
+],
+function (err, results) { });
+
+async.parallel([
+ function (callback) {
+ setTimeout(function () {
+ callback(null, 'one');
+ }, 200);
+ },
+ function (callback) {
+ setTimeout(function () {
+ callback(null, 'two');
+ }, 100);
+ },
+],
+function (err, results) { });
+
+
+async.parallel({
+ one: function (callback) {
+ setTimeout(function () {
+ callback(null, 1);
+ }, 200);
+ },
+ two: function (callback) {
+ setTimeout(function () {
+ callback(null, 2);
+ }, 100);
+ },
+},
+function (err, results) { });
+
+async.parallel({
+ one: function (callback) {
+ setTimeout(function () {
+ callback(null, 1);
+ }, 200);
+ },
+ two: function (callback) {
+ setTimeout(function () {
+ callback(null, 2);
+ }, 100);
+ },
+},
+ function (err, results) { });
+
+async.parallelLimit({
+ one: function (callback) {
+ setTimeout(function () {
+ callback(null, 1);
+ }, 200);
+ },
+ two: function (callback) {
+ setTimeout(function () {
+ callback(null, 2);
+ }, 100);
+ },
+},
+ 2,
+ function (err, results) { }
+);
+
+
+function whileFn(callback) {
+ count++;
+ setTimeout(callback, 1000);
+}
+
+function whileTest() { return count < 5; }
+var count = 0;
+async.whilst(whileTest, whileFn, function (err) { });
+async.until(whileTest, whileFn, function (err) { });
+async.doWhilst(whileFn, whileTest, function (err) { });
+async.doUntil(whileFn, whileTest, function (err) { });
+
+async.during(function (testCallback) { testCallback(new Error(), false); }, function (callback) { callback() }, function (error) { console.log(error) });
+async.doDuring(function (callback) { callback() }, function (testCallback) { testCallback(new Error(), false); }, function (error) { console.log(error) });
+async.forever(function (errBack) {
+ errBack(new Error("Not going on forever."));
+},
+ function (error) {
+ console.log(error);
+ }
+);
+
+async.waterfall([
+ function (callback) {
+ callback(null, 'one', 'two');
+ },
+ function (arg1, arg2, callback) {
+ callback(null, 'three');
+ },
+ function (arg1, callback) {
+ callback(null, 'done');
+ }
+], function (err, result) { });
+
+
+var q = async.queue(function (task: any, callback) {
+ console.log('hello ' + task.name);
+ callback();
+}, 2);
+
+
+q.drain = function () {
+ console.log('all items have been processed');
+}
+
+q.push({ name: 'foo' });
+
+q.push({ name: 'bar' }, function (err) {
+ console.log('finished processing bar');
+});
+
+q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
+ console.log('finished processing bar');
+});
+
+q.unshift({ name: 'foo' });
+
+q.unshift({ name: 'bar' }, function (err) {
+ console.log('finished processing bar');
+});
+
+q.unshift([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
+ console.log('finished processing bar');
+});
+
+var qLength : number = q.length();
+var qStarted : boolean = q.started;
+var qPaused : boolean = q.paused;
+var qProcessingCount : number = q.running();
+var qIsIdle : boolean = q.idle();
+
+q.saturated = function() {
+ console.log('queue is saturated.');
+}
+
+q.empty = function() {
+ console.log('queue is empty.');
+}
+
+q.drain = function() {
+ console.log('queue was drained.');
+}
+
+q.pause();
+q.resume();
+q.kill();
+
+// tests for strongly typed tasks
+var q2 = async.queue(function (task: string, callback) {
+ console.log('Task: ' + task);
+ callback();
+}, 1);
+
+q2.push('task1');
+
+q2.push('task2', function (error) {
+ console.log('Finished tasks');
+});
+
+q2.push(['task3', 'task4', 'task5'], function (error) {
+ console.log('Finished tasks');
+});
+
+q2.unshift('task1');
+
+q2.unshift('task2', function (error) {
+ console.log('Finished tasks');
+});
+
+q2.unshift(['task3', 'task4', 'task5'], function (error) {
+ console.log('Finished tasks');
+});
+
+// create a cargo object with payload 2
+var cargo = async.cargo(function (tasks, callback) {
+ for (var i = 0; i < tasks.length; i++) {
+ console.log('hello ' + tasks[i].name);
+ }
+ callback();
+}, 2);
+
+
+// add some items
+cargo.push({ name: 'foo' }, function (err) {
+ console.log('finished processing foo');
+});
+cargo.push({ name: 'bar' }, function (err) {
+ console.log('finished processing bar');
+});
+cargo.push({ name: 'baz' }, function (err) {
+ console.log('finished processing baz');
+});
+
+var filename = '';
+async.auto({
+ get_data: function (callback) { },
+ make_folder: function (callback) { },
+ //arrays with different types are not accepted by TypeScript.
+ write_file: ['get_data', 'make_folder', function (callback) {
+ callback(null, filename);
+ }],
+ //arrays with different types are not accepted by TypeScript.
+ email_link: ['write_file', function (callback, results) { }]
+});
+
+async.retry(3, function (callback, results) { }, function (err, result) { });
+async.retry({ times: 3, interval: 200 }, function (callback, results) { }, function (err, result) { });
+
+
+async.parallel([
+ function (callback) { },
+ function (callback) { }
+],
+function (results) {
+ async.series([
+ function (callback) { },
+ function email_link(callback) { }
+ ]);
+});
+
+var sys;
+var iterator = async.iterator([
+ function () { sys.p('one'); },
+ function () { sys.p('two'); },
+ function () { sys.p('three'); }
+]);
+
+async.parallel([
+ async.apply(fs.writeFile, 'testfile1', 'test1'),
+ async.apply(fs.writeFile, 'testfile2', 'test2'),
+]);
+
+
+async.parallel([
+ function (callback) {
+ fs.writeFile('testfile1', 'test1', callback);
+ },
+ function (callback) {
+ fs.writeFile('testfile2', 'test2', callback);
+ },
+]);
+
+var call_order = [];
+async.nextTick(function () {
+ call_order.push('two');
+});
+call_order.push('one');
+
+var slow_fn = function (name, callback) {
+ callback(null, 123);
+};
+var fn = async.memoize(slow_fn);
+fn('some name', function () {});
+async.unmemoize(fn);
+async.ensureAsync(function () { });
+async.constant(42);
+async.asyncify(function () { });
+
+async.log(function (name, callback) {
+ setTimeout(function () {
+ callback(null, 'hello ' + name);
+ }, 0);
+}, "world"
+ );
+
+async.dir(function (name, callback) {
+ setTimeout(function () {
+ callback(null, { hello: name });
+ }, 1000);
+}, "world");
diff --git a/async/async-tests.ts.tscparams b/async/async-tests.ts.tscparams
index d3f5a12fa..8b1378917 100644
--- a/async/async-tests.ts.tscparams
+++ b/async/async-tests.ts.tscparams
@@ -1 +1 @@
-
+
diff --git a/async/async.d.ts b/async/async.d.ts
index 418f5539b..543b3751d 100644
--- a/async/async.d.ts
+++ b/async/async.d.ts
@@ -1,165 +1,165 @@
-// Type definitions for Async 1.4.2
-// Project: https://github.com/caolan/async
-// Definitions by: Boris Yankov , Arseniy Maximov , Joe Herman
-// Definitions: https://github.com/borisyankov/DefinitelyTyped
-
-interface Dictionary { [key: string]: T; }
-
-interface ErrorCallback { (err?: Error): void; }
-interface AsyncResultCallback { (err: Error, result: T): void; }
-interface AsyncResultArrayCallback { (err: Error, results: T[]): void; }
-interface AsyncResultObjectCallback { (err: Error, results: Dictionary): void; }
-
-interface AsyncFunction { (callback: (err?: Error, result?: T) => void): void; }
-interface AsyncIterator { (item: T, callback: ErrorCallback): void; }
-interface AsyncForEachOfIterator { (item: T, key: number, callback: ErrorCallback): void; }
-interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; }
-interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; }
-interface AsyncBooleanIterator { (item: T, callback: (truthValue: boolean) => void): void; }
-
-interface AsyncWorker { (task: T, callback: ErrorCallback): void; }
-interface AsyncVoidFunction { (callback: ErrorCallback): void; }
-
-interface AsyncQueue {
- length(): number;
- started: boolean;
- running(): number;
- idle(): boolean;
- concurrency: number;
- push(task: T, callback?: ErrorCallback): void;
- push(task: T[], callback?: ErrorCallback): void;
- unshift(task: T, callback?: ErrorCallback): void;
- unshift(task: T[], callback?: ErrorCallback): void;
- saturated: () => any;
- empty: () => any;
- drain: () => any;
- paused: boolean;
- pause(): void
- resume(): void;
- kill(): void;
-}
-
-interface AsyncPriorityQueue {
- length(): number;
- concurrency: number;
- started: boolean;
- paused: boolean;
- push(task: T, priority: number, callback?: AsyncResultArrayCallback): void;
- push(task: T[], priority: number, callback?: AsyncResultArrayCallback): void;
- saturated: () => any;
- empty: () => any;
- drain: () => any;
- running(): number;
- idle(): boolean;
- pause(): void;
- resume(): void;
- kill(): void;
-}
-
-interface AsyncCargo {
- length(): number;
- payload: number;
- push(task: any, callback? : Function): void;
- push(task: any[], callback? : Function): void;
- saturated(): void;
- empty(): void;
- drain(): void;
- idle(): boolean;
- pause(): void;
- resume(): void;
- kill(): void;
-}
-
-interface Async {
-
- // Collections
- each(arr: T[], iterator: AsyncIterator, callback?: ErrorCallback): void;
- eachSeries(arr: T[], iterator: AsyncIterator, callback?: ErrorCallback): void;
- eachLimit(arr: T[], limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void;
- forEachOf(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
- forEachOf(obj: T[], iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void;
- forEachOfSeries(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
- forEachOfSeries(obj: T[], iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void;
- forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
- forEachOfLimit(obj: T[], limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void;
- map(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): any;
- mapSeries(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): any;
- mapLimit(arr: T[], limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): any;
- filter(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- select(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- filterSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- selectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- filterLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- selectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- reject(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- rejectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- rejectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (results: T[]) => any): any;
- reduce(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any;
- inject(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any;
- foldl(arr: T[], memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): any;
- reduceRight(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any;
- foldr(arr: T[], memo: R, iterator: AsyncMemoIterator, callback: AsyncResultCallback): any;
- detect(arr: T[], iterator: AsyncBooleanIterator, callback?: (result: T) => void): any;
- detectSeries(arr: T[], iterator: AsyncBooleanIterator, callback?: (result: T) => void): any;
- detectLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (result: T) => void): any;
- sortBy(arr: T[], iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): any;
- some(arr: T[], iterator: AsyncBooleanIterator, callback?: (result: boolean) => void): any;
- someLimit(arr: T[], limit: number, iterator: AsyncBooleanIterator, callback?: (result: boolean) => void): any;
- any(arr: T[], iterator: AsyncBooleanIterator, callback?: (result: boolean) => void): any;
- every(arr: T[], iterator: AsyncBooleanIterator, callback?: (result: boolean) => any): any;
- everyLimit