Merge remote-tracking branch 'upstream/types-2.0' into types-2.0

This commit is contained in:
Peter Safranek
2016-11-19 13:41:31 -08:00
1240 changed files with 188629 additions and 41530 deletions
+3 -1
View File
@@ -30,10 +30,12 @@ _infrastructure/tests/build
*.iml
*.js.map
!*.js/
!scripts/new-package.js
!scripts/lint.js
node_modules
.sublimets
.settings/launch.json
.vscode
yarn.lock
+1 -1
View File
@@ -1,6 +1,6 @@
language: node_js
node_js:
- 4
- 6.9.1
sudo: false
+2 -1
View File
@@ -401,6 +401,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](egg.js/egg.js.d.ts) [Egg.js](https://github.com/mikeflynn/egg.js) by [Markus Peloso](https://github.com/ToastHawaii)
* [:link:](ejs-locals/ejs-locals.d.ts) [ejs-locals](https://github.com/randometc/ejs-locals) by [jt000](https://github.com/jt000)
* [:link:](ejs/ejs.d.ts) [ejs.js](http://ejs.co) by [Ben Liddicott](https://github.com/benliddicott/DefinitelyTyped)
* [:link:](ejson/ejson.d.ts) [ejson](https://www.npmjs.com/package/ejson) by [Shantanu Bhadoria](https://github.com/shantanubhadoria)
* [:link:](elasticsearch/elasticsearch.d.ts) [elasticsearch](https://www.elastic.co) by [Casper Skydt](https://github.com/CasperSkydt/DefinitelyTyped), [Blake Smith](https://github.com/bfsmith/DefinitelyTyped)
* [:link:](jquery.elang/jquery.elang.d.ts) [eLang](https://github.com/sumegizoltan/ELang) by [Zoltan Sumegi](https://github.com/sumegizoltan)
* [:link:](github-electron/github-electron.d.ts) [Electron](http://electron.atom.io) by [jedmao](https://github.com/jedmao), [rhysd](https://rhysd.github.io), [Milan Burda](https://github.com/miniak)
@@ -1189,7 +1190,7 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](ng-stomp/ng-stomp.d.ts) [ngStomp](https://github.com/beevelop/ng-stomp) by [Lukasz Potapczuk](https://github.com/lpotapczuk)
* [:link:](ngstorage/ngstorage.d.ts) [ngstorage](https://github.com/gsklee/ngStorage) by [Jakub Pistek](https://github.com/kubiq)
* [:link:](nightmare/nightmare.d.ts) [Nightmare](https://github.com/segmentio/nightmare) by [horiuchi](https://github.com/horiuchi)
* [:link:](noble/noble.d.ts) [noble](https://github.com/sandeepmistry/noble) by [Seon-Wook Park](https://github.com/swook), [Hans Bakker](https://github.com/wind-rider)
* [:link:](noble/noble.d.ts) [noble](https://github.com/sandeepmistry/noble) by [Seon-Wook Park](https://github.com/swook), [Hans Bakker](https://github.com/wind-rider), [Shantanu Bhadoria](https://github.com/shantanubhadoria)
* [:link:](nock/nock.d.ts) [nock](https://github.com/pgte/nock) by [bonnici](https://github.com/bonnici)
* [:link:](node-imap/imap.d.ts) [node imap](https://github.com/mscdex/node-imap) by [Steve Fenton](https://github.com/Steve-Fenton)
* [:link:](oauth2-server/oauth2-server.d.ts) [Node OAuth2 Server](https://github.com/thomseddon/node-oauth2-server) by [Robbie Van Gorkom](https://github.com/vangorra)
+16 -7
View File
@@ -1,8 +1,17 @@
case 1. Add a new type definition.
- [ ] checked compilation succeeds with `--target es6` and `--noImplicitAny` options.
- [ ] has correct [naming convention](http://definitelytyped.org/guides/contributing.html#naming-the-file)
- [ ] has a [test file](http://definitelytyped.org/guides/contributing.html#tests) with the suffix of `-tests.ts` or `-tests.tsx`.
Please fill in this template.
case 2. Improvement to existing type definition.
- documentation or source code reference which provides context for the suggested changes. url http://api.jquery.com/html .
- it has been reviewed by a DefinitelyTyped member.
- [ ] Prefer to make your PR against the `types-2.0` branch.
- [ ] Test the change in your own code.
- [ ] Follow the advice from the [readme](https://github.com/DefinitelyTyped/DefinitelyTyped#make-a-pull-request).
- [ ] Avoid [common mistakes](https://github.com/DefinitelyTyped/DefinitelyTyped#common-mistakes).
- [ ] Run `npm run lint -- package-name` if a `tslint.json` is present.
If adding a new definition:
- [ ] The package does not provide its own types, and you can not add them.
- [ ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
- [ ] Run `tsc` without errors.
- [ ] Include the required [files](https://github.com/DefinitelyTyped/DefinitelyTyped#create-a-new-package) and header. Base these on the README, *not* on an existing project.
If changing an existing definition:
- [ ] Provide a URL to documentation or source code which provides context for the suggested changes: <<url here>>
- [ ] Increase the version number in the header if appropriate.
+195 -14
View File
@@ -4,36 +4,217 @@
> The repository for *high quality* TypeScript type definitions.
For more information see the [definitelytyped.org](http://definitelytyped.org) website.
Also see the [definitelytyped.org](http://definitelytyped.org) website, although information in this README is more up-to-date.
## Usage
Include a line like this:
## What are declaration files?
```typescript
/// <reference path="jquery.d.ts" />
See the [TypeScript handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html).
## How do I get them?
### npm
This is the preferred method. This is only available for TypeScript 2.0+ users. For example:
```sh
npm install --save-dev @types/node
```
## Contributions
The types should then be automatically included by the compiler.
See more in the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/consumption.html).
For an NPM package "foo", typings for it will be at "@types/foo".
If you can't find your package, look for it on [TypeSearch](https://microsoft.github.io/TypeSearch/).
If you still can't find it, check if it [bundles](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) its own typings.
This is usually provided in a `"types"` or `"typings"` field in the `package.json`,
or just look for any ".d.ts" files in the package and manually include them with a `/// <reference path="" />`.
### Other methods
These can be used by TypeScript 1.0.
* [Typings](https://github.com/typings/typings)
* [NuGet](http://nuget.org/Tpackages?q=DefinitelyTyped)
* Manually download from the `master` branch of this repository
You may need to add manual [references](http://www.typescriptlang.org/docs/handbook/triple-slash-directives.html).
## How can I contribute?
DefinitelyTyped only works because of contributions by users like you!
Please see the [contribution guide](http://definitelytyped.org/guides/contributing.html) on how to contribute to DefinitelyTyped.
### Test
## How to get the definitions
Before you share your improvement with the world, use it yourself.
* Directly from the GitHub repos
* [NuGet packages](http://nuget.org/packages?q=DefinitelyTyped)
* [Typings - TypeScript Definition Manager](https://github.com/typings/typings)
#### Test editing an exiting package
## List of definitions
To add new features you can use [module augmentation](http://www.typescriptlang.org/docs/handbook/declaration-merging.html).
You can also directly edit the types in `node_modules/@types/foo/index.d.ts`,
or copy them from there and paste inside of `declarations.d.ts` and follow the steps below.
* See [CONTRIBUTORS.md](CONTRIBUTORS.md)
## Requested definitions
#### Test a new package
* Add a new file `declarations.d.ts` to your project.
* Add it to the compilation, through `"includes"` or `"files"` in your [tsconfig](http://www.typescriptlang.org/docs/handbook/tsconfig-json.html),
or through a `/// <reference path="" />` declaration in your code.
* Inside `declarations.d.ts`, write `declare module "foo" { }`, then write the module declaration inside.
* Test that your code works.
* *Then*, once you've tested your definitions, make a PR contributing the definition.
### Make a pull request
Once you've tested your package, you can share it on DefinitelyTyped.
First, [fork](https://guides.github.com/activities/forking/) this repository.
Then inside your repository:
* `git checkout types-2.0`
New work should generally be done on the `types-2.0` branch.
If you want your changes to be available to `typings` users, then you may edit `master` instead.
#### Edit an existing package
* `cd my-package-to-edit`
* Make changes. Remember to edit tests.
* You may also want to add yourself to "Definitions by" section of the package header.
* `npm install -g typescript@2.0` and run `tsc`.
When you make a PR to edit an existing package, `dt-bot` should @-mention previous authors.
If it doesn't, you can do so yourself in the comment associated with the PR.
#### Create a new package
If you are the library author, or can make a pull request to the library, [bundle](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) types instead of publishing to DefinitelyTyped.
If you are adding typings for an NPM package, create a directory with the same name.
If the package you are adding typings for is not on NPM, make sure the name you choose for it does not conflict with the name of a package on NPM.
(You can use `npm info foo` to check for the existence of the `foo` package.)
Your package should have this structure:
| File | Purpose |
| --- | --- |
| index.d.ts | This contains the typings for the package. |
| foo-tests.ts | This contains sample code which tests the typings. This code does *not* run, but it is type-checked. |
| tsconfig.json | This allows you to run `tsc` within the package. |
Generate these by running `npm run new-package -- new-package-name`.
You may edit the `tsconfig.json` to add new files or to add the `"jsx"` compiler option.
DefinitelyTyped members routinely monitor for new PRs, though keep in mind that the number of other PRs may slow things down.
For a good example package, see [base64-js](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/base64-js).
#### Common mistakes
* First, follow advice from the [handbook](http://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html).
* Formatting: Either use all tabs, or always use 4 spaces. Also, always use semicolons, and use egyptian braces.
* `interface X {}`: An empty interface is essentially the `{}` type: it places no constraints on an object.
* `interface IFoo {}`: Don't add `I` to the front of an interface name.
* `interface Foo { new(): Foo; }`:
This defines a type of objects that are new-able. You probably want `declare class Foo { constructor(); }
* `const Class: { new(): IClass; }`:
Prefer to use a class declaration `class Class { constructor(); }` instead of a new-able constant.
* `namespace foo {}`:
Do not add a namespace just so that the `import * as foo` syntax will work.
If it is commonJs module with a single export, you should use the `import foo = require("foo")` syntax.
See more explanation [here](https://stackoverflow.com/questions/39415661/why-cant-i-import-a-class-or-function-with-import-as-x-from-y).
* `getMeAT<T>(): T`:
If a type parameter does not appear in the types of any parameters, you don't really have a generic function, you just have a disguised type assertion.
Prefer to use a real type assertion, e.g. `getMeAT() as number`.
Example where a type parameter is acceptable: `function id<T>(value: T): T;`.
Example where it is not acceptable: `function parseJson<T>(json: string): T;`.
Exception: `new Map<string, number>()` is OK.
#### Removing a package
When a package [bundles](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) its own types, types should be removed from DefinitelyTyped to avoid confusion.
Make a PR doing the following:
* Delete the directory.
* Add a new entry to `notNeededPackages.json`.
- `libraryName`: Descriptive name of the library, e.g. "Angular 2" instead of "angular2". (May be identical to "typingsPackageName".)
- `typingsPackageName`: This is the name of the directory you just deleted.
- `sourceRepoURL`: This should point to the repository that contains the typings.
- `asOfVersion`: A stub will be published to `@types/foo` with this version. Should be higher than any currently published version.
* Any other packages in DefinitelyTyped that referenced the deleted package should be updated to reference the bundled types.
To do this, add a `package.json` with `"dependencies": { "foo": "x.y.z" }`.
#### Lint
To lint a package, just add a `tslint.json` to that package containing `{ "extends": "../tslint.json" }`. All new packages must be linted.
If a `tslint.json` turns rules off, this is because that hasn't been fixed yet. For example:
```json
{
"extends": "../tslint.json",
"rules": {
// This package uses the Function type, and it will take effort to fix.
"forbidden-types": false
}
}
```
(To indicate that a lint rule truly does not apply, use `// tslint:disable:rule-name` or better, `//tslint:disable-next-line:rule-name`.)
Only `.d.ts` files are linted.
Test the linter by running `npm run lint -- package-name`. Do not use a globally installed tslint.
## FAQ
#### What exactly is the relationship between this repository and the `@types` packages on NPM?
The `types-2.0` branch is automatically published to the `@types` scope on NPM thanks to [types-publisher](https://github.com/Microsoft/types-publisher).
This usually happens within an hour of changes being merged.
Changes to the `master` branch are also manually merged into the `types-2.0` branch, but this takes longer.
#### I'm writing a definition that depends on another definition. Should I use `<reference types="" />` or an import?
If the module you're referencing is an external module (uses `export`), use an import.
If the module you're referenceing is an ambient module (uses `declare module`, or just declares globals), use `<reference types="" />`.
#### What do I do about older versions of typings?
Currently we don't support this, though it is [planned](https://github.com/Microsoft/types-publisher/issues/3).
If you're adding a new major version of a library, you can copy `index.d.ts` to `foo-v2.3.d.ts` and edit `index.d.ts` to be the new version.
#### I notice some packages having a `package.json` here.
Usually you won't need this. When publishing a package we will normally automatically create a `package.json` for it.
A `package.json` may be included for the sake of specifying dependencies. Here's an [example](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/types-2.0/pikaday/package.json).
We do not allow other fields, such as `"description"`, to be defined manually.
Also, if you need to reference an older version of typings, you must do that by adding `"dependencies": { "@types/foo": "x.y.z" }` to the package.json.
#### I notice some `tsconfig.json` are missing `"noImplicitAny": true` or `"strictNullChecks": true`.
Then they are wrong. You can help by submitting a pull request to fix them.
#### Definitions in types-2.0 seem written differently than in master.
If you're targeting types-2.0, write it like the types-2.0 definitions.
If you're targeting master, we may change it to the new style when merging from master to types-2.0.
#### Can I request a definition?
Here are the [currently requested definitions](https://github.com/DefinitelyTyped/DefinitelyTyped/labels/Definition%3ARequest).
## License
This project is licensed under the MIT license.
@@ -14,6 +14,6 @@
},
"files": [
"index.d.ts",
"rails-actioncable-tests.ts"
"actioncable-tests.ts"
]
}
+1 -1
View File
@@ -81,7 +81,7 @@ declare namespace Ajv {
passContext?: boolean;
loopRequired?: number;
ownProperties?: boolean;
multipleOfPrecision?: boolean;
multipleOfPrecision?: boolean | number;
errorDataPath?: string,
messages?: boolean;
beautify?: boolean;
+219
View File
@@ -0,0 +1,219 @@
// Type definitions for amqplib 0.3.x
// Project: https://github.com/squaremo/amqp.node
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="when" />
/// <reference types="node" />
declare module "amqplib/properties" {
namespace Replies {
interface Empty {
}
interface AssertQueue {
queue: string;
messageCount: number;
consumerCount: number;
}
interface PurgeQueue {
messageCount: number;
}
interface DeleteQueue {
messageCount: number;
}
interface AssertExchange {
exchange: string;
}
interface Consume {
consumerTag: string;
}
}
namespace Options {
interface AssertQueue {
exclusive?: boolean;
durable?: boolean;
autoDelete?: boolean;
arguments?: any;
messageTtl?: number;
expires?: number;
deadLetterExchange?: string;
deadLetterRoutingKey?: string;
maxLength?: number;
}
interface DeleteQueue {
ifUnused?: boolean;
ifEmpty?: boolean;
}
interface AssertExchange {
durable?: boolean;
internal?: boolean;
autoDelete?: boolean;
alternateExchange?: string;
arguments?: any;
}
interface DeleteExchange {
ifUnused?: boolean;
}
interface Publish {
expiration?: string;
userId?: string;
CC?: string | string[];
mandatory?: boolean;
persistent?: boolean;
deliveryMode?: boolean | number;
BCC?: string | string[];
contentType?: string;
contentEncoding?: string;
headers?: any;
priority?: number;
correlationId?: string;
replyTo?: string;
messageId?: string;
timestamp?: number;
type?: string;
appId?: string;
}
interface Consume {
consumerTag?: string;
noLocal?: boolean;
noAck?: boolean;
exclusive?: boolean;
priority?: number;
arguments?: any;
}
interface Get {
noAck?: boolean;
}
}
interface Message {
content: Buffer;
fields: any;
properties: any;
}
}
declare module "amqplib" {
import events = require("events");
import when = require("when");
import shared = require("amqplib/properties")
export import Replies = shared.Replies;
export import Options = shared.Options;
export import Message = shared.Message;
interface Connection extends events.EventEmitter {
close(): when.Promise<void>;
createChannel(): when.Promise<Channel>;
createConfirmChannel(): when.Promise<Channel>;
}
interface Channel extends events.EventEmitter {
close(): when.Promise<void>;
assertQueue(queue: string, options?: Options.AssertQueue): when.Promise<Replies.AssertQueue>;
checkQueue(queue: string): when.Promise<Replies.AssertQueue>;
deleteQueue(queue: string, options?: Options.DeleteQueue): when.Promise<Replies.DeleteQueue>;
purgeQueue(queue: string): when.Promise<Replies.PurgeQueue>;
bindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
unbindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
assertExchange(exchange: string, type: string, options?: Options.AssertExchange): when.Promise<Replies.AssertExchange>;
checkExchange(exchange: string): when.Promise<Replies.Empty>;
deleteExchange(exchange: string, options?: Options.DeleteExchange): when.Promise<Replies.Empty>;
bindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
unbindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): when.Promise<Replies.Consume>;
cancel(consumerTag: string): when.Promise<Replies.Empty>;
get(queue: string, options?: Options.Get): when.Promise<Message | boolean>;
ack(message: Message, allUpTo?: boolean): void;
ackAll(): void;
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
nackAll(requeue?: boolean): void;
reject(message: Message, requeue?: boolean): void;
prefetch(count: number, global?: boolean): when.Promise<Replies.Empty>;
recover(): when.Promise<Replies.Empty>;
}
function connect(url: string, socketOptions?: any): when.Promise<Connection>;
}
declare module "amqplib/callback_api" {
import events = require("events");
import shared = require("amqplib/properties")
export import Replies = shared.Replies;
export import Options = shared.Options;
export import Message = shared.Message;
interface Connection extends events.EventEmitter {
close(callback?: (err: any) => void): void;
createChannel(callback: (err: any, channel: Channel) => void): void;
createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void;
}
interface Channel extends events.EventEmitter {
close(callback: (err: any) => void): void;
assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void): void;
checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void): void;
purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void): void;
bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
assertExchange(exchange: string, type: string, options?: Options.AssertExchange, callback?: (err: any, ok: Replies.AssertExchange) => void): void;
checkExchange(exchange: string, callback?: (err: any, ok: Replies.Empty) => void): void;
deleteExchange(exchange: string, options?: Options.DeleteExchange, callback?: (err: any, ok: Replies.Empty) => void): void;
bindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
unbindExchange(destination: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume, callback?: (err: any, ok: Replies.Consume) => void): void;
cancel(consumerTag: string, callback?: (err: any, ok: Replies.Empty) => void): void;
get(queue: string, options?: Options.Get, callback?: (err: any, ok: Message | boolean) => void): void;
ack(message: Message, allUpTo?: boolean): void;
ackAll(): void;
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
nackAll(requeue?: boolean): void;
reject(message: Message, requeue?: boolean): void;
prefetch(count: number, global?: boolean): void;
recover(callback?: (err: any, ok: Replies.Empty) => void): void;
}
interface ConfirmChannel extends Channel {
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
waitForConfirms(callback?: (err: any) => void): void;
}
function connect(callback: (err: any, connection: Connection) => void): void;
function connect(url: string, callback: (err: any, connection: Connection) => void): void;
function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void;
}
+20 -22
View File
@@ -1,44 +1,42 @@
// promise api tests
import amqp = require("amqplib");
import amqp = require('amqplib');
var msg = "Hello World";
var msg = 'Hello World';
// test promise api
amqp.connect("amqp://localhost")
amqp.connect('amqp://localhost')
.then(connection => {
return connection.createChannel()
.tap(channel => channel.checkQueue("myQueue"))
.then(channel => channel.sendToQueue("myQueue", new Buffer(msg)))
.ensure(() => connection.close());
.tap(channel => channel.checkQueue('myQueue'))
.then(channel => channel.sendToQueue('myQueue', new Buffer(msg)))
.finally(() => connection.close());
});
amqp.connect("amqp://localhost")
amqp.connect('amqp://localhost')
.then(connection => {
return connection.createChannel()
.tap(channel => channel.checkQueue("myQueue"))
.then(channel => channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString())))
.ensure(() => connection.close());
.tap(channel => channel.checkQueue('myQueue'))
.then(channel => channel.consume('myQueue', newMsg => console.log('New Message: ' + newMsg.content.toString())))
.finally(() => connection.close());
});
// test promise api properties
var amqpMessage: amqp.Message;
amqpMessage.properties.contentType = "application/json";
amqpMessage.properties.contentType = 'application/json';
var amqpAssertExchangeOptions: amqp.Options.AssertExchange;
var anqpAssertExchangeReplies: amqp.Replies.AssertExchange;
// callback api tests
import amqpcb = require("amqplib/callback_api");
import amqpcb = require('amqplib/callback_api');
amqpcb.connect("amqp://localhost", (err, connection) => {
amqpcb.connect('amqp://localhost', (err, connection) => {
if(!err) {
connection.createChannel((err, channel) => {
if (!err) {
channel.assertQueue("myQueue", {}, (err, ok) => {
channel.assertQueue('myQueue', {}, (err, ok) => {
if(!err) {
channel.sendToQueue("myQueue", new Buffer(msg));
channel.sendToQueue('myQueue', new Buffer(msg));
}
});
}
@@ -46,13 +44,13 @@ amqpcb.connect("amqp://localhost", (err, connection) => {
}
});
amqpcb.connect("amqp://localhost", (err, connection) => {
amqpcb.connect('amqp://localhost', (err, connection) => {
if(!err) {
connection.createChannel((err, channel) => {
if (!err) {
channel.assertQueue("myQueue", {}, (err, ok) => {
channel.assertQueue('myQueue', {}, (err, ok) => {
if(!err) {
channel.consume("myQueue", newMsg => console.log("New Message: " + newMsg.content.toString()));
channel.consume('myQueue', newMsg => console.log('New Message: ' + newMsg.content.toString()));
}
});
}
@@ -62,6 +60,6 @@ amqpcb.connect("amqp://localhost", (err, connection) => {
// test callback api properties
var amqpcbMessage: amqpcb.Message;
amqpcbMessage.properties.contentType = "application/json";
amqpcbMessage.properties.contentType = 'application/json';
var amqpcbAssertExchangeOptions: amqpcb.Options.AssertExchange;
var anqpcbAssertExchangeReplies: amqpcb.Replies.AssertExchange;
var anqpcbAssertExchangeReplies: amqpcb.Replies.AssertExchange;
+84 -77
View File
@@ -1,13 +1,76 @@
// Type definitions for amqplib 0.3.x
// Type definitions for amqplib 0.5.x
// Project: https://github.com/squaremo/amqp.node
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>
// Definitions by: Michael Nahkies <https://github.com/mnahkies>, Ab Reitsma <https://github.com/abreits>, Nicolás Fantone <https://github.com/nfantone>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="when" />
/// <reference types="node" />
declare module "amqplib/properties" {
namespace Replies {
declare module 'amqplib' {
import * as Promise from 'bluebird';
import * as events from 'events';
import shared = require('amqplib/properties');
export import Replies = shared.Replies;
export import Options = shared.Options;
export import Message = shared.Message;
export interface Connection extends events.EventEmitter {
close(): Promise<void>;
createChannel(): Promise<Channel>;
createConfirmChannel(): Promise<ConfirmChannel>;
}
export interface Channel extends events.EventEmitter {
close(): Promise<void>;
assertQueue(queue: string, options?: Options.AssertQueue): Promise<Replies.AssertQueue>;
checkQueue(queue: string): Promise<Replies.AssertQueue>;
deleteQueue(queue: string, options?: Options.DeleteQueue): Promise<Replies.DeleteQueue>;
purgeQueue(queue: string): Promise<Replies.PurgeQueue>;
bindQueue(queue: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
unbindQueue(queue: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
assertExchange(exchange: string, type: string, options?: Options.AssertExchange): Promise<Replies.AssertExchange>;
checkExchange(exchange: string): Promise<Replies.Empty>;
deleteExchange(exchange: string, options?: Options.DeleteExchange): Promise<Replies.Empty>;
bindExchange(destination: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
unbindExchange(destination: string, source: string, pattern: string, args?: any): Promise<Replies.Empty>;
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): Promise<Replies.Consume>;
cancel(consumerTag: string): Promise<Replies.Empty>;
get(queue: string, options?: Options.Get): Promise<Message | boolean>;
ack(message: Message, allUpTo?: boolean): void;
ackAll(): void;
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
nackAll(requeue?: boolean): void;
reject(message: Message, requeue?: boolean): void;
prefetch(count: number, global?: boolean): Promise<Replies.Empty>;
recover(): Promise<Replies.Empty>;
}
export interface ConfirmChannel extends Channel {
publish(exchange:string, routingKey:string, content:Buffer, options?:Options.Publish, callback?:(err:any, ok:Replies.Empty) => void):boolean;
sendToQueue(queue:string, content:Buffer, options?:Options.Publish, callback?:(err:any, ok:Replies.Empty) => void):boolean;
waitForConfirms(): Promise<void>;
}
export function connect(url: string, socketOptions?: any): Promise<Connection>;
}
declare module 'amqplib/properties' {
export namespace Replies {
interface Empty {
}
interface AssertQueue {
@@ -29,7 +92,7 @@ declare module "amqplib/properties" {
}
}
namespace Options {
export namespace Options {
interface AssertQueue {
exclusive?: boolean;
durable?: boolean;
@@ -40,6 +103,7 @@ declare module "amqplib/properties" {
deadLetterExchange?: string;
deadLetterRoutingKey?: string;
maxLength?: number;
maxPriority?: number;
}
interface DeleteQueue {
ifUnused?: boolean;
@@ -56,7 +120,7 @@ declare module "amqplib/properties" {
ifUnused?: boolean;
}
interface Publish {
expiration?: string;
expiration?: string | number;
userId?: string;
CC?: string | string[];
@@ -89,92 +153,35 @@ declare module "amqplib/properties" {
}
}
interface Message {
export interface Message {
content: Buffer;
fields: any;
properties: any;
}
}
declare module "amqplib" {
declare module 'amqplib/callback_api' {
import events = require('events');
import shared = require('amqplib/properties')
import events = require("events");
import when = require("when");
import shared = require("amqplib/properties")
export import Replies = shared.Replies;
export import Options = shared.Options;
export import Message = shared.Message;
interface Connection extends events.EventEmitter {
close(): when.Promise<void>;
createChannel(): when.Promise<Channel>;
createConfirmChannel(): when.Promise<Channel>;
}
interface Channel extends events.EventEmitter {
close(): when.Promise<void>;
assertQueue(queue: string, options?: Options.AssertQueue): when.Promise<Replies.AssertQueue>;
checkQueue(queue: string): when.Promise<Replies.AssertQueue>;
deleteQueue(queue: string, options?: Options.DeleteQueue): when.Promise<Replies.DeleteQueue>;
purgeQueue(queue: string): when.Promise<Replies.PurgeQueue>;
bindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
unbindQueue(queue: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
assertExchange(exchange: string, type: string, options?: Options.AssertExchange): when.Promise<Replies.AssertExchange>;
checkExchange(exchange: string): when.Promise<Replies.Empty>;
deleteExchange(exchange: string, options?: Options.DeleteExchange): when.Promise<Replies.Empty>;
bindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
unbindExchange(destination: string, source: string, pattern: string, args?: any): when.Promise<Replies.Empty>;
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish): boolean;
sendToQueue(queue: string, content: Buffer, options?: Options.Publish): boolean;
consume(queue: string, onMessage: (msg: Message) => any, options?: Options.Consume): when.Promise<Replies.Consume>;
cancel(consumerTag: string): when.Promise<Replies.Empty>;
get(queue: string, options?: Options.Get): when.Promise<Message | boolean>;
ack(message: Message, allUpTo?: boolean): void;
ackAll(): void;
nack(message: Message, allUpTo?: boolean, requeue?: boolean): void;
nackAll(requeue?: boolean): void;
reject(message: Message, requeue?: boolean): void;
prefetch(count: number, global?: boolean): when.Promise<Replies.Empty>;
recover(): when.Promise<Replies.Empty>;
}
function connect(url: string, socketOptions?: any): when.Promise<Connection>;
}
declare module "amqplib/callback_api" {
import events = require("events");
import shared = require("amqplib/properties")
export import Replies = shared.Replies;
export import Options = shared.Options;
export import Message = shared.Message;
interface Connection extends events.EventEmitter {
export interface Connection extends events.EventEmitter {
close(callback?: (err: any) => void): void;
createChannel(callback: (err: any, channel: Channel) => void): void;
createConfirmChannel(callback: (err: any, confirmChannel: ConfirmChannel) => void): void;
}
interface Channel extends events.EventEmitter {
export interface Channel extends events.EventEmitter {
close(callback: (err: any) => void): void;
assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err:any, ok: Replies.AssertQueue) => void): void;
assertQueue(queue?: string, options?: Options.AssertQueue, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
checkQueue(queue: string, callback?: (err: any, ok: Replies.AssertQueue) => void): void;
deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err:any, ok: Replies.DeleteQueue) => void): void;
purgeQueue(queue: string, callback?: (err:any, ok: Replies.PurgeQueue) => void): void;
deleteQueue(queue: string, options?: Options.DeleteQueue, callback?: (err: any, ok: Replies.DeleteQueue) => void): void;
purgeQueue(queue: string, callback?: (err: any, ok: Replies.PurgeQueue) => void): void;
bindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
unbindQueue(queue: string, source: string, pattern: string, args?: any, callback?: (err: any, ok: Replies.Empty) => void): void;
@@ -206,14 +213,14 @@ declare module "amqplib/callback_api" {
recover(callback?: (err: any, ok: Replies.Empty) => void): void;
}
interface ConfirmChannel extends Channel {
export interface ConfirmChannel extends Channel {
publish(exchange: string, routingKey: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
sendToQueue(queue: string, content: Buffer, options?: Options.Publish, callback?: (err: any, ok: Replies.Empty) => void): boolean;
waitForConfirms(callback?: (err: any) => void): void;
}
function connect(callback: (err: any, connection: Connection) => void): void;
function connect(url: string, callback: (err: any, connection: Connection) => void): void;
function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void;
export function connect(callback: (err: any, connection: Connection) => void): void;
export function connect(url: string, callback: (err: any, connection: Connection) => void): void;
export function connect(url: string, socketOptions: any, callback: (err: any, connection: Connection) => void): void;
}
+3 -3
View File
@@ -1,8 +1,8 @@
import AnalyticsNode = require("analytics-node");
var analytics: AnalyticsNode.Analytics;
import Analytics = require("analytics-node");
var analytics: Analytics;
function testConfig(): void {
analytics = new AnalyticsNode.Analytics('YOUR_WRITE_KEY', {
analytics = new Analytics('YOUR_WRITE_KEY', {
flushAt: 20,
flushAfter: 10000
});
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: Andrew Fong <https://github.com/fongandrew>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export = AnalyticsNode;
export = AnalyticsNode.Analytics;
declare namespace AnalyticsNode {
+1 -1
View File
@@ -13,6 +13,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
@@ -0,0 +1,14 @@
/// <reference path="./index.d.ts" />
/// <reference path="../angular/index.d.ts" />
import * as angular from "angular";
import {ClipboardService} from "angular-clipboard";
const app = angular.module('testModule', ['angular-clipboard']);
app.controller('TestController', ($scope: ng.IScope, clipboard: ClipboardService) => {
$scope['testCopy'] = () => {
if (clipboard.supported) {
clipboard.copyText('hiiiiiii');
}
};
});
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for angular-clipboard v1.5
// Project: https://github.com/omichelsen/angular-clipboard
// Definitions by: Bradford Wagner <https://github.com/bradfordwagner/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Definition of the Clipboard Service
*/
export interface ClipboardService {
/**
* tells us whether or not angular-clipboard is supported
*/
supported: boolean;
/**
* copies text to a clipboard
* @param text the text to be copied to the clipboard
*/
copyText(text: string): void;
}
+19
View File
@@ -0,0 +1,19 @@
{
"files": [
"index.d.ts",
"angular-clipboard-tests.ts"
],
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
}
}
+1 -1
View File
@@ -13,6 +13,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
+1 -1
View File
@@ -14,6 +14,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
+59 -53
View File
@@ -1,73 +1,79 @@
// Type definitions for angular-gettext v2.1.0
// Type definitions for angular-gettext v2.1.0
// Project: https://angular-gettext.rocketeer.be/
// Definitions by: Ákos Lukács <https://github.com/AkosLukacs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="angular" />
declare namespace angular.gettext {
interface gettextCatalog {
//////////////
/// Fields ///
//////////////
/** (default: false): Whether or not to prefix untranslated strings with [MISSING]: or a custom prefix. */
debug: boolean;
/** (default: [MISSING]:): Custom prefix for untranslated strings. */
debugPrefix: string;
/** (default: false): Whether or not to wrap all processed text with markers.Example output: [Welcome] */
showTranslatedMarkers: boolean;
/** (default: [): Custom prefix to mark strings that have been run through angular-gettext. */
translatedMarkerPrefix: string;
/** (default: ]): Custom suffix to mark strings that have been run through angular-gettext. */
translatedMarkerSuffix: string;
/** An object of loaded translation strings.Shouldn't be used directly. */
strings: {};
/** The default language, in which you're application is written. This defaults to English and it's generally a bad idea to use anything else: if your language has different pluralization rules you'll end up with incorrect translations. Deprecated
* @deprecreated
*/
baseLanguage: string;
import * as angular from 'angular';
///////////////
/// Methods ///
///////////////
declare module 'angular' {
export namespace gettext {
interface gettextCatalog {
/** Sets the current language and makes sure that all translations get updated correctly. */
setCurrentLanguage(lang: string): void;
//////////////
/// Fields ///
//////////////
/** Returns the current language. */
getCurrentLanguage(): string;
/** (default: false): Whether or not to prefix untranslated strings with [MISSING]: or a custom prefix. */
debug: boolean;
/** (default: [MISSING]:): Custom prefix for untranslated strings. */
debugPrefix: string;
/** (default: false): Whether or not to wrap all processed text with markers.Example output: [Welcome] */
showTranslatedMarkers: boolean;
/** (default: [): Custom prefix to mark strings that have been run through angular-gettext. */
translatedMarkerPrefix: string;
/** (default: ]): Custom suffix to mark strings that have been run through angular-gettext. */
translatedMarkerSuffix: string;
/** An object of loaded translation strings.Shouldn't be used directly. */
strings: {};
/** The default language, in which you're application is written. This defaults to English and it's generally a bad idea to use anything else: if your language has different pluralization rules you'll end up with incorrect translations. Deprecated
* @deprecreated
*/
baseLanguage: string;
/** Processes an object of string definitions. More details https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/
* @param language A language code.
* @param strings A dictionary of strings. The format of this dictionary is:
* - Keys: Singular English strings (as defined in the source files)
* - Values: Either a single string for signular-only strings or an array of plural forms.
*/
setStrings(language: string, strings: { [key: string]: string|string[] }): void;
/** Get the correct pluralized (but untranslated) string for the value of n. */
getStringForm(string: string, n: number): string;
///////////////
/// Methods ///
///////////////
/** Translate a string with the given scope. Uses Angular.JS interpolation, so something like this will do what you expect:
* var hello = gettextCatalog.getString("Hello {{name}}!", { name: "Ruben" });
* // var hello will be "Hallo Ruben!" in Dutch.
* The scope parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
*/
getString(string: string, scope?: any, context?: string): string;
/** Sets the current language and makes sure that all translations get updated correctly. */
setCurrentLanguage(lang: string): void;
/** Translate a plural string with the given context. */
getPlural(n: number, string: string, stringPlural: string, context?: any): string;
/** Returns the current language. */
getCurrentLanguage(): string;
/** Load a set of translation strings from a given URL.This should be a JSON catalog generated with grunt-angular-gettext. More details https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ */
loadRemote(url: string): ng.IHttpPromise<any>;
}
/** Processes an object of string definitions. More details https://angular-gettext.rocketeer.be/dev-guide/manual-setstrings/
* @param language A language code.
* @param strings A dictionary of strings. The format of this dictionary is:
* - Keys: Singular English strings (as defined in the source files)
* - Values: Either a single string for signular-only strings or an array of plural forms.
*/
setStrings(language: string, strings: { [key: string]: string|string[] }): void;
/** If you have text that should be translated in your JavaScript code, wrap it with a call to a function named gettext. This module provides an injectable function to do so */
interface gettextFunction {
(dummyString: string): string;
/** Get the correct pluralized (but untranslated) string for the value of n. */
getStringForm(string: string, n: number): string;
/** Translate a string with the given scope. Uses Angular.JS interpolation, so something like this will do what you expect:
* var hello = gettextCatalog.getString("Hello {{name}}!", { name: "Ruben" });
* // var hello will be "Hallo Ruben!" in Dutch.
* The scope parameter is optional: pass null (or don't pass anything) if you're not using it: this skips interpolation and is a lot faster.
*/
getString(string: string, scope?: any, context?: string): string;
/** Translate a plural string with the given context. */
getPlural(n: number, string: string, stringPlural: string, context?: any): string;
/** Load a set of translation strings from a given URL.This should be a JSON catalog generated with grunt-angular-gettext. More details https://angular-gettext.rocketeer.be/dev-guide/lazy-loading/ */
loadRemote(url: string): ng.IHttpPromise<any>;
}
/** If you have text that should be translated in your JavaScript code, wrap it with a call to a function named gettext. This module provides an injectable function to do so */
interface gettextFunction {
(dummyString: string): string;
}
}
}
@@ -1,62 +0,0 @@
// Type definitions for angular-google-analytics v1.1.0
// Project: https://github.com/revolunet/angular-google-analytics
// Definitions by: Matt Wheatley <https://github.com/terrawheat>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace angular.google.analytics {
interface AnalyticsService {
/**
* @summary If logging is enabled then all outbound calls are accessible via an in-memory array.
* This is useful for troubleshooting and seeing the order of outbound calls with parameters.
*/
log: Array<Object>;
/**
* @summary If in offline mode then all calls are queued to an in-memory array for future processing.
* All calls queued to the offlineQueue are not outbound calls yet and hence do not show up in the log.
*/
offlineQueue: Array<Object>;
/**
* @summary Returns the current URL that would be sent if a `trackPage` call was made.
* @return {string} The URL
*/
getUrl: () => string;
/**
* @summary Manually create classic analytics (ga.js) script tag
*/
createScriptTag: () => void;
/**
* @summary Manually create universal analytics (analytics.js) script tag
*/
createAnalyticsScriptTag: () => void;
/**
* @summary Allows for advanced configuration and definitions in univeral analytics only. This is a no-op when using classic analytics.
*/
set: (key: string, value: any, accountName?: string) => void;
/**
* @summary Creates a new page view event
* @param {string} pageURL URL of page view
* @param {string} title Page Title
* @param {Object} dimensions Additional dimensions and metrics
*/
trackPage: (pageURL: string, title?: string, dimensions?: { [expr: string]: any }) => void;
/**
* @summary Create a new event
*/
trackEvent: (category: string, action: string, label: string, value?: any, nonInteractionFlag?: boolean, dimensions?: { [expr: string]: any }) => void;
trackException: (descrption: string, isFatal: boolean) => void;
/**
* @summary While in offline mode, no calls to the ga function or pushes to the gaq array are made.
* This will queue all calls for later sending once offline mode is reset to false.
*/
offline: (offlineMode: boolean) => void;
}
}
+199 -138
View File
@@ -4,171 +4,232 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="angular" />
/// <reference path="angular-google-analytics-service.d.ts" />
import * as angular from 'angular';
declare namespace angular.google.analytics {
declare module 'angular' {
export namespace google.analytics {
/**
* @summary Interface for {@link AnalyticsService}.
* @interface
*/
interface AnalyticsService {
/**
* @summary If logging is enabled then all outbound calls are accessible via an in-memory array.
* This is useful for troubleshooting and seeing the order of outbound calls with parameters.
*/
log: Array<Object>;
/**
* @summary If in offline mode then all calls are queued to an in-memory array for future processing.
* All calls queued to the offlineQueue are not outbound calls yet and hence do not show up in the log.
*/
offlineQueue: Array<Object>;
/**
* @summary Returns the current URL that would be sent if a `trackPage` call was made.
* @return {string} The URL
*/
getUrl: () => string;
/**
* @summary Manually create classic analytics (ga.js) script tag
*/
createScriptTag: () => void;
/**
* @summary Manually create universal analytics (analytics.js) script tag
*/
createAnalyticsScriptTag: () => void;
/**
* @summary Allows for advanced configuration and definitions in univeral analytics only. This is a no-op when using classic analytics.
*/
set: (key: string, value: any, accountName?: string) => void;
/**
* @summary Creates a new page view event
* @param {string} pageURL URL of page view
* @param {string} title Page Title
* @param {Object} dimensions Additional dimensions and metrics
*/
trackPage: (pageURL: string, title?: string, dimensions?: { [expr: string]: any }) => void;
/**
* @summary Create a new event
*/
trackEvent: (category: string, action: string, label: string, value?: any, nonInteractionFlag?: boolean, dimensions?: { [expr: string]: any }) => void;
trackException: (descrption: string, isFatal: boolean) => void;
/**
* @summary While in offline mode, no calls to the ga function or pushes to the gaq array are made.
* This will queue all calls for later sending once offline mode is reset to false.
*/
offline: (offlineMode: boolean) => void;
}
/**
* @summary Interface for {@link AnalysticsProvider}.
* @interface
*/
interface AnalyticsProvider {
/**
* @summary Use Delay Script Tag Insertion.
* @param {boolean} val If true, the delay script tag is inserted.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
delayScriptTag(val: boolean): AnalyticsProvider;
/**
* @summary Use Delay Script Tag Insertion.
* @param {boolean} val If true, the delay script tag is inserted.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
delayScriptTag(val: boolean): AnalyticsProvider;
/**
* @summary Activates the test mode.
*/
enterTestMode(): void;
/**
* @summary Activates the test mode.
*/
enterTestMode(): void;
/**
* @summary Gets the global cookie configuration.
* @return {Object} The global cookie configuration.
*/
getCookieConfig(): Object;
/**
* @summary Gets the global cookie configuration.
* @return {Object} The global cookie configuration.
*/
getCookieConfig(): Object;
/**
* @summary Ignore first page view.
* @param {boolean} val If true, the first page view is ignored.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
ignoreFirstPageLoad(val: boolean): AnalyticsProvider;
/**
* @summary Ignore first page view.
* @param {boolean} val If true, the first page view is ignored.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
ignoreFirstPageLoad(val: boolean): AnalyticsProvider;
/**
* @summary Enable Service Logging.
* @param {boolean} val If true, log all outbound calls to an in-memory array accessible.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
logAllCalls(val: boolean): AnalyticsProvider;
/**
* @summary Enable Service Logging.
* @param {boolean} val If true, log all outbound calls to an in-memory array accessible.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
logAllCalls(val: boolean): AnalyticsProvider;
/**
* @summary Set Google Analytics Accounts.
* @param {Object} tracker The account identifier(s).
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setAccount(tracker: string|Object|Array<Object>): AnalyticsProvider;
/**
* @summary Set Google Analytics Accounts.
* @param {Object} tracker The account identifier(s).
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setAccount(tracker: string | Object | Array<Object>): AnalyticsProvider;
/**
* @summary Set Cookie Configuration.
* @param {Object} config The custom cookie parameters.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
* @deprecated
*/
setCookieConfig(config: Object): AnalyticsProvider;
/**
* @summary Set Cookie Configuration.
* @param {Object} config The custom cookie parameters.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
* @deprecated
*/
setCookieConfig(config: Object): AnalyticsProvider;
/**
* @summary Set cross-linked domains.
* @param {Array<string>} domains The domains.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setCrossLinkDomains(domains: Array<string>): AnalyticsProvider;
/**
* @summary Set cross-linked domains.
* @param {Array<string>} domains The domains.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setCrossLinkDomains(domains: Array<string>): AnalyticsProvider;
/**
* @summary Set currency.
* @param {string} currencyCode The currency code.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setCurrency(currencyCode: string): AnalyticsProvider;
/**
* @summary Set currency.
* @param {string} currencyCode The currency code.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setCurrency(currencyCode: string): AnalyticsProvider;
/**
* @summary Set Domain Name.
* @param {string} domain The domain name.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setDomainName(domain: string): AnalyticsProvider;
/**
* @summary Set Domain Name.
* @param {string} domain The domain name.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setDomainName(domain: string): AnalyticsProvider;
/**
* @summary Enable Experiment (universal analytics only).
* @param {string} id The experiment identifier.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setExperimentId(id: string): AnalyticsProvider;
/**
* @summary Enable Experiment (universal analytics only).
* @param {string} id The experiment identifier.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setExperimentId(id: string): AnalyticsProvider;
/**
* @summary Support Hybrid Mobile Applications.
* @param {boolean} val If true, each account object will disable protocol checking and all injected scripts will use the HTTPS protocol.
*/
setHybridMobileSupport(val: boolean): AnalyticsProvider;
/**
* @summary Support Hybrid Mobile Applications.
* @param {boolean} val If true, each account object will disable protocol checking and all injected scripts will use the HTTPS protocol.
*/
setHybridMobileSupport(val: boolean): AnalyticsProvider;
/**
* @summary Set the default page event name.
* @param {string} name The default page event name.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setPageEvent(name: string): AnalyticsProvider;
/**
* @summary Set the default page event name.
* @param {string} name The default page event name.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
setPageEvent(name: string): AnalyticsProvider;
/**
* @summary Sets the regex to scrub location before sending to analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
* @param {RegExp} regex The regex.
*/
setRemoveRegExp(regex: RegExp): AnalyticsProvider;
/**
* @summary Sets the regex to scrub location before sending to analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
* @param {RegExp} regex The regex.
*/
setRemoveRegExp(regex: RegExp): AnalyticsProvider;
/**
* @summary Starts the offline mode.
* @param {boolean} val If true, the offline mode is started.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
startOffline(val: boolean): AnalyticsProvider;
/**
* @summary Starts the offline mode.
* @param {boolean} val If true, the offline mode is started.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
startOffline(val: boolean): AnalyticsProvider;
/**
* @summary Track all routes.
* @param {boolean} val If true, all routes are tracked.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackPages(doTrack: boolean): AnalyticsProvider;
/**
* @summary Track all routes.
* @param {boolean} val If true, all routes are tracked.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackPages(doTrack: boolean): AnalyticsProvider;
/**
* @summary Sets the URL prefix.
* @param {string} prefix The URL prefix.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackPrefix(prefix: string): AnalyticsProvider;
/**
* @summary Sets the URL prefix.
* @param {string} prefix The URL prefix.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackPrefix(prefix: string): AnalyticsProvider;
/**
* @summary Track all URL query parameters.
* @param {boolean} val If true, all URL query parameters are tracked.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackUrlParams(val: boolean): AnalyticsProvider;
/**
* @summary Track all URL query parameters.
* @param {boolean} val If true, all URL query parameters are tracked.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
trackUrlParams(val: boolean): AnalyticsProvider;
/**
* @summary Use Classic Analytics.
* @param {boolean} val If true, use classic analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useAnalytics(val: boolean): AnalyticsProvider;
/**
* @summary Use Classic Analytics.
* @param {boolean} val If true, use classic analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useAnalytics(val: boolean): AnalyticsProvider;
/**
* @summary Use Cross Domain Linking.
* @param {boolean} val If true, the cross-linked domains are registered with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useCrossDomainLinker(val: boolean): AnalyticsProvider;
/**
* @summary Use Cross Domain Linking.
* @param {boolean} val If true, the cross-linked domains are registered with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useCrossDomainLinker(val: boolean): AnalyticsProvider;
/**
* @summary Use Display Features.
* @param {boolean} val If true, the display features module is loaded with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useDisplayFeatures(val: boolean): AnalyticsProvider;
/**
* @summary Use Display Features.
* @param {boolean} val If true, the display features module is loaded with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useDisplayFeatures(val: boolean): AnalyticsProvider;
/**
* @summary Enable enhanced e-commerce module.
* @param {boolean} val If true, the enhanced e-commerce module is enabled.
* @param {boolean} enhanced If true, the "ec.js" file is used, otherwises, the "ecommerce.js" is used.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useECommerce(val: boolean, enhanced: boolean): AnalyticsProvider;
/**
* @summary Enable enhanced e-commerce module.
* @param {boolean} val If true, the enhanced e-commerce module is enabled.
* @param {boolean} enhanced If true, the "ec.js" file is used, otherwises, the "ecommerce.js" is used.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useECommerce(val: boolean, enhanced: boolean): AnalyticsProvider;
/**
* @summary Use Enhanced Link Attribution.
* @param {boolean} val If true, the enhanced link attribution module is loaded with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useEnhancedLinkAttribution(val: boolean): AnalyticsProvider;
/**
* @summary Use Enhanced Link Attribution.
* @param {boolean} val If true, the enhanced link attribution module is loaded with Google Analytics.
* @return {angular.google.analytics.IAnalyticsProvider} The object instance.
*/
useEnhancedLinkAttribution(val: boolean): AnalyticsProvider;
}
}
}
+12
View File
@@ -158,6 +158,7 @@ declare module 'angular' {
hideDelay(delay: number): T;
position(position: string): T;
parent(parent?: string | Element | JQuery): T; // default: root node
toastClass(toastClass: string): T;
}
interface ISimpleToastPreset extends IToastPreset<ISimpleToastPreset> {
@@ -335,6 +336,7 @@ declare module 'angular' {
onRemoving?: Function;
onDomRemoved?: Function;
origin?: string | JQuery | Element;
onCloseSuccess?: ((panel: IPanelRef, closeReason: string) => any);
}
interface IPanelRef {
@@ -407,6 +409,16 @@ declare module 'angular' {
interceptorTypes: {
CLOSE: string,
};
closeReasons: {
CLICK_OUTSIDE: string,
ESCAPE: string,
};
absPosition: {
TOP: string,
RIGHT: string,
BOTTOM: string,
LEFT: string,
};
}
}
}
+1 -1
View File
@@ -107,7 +107,7 @@ declare module 'angular' {
interface IComponentControllerService {
// TBinding is an interface exposed by a component as per John Papa's style guide
// https://github.com/johnpapa/angular-styleguide/blob/master/a1/README.md#accessible-members-up-top
<T, TBinding>(componentName: string, locals: { $scope: IScope, [key: string]: any }, bindings?: TBinding, ident?: string): T;
<T, TBinding>(componentName: string, locals: { $scope?: IScope, [key: string]: any }, bindings?: TBinding, ident?: string): T;
}
+1 -1
View File
@@ -15,6 +15,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
@@ -66,7 +66,7 @@ angular
PermissionStore.removePermissionDefinition('user');
let permissions: Array<permissionNamespace.Permission> = PermissionStore.getStore();
let permissions = PermissionStore.getStore();
});
@@ -90,5 +90,5 @@ angular
RoleStore.removeRoleDefinition('user');
let roles: Array<permissionNamespace.Role> = RoleStore.getStore();
let roles = RoleStore.getStore();
});
+38 -19
View File
@@ -30,8 +30,8 @@ declare module 'angular' {
* @param validationFunction {Function} Function used to validate if permission is valid
*/
definePermission(
name: string,
validationFunction: (permission?: string, transitionProperties?: TransitionProperties) => boolean | angular.IPromise<any>
permissionName: string,
validationFunction: PermissionValidationFunction
): void;
/**
@@ -43,10 +43,14 @@ declare module 'angular' {
* @param validationFunction {Function} Function used to validate if permission is valid
*/
defineManyPermissions(
permissions: string[],
validationFunction: (permission?: string, transitionProperties?: TransitionProperties) => boolean | angular.IPromise<any>
permissionNames: string[],
validationFunction: PermissionValidationFunction
): void;
/**
* Removes all permissions
* @method
*/
clearStore(): void;
/**
@@ -55,7 +59,7 @@ declare module 'angular' {
*
* @param permissionName {String} Name of defined permission
*/
removePermissionDefinition(permission: string): void;
removePermissionDefinition(permissionName: string): void;
/**
* Checks if permission exists
@@ -66,13 +70,21 @@ declare module 'angular' {
*/
hasPermissionDefinition(permissionName: string): boolean;
/**
* Returns permission by it's name
* @method
*
* @returns {permission.Permission} Permissions definition object
*/
getPermissionDefinition(permissionName: string): Permission;
/**
* Returns all permissions
* @method
*
* @returns {Object} Permissions collection
*/
getStore(): Permission[];
getStore(): { [permissionName: string]: Permission };
}
export interface RoleStore {
@@ -85,8 +97,8 @@ declare module 'angular' {
* @param [validationFunction] {Function} Function used to validate if permissions in role are valid
*/
defineRole(
role: string,
permissions: Array<string>,
roleName: string,
permissions: string[],
validationFunction: RoleValidationFunction
): void;
@@ -97,7 +109,10 @@ declare module 'angular' {
* @param roleName {String} Name of defined role
* @param permissions {Array} Set of permission names
*/
defineRole(role: string, permissions: Array<string>): void;
defineRole(
roleName: string,
permissions: string[]
): void;
/**
* Checks if role is defined in store
@@ -106,7 +121,7 @@ declare module 'angular' {
* @param roleName {String} Name of role
* @returns {Boolean}
*/
hasRoleDefinition(role: string): boolean;
hasRoleDefinition(roleName: string): boolean;
/**
* Returns role definition object by it's name
@@ -136,27 +151,31 @@ declare module 'angular' {
*
* @returns {Object} Defined roles collection
*/
getStore(): Role[];
getStore(): { [roleName: string]: Role };
}
export interface Role {
roleName: string;
permissionNames: string[];
validationFunction?: RoleValidationFunction;
validateRole: () => angular.IPromise<any>;
}
export interface Permission {
permissionName: string;
validationFunction?: PermissionValidationFunction;
validatePermission: () => angular.IPromise<any>;
}
interface RoleValidationFunction {
(permission?: string, transitionProperties?: TransitionProperties): boolean | angular.IPromise<any>;
}
export type RoleValidationFunction = (
roleName?: string,
transitionProperties?: TransitionProperties
) => boolean | angular.IPromise<any>;
interface PermissionValidationFunction {
(permission?: string, transitionProperties?: TransitionProperties): boolean | angular.IPromise<any>;
}
export type PermissionValidationFunction = (
permissionName?: string,
transitionProperties?: TransitionProperties
) => boolean | angular.IPromise<any>;
export interface IPermissionState extends angular.ui.IState {
data?: any | DataWithPermissions;
@@ -164,8 +183,8 @@ declare module 'angular' {
export interface DataWithPermissions {
permissions?: {
only?: (() => void) | Array<string> | angular.IPromise<any>;
except?: (() => void) | Array<string> | angular.IPromise<any>;
only?: (() => void) | string | string[] | angular.IPromise<any>;
except?: (() => void) | string | string[] | angular.IPromise<any>;
redirectTo: string | (() => string) | (() => PermissionRedirectConfigation) | { [index: string]: PermissionRedirectConfigation }
};
}
@@ -0,0 +1,20 @@
angular.module('promise-tracker-tests', []).run(['$q', 'promiseTracker',
($q: angular.IQService, promiseTracker: angular.promisetracker.PromiseTrackerService) => {
const trackerWithoutOptions = promiseTracker();
const options = {
activationDelay: 10,
minDuration: 500
} as angular.promisetracker.PromiseTrackerOptions;
const trackerWithOptions = promiseTracker(options);
const isActive: boolean = trackerWithOptions.active();
const tracking: boolean = trackerWithOptions.tracking();
const trackingCount: number = trackerWithOptions.trackingCount();
trackerWithOptions.cancel();
const createdPromise: angular.IDeferred<void> = trackerWithOptions.createPromise();
const promiseToAdd = $q.defer().promise;
const addedPromise: angular.IDeferred<void> = trackerWithOptions.addPromise(promiseToAdd);
}]);
+30
View File
@@ -0,0 +1,30 @@
// Type definitions for angular-promise-tracker 2.2.2
// Project: https://github.com/ajoslin/angular-promise-tracker
// Definitions by: Rufus Linke <https://github.com/rufusl/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="angular" />
import * as angular from 'angular';
declare module 'angular' {
export namespace promisetracker {
interface PromiseTrackerOptions {
activationDelay: number;
minDuration: number;
}
interface PromiseTracker {
active(): boolean;
tracking(): boolean;
trackingCount(): number;
addPromise<T>(promise: angular.IPromise<T>): angular.IDeferred<void>;
createPromise(): angular.IDeferred<void>;
cancel(): void;
}
interface PromiseTrackerService {
(options?: PromiseTrackerOptions): PromiseTracker;
}
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"angular-promise-tracker-tests.ts"
]
}
+1 -1
View File
@@ -14,6 +14,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
+1 -1
View File
@@ -14,6 +14,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
+1 -1
View File
@@ -14,6 +14,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
+1 -1
View File
@@ -14,6 +14,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
@@ -0,0 +1,40 @@
import * as angular from "angular";
import { ui } from "angular";
angular.module("test", [
"ui.router",
"ui.router.default"
])
.config(function($stateProvider: ui.IStateProvider) {
$stateProvider
.state('concrete', {
// no abstract or default
})
.state('string', {
abstract: true,
default: 'concrete'
})
.state('func_str', {
abstract: true,
default: function($rootScope): string { return $rootScope.test; }
})
.state('func_promise', {
abstract: true,
default: function($q: ng.IQService): ng.IPromise<string> {
return $q.when("concrete");
}
})
.state('injection_str', {
abstract: true,
default: ["$rootScope", function($rootScope) {
return $rootScope.test;
}]
})
.state('injection_promise', {
abstract: true,
default: ["$q", function($q: ng.IQService) {
return $q.when("concrete");
}]
})
;
});
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for angular-ui-router-default 0.5+
// Project: https://github.com/nonplus/angular-ui-router-default
// Definitions by: Stepan Riha <https://github.com/nonplus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as aur from "angular-ui-router";
declare module "angular" {
namespace ui {
export type StateDefaultSpecifier = string
| ((...args: any[]) => string)
| ((...args: any[]) => ng.IPromise<string>)
| (string | ((...args: any[]) => string))[]
| (string | ((...args: any[]) => ng.IPromise<string>))[];
interface IState {
default?: StateDefaultSpecifier
}
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"angular-ui-router-default-tests.ts"
]
}
@@ -0,0 +1,28 @@
angular.module("test", [
"ui.bootstrap",
"ui.router",
"ui.router.default"
])
.config(function($stateProvider: angular.ui.IStateProvider) {
$stateProvider
.state('contacts', {
// no modal
resolve: {
a: function() {
return "a";
},
b: function() {
return ["a", "b"];
}
}
})
.state('contacts.contact', {
// boolean modal
modal: true
})
.state('contacts.contact.edit', {
// string[] modal
modal: ["a", "b"]
})
;
});
+14
View File
@@ -0,0 +1,14 @@
// Type definitions for angular-ui-uib-modal 0.11+ (ui.router module)
// Project: https://github.com/nonplus/angular-ui-router-uib-modal
// Definitions by: Stepan Riha <https://github.com/nonplus>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as auir from "angular-ui-router";
declare module "angular" {
namespace ui {
interface IState {
modal?: boolean | string[];
}
}
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"angular-ui-router-uib-modal-tests.ts"
]
}
+1 -1
View File
@@ -14,6 +14,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
+1 -1
View File
@@ -14,6 +14,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
+41 -2
View File
@@ -191,8 +191,25 @@ mod.controller({
MyCtrl2: function() {},
MyCtrl3: ['$fooService', function($fooService: any) { }]
});
mod.directive('name', <any>function ($scope: ng.IScope) { })
mod.directive('name', ['$scope', <any>function ($scope: ng.IScope) { }])
mod.directive('myDirectiveA', ($rootScope: ng.IRootScopeService) => {
return (scope, el, attrs) => {
let foo = 'none';
el.click(e => {
foo = e.type;
$rootScope.$apply();
});
scope.$watch(() => foo, () => el.text(foo));
};
});
mod.directive('myDirectiveB', ['$rootScope', function ($rootScope: ng.IRootScopeService) {
return {
link(scope, el, attrs) {
el.click(e => {
el.hide();
});
}
};
}]);
mod.directive({
myFooDir: () => ({
template: 'my-foo-dir.tpl.html'
@@ -278,8 +295,14 @@ namespace TestQ {
b: string;
c: boolean;
}
interface TValue {
e: number;
f: boolean;
}
var tResult: TResult;
var promiseTResult: angular.IPromise<TResult>;
var tValue: TValue;
var promiseTValue: angular.IPromise<TValue>;
var $q: angular.IQService;
var promiseAny: angular.IPromise<any>;
@@ -348,6 +371,22 @@ namespace TestQ {
let result: angular.IPromise<TResult>;
result = $q.when<TResult>(tResult);
result = $q.when<TResult>(promiseTResult);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult, (any) => any);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => tResult, (any) => any, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => tResult);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => tResult, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => tResult, (any) => any, (any) => any);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult, (any) => any);
result = $q.when<TResult, TValue>(tValue, (result: TValue) => promiseTResult, (any) => any, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => promiseTResult);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => any);
result = $q.when<TResult, TValue>(promiseTValue, (result: TValue) => promiseTResult, (any) => any, (any) => any);
}
}
+13 -10
View File
@@ -1,6 +1,6 @@
// Type definitions for Angular JS 1.5
// Project: http://angularjs.org
// Definitions by: Diego Vilar <http://github.com/diegovilar>
// Definitions by: Diego Vilar <http://github.com/diegovilar>, Georgii Dolzhykov <http://github.com/thorn0>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery" />
@@ -984,9 +984,7 @@ declare namespace angular {
* See http://docs.angularjs.org/api/ng/service/$q
*/
interface IQService {
new <T>(resolver: (resolve: IQResolveReject<T>) => any): IPromise<T>;
new <T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
<T>(resolver: (resolve: IQResolveReject<T>) => any): IPromise<T>;
<T>(resolver: (resolve: IQResolveReject<T>, reject: IQResolveReject<any>) => any): IPromise<T>;
/**
@@ -1043,6 +1041,7 @@ declare namespace angular {
* @param value Value or a promise
*/
when<T>(value: IPromise<T>|T): IPromise<T>;
when<TResult, T>(value: IPromise<T>|T, successCallback: (promiseValue: T) => IPromise<TResult>|TResult, errorCallback?: (reason: any) => any, notifyCallback?: (state: any) => any): IPromise<TResult>;
/**
* Wraps an object that might be a value or a (3rd party) then-able promise into a $q promise. This is useful when you are dealing with an object that might or might not be a promise, or if the promise comes from a source that can't be trusted.
*/
@@ -1228,6 +1227,11 @@ declare namespace angular {
(scope: IScope, cloneAttachFn: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery;
// If one argument is provided, then it's assumed to be the cloneAttachFn.
(cloneAttachFn?: ICloneAttachFunction, futureParentElement?: JQuery, slotName?: string): JQuery;
/**
* Returns true if the specified slot contains content (i.e. one or more DOM nodes)
*/
isSlotFilled(slotName: string): boolean;
}
///////////////////////////////////////////////////////////////////////////
@@ -1379,12 +1383,12 @@ declare namespace angular {
*/
url: string;
/**
* Event listeners to be bound to the XMLHttpRequest object.
* Event listeners to be bound to the XMLHttpRequest object.
* To bind events to the XMLHttpRequest upload object, use uploadEventHandlers. The handler will be called in the context of a $apply block.
*/
eventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
/**
* Event listeners to be bound to the XMLHttpRequest upload object.
* Event listeners to be bound to the XMLHttpRequest upload object.
* To bind events to the XMLHttpRequest object, use eventHandlers. The handler will be called in the context of a $apply block.
*/
uploadEventHandlers?: { [type: string]: EventListenerOrEventListenerObject };
@@ -1708,7 +1712,7 @@ declare namespace angular {
(new (...args: any[]) => IController) |
// Instead of classes, plain functions are often used as controller constructors, especially in examples.
((...args: any[]) => (void | IController));
/**
* Directive controllers have a well-defined lifecycle. Each controller can implement "lifecycle hooks". These are methods that
* will be called by Angular at certain points in the life cycle of the directive.
@@ -1771,7 +1775,7 @@ declare namespace angular {
///////////////////////////////////////////////////////////////////////////
interface IDirectiveFactory {
(...args: any[]): IDirective;
(...args: any[]): IDirective | IDirectiveLinkFn;
}
interface IDirectiveLinkFn {
@@ -1779,8 +1783,8 @@ declare namespace angular {
scope: IScope,
instanceElement: JQuery,
instanceAttributes: IAttributes,
controller: {},
transclude: ITranscludeFunction
controller?: IController | IController[] | {[key: string]: IController},
transclude?: ITranscludeFunction
): void;
}
@@ -1808,7 +1812,6 @@ declare namespace angular {
controller?: string | Injectable<IControllerConstructor>;
controllerAs?: string;
/**
* @deprecated
* Deprecation warning: although bindings for non-ES6 class controllers are currently bound to this before
* the controller constructor is called, this use is now deprecated. Please place initialization code that
* relies upon bindings inside a $onInit method on the controller, instead.
+28 -6
View File
@@ -1,10 +1,32 @@
var shouldBeString: string;
///////////////////////////////////////////////////////////////////////////////
// Variables
///////////////////////////////////////////////////////////////////////////////
let shouldBeString: string;
let testInputText: string = 'TEST';
declare var $sanitizeService: ng.sanitize.ISanitizeService;
shouldBeString = $sanitizeService(shouldBeString);
///////////////////////////////////////////////////////////////////////////////
// Test sanitize service
///////////////////////////////////////////////////////////////////////////////
declare let $sanitizeService: ng.sanitize.ISanitizeService;
shouldBeString = $sanitizeService(testInputText);
declare var $linky: ng.sanitize.filter.ILinky;
shouldBeString = $linky(shouldBeString);
shouldBeString = $linky(shouldBeString, shouldBeString);
///////////////////////////////////////////////////////////////////////////////
// Test `linky` filter
///////////////////////////////////////////////////////////////////////////////
declare let $linky: ng.sanitize.filter.ILinky;
// Should be string for simple text and target parameters
shouldBeString = $linky(testInputText, testInputText);
// Should be string for simple text, target and attributes parameters
let attributesAsFunction = () => {
};
shouldBeString = $linky(shouldBeString, testInputText, {
"attributeKey1": "attributeValue1",
"attributeKey2": "attributeValue2"
});
shouldBeString = $linky(shouldBeString, testInputText, (url: string) => {
return {"attributeKey1": "attributeValue1"}
});
+1 -1
View File
@@ -14,6 +14,6 @@
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": false
"forceConsistentCasingInFileNames": true
}
}
+5
View File
@@ -0,0 +1,5 @@
import * as anybar from 'anybar'
anybar('red', { port: 123 })
anybar('green')
+10
View File
@@ -0,0 +1,10 @@
// Type definitions for anybar 2.0.1
// Project: https://github.com/sindresorhus/anybar
// Definitions by: Chris Khoo <https://github.com/khoomeister>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace anybar { }
declare function anybar(color: string, options?: { port: number }): void
export = anybar
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"anybar-tests.ts"
]
}
+9 -1
View File
@@ -11,4 +11,12 @@ var readStream = FS.createReadStream('./archiver.d.ts');
archiver.pipe(writeStream);
archiver.append(readStream, {name: 'archiver.d.ts'});
archiver.finalize();
archiver.finalize();
archiver.directory('./path', './someOtherPath');
archiver.directory('./path', { name: "testName"} );
archiver.directory('./', "", {});
archiver.directory('./', {name: 'test'}, {});
archiver.bulk({ mappaing: {} });
+23 -15
View File
@@ -18,24 +18,32 @@
import * as FS from 'fs';
import * as STREAM from 'stream';
interface nameInterface {
name?: string;
}
interface Archiver extends STREAM.Transform {
pipe(writeStream: FS.WriteStream): void;
append(source: FS.ReadStream | Buffer | string, name: nameInterface): void;
finalize(): void;
}
interface Options {
}
declare function archiver(format: string, options?: Options): Archiver;
declare function archiver(format: string, options?: archiver.Options): archiver.Archiver;
declare namespace archiver {
function create(format: string, options?: Options): Archiver;
export function create(format: string, options?: Options): Archiver;
export interface nameInterface {
name?: string;
}
export interface Archiver extends STREAM.Transform {
pipe(writeStream: FS.WriteStream): void;
append(source: FS.ReadStream | Buffer | string, name: nameInterface): void;
directory(dirpath: string, destpath: nameInterface | string): void;
directory(dirpath: string, destpath: nameInterface | string, data: any | Function): void;
bulk(mappings: any): void;
finalize(): void;
}
export interface Options {
}
}
export = archiver;
+39
View File
@@ -0,0 +1,39 @@
import arrayForEach = require('array-foreach');
const array: Array<number> = [1, 2, 3, 4];
const result: Array<number> = [];
arrayForEach(array, (i: number) => {
result.push(i);
});
arrayForEach(array, (i: number, index: number) => {
result.push(i + index);
});
arrayForEach(array, (i: number, index: number, array: Array<number>) => {
result.push(array[i]);
});
const resultThis: Array<{i: number, that: string}> = [];
arrayForEach(array, (i: number) => {
resultThis.push({
i: i,
that: this.that
});
}, { that: 'jeff' });
arrayForEach(array, (i: number, index: number) => {
resultThis.push({
i: i + index,
that: this.that
});
}, { that: 'jeff' });
arrayForEach(array, (i: number, index: number, array: Array<number>) => {
resultThis.push({
i: array[i],
that: this.that
});
}, { that: 'jeff' });
+21
View File
@@ -0,0 +1,21 @@
// Type definitions for array-foreach
// Project: https://www.npmjs.com/package/array-foreach
// Definitions by: Steve Jenkins <https://github.com/skysteve>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Performs the specified action for each element in an array.
* @param arr Array of items to iterate over
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
declare function forEach<T>(arr: Array<T>, callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => void, thisArg?: any): void;
/**
* Performs the specified action for each element in an array.
* @param arr Nodelist of items to iterate over
* @param callbackfn A function that accepts up to three arguments. forEach calls the callbackfn function one time for each element in the array.
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
*/
declare function forEach<T extends Node>(arr: NodeListOf<T>, callbackfn: (value: T, index: number, array: ReadonlyArray<T>) => void, thisArg?: any): void;
export = forEach;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"array-foreach-tests.ts"
]
}
+52
View File
@@ -0,0 +1,52 @@
import { LocalLengthBlock, Null } from "asn1js";
import { OctetString } from "asn1js";
import { ObjectIdentifier } from "asn1js";
import { UTCTime } from "asn1js";
let t = new LocalLengthBlock();
{
// Null
let testNull = new Null();
let json = testNull.toJSON();
testNull.toBER();
testNull.fromBER(new Uint8Array(0).buffer, 0, 0);
}
{
// OctetString
let test = new OctetString();
let json = test.toJSON();
test.toBER();
test.fromBER(new Uint8Array(0).buffer, 0, 0);
test.isEqual(test);
OctetString.blockName() === "name";
}
{
// ObjectIdentifier
let test = new ObjectIdentifier();
let json = test.toJSON();
test.toBER();
test.fromBER(new Uint8Array(0).buffer, 0, 0);
OctetString.blockName() === "name";
}
{
// UTCTime
let test = new UTCTime();
test = new UTCTime({
value: ""
});
test = new UTCTime({
valueDate: new Date()
});
let json = test.toJSON();
test.toBER();
test.fromBER(new Uint8Array(0).buffer, 0, 0);
OctetString.blockName() === "name";
}
+675
View File
@@ -0,0 +1,675 @@
// Type definitions for asn1js
// Project: https://github.com/PeculiarVentures/ASN1.js
// Definitions by: Stepan Miroshin <https://github.com/microshine>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
import { getParametersValue, padNumber, isEqualBuffer, bufferToHexCodes, checkBufferParams, utilToBase, utilFromBase, utilEncodeTC, utilDecodeTC, utilConcatBuf, nearestPowerOf2 } from "pvutils";
export = Asn1js;
declare namespace Asn1js {
interface LocalBaseBlockParams {
blockLength?: number;
error?: string;
warnings?: string[];
valueBeforeDecode?: ArrayBuffer;
}
interface JsonLocalBaseBlock {
blockName: string;
blockLength: number;
error: string;
warnings: string[];
valueBeforeDecode: ArrayBuffer;
}
class LocalBaseBlock {
blockLength: number;
error: string;
warnings: string[];
valueBeforeDecode: ArrayBuffer;
constructor(params?: LocalBaseBlockParams);
/**
* Aux function, need to get a block name. Need to have it here for inhiritence
*
* @static
* @returns {string}
*
* @memberOf LocalBaseBlock
*/
static blockName(): string;
/**
* Convertion for the block to JSON object
*
* @returns {JsonLocalBaseBlock}
*
* @memberOf LocalBaseBlock
*/
toJSON(): JsonLocalBaseBlock;
}
interface LocalHexBlockParams extends LocalBaseBlockParams {
isHexOnly?: boolean;
valueHex?: ArrayBuffer;
}
interface ILocalHexBlock {
isHexOnly: boolean;
valueHex: ArrayBuffer;
/**
* Base function for converting block from BER encoded array of bytes
*
* @param {ArrayBuffer} inputBuffer ASN.1 BER encoded array
* @param {number} inputOffset Offset in ASN.1 BER encoded array where decoding should be started
* @param {number} inputLength Maximum length of array of bytes which can be using in this function
* @returns {number} Offset after least decoded byte
*
* @memberOf LocalHexBlockMixin
*/
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
/**
* Encoding of current ASN.1 block into ASN.1 encoded array (BER rules)
*
* @param {boolean} [sizeOnly=false] Flag that we need only a size of encoding, not a real array of bytes
* @returns {ArrayBuffer}
*
* @memberOf LocalHexBlockMixin
*/
toBER(sizeOnly?: boolean): ArrayBuffer;
/**
* Convertion for the block to JSON object
* @returns {*}
*/
toJSON(): any;
}
class LocalHexBlock implements ILocalHexBlock {
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params: any);
/**
* Aux function, need to get a block name. Need to have it here for inhiritence
*
* @static
* @returns {string}
*
* @memberOf LocalHexBlockMixin
*/
static blockName(): string;
/**
* Base function for converting block from BER encoded array of bytes
*
* @param {ArrayBuffer} inputBuffer ASN.1 BER encoded array
* @param {number} inputOffset Offset in ASN.1 BER encoded array where decoding should be started
* @param {number} inputLength Maximum length of array of bytes which can be using in this function
* @returns {number} Offset after least decoded byte
*
* @memberOf LocalHexBlockMixin
*/
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
/**
* Encoding of current ASN.1 block into ASN.1 encoded array (BER rules)
*
* @param {boolean} [sizeOnly=false] Flag that we need only a size of encoding, not a real array of bytes
* @returns {ArrayBuffer}
*
* @memberOf LocalHexBlockMixin
*/
toBER(sizeOnly?: boolean): ArrayBuffer;
/**
* Convertion for the block to JSON object
* @returns {*}
*/
toJSON(): any;
}
interface LocalIdentificationBlockParams {
idBlock?: LocalHexBlockParams & {
isConstructed?: boolean;
tagClass?: number;
tagNumber?: number;
};
}
class LocalIdentificationBlock extends LocalBaseBlock implements ILocalHexBlock {
isConstructed: boolean;
tagClass: number;
tagNumber: number;
constructor(params?: LocalIdentificationBlockParams);
// ILocalHexBlock implementation
isHexOnly: boolean;
valueHex: ArrayBuffer;
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
interface LocalLengthBlockParams {
lenBlock?: {
isIndefiniteForm?: boolean;
longFormUsed?: boolean;
length: number;
}
}
class LocalLengthBlock extends LocalBaseBlock {
isIndefiniteForm: boolean;
longFormUsed: boolean;
length: number;
constructor(params?: LocalLengthBlockParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): void;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
class LocalValueBlock extends LocalBaseBlock {
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): void;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
interface BaseBlockParams extends LocalBaseBlockParams {
name?: string;
optional?: boolean;
primitiveSchema?: Object;
}
class BaseBlock<T extends LocalValueBlock> extends LocalBaseBlock {
constructor(parameters?: BaseBlockParams, valueBlockType?: typeof LocalValueBlock);
idBlock: LocalIdentificationBlock;
lenBlock: LocalLengthBlock;
valueBlock: T;
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
interface LocalPrimitiveValueBlockParams extends LocalBaseBlockParams {
valueHex?: ArrayBuffer;
isHexOnly?: boolean;
}
class LocalPrimitiveValueBlock extends LocalValueBlock {
valueHex: ArrayBuffer;
isHexOnly: boolean;
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
class Primitive extends BaseBlock<LocalPrimitiveValueBlock> {
}
interface LocalConstructedValueBlockParams extends LocalBaseBlockParams {
value?: LocalValueBlock;
isIndefiniteForm?: boolean;
}
class LocalConstructedValueBlock extends LocalValueBlock {
value: LocalValueBlock[];
isIndefiniteForm: boolean;
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
class Constructed extends BaseBlock<LocalConstructedValueBlock> { }
interface LocalEndOfContentValueBlockParams extends LocalBaseBlockParams { }
class LocalEndOfContentValueBlock extends LocalValueBlock {
constructor(params?: LocalEndOfContentValueBlockParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
export class EndOfContent extends BaseBlock<LocalEndOfContentValueBlock> { }
interface LocalBooleanValueBlockParams extends LocalBaseBlockParams {
value?: boolean;
isHexOnly?: boolean;
valueHex?: ArrayBuffer;
}
class LocalBooleanValueBlock extends LocalValueBlock {
value: boolean;
isHexOnly: boolean;
valueHex: ArrayBuffer;
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
class Boolean extends BaseBlock<LocalBooleanValueBlock> { }
class Sequence extends Constructed { }
class Set extends Constructed { }
class Null extends BaseBlock<LocalValueBlock> { }
interface LocalOctetStringValueBlockParams extends LocalConstructedValueBlockParams, LocalHexBlockParams {
isConstructed?: boolean;
}
class LocalOctetStringValueBlock extends LocalConstructedValueBlock implements ILocalHexBlock {
isConstructed: boolean;
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params?: LocalOctetStringValueBlockParams);
}
export class OctetString extends BaseBlock<LocalOctetStringValueBlock> {
constructor(params?: LocalOctetStringValueBlockParams);
/**
* Checking that two OCTETSTRINGs are equal
*
* @param {OctetString} octetString
* @returns {boolean}
*
* @memberOf OctetString
*/
isEqual(octetString: OctetString): boolean;
}
interface LocalBitStringValueBlockParams extends LocalConstructedValueBlockParams, LocalHexBlockParams {
unusedBits?: number;
isConstructed?: boolean;
blockLength?: number;
}
class LocalBitStringValueBlock extends LocalConstructedValueBlock implements LocalHexBlock {
unusedBits: number;
isConstructed: boolean;
blockLength: number;
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params?: LocalBitStringValueBlockParams);
}
class BitString extends BaseBlock<LocalBitStringValueBlock> {
constructor(params?: LocalBitStringValueBlockParams);
/**
* Checking that two BITSTRINGs are equal
* @param {BitString} bitString
*/
isEqual(bitString: BitString): boolean;
}
interface LocalIntegerValueBlockParams extends LocalBaseBlockParams, LocalHexBlockParams {
}
class LocalIntegerValueBlock extends LocalValueBlock implements LocalHexBlock {
valueDec: number;
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params?: LocalIntegerValueBlockParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
/**
* Base function for converting block from DER encoded array of bytes
*
* @param {ArrayBuffer} inputBuffer ASN.1 DER encoded array
* @param {number} inputOffset Offset in ASN.1 DER encoded array where decoding should be started
* @param {number} inputLength Maximum length of array of bytes which can be using in this function
* @param {number} [expectedLength=0] Expected length of converted "valueHex" buffer
* @returns {number} Offset after least decoded byte
*/
fromDER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number, expectedLength?: number): number;
/**
* Encoding of current ASN.1 block into ASN.1 encoded array (DER rules)
*
* @param {boolean} [sizeOnly=false] Flag that we need only a size of encoding, not a real array of bytes
* @returns {ArrayBuffer}
*/
toDER(sizeOnly?: boolean): ArrayBuffer;
}
interface IntegerParams {
value?: number;
}
export class Integer extends BaseBlock<LocalIntegerValueBlock> {
constructor(params?: IntegerParams)
/**
* Compare two Integer object, or Integer and ArrayBuffer objects
*
* @param {(Integer | ArrayBuffer)} otherValue
* @returns {boolean}
*
* @memberOf Integer
*/
isEqual(otherValue: Integer | ArrayBuffer): boolean;
/**
* Convert current Integer value from BER into DER format
*
* @returns {Integer}
*/
convertToDER(): Integer;
/**
* Convert current Integer value from DER to BER format
* @returns {Integer}
*/
convertFromDER(): Integer;
}
class Enumerated extends Integer { }
interface LocalSidValueBlockParams extends LocalBaseBlockParams, LocalHexBlockParams {
valueDec?: number;
isFirstSid?: boolean;
}
class LocalSidValueBlock extends LocalBaseBlock implements LocalHexBlock {
valueDec: number;
isFirstSid: boolean;
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params?: LocalSidValueBlockParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
toString(): string;
}
interface LocalObjectIdentifierValueBlockParams extends LocalBaseBlockParams {
value?: string;
}
class LocalObjectIdentifierValueBlock extends LocalValueBlock {
constructor(params?: LocalObjectIdentifierValueBlockParams);
/**
* Create "LocalObjectIdentifierValueBlock" class from string
*
* @param {string} string Input string to convert from
* @returns {boolean}
*/
fromString(data: string): boolean;
/**
* Converts "LocalObjectIdentifierValueBlock" class to string
*
* @returns {string}
*
* @memberOf LocalObjectIdentifierValueBlock
*/
toString(): string;
}
export class ObjectIdentifier extends BaseBlock<LocalObjectIdentifierValueBlock> {
constructor(params?: LocalObjectIdentifierValueBlockParams);
}
interface LocalUtf8StringValueBlockParams extends LocalBaseBlockParams, LocalHexBlock {
}
class LocalUtf8StringValueBlock extends LocalBaseBlock implements LocalHexBlock {
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params?: LocalSidValueBlockParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
toString(): string;
}
interface Utf8StringParams {
value?: string;
}
class Utf8String extends BaseBlock<LocalUtf8StringValueBlock> {
constructor(params?: Utf8StringParams);
/**
* Function converting ArrayBuffer into ASN.1 internal string
*
* @param {ArrayBuffer} inputBuffer ASN.1 BER encoded array
*
* @memberOf Utf8String
*/
fromBuffer(inputBuffer: ArrayBuffer): void;
/**
* Function converting JavaScript string into ASN.1 internal class
*
* @param {string} inputString ASN.1 BER encoded array
*
* @memberOf Utf8String
*/
fromString(inputString: string): void;
}
interface LocalBmpStringValueBlockParams extends LocalHexBlockParams, LocalBaseBlockParams {
}
class LocalBmpStringValueBlock extends LocalBaseBlock implements LocalHexBlock {
value: string;
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params?: LocalBmpStringValueBlockParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
interface BmpStringParams {
value?: string;
}
export class BmpString extends BaseBlock<LocalBmpStringValueBlock> {
constructor(params?: BmpStringParams);
/**
* Function converting ArrayBuffer into ASN.1 internal string
*
* @param {ArrayBuffer} inputBuffer ASN.1 BER encoded array
*
* @memberOf BmpString
*/
fromBuffer(inputBuffer: ArrayBuffer): void;
/**
* Function converting JavaScript string into ASN.1 internal class
*
* @param {string} inputString ASN.1 BER encoded array
*
* @memberOf BmpString
*/
fromString(inputString: string): void;
}
interface LocalUniversalStringValueParams extends LocalHexBlockParams, LocalBaseBlockParams {
}
class LocalUniversalStringValueBlock extends LocalBaseBlock implements LocalHexBlock {
value: string;
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params?: LocalUniversalStringValueParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
interface UniversalStringParams {
value?: string;
}
export class UniversalString extends BaseBlock<LocalUniversalStringValueBlock> {
constructor(params?: UniversalStringParams);
/**
* Function converting ArrayBuffer into ASN.1 internal string
*
* @param {ArrayBuffer} inputBuffer ASN.1 BER encoded array
*
* @memberOf UniversalString
*/
fromBuffer(inputBuffer: ArrayBuffer): void;
/**
* Function converting JavaScript string into ASN.1 internal class
*
* @param {string} inputString ASN.1 BER encoded array
*
* @memberOf UniversalString
*/
fromString(inputString: string): void;
}
interface LocalSimpleLocalSimpleStringValueBlockParams extends LocalHexBlockParams, LocalBaseBlockParams {
}
class LocalSimpleLocalSimpleStringValueBlock extends LocalBaseBlock implements LocalHexBlock {
value: string;
isHexOnly: boolean;
valueHex: ArrayBuffer;
constructor(params?: LocalSimpleLocalSimpleStringValueBlockParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
interface LocalSimpleStringBlockParams {
value?: string;
}
export class LocalSimpleStringBlock extends BaseBlock<LocalSimpleLocalSimpleStringValueBlock> {
constructor(params?: LocalSimpleStringBlockParams);
/**
* Function converting ArrayBuffer into ASN.1 internal string
*
* @param {ArrayBuffer} inputBuffer ASN.1 BER encoded array
*
* @memberOf LocalSimpleStringBlock
*/
fromBuffer(inputBuffer: ArrayBuffer): void;
/**
* Function converting JavaScript string into ASN.1 internal class
*
* @param {string} inputString ASN.1 BER encoded array
*
* @memberOf LocalSimpleStringBlock
*/
fromString(inputString: string): void;
}
export class NumericString extends LocalSimpleStringBlock { }
export class PrintableString extends LocalSimpleStringBlock { }
export class TeletexString extends LocalSimpleStringBlock { }
export class VideotexString extends LocalSimpleStringBlock { }
export class IA5String extends LocalSimpleStringBlock { }
export class GraphicString extends LocalSimpleStringBlock { }
export class VisibleString extends LocalSimpleStringBlock { }
export class GeneralString extends LocalSimpleStringBlock { }
export class CharacterString extends LocalSimpleStringBlock { }
interface UTCTimeParams extends LocalSimpleLocalSimpleStringValueBlockParams {
value?: string;
valueDate?: Date;
}
export class UTCTime extends VisibleString {
year: number;
month: number;
day: number;
hour: number;
minute: number;
second: number;
constructor(params?: UTCTimeParams);
/**
* Function converting ASN.1 internal string into ArrayBuffer
*
* @returns {ArrayBuffer}
*
* @memberOf UTCTime
*/
toBuffer(): ArrayBuffer;
/**
* Function converting "Date" object into ASN.1 internal string
*
* @param {Date} inputDate JavaScript "Date" object
*
* @memberOf UTCTime
*/
fromDate(inputDate: Date): void;
/**
* Function converting ASN.1 internal string into "Date" object
*
* @returns {Date}
*
* @memberOf UTCTime
*/
toDate(): Date;
}
class GeneralizedTime extends UTCTime {
millisecond: number;
}
class DATE extends Utf8String { }
class TimeOfDay extends Utf8String { }
class DateTime extends Utf8String { }
class Duration extends Utf8String { }
class TIME extends Utf8String { }
interface ChoiceParams {
value?: LocalValueBlock[];
optional?: boolean;
}
class Choice {
value: LocalValueBlock[];
optional: boolean;
constructor(params?: ChoiceParams);
}
interface AnyParams {
name?: string;
optional?: boolean;
}
class Any {
name: string;
optional: boolean;
constructor(params?: AnyParams);
}
interface RepeatedParams {
name?: string;
optional?: boolean;
value?: Any;
local?: boolean;
}
class Repeated {
name: string;
optional: boolean;
value: Any;
local: boolean;
constructor(params?: RepeatedParams);
}
interface RawDataParams {
data?: ArrayBuffer;
}
class RawData {
data: ArrayBuffer;
constructor(params?: RawDataParams);
fromBER(inputBuffer: ArrayBuffer, inputOffset: number, inputLength: number): number;
toBER(sizeOnly?: boolean): ArrayBuffer;
}
/**
* Major function for decoding ASN.1 BER array into internal library structuries
*
* @param {ArrayBuffer} inputBuffer ASN.1 BER encoded array of bytes
* @returns {{ offset: number; result: LocalBaseBlock }}
*/
function fromBER(inputBuffer: ArrayBuffer): { offset: number; result: LocalBaseBlock };
/**
* Compare of two ASN.1 object trees
*
* @param {*} root Root of input ASN.1 object tree
* @param {*} inputData Input ASN.1 object tree
* @param {*} inputSchema Input ASN.1 schema to compare with
* @returns {{ verified: boolean, result?: any }}
*/
function compareSchema(root: any, inputData: any, inputSchema: any): { verified: boolean, result?: any };
/**
* ASN.1 schema verification for ArrayBuffer data
*
* @param {ArrayBuffer} inputBuffer Input BER-encoded ASN.1 data
* @param {*} inputSchema Input ASN.1 schema to verify against to
* @returns {{ verified: boolean, result?: any }}
*/
function verifySchema(inputBuffer: ArrayBuffer, inputSchema: any): { verified: boolean, result?: any };
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"asn1js-tests.ts"
]
}
+62
View File
@@ -0,0 +1,62 @@
import AsyncPolling = require("async-polling");
// Tests based on examples in https://github.com/cGuille/async-polling#readme
AsyncPolling(end => {
end();
}, 3000).run();
function someAsynchroneProcess(callback: (error?: Error, response?: any) => any): any {
callback();
}
let polling = AsyncPolling(end => {
someAsynchroneProcess(function (error, response) {
if (error) {
end(error);
return;
}
end(null, response);
});
}, 3000);
polling.on("error", (error: Error) => {});
polling.on("result", (result: any) => {});
polling.run();
polling.stop();
AsyncPolling(function(end) {
this.stop();
end();
}, 3000).run();
let i = 0;
polling = AsyncPolling(function(end) {
++i;
if (i === 3) {
return end(new Error("i is " + i));
}
if (i >= 5) {
this.stop();
return end(null, `#${i} stop`);
}
end(null, `#${i} wait a second...`);
}, 1000);
const eventNames: AsyncPolling.EventName[] = ["run", "start", "end", "schedule", "stop"];
eventNames.forEach(eventName => {
polling.on(eventName, () => {
console.log("lifecycle:", eventName);
});
});
polling.on("result", (result: any) => {
console.log("result:", result);
});
polling.on("error", (error: Error) => {
console.error("error:", error);
});
polling.run();
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for AsyncPolling
// Project: https://github.com/cGuille/async-polling
// Definitions by: Zlatko Andonovski <https://github.com/Goldsmith42/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace AsyncPolling {
export type EventName = "run"|"start"|"error"|"result"|"end"|"schedule"|"stop";
}
declare function AsyncPolling<Result>(pollingFunc: (end: (err?: Error, result?: Result) => any) => any, delay: number): {
run: () => any;
stop: () => any;
on: (eventName: AsyncPolling.EventName, listener: Function) => any;
}
export = AsyncPolling;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"async-polling-tests.ts"
]
}
+399 -45
View File
@@ -1,9 +1,10 @@
/// <reference types="node" />
import fs = require("fs");
import process = require("process");
var path: {
exists: (path: string, callback?: (err: string, exists: boolean) => any) => void;
declare var path: {
exists: (path: string, callback?: (err: Error, exists: boolean) => any) => void;
};
function callback() { }
@@ -33,8 +34,8 @@ async.series([
function () { }
]);
var data = [];
function asyncProcess(item, callback) { }
var data: any[] = [];
function asyncProcess(item: any, callback: (err: Error, result: any) => void) { }
async.map(data, asyncProcess, function (err, results) {
console.log(results);
});
@@ -49,11 +50,11 @@ var saveFile = function () { }
async.each(openFiles, saveFile, function (err) { });
async.eachSeries(openFiles, saveFile, function (err) { });
var documents, requestApi;
var documents: any, requestApi: any;
async.eachLimit(documents, 20, requestApi, function (err) { });
// forEachOf* functions. May accept array or object.
function forEachOfIterator(item, key, forEachOfIteratorCallback) {
function forEachOfIterator(item: string, key: string, forEachOfIteratorCallback: any) {
console.log("ForEach: item=" + item + ", key=" + key);
forEachOfIteratorCallback();
}
@@ -64,9 +65,8 @@ 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) {
function reducer(memo: any, item: any, callback: any) {
process.nextTick(function () {
callback(null, memo + item)
});
@@ -103,20 +103,20 @@ async.concatSeries(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) {
async.series([
function (callback) {
callback(null, 'one');
callback(undefined, 'one');
},
function (callback) {
callback(null, 'two');
callback(undefined, 'two');
},
],
function (err, results) { });
async.series<string>([
function (callback) {
callback(null, 'one');
callback(undefined, 'one');
},
function (callback) {
callback(null, 'two');
callback(undefined, 'two');
},
],
function (err, results) { });
@@ -124,12 +124,12 @@ function (err, results) { });
async.series({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
callback(undefined, 1);
}, 200);
},
two: function (callback) {
setTimeout(function () {
callback(null, 2);
callback(undefined, 2);
}, 100);
},
},
@@ -138,25 +138,25 @@ function (err, results) { });
async.series<number>({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
callback(undefined, 1);
}, 200);
},
two: function (callback) {
setTimeout(function () {
callback(null, 2);
callback(undefined, 2);
}, 100);
},
},
function (err, results) { });
async.times(5, function(n, next) {
next(null, n)
next(undefined as any, n)
}, function(err, results) {
console.log(results)
})
async.timesSeries(5, function(n, next) {
next(null, n)
next(undefined as any, n)
}, function(err, results) {
console.log(results)
})
@@ -164,12 +164,12 @@ async.timesSeries(5, function(n, next) {
async.parallel([
function (callback) {
setTimeout(function () {
callback(null, 'one');
callback(undefined, 'one');
}, 200);
},
function (callback) {
setTimeout(function () {
callback(null, 'two');
callback(undefined, 'two');
}, 100);
},
],
@@ -178,12 +178,12 @@ function (err, results) { });
async.parallel<string>([
function (callback) {
setTimeout(function () {
callback(null, 'one');
callback(undefined, 'one');
}, 200);
},
function (callback) {
setTimeout(function () {
callback(null, 'two');
callback(undefined, 'two');
}, 100);
},
],
@@ -193,12 +193,12 @@ function (err, results) { });
async.parallel({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
callback(undefined, 1);
}, 200);
},
two: function (callback) {
setTimeout(function () {
callback(null, 2);
callback(undefined, 2);
}, 100);
},
},
@@ -207,12 +207,12 @@ function (err, results) { });
async.parallel<number>({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
callback(undefined, 1);
}, 200);
},
two: function (callback) {
setTimeout(function () {
callback(null, 2);
callback(undefined, 2);
}, 100);
},
},
@@ -221,12 +221,12 @@ async.parallel<number>({
async.parallelLimit({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
callback(undefined, 1);
}, 200);
},
two: function (callback) {
setTimeout(function () {
callback(null, 2);
callback(undefined, 2);
}, 100);
},
},
@@ -235,7 +235,7 @@ async.parallelLimit({
);
function whileFn(callback) {
function whileFn(callback: any) {
count++;
setTimeout(callback, 1000);
}
@@ -258,19 +258,19 @@ async.forever(function (errBack) {
);
async.waterfall([
function (callback) {
function (callback: any) {
callback(null, 'one', 'two');
},
function (arg1, arg2, callback) {
function (arg1: any, arg2: any, callback: any) {
callback(null, 'three');
},
function (arg1, callback) {
function (arg1: any, callback: any) {
callback(null, 'done');
}
], function (err, result) { });
var q = async.queue<any>(function (task: any, callback) {
var q = async.queue<any>(function (task: any, callback: any) {
console.log('hello ' + task.name);
callback();
}, 2);
@@ -323,7 +323,7 @@ q.resume();
q.kill();
// tests for strongly typed tasks
var q2 = async.queue<string>(function (task: string, callback) {
var q2 = async.queue<string>(function (task: string, callback: any) {
console.log('Task: ' + task);
callback();
}, 1);
@@ -358,26 +358,26 @@ var cargo = async.cargo(function (tasks, callback) {
// add some items
cargo.push({ name: 'foo' }, function (err) {
cargo.push({ name: 'foo' }, function (err: Error) {
console.log('finished processing foo');
});
cargo.push({ name: 'bar' }, function (err) {
cargo.push({ name: 'bar' }, function (err: Error) {
console.log('finished processing bar');
});
cargo.push({ name: 'baz' }, function (err) {
cargo.push({ name: 'baz' }, function (err: Error) {
console.log('finished processing baz');
});
var filename = '';
async.auto({
get_data: function (callback) { },
make_folder: function (callback) { },
get_data: function (callback: any) { },
make_folder: function (callback: any) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback) {
write_file: ['get_data', 'make_folder', <any>function (callback: any) {
callback(null, filename);
}],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback, results) { }]
email_link: ['write_file', <any>function (callback: any, results: any) { }]
});
async.retry(3, function (callback, results) { }, function (err, result) { });
@@ -411,13 +411,13 @@ async.parallel([
},
]);
var call_order = [];
var call_order: string[] = [];
async.nextTick(function () {
call_order.push('two');
});
call_order.push('one');
var slow_fn = function (name, callback) {
var slow_fn = function (name: string, callback: any) {
callback(null, 123);
};
var fn = async.memoize(slow_fn);
@@ -427,15 +427,369 @@ async.ensureAsync(function () { });
async.constant(42);
async.asyncify(function () { });
async.log(function (name, callback) {
async.log(function (name: any, callback: any) {
setTimeout(function () {
callback(null, 'hello ' + name);
}, 0);
}, "world"
);
async.dir(function (name, callback) {
async.dir(function (name: string, callback: any) {
setTimeout(function () {
callback(null, { hello: name });
}, 1000);
}, "world");
// each
async.each<number>({
"a": 1,
"b": 2
}, function(val: number, next: ErrorCallback): void {
setTimeout(function(): void {
console.log(`async.each: ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.each: done.");
});
async.eachSeries<number>({
"a": 1,
"b": 2
}, function(val: number, next: ErrorCallback): void {
setTimeout(function(): void {
console.log(`async.eachSeries: ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.eachSeries: done.");
});
async.eachLimit<number>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, next: ErrorCallback): void {
setTimeout(function(): void {
console.log(`async.eachLimit: ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.eachLimit: done.");
});
// forEachOf/eachOf
async.eachOf<number>({
"a": 1,
"b": 2
}, function(val: number, key: string, next: ErrorCallback): void {
setTimeout(function(): void {
console.log(`async.forEachOf/eachOf: ${key} = ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.forEachOf/eachOf: done.");
});
async.forEachOfSeries<number>({
"a": 1,
"b": 2
}, function(val: number, key: string, next: ErrorCallback): void {
setTimeout(function(): void {
console.log(`async.forEachOfSeries: ${key} = ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.forEachOfSeries: done.");
});
async.forEachOfLimit<number>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, key: string, next: ErrorCallback): void {
setTimeout(function(): void {
console.log(`async.forEachOfLimit: ${key} = ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.forEachOfLimit: done.");
});
// map
async.map<number, string>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
console.log(`async.map: ${val}`);
next(undefined as any, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.map: done with results", results);
});
async.mapSeries<number, string>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
console.log(`async.mapSeries: ${val}`);
next(undefined as any, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.mapSeries: done with results", results);
});
async.mapLimit<number, string>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
console.log(`async.mapLimit: ${val}`);
next(undefined as any, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.mapLimit: done with results", results);
});
// mapValues
async.mapValues<number, string>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, key: string, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
console.log(`async.mapValues: ${key} = ${val}`);
next(undefined as any, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.mapValues: done with results", results);
});
async.mapValuesSeries<number, string>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, key: string, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
console.log(`async.mapValuesSeries: ${key} = ${val}`);
next(undefined as any, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.mapValuesSeries: done with results", results);
});
// filter/select/reject
async.filter<number>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncBooleanResultCallback): void {
setTimeout(function(): void {
console.log(`async.filter/select: ${val}`);
next(undefined as any, val % 2 === 0);
}, 500);
}, function(err: Error, results: number[]): void {
console.log("async.filter/select: done with results", results);
});
async.reject<number>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncBooleanResultCallback): void {
setTimeout(function(): void {
console.log(`async.reject: ${val}`);
next(undefined as any, val % 2 === 0);
}, 500);
}, function(err: Error, results: number[]): void {
console.log("async.reject: done with results", results);
});
// concat
async.concat<string, string>({
"a": "1",
"b": "2",
"c": "3"
}, function(item: string, next: AsyncResultCallback<string[]>): void {
console.log(`async.concat: ${item}`);
next(undefined as any, [item, item, item]);
}, function(err: Error, results: string[]) {
console.log("async.concat: done with results", results);
});
// detect/find
async.detect<number>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback): void {
console.log(`async.detect/find: ${item}`);
next(undefined as any, item > 1);
}, function(err: Error, result: number) {
if (err) {
console.log(err);
} else {
console.log("async.detect/find: done with result", result);
}
});
// every/all
async.every<number>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback): void {
console.log(`async.every/all: ${item}`);
next(undefined as any, item > 0);
}, function(err: Error, result: boolean) {
console.log("async.every/all: done with result", result);
});
// some/any
async.some<number>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback): void {
console.log(`async.some/any: ${item}`);
next(undefined as any, item > 2);
}, function(err: Error, result: boolean) {
console.log("async.some/any: done with result", result);
});
+77 -57
View File
@@ -1,11 +1,13 @@
// Type definitions for Async 2.0.1
// Project: https://github.com/caolan/async
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Arseniy Maximov <https://github.com/kern0>, Joe Herman <https://github.com/Penryn>
// Definitions by: Boris Yankov <https://github.com/borisyankov/>, Arseniy Maximov <https://github.com/kern0>, Joe Herman <https://github.com/Penryn>, Angus Fenying <https://github.com/fenying>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Dictionary<T> { [key: string]: T; }
interface ErrorCallback { (err?: Error): void; }
interface AsyncWaterfallCallback { (err: Error, ...args: any[]): void; }
interface AsyncBooleanResultCallback { (err: Error, truthValue: boolean): void; }
interface AsyncResultCallback<T> { (err: Error, result: T): void; }
interface AsyncResultArrayCallback<T> { (err: Error, results: T[]): void; }
interface AsyncResultObjectCallback<T> { (err: Error, results: Dictionary<T>): void; }
@@ -15,7 +17,7 @@ interface AsyncIterator<T> { (item: T, callback: ErrorCallback): void; }
interface AsyncForEachOfIterator<T> { (item: T, key: number|string, callback: ErrorCallback): void; }
interface AsyncResultIterator<T, R> { (item: T, callback: AsyncResultCallback<R>): void; }
interface AsyncMemoIterator<T, R> { (memo: R, item: T, callback: AsyncResultCallback<R>): void; }
interface AsyncBooleanIterator<T> { (item: T, callback: (err: string, truthValue: boolean) => void): void; }
interface AsyncBooleanIterator<T> { (item: T, callback: AsyncBooleanResultCallback): void; }
interface AsyncWorker<T> { (task: T, callback: ErrorCallback): void; }
interface AsyncVoidFunction { (callback: ErrorCallback): void; }
@@ -89,52 +91,74 @@ interface Async {
// Collections
each<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
eachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
each<T>(arr: Dictionary<T>, iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
eachSeries: typeof async.each;
eachLimit<T>(arr: T[], limit: number, iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
forEachOf(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
eachLimit<T>(arr: Dictionary<T>, limit: number, iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
forEach: typeof async.each;
forEachSeries: typeof async.each;
forEachLimit: typeof async.eachLimit;
forEachOf<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
forEachOfSeries(obj: any, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
forEachOfSeries<T>(obj: T[], iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
forEachOfLimit(obj: any, limit: number, iterator: (item: any, key: string|number, callback?: ErrorCallback) => void, callback: ErrorCallback): void;
forEachOf<T>(obj: Dictionary<T>, iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
forEachOfSeries: typeof async.forEachOf;
forEachOfLimit<T>(obj: T[], limit: number, iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
mapSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
mapLimit<T, R>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): any;
mapValuesLimit<T, R>(obj: {[name: string]: T}, limit: number, iteratee: (value: string, key: T, callback: AsyncResultCallback<R>) => void, callback: AsyncResultCallback<R[]>): void;
mapValues<T, R>(obj: {[name: string]: T}, iteratee: (value: string, key: T, callback: AsyncResultCallback<R>) => void, callback: AsyncResultCallback<R[]>): void;
forEachOfLimit<T>(obj: Dictionary<T>, limit: number, iterator: AsyncForEachOfIterator<T>, callback?: ErrorCallback): void;
eachOf: typeof async.forEachOf;
eachOfSeries: typeof async.forEachOf;
eachOfLimit: typeof async.forEachOfLimit;
map<T, R>(arr: T[], iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): void;
map<T, R>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): void;
mapSeries: typeof async.map;
mapLimit<T, R>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): void;
mapLimit<T, R>(arr: Dictionary<T>, limit: number, iterator: AsyncResultIterator<T, R>, callback?: AsyncResultArrayCallback<R>): void;
mapValuesLimit<T, R>(obj: Dictionary<T>, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback<R>) => void, callback: AsyncResultCallback<R[]>): void;
mapValues<T, R>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R>) => void, callback: AsyncResultCallback<R[]>): void;
mapValuesSeries: typeof async.mapValues;
filter<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
select<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
filterSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
selectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
filterLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
selectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
reject<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
rejectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
rejectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): any;
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any;
inject<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any;
foldl<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): any;
reduceRight<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
foldr<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback: AsyncResultCallback<R>): any;
detect<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): any;
filter<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): void;
filter<T>(arr: Dictionary<T>, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): void;
filterSeries: typeof async.filter;
filterLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): void;
filterLimit<T>(arr: Dictionary<T>, limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultArrayCallback<T>): void;
select: typeof async.filter;
selectSeries: typeof async.filter;
selectLimit: typeof async.filterLimit;
reject: typeof async.filter;
rejectSeries: typeof async.filter;
rejectLimit: typeof async.filterLimit;
reduce<T, R>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R>, callback?: AsyncResultCallback<R>): void;
inject: typeof async.reduce;
foldl: typeof async.reduce;
reduceRight: typeof async.reduce;
foldr: typeof async.reduce;
detect<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): void;
detect<T>(arr: Dictionary<T>, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): void;
detectSeries: typeof async.detect;
detectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): void;
detectLimit<T>(arr: Dictionary<T>, limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): void;
find: typeof async.detect;
detectSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): any;
findSeries: typeof async.detectSeries;
detectLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncResultCallback<T>): any;
findSeries: typeof async.detect;
findLimit: typeof async.detectLimit;
sortBy<T, V>(arr: T[], iterator: AsyncResultIterator<T, V>, callback?: AsyncResultArrayCallback<T>): any;
some<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
someLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
anyLimit: typeof async.someLimit;
someSeries<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
sortBy<T, V>(arr: T[], iterator: AsyncResultIterator<T, V>, callback?: AsyncResultArrayCallback<T>): void;
some<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncBooleanResultCallback): void;
some<T>(arr: Dictionary<T>, iterator: AsyncBooleanIterator<T>, callback?: AsyncBooleanResultCallback): void;
someSeries: typeof async.some;
someLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncBooleanResultCallback): void;
someLimit<T>(arr: Dictionary<T>, limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncBooleanResultCallback): void;
any: typeof async.some;
anySeries: typeof async.someSeries;
any<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => void): any;
every<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any;
everyLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any;
all<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: (result: boolean) => any): any;
concat<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): any;
concatSeries<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): any;
anyLimit: typeof async.someLimit;
every<T>(arr: T[], iterator: AsyncBooleanIterator<T>, callback?: AsyncBooleanResultCallback): void;
every<T>(arr: Dictionary<T>, iterator: AsyncBooleanIterator<T>, callback?: AsyncBooleanResultCallback): void;
everySeries: typeof async.every;
everyLimit<T>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncBooleanResultCallback): void;
everyLimit<T>(arr: Dictionary<T>, limit: number, iterator: AsyncBooleanIterator<T>, callback?: AsyncBooleanResultCallback): void;
all: typeof async.every;
allSeries: typeof async.every;
allLimit: typeof async.everyLimit;
concat<T, R>(arr: T[], iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): void;
concat<T, R>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R[]>, callback?: AsyncResultArrayCallback<R>): void;
concatSeries: typeof async.concat;
// Control Flow
series<T>(tasks: AsyncFunction<T>[], callback?: AsyncResultArrayCallback<T>): void;
@@ -143,14 +167,14 @@ interface Async {
parallel<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void;
parallelLimit<T>(tasks: Array<AsyncFunction<T>>, limit: number, callback?: AsyncResultArrayCallback<T>): void;
parallelLimit<T>(tasks: Dictionary<AsyncFunction<T>>, limit: number, callback?: AsyncResultObjectCallback<T>): void;
whilst(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void;
doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void;
until(test: () => boolean, fn: AsyncVoidFunction, callback: (err: any) => void): void;
doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: (err: any) => void): void;
during(test: (testCallback : (error: Error, truth: boolean) => void) => void, fn: AsyncVoidFunction, callback: (err: any) => void): void;
doDuring(fn: AsyncVoidFunction, test: (testCallback: (error: Error, truth: boolean) => void) => void, callback: (err: any) => void): void;
forever(next: (errCallback : (err: Error) => void) => void, errBack: (err: Error) => void) : void;
waterfall(tasks: Function[], callback?: (err: Error, results?: any) => void): void;
whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void;
doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void;
until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void;
doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void;
during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void;
doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void;
forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void;
waterfall<T>(tasks: Function[], callback?: AsyncResultCallback<T>): void;
compose(...fns: Function[]): Function;
seq(...fns: Function[]): Function;
applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
@@ -158,19 +182,15 @@ interface Async {
queue<T>(worker: AsyncWorker<T>, concurrency?: number): AsyncQueue<T>;
priorityQueue<T>(worker: AsyncWorker<T>, concurrency: number): AsyncPriorityQueue<T>;
cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo;
auto(tasks: any, concurrency?: number, callback?: (error: Error, results: any) => void): void;
autoInject(tasks: any, callback?: (error: Error, results: any) => void): void;
retry<T>(opts: number, task: (callback : AsyncResultCallback<T>, results: any) => void, callback: (error: Error, results: any) => void): void;
retry<T>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T>, results : any) => void, callback: (error: Error, results: any) => void): void;
auto(tasks: any, concurrency?: number, callback?: AsyncResultCallback<any>): void;
autoInject(tasks: any, callback?: AsyncResultCallback<any>): void;
retry<T>(opts: number, task: (callback : AsyncResultCallback<T>, results: any) => void, callback: AsyncResultCallback<any>): void;
retry<T>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T>, results : any) => void, callback: AsyncResultCallback<any>): void;
retryable<T>(opts: number | {times: number, interval: number}, task: AsyncFunction<T>): AsyncFunction<T>;
apply(fn: Function, ...arguments: any[]): AsyncFunction<any>;
nextTick(callback: Function, ...args: any[]): void;
setImmediate: typeof async.nextTick;
allLimit<T>(arr: T[], limit: number, iteratee: AsyncBooleanIterator<T>, cb?: (result: boolean) => any) : any;
everySeries<T>(arr: T[], iteratee: AsyncBooleanIterator<T>, cb?: (result: boolean) => any) : any
allSeries: typeof async.everySeries;
reflect<T>(fn: AsyncFunction<T>) : (callback: (err: void, result: {error?: Error, value?: T}) => void) => void;
reflectAll<T>(tasks: AsyncFunction<T>[]): ((callback: (err: void, result: {error?: Error, value?: T}) => void) => void)[];
+2 -2
View File
@@ -2,8 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": false,
"strictNullChecks": false,
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
+1 -1
View File
@@ -122,5 +122,5 @@ interface Auth0LockStatic {
declare var Auth0Lock: Auth0LockStatic;
declare module "auth0-lock" {
export = Auth0Lock;
export default Auth0Lock;
}
+55
View File
@@ -0,0 +1,55 @@
var input = document.getElementById("myinput");
new Awesomplete(input, {list: "#mylist"});
new Awesomplete(input, {list: document.querySelector("#mylist")});
new Awesomplete(input, {
list: ["Ada", "Java", "JavaScript", "LOLCODE", "Node.js", "Ruby on Rails"]
});
var awesomplete = new Awesomplete(input);
awesomplete.list = ["Ada", "Java", "JavaScript", "LOLCODE", "Node.js", "Ruby on Rails"];
new Awesomplete(input, {
list: [
{ label: "Belarus", value: "BY" },
{ label: "China", value: "CN" },
{ label: "United States", value: "US" }
]
});
// Same with arrays:
new Awesomplete(input, {
list: [
[ "Belarus", "BY" ],
[ "China", "CN" ],
[ "United States", "US" ]
]
});
new Awesomplete('input[type="email"]', {
list: ["aol.com", "att.net", "comcast.net", "facebook.com", "gmail.com", "gmx.com", "googlemail.com", "google.com", "hotmail.com", "hotmail.co.uk", "mac.com", "me.com", "mail.com", "msn.com", "live.com", "sbcglobal.net", "verizon.net", "yahoo.com", "yahoo.co.uk"],
data: function (text: string, input: any) {
return input.slice(0, input.indexOf("@")) + "@" + text;
},
filter: Awesomplete.FILTER_STARTSWITH
});
new Awesomplete('input[data-multiple]', {
filter: function(text: string, input: any) {
return Awesomplete.FILTER_CONTAINS(text, input.match(/[^,]*$/)[0]);
},
replace: function(text: string) {
var before = this.input.value.match(/^.+,\s*|/)[0];
this.input.value = before + text + ", ";
}
});
var ajax = new XMLHttpRequest();
ajax.open("GET", "https://restcountries.eu/rest/v1/lang/fr", true);
ajax.onload = function() {
var list = JSON.parse(ajax.responseText).map(function(i: any) { return i.name; });
new Awesomplete(document.querySelector("#ajax-example input"),{ list: list });
};
ajax.send();
+49
View File
@@ -0,0 +1,49 @@
// Type definitions for Awesomplete v1.1.0
// Project: https://leaverou.github.io/awesomplete/
// Definitions by: webbiesdk <https://github.com/webbiesdk/>, Ben Dixon <https://github.com/bmdixon/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Awesomplete {
constructor(input: Element | HTMLElement | string, o?: AwesompleteOptions);
static all: Array<any>;
static $$: (expr: string | NodeSelector, con?: any) => NodeList;
static ITEM: (text: string, input: string) => HTMLElement;
static $: {
(expr: string|Element, con?: NodeSelector): string | Element;
regExpEscape: (s: { replace: (arg0: RegExp, arg1: string) => void }) => any;
create: (tag: string, o: any) => HTMLElement;
fire: (target: EventTarget, type: string, properties: any) => any;
siblingIndex: (el: Element) => number;
};
static FILTER_STARTSWITH: (text: string, input: string) => boolean;
static FILTER_CONTAINS: (text: string, input: string) => boolean;
static SORT_BYLENGTH: (a: number | any[], b: number | any[]) => number;
static REPLACE: (text: any) => void;
next: () => void;
container: HTMLElement;
select: (selected?: HTMLElement, originalTarget?: HTMLElement) => void;
previous: () => void;
index: number;
opened: number;
list: string | string[] | Element | { label: string, value: any }[] | [string, string][];
input: HTMLElement | string;
goto: (i: number) => void;
ul: HTMLElement;
close: () => void;
evaluate: () => void;
selected: boolean;
open: () => void;
status: HTMLElement;
}
interface AwesompleteOptions {
list?: string | string[] | Element | { label: string, value: any }[] | [string, string][];
minChars?: Number;
maxItems?: Number;
autoFirst?: boolean;
data?: Function;
filter?: Function;
sort?: Function;
item?: Function;
replace?: Function;
}
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"awesomplete-tests.ts"
]
}
+42 -15
View File
@@ -1,17 +1,18 @@
import lambda = require('aws-lambda');
/// <reference types="aws-lambda" />
var str: string;
var date: Date;
var anyObj: any;
var num: number;
var identity: lambda.CognitoIdentity;
var error: Error;
var b: boolean;
var clientCtx: lambda.ClientContext;
var str: string = "any string";
var date: Date = new Date();
var anyObj: any = { abc: 123 };
var num: number = 5;
var error: Error = new Error();
var b: boolean = true;
var clientCtx: AWSLambda.ClientContext;
var clientContextEnv: AWSLambda.ClientContextEnv;
var clientContextClient: AWSLambda.ClientContextClient;
var context: AWSLambda.Context;
var identity: AWSLambda.CognitoIdentity;
/* Context */
var context: lambda.Context;
b = context.callbackWaitsForEmptyEventLoop;
str = context.functionName;
str = context.functionVersion;
@@ -24,15 +25,41 @@ identity = context.identity;
clientCtx = context.clientContext;
/* CognitoIdentity */
var identity: lambda.CognitoIdentity;
str = identity.cognitoIdentityId;
str = identity.cognitoIdentityPoolId;
/* ClientContext */
clientContextClient = clientCtx.client;
anyObj = clientCtx.Custom;
clientContextEnv = clientCtx.env;
/* ClientContextEnv */
str = clientContextEnv.locale;
str = clientContextEnv.make;
str = clientContextEnv.model;
str = clientContextEnv.platform;
str = clientContextEnv.platformVersion;
/* ClientContextClient */
str = clientContextClient.appPackageName;
str = clientContextClient.appTitle;
str = clientContextClient.appVersionCode;
str = clientContextClient.appVersionName;
str = clientContextClient.installationId;
/* Callback */
function callback(cb: lambda.Callback) {
function callback(cb: AWSLambda.Callback) {
cb();
cb(null);
cb(error);
cb(null, anyObj);
}
}
/* Compatibility functions */
context.done();
context.done(error);
context.done(error, anyObj);
context.succeed(str);
context.succeed(anyObj);
context.succeed(str, anyObj);
context.fail(error);
context.fail(str);
+6 -3
View File
@@ -3,7 +3,6 @@
// Definitions by: James Darbyshire <https://github.com/darbio/aws-lambda-typescript>, Michael Skarum <https://github.com/skarum>, Stef Heyenrath <https://github.com/StefH/DefinitelyTyped>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Context
// http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
interface Context {
@@ -23,7 +22,9 @@ interface Context {
getRemainingTimeInMillis(): number;
// Functions for compatibility with earlier Node.js Runtime v0.10.42
log(message: string, object: any): void;
// For more details see http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-using-old-runtime.html#nodejs-prog-model-oldruntime-context-methods
done(error?: Error, result?: any): void;
fail(error: Error): void;
fail(message: string): void;
succeed(message: string): void;
succeed(object: any): void;
@@ -64,4 +65,6 @@ interface ClientContextEnv {
* @param error – an optional parameter that you can use to provide results of the failed Lambda function execution.
* @param result – an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible.
*/
export type Callback = (error?: Error, result?: any) => void;
export type Callback = (error?: Error, result?: any) => void;
export as namespace AWSLambda;
+39
View File
@@ -381,3 +381,42 @@ dynamoDBDocClient.query(
else console.log(data); // successful response
}
);
var kinesis = new AWS.Kinesis();
var putRecordParam = {
Data: new Buffer('...') || 'STRING_VALUE', /* required */
PartitionKey: 'STRING_VALUE', /* required */
StreamName: 'STRING_VALUE', /* required */
ExplicitHashKey: 'STRING_VALUE',
SequenceNumberForOrdering: 'STRING_VALUE'
};
kinesis.putRecord(putRecordParam, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
var putRecordParams = {
Records: [ /* required */
{
Data: new Buffer('...') || 'STRING_VALUE', /* required */
PartitionKey: 'STRING_VALUE', /* required */
ExplicitHashKey: 'STRING_VALUE'
},
/* more items */
],
StreamName: 'STRING_VALUE' /* required */
};
kinesis.putRecords(putRecordParams, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
var increaseStreamRetentionPeriodParams = {
RetentionPeriodHours: 0, /* required */
StreamName: 'STRING_VALUE' /* required */
};
kinesis.increaseStreamRetentionPeriod(increaseStreamRetentionPeriodParams, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else console.log(data); // successful response
});
+91 -5
View File
@@ -1,6 +1,6 @@
// Type definitions for aws-sdk
// Project: https://github.com/aws/aws-sdk-js
// Definitions by: midknight41 <https://github.com/midknight41>
// Definitions by: midknight41 <https://github.com/midknight41>, Casper Skydt <https://github.com/CasperSkydt>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Imported from: https://github.com/soywiz/typescript-node-definitions/aws-sdk.d.ts
@@ -335,6 +335,56 @@ export declare class SNS {
publish(request: Sns.PublishRequest, callback: (err: any, data: any) => void): void;
}
export class Kinesis {
constructor(options?: any);
endpoint: Endpoint;
putRecord(params: KINESIS.PutRecordParams, callback: (error: Error, data: KINESIS.PutRecordResult) => void): void;
putRecords(params: KINESIS.PutRecordsParams, callback: (error: Error, data: KINESIS.PutRecordsResult) => void): void;
increaseStreamRetentionPeriod(params: KINESIS.IncreaseStreamRetentionPeriodParams, callback: (error: Error, data: any) => void): void;
}
export module KINESIS {
export interface Record {
Data: Buffer | string | Blob;
PartitionKey: string;
ExplicitHashKey?: string;
}
export interface RecordResult {
SequenceNumber: string;
ShardId: string;
ErrorCode: string;
ErrorMessage: string;
}
export interface PutRecordParams extends Record {
StreamName: string;
SequenceNumberForOrdering?: string;
}
export interface PutRecordResult {
ShardId: string;
SequenceNumber: string;
}
export interface PutRecordsParams {
StreamName: string;
Records: Record[];
}
export interface PutRecordsResult {
FailedRecordCount: number;
Records: RecordResult[]
}
export interface IncreaseStreamRetentionPeriodParams {
RetentionPeriodHours: number;
StreamName: string;
}
}
export declare class SWF {
constructor(options?: any);
endpoint: Endpoint;
@@ -378,7 +428,8 @@ export declare class S3 {
endpoint: Endpoint;
getObject(params: s3.GetObjectRequest, callback?: (err: Error, data: any) => void): any;
putObject(params: s3.PutObjectRequest, callback: (err: Error, data: any) => void): void;
putObject(params: s3.PutObjectRequest, callback?: (err: Error, data: any) => void): any;
copyObject(params: s3.CopyObjectRequest, callback?: (err: Error, data: any) => void): any;
deleteObject(params: s3.DeleteObjectRequest, callback: (err: Error, data: any) => void): void;
headObject(params: s3.HeadObjectRequest, callback: (err: Error, data: any) => void): void;
getSignedUrl(operation: string, params: any): string;
@@ -522,7 +573,8 @@ export declare module DynamoDB {
interface UpdateParam extends _DDBDC_Writer {
Key: _DDBDC_Keys;
AttributeUpdates: {
UpdateExpression?: string;
AttributeUpdates?: {
[someKey: string]: {
Action: "PUT" | "ADD" | "DELETE";
Value: any
@@ -615,8 +667,8 @@ export module CloudFormation {
ResourceTypes?: string[];
OnFailure?: string[]; // cannot specify both DisableRollback and OnFailure
// DO_NOTHING | ROLLBACK | DELETE
StackPolicyBody?: string[]; // cannot specify both StackPolicyBody and StackPolicyURL
StackPolicyURL?: string[]; // cannot specify both StackPolicyBody and StackPolicyURL
StackPolicyBody?: string; // cannot specify both StackPolicyBody and StackPolicyURL
StackPolicyURL?: string; // cannot specify both StackPolicyBody and StackPolicyURL
Tags?: CloudFormation.Tag[];
}
@@ -2252,6 +2304,40 @@ export declare module s3 {
WebsiteRedirectLocation?: string;
}
export interface CopyObjectRequest {
Bucket: string;
CopySource: string;
Key: string;
ACL?: string;
CacheControl?: string;
ContentDisposition?: string;
ContentEncoding?: string;
ContentLanguage?: string;
ContentType?: string;
CopySourceIfMatch?: string;
CopySourceIfModifiedSince?: any;
CopySourceIfNoneMatch?: string;
CopySourceIfUnmodifiedSince?: any;
CopySourceSSECustomerAlgorithm?: string;
CopySourceSSECustomerKey?: any;
CopySourceSSECustomerKeyMD5?: string;
Expires?: any;
GrantFullControl?: string;
GrantRead?: string;
GrantReadACP?: string;
GrantWriteACP?: string;
Metadata?: { [key: string]: string; };
MetadataDirective?: string;
RequestPayer?: string;
SSECustomerAlgorithm?: string;
SSECustomerKey?: any;
SSECustomerKeyMD5?: string;
SSEKMSKeyId?: string;
ServerSideEncryption?: string;
StorageClass?: string;
WebsiteRedirectLocation?: string;
}
export interface GetObjectRequest {
Bucket: string;
IfMatch?: string;
@@ -0,0 +1,28 @@
/// <reference types="express"/>
import * as awsServerlessExpress from 'aws-serverless-express';
import * as express from 'express';
const app = express();
const server = awsServerlessExpress.createServer(app, () => {});
const mockEvent = {
key: 'value'
};
const mockContext = {
callbackWaitsForEmptyEventLoop: true,
functionName: 'testFunction',
functionVersion: '1',
invokedFunctionArn: 'arn',
memoryLimitInMB: 128,
awsRequestId: 'id',
logGroupName: 'group',
logStreamName: 'stream',
getRemainingTimeInMillis: () => 2000,
done: () => false,
fail: (error: any) => false,
succeed: (message: string) => false
};
awsServerlessExpress.proxy(server, mockEvent, mockContext);
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for aws-serverless-express
// Project: https://github.com/awslabs/aws-serverless-express
// Definitions by: Ben Speakman <https://github.com/threesquared>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node"/>
import * as http from 'http';
import * as lambda from 'aws-lambda';
export function createServer(
requestListener: (request: http.IncomingMessage, response: http.ServerResponse) => http.Server,
serverListenCallback?: () => any
): http.Server;
export function proxy(
server: http.Server,
event: any,
context: lambda.Context
): void;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"aws-serverless-express-tests.ts"
]
}
+24
View File
@@ -0,0 +1,24 @@
/// <reference path="./index.d.ts" />
import * as aws4 from ".";
let requestSigner = new aws4.RequestSigner({}, {});
requestSigner.matchHost("");
requestSigner.isSingleRegion();
requestSigner.createHost();
requestSigner.prepareRequest();
requestSigner.sign();
requestSigner.getDateTime();
requestSigner.getDate();
requestSigner.authHeader();
requestSigner.signature();
requestSigner.stringToSign();
requestSigner.canonicalString();
requestSigner.canonicalHeaders();
requestSigner.signedHeaders();
requestSigner.credentialString();
requestSigner.defaultCredentials();
requestSigner.parsePath();
requestSigner.formatPath();
aws4.sign({}, {});
+33
View File
@@ -0,0 +1,33 @@
// Type definitions for aws4 1.5.0
// Project: https://github.com/mhart/aws4
// Definitions by: Andrew Crites <https://github.com/ajcrites>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export class RequestSigner {
constructor(request?: any, credentials?: any);
request: any;
credentials: any;
service: any;
region: any;
isCodeCommitGit: any;
matchHost(host?: string): string;
isSingleRegion(): boolean;
createHost(): string;
prepareRequest(): void;
sign(): any;
getDateTime(): string;
getDate(): string;
authHeader(): string;
signature(): string;
stringToSign(): string;
canonicalString(): string;
canonicalHeaders(): string;
signedHeaders(): string;
credentialString(): string;
defaultCredentials(): any;
parsePath(): any;
formatPath(): string;
}
export function sign(options?: any, credentials?: any): RequestSigner;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"aws4-tests.ts"
]
}
+4
View File
@@ -69,6 +69,10 @@ axios.post("http://example.com/", {
]
});
var config: Axios.AxiosXHRConfigBase<any> = {headers: {}};
config.headers['X-Custom-Header'] = 'baz';
axios.post("http://example.com/", config);
var getRepoIssue = axios.get<Issue>("https://api.github.com/repos/mzabriskie/axios/issues/1");
var axiosInstance = axios.create({
+1 -1
View File
@@ -39,7 +39,7 @@ declare namespace Axios {
/**
* custom headers to be sent
*/
headers?: Object;
headers?: {[key: string]: any};
/**
* URL parameters to be sent with the request
+3 -4
View File
@@ -1,6 +1,5 @@
/// <reference path="base64-js.d.ts" />
import * as base64js from "base64-js";
import * as base64js from 'base64-js';
const bytes: Uint8Array = base64js.toByteArray('shemp');
const length: number = base64js.byteLength("");
const bytes: Uint8Array = base64js.toByteArray("");
const decoded: string = base64js.fromByteArray(new Uint8Array(0));
+3 -2
View File
@@ -1,7 +1,8 @@
// Type definitions for base64-js v1.1.2
// Type definitions for base64-js 1.2
// Project: https://github.com/beatgammit/base64-js
// Definitions by: Peter Safranek <https://github.com/pe8ter>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function byteLength(encoded: string): number;
export function toByteArray(encoded: string): Uint8Array;
export function fromByteArray(bytes: Uint8Array): string;
export function fromByteArray(bytes: Uint8Array): string;
+2 -2
View File
@@ -3,7 +3,7 @@
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": false,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
@@ -14,6 +14,6 @@
},
"files": [
"index.d.ts",
"base64-js-test.ts"
"base64-js-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "../tslint.json" }
+9
View File
@@ -0,0 +1,9 @@
import * as bases from 'bases';
let bs16String: string = bases.toBase(200, 16); // => 'c8'
let bs62String: string = bases.toBase(99999, 62); // => 'q0T'
let customBaseString: string = bases.toAlphabet(300, 'aAbBcC'); // => 'Abba'
let frombs16Int: number = bases.fromBase('c8', 16); // => 200
let frombs62Int: number = bases.fromBase('q0T', 62); // => 99999
let customBaseInt: number = bases.fromAlphabet('Abba', 'aAbBcC'); // => 300
+20
View File
@@ -0,0 +1,20 @@
// Type definitions for bases 0.2.1
// Project: https://github.com/aseemk/bases.js
// Definitions by: Hari Krishna <https://github.com/harikv>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export function toAlphabet(num: number, alphabet: string): string;
export function fromAlphabet(str: string, alphabet: string): number;
export function toBase(num: number, base: number): string;
export function fromBase(str: string, base:number): number;
export let KNOWN_ALPHABETS: any;
export let NUMERALS: string;
export let LETTERS_LOWERCASE: string;
export let LETTERS_UPPERCASE: string;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bases-tests.ts"
]
}
+8
View File
@@ -0,0 +1,8 @@
import ponyBind = require('bind-ponyfill');
let boundFn: Function;
boundFn = ponyBind(() => { console.log(this); }, 'Hello world!');
boundFn = ponyBind((...args: Array<string>) => { console.log(this, ...args); }, 'Hello world!', 'arg1');
boundFn = ponyBind((...args: Array<string>) => { console.log(this, ...args); }, 'Hello world!', 'arg1', 'arg2');
boundFn = ponyBind((arg1: string, arg2: number) => { console.log(this, arg1, arg2); }, 'Hello world!', 'arg1', 2);
+7
View File
@@ -0,0 +1,7 @@
// Type definitions for bind-ponyfill 0.1.0
// Project: https://www.npmjs.com/package/bind-ponyfill
// Definitions by: Steve Jenkins <https://github.com/skysteve>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare function ponyBind(fn: Function, that: any, ...args: Array<any>): Function;
export = ponyBind;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bind-ponyfill-tests.ts"
]
}
+1
View File
@@ -1,3 +1,4 @@
/// <reference types="bit-array" />
import BitArray = require("bit-array");
+20
View File
@@ -0,0 +1,20 @@
import * as bonjour from 'bonjour';
var bonjourOptions: bonjour.BonjourOptions;
var bonjourInstance: bonjour.Bonjour;
var serviceOptions: bonjour.ServiceOptions;
var service: bonjour.Service;
var browserOptions: bonjour.BrowserOptions;
var browser: bonjour.Browser;
bonjourOptions = { interface: '192.168.1.1', port: 5353 };
bonjourInstance = new bonjour.Bonjour(bonjourOptions);
serviceOptions = { name: 'My Web Server', type: 'http', port: 3000 };
service = bonjourInstance.publish(serviceOptions);
browserOptions = { protocol: 'tcp', type: 'http' };
browser = bonjour.find(browserOptions);
+68
View File
@@ -0,0 +1,68 @@
// Type definitions for bonjour v3.5.0
// Project: https://github.com/watson/bonjour
// Definitions by: Quentin Lampin <https://github.com/quentin-ol/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface BonjourOptions {
multicast?: boolean;
interface?: string;
port?: number;
ip?: string;
ttl?: number;
loopback?: boolean;
reuseAddr?: boolean;
}
export interface BrowserOptions {
type?: string;
subtypes?: string[];
protocol?: string;
txt?: Object;
}
export interface ServiceOptions {
name: string;
host?: string;
port: number;
type: string;
subtypes?: string[];
protocol?: 'udp'|'tcp';
txt?: Object;
}
export interface Service {
name: string;
type: string;
subtypes: string[];
protocol: string;
host: string;
port: number;
fqdn: string;
rawTxt: Object;
txt: Object;
published: boolean;
stop: (cb: ()=>any) => void;
start: () => void;
}
export class Bonjour {
constructor(opts: BonjourOptions);
publish(options: ServiceOptions):Service;
unpublishAll(cb: ()=>any): void;
find(options:BrowserOptions, onUp: ()=>any): Browser;
findOne(options:any, cb: (service: Service)=>any): Browser;
destroy():void;
}
export class Browser {
services: Service[];
start():void;
update():void;
stop():void;
}
export function find(options: BrowserOptions, onUp?: ()=>any): Browser;
export function findOne(options: BrowserOptions): Browser;
+19
View File
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"bonjour-tests.ts"
]
}
+2 -1
View File
@@ -2,6 +2,7 @@ import * as Knex from 'knex';
import * as Bookshelf from 'bookshelf';
import * as assert from 'assert';
import * as express from 'express';
import * as _ from "lodash";
/**
* The examples/tests below follow Bookshelf documentation chapter after chapter: http://bookshelfjs.org/
@@ -296,7 +297,7 @@ class Account extends bookshelf.Model<Account> {
}
{
var checkit = require('checkit');
//todo: make sure this works with BlueBird 3.0
var bcrypt:any; // = Promise.promisifyAll(require('bcrypt'));
+1
View File
@@ -40,6 +40,7 @@ interface BootboxConfirmOptions extends BootboxDialogOptions {
interface BootboxPromptOptions extends BootboxBaseOptions {
title: string;
value?: string;
inputType?: string;
callback: (result: string) => any;
buttons?: BootboxConfirmPromptButtonMap;
}
+7 -1
View File
@@ -12,7 +12,7 @@
* “w” (week), “m” (month), and “y” (year).
*
* See online docs for more info:
* http://bootstrap-datepicker.readthedocs.org/en/release/options.html
* https://bootstrap-datepicker.readthedocs.io/en/latest/options.html
*/
interface DatepickerOptions {
format?: string | DatepickerCustomFormatOptions;
@@ -36,6 +36,12 @@ interface DatepickerOptions {
multidateSeparator?: string;
orientation?: string;
assumeNearbyYear?: any;
viewMode?: string;
templates?: any;
zIndexOffset?: number;
showOnFocus?: boolean;
immediateUpdates?: boolean;
title?: string;
}
interface DatepickerCustomFormatOptions {
@@ -0,0 +1,40 @@
/// <reference types="jquery"/>
$(".selectpicker").selectpicker({
actionsBox: true,
container: "body",
countSelectedText: "counts > #",
deselectAllText: "test",
dropdownAlignRight: true,
dropupAuto: true,
header: "test",
hideDisabled: true,
iconBase: "fa",
liveSearch: true,
liveSearchNormalize: true,
liveSearchPlaceholder: "test",
liveSearchStyle: "contains",
maxOptions: 10,
maxOptionsText: "test",
mobile: true,
multipleSeparator: ", ",
noneSelectedText: "test",
selectAllText: "test",
selectedTextFormat: "values",
selectOnTab: true,
showContent: true,
showIcon: true,
showSubtext: true,
showTick: true,
size: "auto",
style: "test",
tickIcon: "test",
title: "test",
width: "auto"
})
$(".selectpicker").selectpicker("val", "foo")
$(".selectpicker").selectpicker("val", ["foo", "bar"])
$(".selectpicker").selectpicker("selectAll")
$(".selectpicker").selectpicker("setStyle", "btn-large", "add")
+44
View File
@@ -0,0 +1,44 @@
// Type definitions for bootstrap-select v1.11.2
// Project: https://silviomoreto.github.io/bootstrap-select/
// Definitions by: Karol Janyst <https://github.com/LKay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="jquery"/>
interface BootstrapSelectOptions {
actionsBox?: boolean
container?: string | boolean
countSelectedText?: string | Function
deselectAllText?: string
dropdownAlignRight?: string | boolean
dropupAuto?: boolean
header?: string
hideDisabled?: boolean
iconBase?: string
liveSearch?: boolean
liveSearchNormalize?: boolean
liveSearchPlaceholder?: string
liveSearchStyle?: string
maxOptions?: number | boolean
maxOptionsText?: string | Array<any> | Function
mobile?: boolean
multipleSeparator?: string
noneSelectedText?: string
selectAllText?: string
selectedTextFormat?: string
selectOnTab?: boolean
showContent?: boolean
showIcon?: boolean
showSubtext?: boolean
showTick?: boolean
size?: string | number | boolean
style?: string
tickIcon?: string
title?: string
width?: string | boolean
}
interface JQuery {
selectpicker(opts?: BootstrapSelectOptions): void
selectpicker(method: string, ...args: Array<string | Array<string>>): void
}

Some files were not shown because too many files have changed in this diff Show More