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

Many badly resolved merge conflicts
This commit is contained in:
Mine Yalcinalp Starks
2016-11-18 20:42:46 -08:00
562 changed files with 187068 additions and 145853 deletions
+1
View File
@@ -37,3 +37,4 @@ node_modules
.settings/launch.json
.vscode
yarn.lock
+4 -2
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)
@@ -1664,7 +1665,8 @@ This document generated by [dt-contributors-generator](https://github.com/vvakam
* [:link:](supertest/supertest.d.ts) [SuperTest](https://github.com/visionmedia/supertest) by [Alex Varju](https://github.com/varju)
* [:link:](supertest-as-promised/supertest-as-promised.d.ts) [SuperTest as Promised](https://github.com/WhoopInc/supertest-as-promised) by [Tanguy Krotoff](https://github.com/tkrotoff)
* [:link:](svg-injector/svg-injector.d.ts) [SVG Injector](https://github.com/iconic/SVGInjector) by [Patrick Westerhoff](https://github.com/poke)
* [:link:](svg-pan-zoom/svg-pan-zoom.d.ts) [svg-pan-zoom](https://github.com/ariutta/svg-pan-zoom) by [Chintan Shah](https://github.com/Promact)
* [:link:](svg-pan-zoom/svg-pan-zoom-2.3.9.d.ts) [svg-pan-zoom](https://github.com/ariutta/svg-pan-zoom) by [Chintan Shah](https://github.com/Promact)
* [:link:](svg-pan-zoom/svg-pan-zoom.d.ts) [svg-pan-zoom](https://github.com/ariutta/svg-pan-zoom) by [César Vidril](https://github.com/Yimiprod)
* [:link:](svg-sprite/svg-sprite.d.ts) [svg-sprite](https://github.com/jkphl/svg-sprite) by [Qubo](https://github.com/tkqubo)
* [:link:](svgjs/svgjs.d.ts) [svg.js](http://www.svgjs.com) by [Sean Hess](https://seanhess.github.io)
* [:link:](svg2png/svg2png.d.ts) [svg2png node package](https://github.com/domenic/svg2png) by [hans windhoff](https://github.com/hansrwindhoff)
+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.
+200 -14
View File
@@ -4,36 +4,222 @@
> 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 follow the steps below.
* See [CONTRIBUTORS.md](CONTRIBUTORS.md)
## Requested definitions
#### Test a new package
Add to your `tsconfig.json`:
```json
"baseUrl": "types",
"typeRoots": ["types"],
```
(You can also use `src/types`.)
Create `types/foo/index.d.ts` containing declarations for the module "foo".
You should now be able import from `"foo"` in your code and it will route to the new type definition.
Then build *and* run the code to make sure your type definition actually corresponds to what happens at runtime.
Once you've tested your definitions with real code, make a PR contributing the definition by copying `types/foo` to `DefinitelyTyped/foo` and adding a `tsconfig.json` and `foo-tests.ts`.
### 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.
+1 -1
View File
@@ -16,7 +16,7 @@ type Action = () => any;
type Callback = (err: Error) => any;
type AnyCallback = (err: Error, obj: any) => any;
type AllowedCallback = (err: Error, allowed: boolean) => any;
type GetUserId = (req: http.ServerRequest, res: http.ServerResponse) => Value;
type GetUserId = (req: http.IncomingMessage, res: http.ServerResponse) => Value;
interface AclStatic {
new (backend: Backend<any>, logger: Logger, options: Option): Acl;
+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;
+3
View File
@@ -24,6 +24,9 @@ declare namespace AmCharts {
/** Set it to true if you want UTC time to be used instead of local time. */
var useUTC: boolean;
/** Object with themes */
var themes: any;
/** Clears all the charts on page, removes listeners and intervals. */
function clear(): void;
+1
View File
@@ -18,6 +18,7 @@ declare module 'angular' {
interface tmhDynamicLocaleProvider extends angular.IServiceProvider {
localeLocationPattern(location: string): tmhDynamicLocaleProvider;
localeLocationPattern(): string;
storageKey(storageKey: string): void;
useStorage(storageName: string): void;
useCookieStorage(): void;
}
+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> {
@@ -337,6 +338,7 @@ declare module 'angular' {
onRemoving?: Function;
onDomRemoved?: Function;
origin?: string | JQuery | Element;
onCloseSuccess?: ((panel: IPanelRef, closeReason: string) => any);
}
interface IPanelRef {
@@ -409,6 +411,16 @@ declare module 'angular' {
interceptorTypes: {
CLOSE: string,
};
closeReasons: {
CLICK_OUTSIDE: string,
ESCAPE: string,
};
absPosition: {
TOP: string,
RIGHT: string,
BOTTOM: string,
LEFT: string,
};
}
}
}
+2 -4
View File
@@ -31,8 +31,6 @@ declare module 'angular' {
// Supports http/https/ftp/mailto and plain email address links.
// see http://code.angularjs.org/1.2.0/docs/api/ngSanitize.filter:linky
interface ILinky {
(text: string, target?: string): string;
}
(text: string, target: string, attributes?: { [attribute: string]: string } | ((url: string) => { [attribute: string]: string })): string;
}
}
}
}
+5
View File
@@ -6,6 +6,11 @@
/// <reference types="signalr" />
/// <reference types="angular" />
declare module "angular-signalr-hub" {
let _: string;
export = _;
}
declare namespace ngSignalr {
interface HubFactory {
/**
@@ -0,0 +1,39 @@
/// <reference path="./angular-ui-router-default.d.ts" />
angular.module("test", [
"ui.router",
"ui.router.default"
])
.config(function($stateProvider: angular.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");
}]
})
;
});
@@ -0,0 +1,17 @@
// 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
/// <reference path="../angular-ui-router/angular-ui-router.d.ts" />
declare namespace angular.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
}
}
@@ -0,0 +1,30 @@
/// <reference path="./angular-ui-router-uib-modal.d.ts" />
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"]
})
;
});
@@ -0,0 +1,12 @@
// 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
/// <reference path="../angular-ui-router/angular-ui-router.d.ts" />
declare namespace angular.ui {
interface IState {
modal?: boolean | string[];
}
}
+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);
}
}
+4 -4
View File
@@ -1043,6 +1043,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.
*/
@@ -1779,7 +1780,7 @@ declare namespace angular {
///////////////////////////////////////////////////////////////////////////
interface IDirectiveFactory {
(...args: any[]): IDirective;
(...args: any[]): IDirective | IDirectiveLinkFn;
}
interface IDirectiveLinkFn {
@@ -1787,8 +1788,8 @@ declare namespace angular {
scope: IScope,
instanceElement: JQuery,
instanceAttributes: IAttributes,
controller: {},
transclude: ITranscludeFunction
controller?: IController | IController[] | {[key: string]: IController},
transclude?: ITranscludeFunction
): void;
}
@@ -1816,7 +1817,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
View File
@@ -137,6 +137,7 @@ export declare class Connection extends events.EventEmitter {
}
export interface NotificationAlertOptions {
title?: string;
subtitle?: string;
body: string;
"title-loc-key"?: string;
"title-loc-args"?: string[];
+4 -4
View File
@@ -346,24 +346,24 @@ interface Client {
* Log an incoming http request to your server. The request data will be tracked during the response "finish" event if it is successful or the request "error"
* event if it fails. The request duration is automatically calculated as the timespan between when the trackRequest method was called, and when the response "finish"
* or request "error" events were fired.
* @param request The http.ServerRequest object to track
* @param request The http.IncomingMessage object to track
* @param response The http.ServerResponse object for this request
* @param properties map[string, string] - additional data used to filter requests in the portal. Defaults to empty.
*/
trackRequest(request: any /* http.ServerRequest */, response: any /* http.ServerResponse */, properties?: {
trackRequest(request: any /* http.IncomingMessage */, response: any /* http.ServerResponse */, properties?: {
[key: string]: string;
}): void;
/**
* Log an incoming http request to your server. The request data is tracked synchronously rather than waiting for the response "finish"" or request "error"" events.
* Use this if you need your request telemetry to respect custom app insights operation and user context (for example if you set any appInsights.client.context.tags).
* @param request The http.ServerRequest object to track
* @param request The http.IncomingMessage object to track
* @param response The http.ServerResponse object for this request
* @param ellapsedMilliseconds The duration for this request. Defaults to 0.
* @param properties map[string, string] - additional data used to filter requests in the portal. Defaults to empty.
* @param error An error that was returned for this request if it was unsuccessful. Defaults to null.
*/
trackRequestSync(request: any /*http.ServerRequest */, response: any /*http.ServerResponse */, ellapsedMilliseconds?: number, properties?: {
trackRequestSync(request: any /*http.IncomingMessage */, response: any /*http.ServerResponse */, ellapsedMilliseconds?: number, properties?: {
[key: string]: string;}, error?: any) : void;
/**
+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: {} });
+5
View File
@@ -25,6 +25,11 @@ interface nameInterface {
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;
}
+13 -4
View File
@@ -1,10 +1,15 @@
// Type definitions for assert and power-assert
// Project: https://github.com/Jxck/assert
// Project: https://github.com/twada/power-assert
// Type definitions for assert
// Project: https://github.com/defunctzombie/commonjs-assert
// Definitions by: vvakame <https://github.com/vvakame>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// copy from assert external module in node.d.ts
// Definitions for commonjs-assert match that of node.js' assert module,
// but commonjs-assert is intended to be used as an independent module,
// for instance when making a stand-alone site or app that doesn't have
// access to node modules. For that reason, these definitions define a
// "assert" module. This will conflict with node.d.ts and other assert
// modules such as "power-assert", but a project should realistically
// only be using one of these at a time.
declare function assert(value:any, message?:string):void;
declare namespace assert {
@@ -51,3 +56,7 @@ declare namespace assert {
export function ifError(value:any):void;
}
declare module "assert" {
export = assert;
}
+64
View File
@@ -0,0 +1,64 @@
/// <reference path="async-polling.d.ts" />
import * as AsyncPolling from "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();
+18
View File
@@ -0,0 +1,18 @@
// 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 module "async-polling" {
module AsyncPolling {
export type EventName = "run"|"start"|"error"|"result"|"end"|"schedule"|"stop";
}
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;
}
+390 -35
View File
@@ -1,23 +1,24 @@
var fs, path;
/// <reference types="async" />
/// <reference types="node" />
import * as fs from "fs";
function callback() {}
function funcStringCbErrBoolean(v:string, cb:(err:Error,res:boolean) => void) {}
async.map(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
async.mapSeries(['file1', 'file2', 'file3'], fs.stat, function (err, results) { });
async.mapLimit(['file1', 'file2', 'file3'], 2, fs.stat, function (err, results) { });
async.map(['file1', 'file2', 'file3'], fs.stat, function (err:Error, results:Array<fs.Stats>) { });
async.mapSeries(['file1', 'file2', 'file3'], fs.stat, function (err:Error, results:Array<fs.Stats>) { });
async.mapLimit(['file1', 'file2', 'file3'], 2, fs.stat, function (err:Error, results:Array<fs.Stats>) { });
async.filter(['file1', 'file2', 'file3'], path.exists, function (results) { });
async.filterSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
async.filterLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
async.select(['file1', 'file2', 'file3'], path.exists, function (results) { });
async.selectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
async.selectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
async.filter(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.filterSeries(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.filterLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.select(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.selectSeries(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.selectLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.reject(['file1', 'file2', 'file3'], path.exists, function (results) { });
async.rejectSeries(['file1', 'file2', 'file3'], path.exists, function (results) { });
async.rejectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (results) { });
async.reject(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.rejectSeries(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.rejectLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,results:Array<string>) { });
async.parallel([
function () { },
@@ -41,9 +42,9 @@ var openFilesObj = {
file2: "fileTwo"
}
var saveFile = function () { }
async.each(openFiles, saveFile, function (err) { });
async.eachSeries(openFiles, saveFile, function (err) { });
var saveFile = function (file:string,cb:(err:Error)=>void) { }
async.each(openFiles, saveFile, function (err:Error) { });
async.eachSeries(openFiles, saveFile, function (err:Error) { });
var documents, requestApi;
async.eachLimit(documents, 20, requestApi, function (err) { });
@@ -73,9 +74,9 @@ async.foldl(numArray, 0, reducer, function (err, result) { });
async.reduceRight(numArray, 0, reducer, function (err, result) { });
async.foldr(numArray, 0, reducer, function (err, result) { });
async.detect(['file1', 'file2', 'file3'], path.exists, function (result) { });
async.detectSeries(['file1', 'file2', 'file3'], path.exists, function (result) { });
async.detectLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
async.detect(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err,result:string) { });
async.detectSeries(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err,result) { });
async.detectLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err,result) { });
async.sortBy(['file1', 'file2', 'file3'], function (file, callback) {
fs.stat(file, function (err, stats) {
@@ -83,13 +84,13 @@ async.sortBy(['file1', 'file2', 'file3'], function (file, callback) {
});
}, function (err, results) { });
async.some(['file1', 'file2', 'file3'], path.exists, function (result) { });
async.someLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
async.any(['file1', 'file2', 'file3'], path.exists, function (result) { });
async.some(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,result:boolean) { });
async.someLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,result:boolean) { });
async.any(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,result:boolean) { });
async.every(['file1', 'file2', 'file3'], path.exists, function (result) { });
async.everyLimit(['file1', 'file2', 'file3'], 2, path.exists, function (result) { });
async.all(['file1', 'file2', 'file3'], path.exists, function (result) { });
async.every(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,result:boolean) { });
async.everyLimit(['file1', 'file2', 'file3'], 2, funcStringCbErrBoolean, function (err:Error,result:boolean) { });
async.all(['file1', 'file2', 'file3'], funcStringCbErrBoolean, function (err:Error,result:boolean) { });
async.concat(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { });
async.concatSeries(['dir1', 'dir2', 'dir3'], fs.readdir, function (err, files) { });
@@ -107,7 +108,7 @@ async.series([
],
function (err, results) { });
async.series<string>([
async.series<string,Error>([
function (callback) {
callback(null, 'one');
},
@@ -131,7 +132,7 @@ async.series({
},
function (err, results) { });
async.series<number>({
async.series<number,Error>({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
@@ -171,7 +172,7 @@ async.parallel([
],
function (err, results) { });
async.parallel<string>([
async.parallel<string,Error>([
function (callback) {
setTimeout(function () {
callback(null, 'one');
@@ -200,7 +201,7 @@ async.parallel({
},
function (err, results) { });
async.parallel<number>({
async.parallel<number,Error>({
one: function (callback) {
setTimeout(function () {
callback(null, 1);
@@ -266,7 +267,7 @@ async.waterfall([
], function (err, result) { });
var q = async.queue<any>(function (task: any, callback) {
var q = async.queue<any,Error>(function (task: any, callback) {
console.log('hello ' + task.name);
callback();
}, 2);
@@ -319,7 +320,7 @@ q.resume();
q.kill();
// tests for strongly typed tasks
var q2 = async.queue<string>(function (task: string, callback) {
var q2 = async.queue<string,Error>(function (task: string, callback) {
console.log('Task: ' + task);
callback();
}, 1);
@@ -382,10 +383,10 @@ async.retry({ times: 3, interval: (retryCount) => { return 200 * retryCount; } }
async.parallel([
function (callback) { },
function (callback: ( err:Error, val:string ) => void ) { },
function (callback) { }
],
function (results) {
function (err:Error,results:Array<string>) {
async.series([
function (callback) { },
function email_link(callback) { }
@@ -435,3 +436,357 @@ async.dir(function (name, callback) {
callback(null, { hello: name });
}, 1000);
}, "world");
// each
async.each<number,Error>({
"a": 1,
"b": 2
}, function(val: number, next: ErrorCallback<Error>): void {
setTimeout(function(): void {
console.log(`async.each: ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.each: done.");
});
async.eachSeries<number, Error>({
"a": 1,
"b": 2
}, function(val: number, next: ErrorCallback<Error>): void {
setTimeout(function(): void {
console.log(`async.eachSeries: ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.eachSeries: done.");
});
async.eachLimit<number, Error>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, next: ErrorCallback<Error>): 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, Error>({
"a": 1,
"b": 2
}, function(val: number, key: string, next: ErrorCallback<Error>): 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, Error>({
"a": 1,
"b": 2
}, function(val: number, key: string, next: ErrorCallback<Error>): void {
setTimeout(function(): void {
console.log(`async.forEachOfSeries: ${key} = ${val}`);
next();
}, 500);
}, function(err?: Error): void {
console.log("async.forEachOfSeries: done.");
});
async.forEachOfLimit<number, Error>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, key: string, next: ErrorCallback<Error>): 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, Error>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncResultCallback<string, Error>): void {
setTimeout(function(): void {
console.log(`async.map: ${val}`);
next(null, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.map: done with results", results);
});
async.mapSeries<number, string, Error>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncResultCallback<string, Error>): void {
setTimeout(function(): void {
console.log(`async.mapSeries: ${val}`);
next(null, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.mapSeries: done with results", results);
});
async.mapLimit<number, string, Error>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, next: AsyncResultCallback<string, Error>): void {
setTimeout(function(): void {
console.log(`async.mapLimit: ${val}`);
next(null, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.mapLimit: done with results", results);
});
// mapValues
async.mapValues<number, string, Error>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, key: string, next: AsyncResultCallback<string, Error>): void {
setTimeout(function(): void {
console.log(`async.mapValues: ${key} = ${val}`);
next(null, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.mapValues: done with results", results);
});
async.mapValuesSeries<number, string, Error>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, key: string, next: AsyncResultCallback<string, Error>): void {
setTimeout(function(): void {
console.log(`async.mapValuesSeries: ${key} = ${val}`);
next(null, val.toString());
}, 500);
}, function(err: Error, results: string[]): void {
console.log("async.mapValuesSeries: done with results", results);
});
// filter/select/reject
async.filter<number, Error>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncBooleanResultCallback<Error>): void {
setTimeout(function(): void {
console.log(`async.filter/select: ${val}`);
next(null, val % 2 === 0);
}, 500);
}, function(err: Error, results: number[]): void {
console.log("async.filter/select: done with results", results);
});
async.reject<number, Error>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncBooleanResultCallback<Error>): void {
setTimeout(function(): void {
console.log(`async.reject: ${val}`);
next(null, val % 2 === 0);
}, 500);
}, function(err: Error, results: number[]): void {
console.log("async.reject: done with results", results);
});
// concat
async.concat<string, string, Error>({
"a": "1",
"b": "2",
"c": "3"
}, function(item: string, next: AsyncResultCallback<string[], Error>): void {
console.log(`async.concat: ${item}`);
next(null, [item, item, item]);
}, function(err: Error, results: string[]) {
console.log("async.concat: done with results", results);
});
// detect/find
async.detect<number, Error>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
console.log(`async.detect/find: ${item}`);
next(null, 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,Error>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
console.log(`async.every/all: ${item}`);
next(null, item > 0);
}, function(err: Error, result: boolean) {
console.log("async.every/all: done with result", result);
});
// some/any
async.some<number, Error>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
console.log(`async.some/any: ${item}`);
next(null, item > 2);
}, function(err: Error, result: boolean) {
console.log("async.some/any: done with result", result);
});
+120 -100
View File
@@ -1,24 +1,26 @@
// 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 AsyncResultCallback<T> { (err: Error, result: T): void; }
interface AsyncResultArrayCallback<T> { (err: Error, results: T[]): void; }
interface AsyncResultObjectCallback<T> { (err: Error, results: Dictionary<T>): void; }
interface ErrorCallback<T> { (err?: T): void; }
interface AsyncWaterfallCallback<E> { (err: E, ...args: any[]): void; }
interface AsyncBooleanResultCallback<E> { (err: E, truthValue: boolean): void; }
interface AsyncResultCallback<T, E> { (err: E, result: T): void; }
interface AsyncResultArrayCallback<T, E> { (err: E, results: T[]): void; }
interface AsyncResultObjectCallback<T, E> { (err: E, results: Dictionary<T>): void; }
interface AsyncFunction<T> { (callback: (err?: Error, result?: T) => void): void; }
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 AsyncFunction<T, E> { (callback: (err?: E, result?: T) => void): void; }
interface AsyncIterator<T, E> { (item: T, callback: ErrorCallback<E>): void; }
interface AsyncForEachOfIterator<T, E> { (item: T, key: number|string, callback: ErrorCallback<E>): void; }
interface AsyncResultIterator<T, R, E> { (item: T, callback: AsyncResultCallback<R, E>): void; }
interface AsyncMemoIterator<T, R, E> { (memo: R, item: T, callback: AsyncResultCallback<R, E>): void; }
interface AsyncBooleanIterator<T, E> { (item: T, callback: AsyncBooleanResultCallback<E>): void; }
interface AsyncWorker<T> { (task: T, callback: ErrorCallback): void; }
interface AsyncVoidFunction { (callback: ErrorCallback): void; }
interface AsyncWorker<T, E> { (task: T, callback: ErrorCallback<E>): void; }
interface AsyncVoidFunction<E> { (callback: ErrorCallback<E>): void; }
interface AsyncQueue<T> {
length(): number;
@@ -26,10 +28,10 @@ interface AsyncQueue<T> {
running(): number;
idle(): boolean;
concurrency: number;
push(task: T, callback?: ErrorCallback): void;
push(task: T[], callback?: ErrorCallback): void;
unshift(task: T, callback?: ErrorCallback): void;
unshift(task: T[], callback?: ErrorCallback): void;
push<E>(task: T, callback?: ErrorCallback<E>): void;
push<E>(task: T[], callback?: ErrorCallback<E>): void;
unshift<E>(task: T, callback?: ErrorCallback<E>): void;
unshift<E>(task: T[], callback?: ErrorCallback<E>): void;
saturated: () => any;
empty: () => any;
drain: () => any;
@@ -51,8 +53,8 @@ interface AsyncPriorityQueue<T> {
concurrency: number;
started: boolean;
paused: boolean;
push(task: T, priority: number, callback?: AsyncResultArrayCallback<T>): void;
push(task: T[], priority: number, callback?: AsyncResultArrayCallback<T>): void;
push<E>(task: T, priority: number, callback?: AsyncResultArrayCallback<T, E>): void;
push<E>(task: T[], priority: number, callback?: AsyncResultArrayCallback<T, E>): void;
saturated: () => any;
empty: () => any;
drain: () => any;
@@ -88,104 +90,122 @@ interface AsyncCargo {
interface Async {
// Collections
each<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
eachSeries<T>(arr: T[], iterator: AsyncIterator<T>, callback?: ErrorCallback): void;
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;
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;
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;
each<T, E>(arr: T[], iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
each<T, E>(arr: Dictionary<T>, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
eachSeries: typeof async.each;
eachLimit<T, E>(arr: T[], limit: number, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
eachLimit<T, E>(arr: Dictionary<T>, limit: number, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
forEach: typeof async.each;
forEachSeries: typeof async.each;
forEachLimit: typeof async.eachLimit;
forEachOf<T, E>(obj: T[], iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
forEachOf<T, E>(obj: Dictionary<T>, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
forEachOfSeries: typeof async.forEachOf;
forEachOfLimit<T, E>(obj: T[], limit: number, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
forEachOfLimit<T, E>(obj: Dictionary<T>, limit: number, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
eachOf: typeof async.forEachOf;
eachOfSeries: typeof async.forEachOf;
eachOfLimit: typeof async.forEachOfLimit;
map<T, R, E>(arr: T[], iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
map<T, R, E>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
mapSeries: typeof async.map;
mapLimit<T, R, E>(arr: T[], limit: number, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
mapLimit<T, R, E>(arr: Dictionary<T>, limit: number, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
mapValuesLimit<T, R, E>(obj: Dictionary<T>, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultCallback<R[], E>): void;
mapValues<T, R, E>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultCallback<R[], E>): 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, E>(arr: T[], iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
filter<T, E>(arr: Dictionary<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
filterSeries: typeof async.filter;
filterLimit<T, E>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
filterLimit<T, E>(arr: Dictionary<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): 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, E>(arr: T[], memo: R, iterator: AsyncMemoIterator<T, R, E>, callback?: AsyncResultCallback<R, E>): void;
inject: typeof async.reduce;
foldl: typeof async.reduce;
reduceRight: typeof async.reduce;
foldr: typeof async.reduce;
detect<T, E>(arr: T[], iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
detect<T, E>(arr: Dictionary<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
detectSeries: typeof async.detect;
detectLimit<T, E>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
detectLimit<T, E>(arr: Dictionary<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): 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, E>(arr: T[], iterator: AsyncResultIterator<T, V, E>, callback?: AsyncResultArrayCallback<T, E>): void;
some<T, E>(arr: T[], iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
some<T, E>(arr: Dictionary<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
someSeries: typeof async.some;
someLimit<T, E>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
someLimit<T, E>(arr: Dictionary<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): 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, E>(arr: T[], iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
every<T, E>(arr: Dictionary<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
everySeries: typeof async.every;
everyLimit<T, E>(arr: T[], limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
everyLimit<T, E>(arr: Dictionary<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
all: typeof async.every;
allSeries: typeof async.every;
allLimit: typeof async.everyLimit;
concat<T, R, E>(arr: T[], iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
concat<T, R, E>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
concatSeries: typeof async.concat;
// Control Flow
series<T>(tasks: AsyncFunction<T>[], callback?: AsyncResultArrayCallback<T>): void;
series<T>(tasks: Dictionary<AsyncFunction<T>>, callback?: AsyncResultObjectCallback<T>): void;
parallel<T>(tasks: Array<AsyncFunction<T>>, callback?: AsyncResultArrayCallback<T>): void;
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;
series<T, E>(tasks: AsyncFunction<T, E>[], callback?: AsyncResultArrayCallback<T, E>): void;
series<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
parallel<T, E>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
parallel<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
parallelLimit<T, E>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
parallelLimit<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
whilst<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
doWhilst<E>(fn: AsyncVoidFunction<E>, test: () => boolean, callback: ErrorCallback<E>): void;
until<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
doUntil<E>(fn: AsyncVoidFunction<E>, test: () => boolean, callback: ErrorCallback<E>): void;
during<E>(test: (testCallback : AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
doDuring<E>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
forever<E>(next: (next : ErrorCallback<E>) => void, errBack: ErrorCallback<E>) : void;
waterfall<T, E>(tasks: Function[], callback?: AsyncResultCallback<T,E>): 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.
applyEachSeries(fns: Function[], argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
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;
retryable<T>(opts: number | {times: number, interval: number}, task: AsyncFunction<T>): AsyncFunction<T>;
apply(fn: Function, ...arguments: any[]): AsyncFunction<any>;
queue<T, E>(worker: AsyncWorker<T, E>, concurrency?: number): AsyncQueue<T>;
priorityQueue<T, E>(worker: AsyncWorker<T, E>, concurrency: number): AsyncPriorityQueue<T>;
cargo<E>(worker : (tasks: any[], callback : ErrorCallback<E>) => void, payload? : number) : AsyncCargo;
auto<E>(tasks: any, concurrency?: number, callback?: AsyncResultCallback<any, E>): void;
autoInject<E>(tasks: any, callback?: AsyncResultCallback<any, E>): void;
retry<T, E>(opts: number, task: (callback : AsyncResultCallback<T, E>, results: any) => void, callback: AsyncResultCallback<any, E>): void;
retry<T, E>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T, E>, results : any) => void, callback: AsyncResultCallback<any, E>): void;
retryable<T, E>(opts: number | {times: number, interval: number}, task: AsyncFunction<T, E>): AsyncFunction<T, E>;
apply<E>(fn: Function, ...arguments: any[]): AsyncFunction<any,E>;
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, E>(fn: AsyncFunction<T, E>) : (callback: (err: void, result: {error?: Error, value?: T}) => void) => void;
reflectAll<T, E>(tasks: AsyncFunction<T, E>[]): ((callback: (err: void, result: {error?: Error, value?: T}) => void) => void)[];
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)[];
timeout<T, E>(fn: AsyncFunction<T, E>, milliseconds: number, info: any): AsyncFunction<T, E>;
timeout<T>(fn: AsyncFunction<T>, milliseconds: number, info: any): AsyncFunction<T>;
times<T, E> (n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
timesSeries<T, E>(n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
timesLimit<T, E>(n: number, limit: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
times<T> (n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
timesSeries<T>(n: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
timesLimit<T>(n: number, limit: number, iterator: AsyncResultIterator<number, T>, callback: AsyncResultArrayCallback<T>): void;
transform<T, R, E>(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void;
transform<T, R, E>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void;
transform<T, R, E>(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void;
transform<T, R, E>(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void;
transform<T, R>(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: Error) => void) => void): void;
transform<T, R>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: string, callback: (error?: Error) => void) => void): void;
transform<T, R>(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: Error) => void) => void): void;
transform<T, R>(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: Error) => void) => void): void;
race<T>(tasks: (AsyncFunction<T>)[], callback: AsyncResultCallback<T>) : void;
race<T, E>(tasks: (AsyncFunction<T, E>)[], callback: AsyncResultCallback<T, E>) : void;
// Utils
memoize(fn: Function, hasher?: Function): Function;
+1 -1
View File
@@ -213,7 +213,7 @@ declare namespace autobahn {
retry_delay_jitter?: number;
url?: string;
protocols?: string[];
onchallenge?: (session: Session, method: string, extra: any) => OnChallengeHandler;
onchallenge?: OnChallengeHandler;
realm?: string;
authmethods?: string[];
authid?: string;
File diff suppressed because it is too large Load Diff
+559
View File
@@ -0,0 +1,559 @@
// Type definitions for automapper-ts
// Project: https://github.com/loedeman/AutoMapper
// Definitions by: Bert Loedeman <https://github.com/loedeman>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare module AutoMapperJs {
/**
* AutoMapper implementation, for both creating maps and performing maps. Comparable usage and functionality to the original
* .NET AutoMapper library is the pursuit of this implementation.
*/
class AutoMapper {
/**
* Initializes the mapper with the supplied configuration.
* @param {(config: IConfiguration) => void} Configuration function to call.
*/
initialize(configFunction: (config: IConfiguration) => void): void;
/**
* Create a createMap curry function which expects only a destination key.
* @param {string} sourceKey The map source key.
* @returns {(destinationKey: string) => ICreateMapFluentFunctions}
*/
createMap(sourceKey: string | (new() => any)): (destinationKey: string | (new() => any)) => ICreateMapFluentFunctions;
/**
* Create a mapping profile.
* @param {string} sourceKey The map source key.
* @param {string} destinationKey The map destination key.
* @returns {Core.ICreateMapFluentFunctions}
*/
createMap(sourceKey: string | (new() => any), destinationKey: string | (new() => any)): ICreateMapFluentFunctions;
/**
* Create a map curry function which expects a destination key and a source object.
* @param sourceKey Source key, for instance the source type name.
* @returns {(destinationKey: string, sourceObject: any) => any}
*/
map(sourceKey: string | (new() => any)): (destinationKey: string | (new() => any), sourceObject: any) => any;
/**
* Create a map curry function which expects only a source object.
* @param sourceKey Source key, for instance the source type name.
* @param destinationKey Destination key, for instance the destination type name.
* @returns {(sourceObject: any) => any}
*/
map(sourceKey: string | (new() => any), destinationKey: string | (new() => any)): (sourceObject: any) => any;
/**
* Execute a mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).
* @param sourceKey Source key, for instance the source type name.
* @param destinationKey Destination key, for instance the destination type name.
* @param sourceObject The source object to map.
* @returns {any} Destination object.
*/
map(sourceKey: string | (new() => any), destinationKey: string | (new() => any), sourceObject: any): any;
/**
* Create a mapAsync curry function which expects a destination key, a source object and a callback function.
* @param sourceKey Source key, for instance the source type name.
* @returns {(destinationKey: string, sourceObject: any, callback: IMapCallback) => void}
*/
mapAsync(sourceKey: string | (new() => any)): (destinationKey: string | (new() => any), sourceObject: any, callback: IMapCallback) => void;
/**
* Create a map curry function which expects only a source object and a callback function.
* @param sourceKey Source key, for instance the source type name.
* @param destinationKey Destination key, for instance the destination type name.
* @param sourceObject The source object to map.
* @returns {(callback: IMapCallback) => void}
*/
mapAsync(sourceKey: string | (new() => any), destinationKey: string | (new() => any), sourceObject: any): (callback: IMapCallback) => void;
/**
* Create a map curry function which expects only a source object and a callback function.
* @param sourceKey Source key, for instance the source type name.
* @param destinationKey Destination key, for instance the destination type name.
* @returns {(sourceObject: any, callback: IMapCallback) => void}
*/
mapAsync(sourceKey: string | (new() => any), destinationKey: string | (new() => any)): (sourceObject: any, callback: IMapCallback) => void;
/**
* Execute an asynchronous mapping from the source object to a new destination object with explicit mapping configuration and supplied mapping options (using createMap).
* @param sourceKey Source key, for instance the source type name.
* @param destinationKey Destination key, for instance the destination type name.
* @param sourceObject The source object to map.
* @param {IMapCallback} callback The callback to call when asynchronous mapping is complete.
*/
mapAsync(sourceKey: string | (new() => any), destinationKey: string | (new() => any), sourceObject: any, callback: IMapCallback): void;
/**
* Validates mapping configuration by dry-running. Since JS does not
* fully support typing, it only checks if properties match on both
* sides. The function needs IMapping.sourceTypeClass and
* IMapping.destinationTypeClass to function.
* @param {boolean} strictMode Whether or not to fail when properties
* sourceTypeClass or destinationTypeClass
* are unavailable.
*/
assertConfigurationIsValid(strictMode?: boolean): void;
}
class AsyncAutoMapper {
/* For Test Purposes Only */
}
/**
* Converts source type to destination type instead of normal member mapping
*/
class TypeConverter implements ITypeConverter {
/**
* Performs conversion from source to destination type.
* @param {IResolutionContext} resolutionContext Resolution context.
* @returns {any} Destination object.
*/
convert(resolutionContext: IResolutionContext): any;
}
export class Profile implements IProfile {
/** Profile name */
public profileName: string;
/** Naming convention for source members */
public sourceMemberNamingConvention: INamingConvention;
/** Naming convention for destination members */
public destinationMemberNamingConvention: INamingConvention;
/**
* Create a createMap curry function which expects only a destination key.
* @param {string} sourceKey The map source key.
* @returns {(destinationKey: string) => ICreateMapFluentFunctions}
*/
protected createMap(sourceKey: string): (destinationKey: string) => ICreateMapFluentFunctions;
/**
* Create a mapping profile.
* @param {string} sourceKey The map source key.
* @param {string} destinationKey The map destination key.
* @returns {Core.ICreateMapFluentFunctions}
*/
protected createMap(sourceKey: string, destinationKey: string): ICreateMapFluentFunctions;
/**
* Implement this method in a derived class and call the CreateMap method to associate that map with this profile.
* Avoid calling the AutoMapper class / automapper instance from this method.
*/
public configure(): void;
}
/**
* Defines the PascalCase naming convention strategy.
*/
class PascalCaseNamingConvention implements INamingConvention {
/** Regular expression on how to tokenize a member. */
splittingExpression: RegExp;
/** Character to separate on. */
separatorCharacter: string;
/**
* Transformation function called when this convention is the destination naming convention.
* @param {string[]} sourcePropertyNameParts Array containing tokenized source property name parts.
* @returns {string} Destination property name
*/
transformPropertyName(sourcePropertyNameParts: string[]): string;
}
/**
* Defines the camelCase naming convention strategy.
*/
class CamelCaseNamingConvention implements INamingConvention {
/** Regular expression on how to tokenize a member. */
splittingExpression: RegExp;
/** Character to separate on. */
separatorCharacter: string;
/**
* Transformation function called when this convention is the destination naming convention.
* @param {string[]} sourcePropertyNameParts Array containing tokenized source property name parts.
* @returns {string} Destination property name
*/
transformPropertyName(sourcePropertyNameParts: string[]): string;
}
interface IProperty {
name: string;
metadata: IPropertyMetadata;
level: number;
sourceMapping: boolean;
ignore: boolean;
async: boolean;
children?: IProperty[];
destinations?: IProperty[];
conversionValuesAndFunctions: any[];
conditionFunction?: (sourceObject: any) => boolean;
}
interface IPropertyMetadata {
mapping: IMapping;
root: IProperty;
parent: IProperty;
destinations: {[name: string]: IPropertyDestinationMetadata};
destinationCount: number;
}
interface IPropertyDestinationMetadata {
source: IProperty;
destination: IProperty;
}
interface IMemberMappingMetaData {
destination: string;
source: string;
sourceMapping: boolean;
ignore: boolean;
async: boolean;
condition: (sourceObject: any) => boolean;
}
/**
* Member mapping properties.
*/
interface IForMemberMapping {
/** The source member property name. */
sourceProperty: string;
/** The destination member property name parts for nested property support (e.g. 'type.name'). */
destinationProperty: string;
/** Source or destination mapping. */
sourceMapping: boolean;
/** All mapping values and/or functions resulting from stacked for(Source)Member calls. */
mappingValuesAndFunctions: Array<any>;
/** Whether or not this destination property must be ignored. */
ignore: boolean;
/** Whether or not this member mapping has an asynchronous mapping function. */
async: boolean;
/**
* The object will only be mapped when the condition is met.
* @param {any} sourceObject The source object to check.
* @returns {boolean}
*/
conditionFunction: (sourceObject: any) => boolean;
}
/**
* Interface for returning an object with available 'sub' functions to enable method chaining (e.g. automapper.createMap().forMember().forMember() ...)
*/
interface ICreateMapFluentFunctions {
/**
* Customize configuration for an individual destination member.
* @param sourceProperty The destination member property name.
* @param valueOrFunction The value or function to use for this individual member.
* @returns {IAutoMapperCreateMapChainingFunctions}
*/
forMember: (sourceProperty: string, valueOrFunction: any |
((opts: IMemberConfigurationOptions) => any) |
((opts: IMemberConfigurationOptions, cb: IMemberCallback) => void)) => ICreateMapFluentFunctions;
/**
* Customize configuration for an individual source member.
* @param sourceProperty The source member property name.
* @param sourceMemberConfigFunction The function to use for this individual member.
* @returns {IAutoMapperCreateMapChainingFunctions}
*/
forSourceMember: (sourceProperty: string,
sourceMemberConfigFunction: ((opts: ISourceMemberConfigurationOptions) => any) |
((opts: ISourceMemberConfigurationOptions, cb: IMemberCallback) => void)
) => ICreateMapFluentFunctions;
/**
* Customize configuration for all destination members.
* @param func The function to use for this individual member.
* @returns {IAutoMapperCreateMapChainingFunctions}
*/
forAllMembers: (func: (destinationObject: any, destinationPropertyName: string, value: any) => void) => ICreateMapFluentFunctions;
/**
* Ignore all members not specified explicitly.
*/
ignoreAllNonExisting: () => ICreateMapFluentFunctions;
/**
* Skip normal member mapping and convert using a custom type converter (instantiated during mapping).
* @param typeConverterClassOrFunction The converter class or function to use when converting.
*/
convertUsing: (typeConverterClassOrFunction: ((resolutionContext: IResolutionContext) => any) |
((resolutionContext: IResolutionContext, callback: IMapCallback) => void) |
ITypeConverter |
(new() => ITypeConverter)
) => void;
/**
* Specify to which class type AutoMapper should convert. When specified, AutoMapper will create an instance of the given type, instead of returning a new object literal.
* @param typeClass The destination type class.
* @returns {IAutoMapperCreateMapChainingFunctions}
*/
convertToType: (typeClass: new () => any) => ICreateMapFluentFunctions;
/**
* Specify which profile should be used when mapping.
* @param {string} profileName The profile name.
* @returns {IAutoMapperCreateMapChainingFunctions}
*/
withProfile: (profileName: string) => void;
}
/**
* The mapping configuration for the current mapping keys/types.
*/
interface IMapping {
/** The mapping source key. */
sourceKey: string;
/** The mapping destination key. */
destinationKey: string;
/** The mappings for forAllMembers functions. */
forAllMemberMappings: Array<(destinationObject: any, destinationPropertyName: string, value: any) => void>;
properties: IProperty[];
/**
* Skip normal member mapping and convert using a type converter.
* @param resolutionContext Context information regarding resolution of a destination value
* @returns {any} Destination object.
*/
typeConverterFunction: ((resolutionContext: IResolutionContext) => any) |
((resolutionContext: IResolutionContext, callback: IMapCallback) => void);
/** The source type class to convert from. */
sourceTypeClass: any;
/** The destination type class to convert to. */
destinationTypeClass: any;
/** The profile used when mapping. */
profile?: IProfile;
/** Whether or not to ignore all properties not specified using createMap. */
ignoreAllNonExisting?: boolean;
/** Whether or not an mapping has to be asynchronous. */
async: boolean;
/*
* PERFORMANCE ENHANCEMENTS
*/
/**
* Item mapping function to use.
*/
mapItemFunction: IMapItemFunction | IAsyncMapItemFunction;
}
// export interface IMappingMapOptimized extends IMapping {
// final: boolean;
// forMemberMappingsArray: Array<IForMemberMapping>;
// }
/**
* Context information regarding resolution of a destination value
*/
export interface IResolutionContext {
/** Source value */
sourceValue: any;
/** Destination value */
destinationValue: any;
/** Source property name */
sourcePropertyName?: string;
/** Destination property name */
destinationPropertyName?: string;
/** Index of current collection mapping */
arrayIndex?: number;
}
/**
* Configuration options for forMember mapping function.
*/
interface IMemberConfigurationOptions {
/**
* Map from a custom source property name.
* @param sourcePropertyName The source property to map.
*/
mapFrom: (sourcePropertyName: string) => void;
/**
* When this configuration function is used, the (destination) property is ignored
* when mapping.
*/
ignore?: () => void;
/**
* If specified, the property will only be mapped when the condition is fulfilled.
*/
condition: (predicate: ((sourceObject: any) => boolean)) => void;
/** The source object to map. */
sourceObject: any;
/** The source property to map. */
sourcePropertyName: string;
/**
* The intermediate destination property value, used for stacking multiple for(Source)Member calls
* while elaborating the intermediate result.
*/
intermediatePropertyValue: any;
}
/**
* Configuration options for forSourceMember mapping function.
*/
interface ISourceMemberConfigurationOptions {
/**
* When this configuration function is used, the source property is ignored
* when mapping.
*/
ignore: () => void;
}
/**
* Member callback interface
*/
interface IMemberCallback {
/**
* Callback function to call when the async operation is executed.
* @param {any} callbackValue Callback value to be used as output for the for(Source)Member call.
*/
(callbackValue: any): void;
}
/**
* Member callback interface
*/
interface IMapCallback {
/**
* Callback function to call when the async operation is executed.
* @param {any} result Callback value to be used as output for the mapAsync call.
*/
(result: any): void;
}
/**
* Converts source type to destination type instead of normal member mapping
*/
export interface ITypeConverter {
/**
* Performs conversion from source to destination type.
* @param {IResolutionContext} resolutionContext Resolution context.
* @returns {any} Destination object.
*/
convert: (resolutionContext: IResolutionContext) => any;
}
/**
* Defines a naming convention strategy.
*/
export interface INamingConvention {
/** Regular expression on how to tokenize a member. */
splittingExpression: RegExp;
/** Character to separate on. */
separatorCharacter: string;
/**
* Transformation function called when this convention is the destination naming convention.
* @param {string[]} sourcePropertyNameParts Array containing tokenized source property name parts.
* @returns {string} Destination property name
*/
transformPropertyName: (sourcePropertyNameParts: string[]) => string;
}
/**
* Configuration for profile-specific maps.
*/
export interface IConfiguration {
/**
* Add an existing profile
* @param profile {IProfile} Profile to add.
*/
addProfile(profile: IProfile): void;
/**
* Create a createMap curry function which expects only a destination key.
* @param {string} sourceKey The map source key.
* @returns {(destinationKey: string) => IAutoMapperCreateMapChainingFunctions}
*/
createMap?(sourceKey: string): (destinationKey: string) => ICreateMapFluentFunctions;
/**
* Create a mapping profile.
* @param {string} sourceKey The map source key.
* @param {string} destinationKey The map destination key.
* @returns {Core.IAutoMapperCreateMapChainingFunctions}
*/
createMap?(sourceKey: string, destinationKey: string): ICreateMapFluentFunctions;
}
/**
* Provides a named configuration for maps. Naming conventions become scoped per profile.
*/
export interface IProfile {
/** Profile name */
profileName: string;
/** Naming convention for source members */
sourceMemberNamingConvention: INamingConvention;
/** Naming convention for destination members */
destinationMemberNamingConvention: INamingConvention;
/**
* Implement this method in a derived class and call the CreateMap method to associate that map with this profile.
* Avoid calling the AutoMapper class / automapper instance from this method.
*/
configure: () => void;
}
export interface IMapItemFunction {
(mapping: IMapping, sourceObject: any, destinationObject: any): any;
}
export interface IAsyncMapItemFunction {
(mapping: IMapping, sourceObject: any, destinationObject: any, callback: IMapCallback): void;
}
interface ICreateMapParameters {
mapping: IMapping;
destinationProperty: string;
conversionValueOrFunction: any;
sourceMapping: boolean;
fluentFunctions: ICreateMapFluentFunctions;
}
interface IGetOrCreatePropertyParameters {
propertyNameParts: string[];
mapping: IMapping;
parent?: IProperty;
propertyArray: IProperty[];
destination?: string;
sourceMapping: boolean;
}
interface ICreatePropertyParameters {
name: string;
mapping: IMapping;
parent: IProperty;
propertyArray: IProperty[];
sourceMapping: boolean;
}
}
declare var automapper: AutoMapperJs.AutoMapper;
+57
View File
@@ -0,0 +1,57 @@
/// <reference path="awesomplete.d.ts" />
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;
}
+16 -7
View File
@@ -1,12 +1,12 @@
import lambda = require('aws-lambda');
var str: string;
var date: Date;
var anyObj: any;
var num: number;
var str: string = "any string";
var date: Date = new Date();
var anyObj: any = { abc: 123 };
var num: number = 5;
var identity: lambda.CognitoIdentity;
var error: Error;
var b: boolean;
var error: Error = new Error();
var b: boolean = true;
var clientCtx: lambda.ClientContext;
/* Context */
@@ -35,4 +35,13 @@ function callback(cb: lambda.Callback) {
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);
+3 -1
View File
@@ -23,7 +23,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;
+60 -3
View File
@@ -20,7 +20,28 @@ export class EnvironmentCredentials extends Credentials {
constructor(profile: string);
}
export interface Logger {
export module CognitoIdentity {
export interface CognitoIdentityCredentialsParams {
IdentityPoolId?: string;
AccountId?: string;
Logins?: {[k: string]: any};
RoleArn?: string;
RoleSessionName?: string;
WebIdentityToken?: string;
ProviderId?: string;
Policy?: string;
DurationSeconds?: number;
IdentityId?: string;
}
}
export class CognitoIdentityCredentials extends Credentials {
constructor(params: CognitoIdentity.CognitoIdentityCredentialsParams);
}
export interface Logger {
write?: (chunk: any, encoding?: string, callback?: () => void) => void;
log?: (...messages: any[]) => void;
}
@@ -357,7 +378,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;
@@ -501,7 +523,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
@@ -2232,6 +2255,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,29 @@
/// <reference path="./aws-serverless-express.d.ts" />
/// <reference path="../express/express.d.ts"/>
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);
+24
View File
@@ -0,0 +1,24 @@
// 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 path="../node/node.d.ts"/>
/// <reference path="../aws-lambda/aws-lambda.d.ts"/>
declare module 'aws-serverless-express' {
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;
}
+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
+1 -1
View File
@@ -346,7 +346,7 @@ export class NodePath<T> {
getData(key: string, def?: any): any;
buildCodeFrameError(msg: string, Error: Error): Error;
buildCodeFrameError<TError extends Error>(msg: string, Error?: new (msg: string) => TError): TError;
traverse(visitor: Visitor, state?: any): void;
+10
View File
@@ -0,0 +1,10 @@
/// <reference path="./bases.d.ts" />
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
+22
View File
@@ -0,0 +1,22 @@
// 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
declare module "bases" {
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;
}
+23
View File
@@ -336,6 +336,29 @@ fooOrBarProm = fooProm.caught(Promise.CancellationError, (reason: any) => {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
{
class CustomError extends Error {
public customField: number;
}
fooProm = fooProm.catch(CustomError, reason => {
let a: number = reason.customField
})
}
{
class CustomErrorWithConstructor extends Error {
constructor(public arg1: boolean, public arg2: number) {
super();
};
}
fooProm = fooProm.catch(CustomErrorWithConstructor, reason => {
let a: boolean = reason.arg1;
let b: number = reason.arg2;
})
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
barProm = fooProm.error((reason: any) => {
return bar;
});
+16 -4
View File
@@ -71,14 +71,19 @@ class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R> {
*/
catch(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(predicate: (error: any) => boolean, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(predicate: (error: any) => boolean, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch(ErrorClass: Function, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(ErrorClass: Function, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(ErrorClass: Function, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(ErrorClass: Function, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch<E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught<E extends Error>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<E extends Error, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<E extends Error, U>(ErrorClass: new (...args: any[]) => E, onReject: (error: E) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
catch(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
caught(predicate: Object, onReject: (error: any) => R | Bluebird.Thenable<R> | void | Bluebird.Thenable<void>): Bluebird<R>;
catch<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
caught<U>(predicate: Object, onReject: (error: any) => U | Bluebird.Thenable<U>): Bluebird<U | R>;
@@ -317,6 +322,13 @@ class Bluebird<R> implements Bluebird.Thenable<R>, Bluebird.Inspection<R> {
*/
cancel(): void;
/**
* Basically sugar for doing: somePromise.catch(function(){});
*
* Which is needed in case error handlers are attached asynchronously to the promise later, which would otherwise result in premature unhandled rejection reporting.
*/
suppressUnhandledRejections(): void;
/**
* Start the chain of promises with `Promise.try`. Any synchronous exceptions will be turned into rejections on the returned promise.
*
+21
View File
@@ -0,0 +1,21 @@
/// <reference path="bonjour.d.ts" />
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);
+71
View File
@@ -0,0 +1,71 @@
// 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
declare module "bonjour" {
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;
}
+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;
}
+1
View File
@@ -36,6 +36,7 @@ interface DatepickerOptions {
multidateSeparator?: string;
orientation?: string;
assumeNearbyYear?: any;
viewMode?: string;
}
interface DatepickerCustomFormatOptions {
+4 -1
View File
@@ -36,7 +36,10 @@ interface NotifySettings {
from?: string;
align?: string;
};
offset?: number;
offset?: number | {
x?: number;
y?: number;
};
spacing?: number;
z_index?: number;
delay?: number;
@@ -0,0 +1,43 @@
// Bootstrap Select Test
// ================================================================================
/// <reference path="bootstrap-select.d.ts" />
/// <reference path="../jquery/jquery.d.ts"/>
$(".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 path="../jquery/jquery.d.ts"/>
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
}
+12
View File
@@ -0,0 +1,12 @@
// Type definitions for Bootstrap Table v1.11.0
// Project: http://bootstrap-table.wenzhixin.net.cn/
// Definitions by: Talat Baig <https://github.com/talatbaig/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../jquery/jquery.d.ts" />
interface JQuery {
bootstrapTable(options?: any): JQuery;
}
declare var bootstrapTable: JQueryStatic;
+11 -3
View File
@@ -50,10 +50,18 @@ braintree.client.create({
selector: '#card-number'
},
cvv: {
selector: '#cvv'
selector: '#cvv',
type: 'password'
},
expirationDate: {
selector: '#expiration-date'
expirationMonth: {
selector: '#expiration-month',
select: {
options: ["01 - Jan", "02 - Feb", "03 - Mar", "04 - Apr", "05 - May", "06 - Jun", "07 - Jul", "08 - Aug", "09 - Sep", "10 - Oct", "11 - Nov", "12 - Dec"]
}
},
expirationYear: {
selector: '#expiration-year',
select: true
}
}
}, function (hostedFieldsErr?: BraintreeError, hostedFieldsInstance?: any) {
+7 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for Braintree-web v3.0.2
// Type definitions for Braintree-web v3.5.0
// Project: https://github.com/braintree/braintree-web
// Definitions by: Guy Shahine <https://github.com/chlela>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -540,12 +540,17 @@ declare namespace BraintreeWeb {
* @typedef {object} field
* @property {string} selector A CSS selector to find the container where the hosted field will be inserted.
* @property {string} [placeholder] Will be used as the `placeholder` attribute of the input. If `placeholder` is not natively supported by the browser, it will be polyfilled.
* @property {boolean} [formatInput=true] - Enable or disable automatic formatting on this field. Note: Input formatting does not work properly on Android and iOS, so input formatting is automatically disabled on those browsers.
* @property {string} [type] Will be used as the `type` attribute of the input. To mask `cvv` input, for instance, `type: "password"` can be used.
* @property {boolean} [formatInput=true] - Enable or disable automatic formatting on this field.
* @property {object|boolean} [select] If truthy, this field becomes a `<select>` dropdown list. This can only be used for `expirationMonth` and `expirationYear` fields.
* @property {string[]} [select.options] An array of 12 strings, one per month. This can only be used for the `expirationMonth` field. For example, the array can look like `['01 - January', '02 - February', ...]`.
*/
interface HostedFieldsField {
selector: string;
placeholder?: string;
type?: string;
formatInput?: boolean;
select?: boolean | { options: string[] };
}
/**
+2 -2
View File
@@ -286,11 +286,11 @@ declare namespace browserSync {
middleware?: MiddlewareHandler;
ws: boolean;
reqHeaders: (config: any) => Hash<any>;
proxyRes: (res: http.ServerResponse, req: http.ServerRequest, next: Function) => any;
proxyRes: (res: http.ServerResponse, req: http.IncomingMessage, next: Function) => any;
}
interface MiddlewareHandler {
(req: http.ServerRequest, res: http.ServerResponse, next: Function): any;
(req: http.IncomingMessage, res: http.ServerResponse, next: Function): any;
}
interface PerRouteMiddleware {
+1 -1
View File
@@ -104,7 +104,7 @@ declare module 'bufferstream/postbuffer' {
http client buffer
*/
constructor(req: http.ServerRequest);
constructor(req: http.IncomingMessage);
/*
set a callback to get all post data from a http server request
*/
+2 -2
View File
@@ -1,4 +1,4 @@
// Type definitions for bull 0.7.0
// Type definitions for bull 1.0.0
// Project: https://github.com/OptimalBits/bull
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -24,7 +24,7 @@ declare module "bull" {
export interface Job {
id: string
jobId: string
/**
* The custom data passed when the job was created
+41
View File
@@ -0,0 +1,41 @@
/// <reference path="bunyan-config.d.ts"/>
import * as bunyan from "bunyan";
import bunyanConfig = require("bunyan-config");
var jsonConfig = {
name: "myLogger",
streams: [{
stream: "stdout"
}, {
stream: { name: "stderr" }
}, {
type: "raw",
stream: {
name: "bunyan-logstash",
params: {
host: "localhost",
port: 5005
}
}
}, {
type: "raw",
stream: {
name: "bunyan-redis",
params: {
host: "localhost",
port: 6379
}
}
}], serializers: {
req: "bunyan:stdSerializers.req",
fromNodeModules: "someNodeModule",
fromNodeModulesWithProps: "someNodeModule:a.b.c",
custom: "./lib/customSerializers:custom",
another: "./lib/anotherSerializer",
absolutePath: "/path/to/serializer:xyz"
}
};
var config = bunyanConfig(jsonConfig);
var logger = require("bunyan").createLogger(bunyanConfig);
+31
View File
@@ -0,0 +1,31 @@
// Type definitions for bunyan-config 0.2.0
// Project: https://github.com/LSEducation/bunyan-config
// Definitions by: Cyril Schumacher <https://github.com/cyrilschumacher>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../bunyan/bunyan.d.ts"/>
declare module "bunyan-config" {
import * as bunyan from "bunyan";
/**
* Configuration.
* @interface
*/
interface Configuration {
name: string;
streams?: bunyan.Stream[];
level?: string | number;
stream?: NodeJS.WritableStream;
serializers?: {};
src?: boolean;
}
/**
* Constructor.
* @param {Configuration} [jsonConfig] A JSON configuration.
* @return {LoggerOptions} A logger options.
*/
function bunyanConfig(jsonConfig?: Configuration): bunyan.LoggerOptions;
export = bunyanConfig;
}
+13
View File
@@ -55,7 +55,20 @@ var options:bunyan.LoggerOptions = {
var log = bunyan.createLogger(options);
var customSerializer = function(anything: any) {
return { obj: anything};
};
log.addSerializers({anything: customSerializer});
log.addSerializers(bunyan.stdSerializers);
log.addSerializers(
{
err: bunyan.stdSerializers.err,
req: bunyan.stdSerializers.req,
res: bunyan.stdSerializers.res
}
);
var child = log.child({name: 'child'});
child.reopenFileStreams();
log.addStream({path: '/dev/null'});
+13 -3
View File
@@ -11,7 +11,7 @@ import { EventEmitter } from 'events';
declare class Logger extends EventEmitter {
constructor(options: LoggerOptions);
addStream(stream: Stream): void;
addSerializers(serializers: Serializers): void;
addSerializers(serializers:Serializers | StdSerializers): void;
child(options: LoggerOptions, simple?: boolean): Logger;
child(obj: Object, simple?: boolean): Logger;
reopenFileStreams(): void;
@@ -58,8 +58,18 @@ interface LoggerOptions {
src?: boolean;
}
interface Serializer {
(input:any): any;
}
interface Serializers {
[key: string]: (input: any) => string;
[key: string]: Serializer
}
interface StdSerializers {
err: Serializer;
res: Serializer;
req: Serializer;
}
interface Stream {
@@ -72,7 +82,7 @@ interface Stream {
count?: number;
}
export declare var stdSerializers: Serializers;
export declare var stdSerializers: StdSerializers;
export declare var TRACE: number;
export declare var DEBUG: number;
+1 -1
View File
@@ -5,7 +5,7 @@ import * as Busboy from 'busboy';
import * as http from 'http';
import * as util from 'util';
function serverFn(req: http.ServerRequest, res: http.ServerResponse) {
function serverFn(req: http.IncomingMessage, res: http.ServerResponse) {
if (req.method === 'POST') {
var busboy = new Busboy({ headers: req.headers });
busboy.on('file', function(fieldname, file, filename, encoding, mimetype) {
+43
View File
@@ -0,0 +1,43 @@
/// <reference path="./bwip-js.d.ts" />
/// <reference path="../node/node.d.ts" />
'use strict';
import * as bwipjs from 'bwip-js';
import * as http from 'http';
import * as fs from 'fs';
bwipjs.loadFont('Inconsolata', 108,
fs.readFileSync('fonts/Inconsolata.otf', 'binary'));
http.createServer(function(req, res) {
// If the url does not begin /?bcid= then 404. Otherwise, we end up
// returning 400 on requests like favicon.ico.
if (req.url.indexOf('/?bcid=') != 0) {
res.writeHead(404, { 'Content-Type':'text/plain' });
res.end('BWIPJS: Unknown request format.', 'utf8');
} else {
bwipjs(req, res);
}
}).listen(3030);
bwipjs.toBuffer({
bcid: 'code128', // Barcode type
text: '0123456789', // Text to encode
scale: 3, // 3x scaling factor
height: 10, // Bar height, in millimeters
includetext: true, // Show human-readable text
textxalign: 'center', // Always good to set this
textfont: 'Inconsolata', // Use your custom font
textsize: 13 // Font size, in points
}, function (err:string|Error, png: Buffer) {
if (err) {
console.log(err);
} else {
// `png` is a Buffer
// png.length : PNG file length
// png.readUInt32BE(16) : PNG image width
// png.readUInt32BE(20) : PNG image height
}
});
+86
View File
@@ -0,0 +1,86 @@
// Type definitions for bwip-js 1.1.1
// Project: https://github.com/metafloor/bwip-js
// Definitions by: TANAKA Koichi <https://github.com/MugeSo/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module 'bwip-js' {
import {IncomingMessage as Request, ServerResponse as Response} from 'http';
module BwipJs {
export function loadFont(fontName:string, sizeMulti: number, fontFile: string): void;
export function toBuffer(opts: ToBufferOptions, callback:(err: string|Error, png: Buffer) => void): void;
interface ToBufferOptions {
bcid: string;
text: string;
parse?: boolean;
parsefunc?: boolean;
height?: number;
width?: number;
scaleX?: number;
scaleY?: number;
scale?: number;
rotate?: 'N'|'R'|'L'|'I';
paddingwidth?: number;
paddingheight?: number;
monochrome?: boolean;
alttext?: boolean;
includetext?: boolean;
textfont?: string;
textsize?: number;
textgaps?: number;
textxalign?:'offleft'|'left'|'center'|'right'|'offright'|'justify';
textyalign?:'below'|'center'|'above';
textxoffset?: number;
textyoffset?: number;
showborder?: boolean;
borderwidth?: number;
borderleft?: number;
borderright?: number;
bordertop?: number;
boraderbottom?: number;
barcolor?: string;
backgroundcolor?: string;
bordercolor?: string;
textcolor?: string;
addontextxoffset?: number;
addontextyoffset?: number;
addontextfont?: string;
addontextsize?: number;
guardwhitespace?: boolean;
guardwidth?: number;
guardheight?: number;
guardleftpos?: number;
guardrightpos?: number;
guardleftypos?: number;
guardrightypos?: number;
sizelimit?: number;
includecheck?: boolean;
includecheckintext?: boolean;
inkspread?: number;
inkspreadh?: number;
inkspreadv?: number;
}
}
function BwipJs(req: Request, res: Response, opts?:BwipJs.ToBufferOptions): void;
export = BwipJs;
}
+3 -2
View File
@@ -6,8 +6,9 @@
import fs = require( 'fs' );
import byline = require( 'byline' );
//TODO can this be typed in an ambient way?
//var stream = byline( fs.createReadStream( 'sample.txt', {encoding: 'utf8'} ) );
var stream = byline();
var stream = byline( fs.createReadStream( 'sample.txt', {encoding: 'utf8'} ) );
var stream = byline.createStream( fs.createReadStream( 'sample.txt', {encoding: 'utf8'} ) );
+24 -27
View File
@@ -5,33 +5,30 @@
/// <reference types="node" />
declare module "byline" {
import stream = require("stream");
import stream = require("stream");
function bl(): bl.LineStream;
function bl(stream: NodeJS.ReadableStream, options?: bl.LineStreamOptions): bl.LineStream;
export interface LineStreamOptions extends stream.TransformOptions {
keepEmptyLines?: boolean;
namespace bl {
export interface LineStreamOptions extends stream.TransformOptions {
keepEmptyLines?: boolean;
}
export interface LineStream extends stream.Transform {
}
export interface LineStreamCreatable extends LineStream {
new (options?: LineStreamOptions): LineStream
}
export function createStream(): LineStream;
export function createStream(stream: NodeJS.ReadableStream, options?: LineStreamOptions): LineStream;
export var LineStream: LineStreamCreatable;
}
export = bl;
}
export interface LineStream extends stream.Transform {
}
export interface LineStreamCreatable extends LineStream {
new (options?: LineStreamOptions): LineStream
}
//TODO is it possible to declare static factory functions without name (directly on the module)
//
// JS:
// // convinience API
// module.exports = function(readStream, options) {
// return module.exports.createStream(readStream, options);
// };
//
// TS:
// ():LineStream; // same as createStream():LineStream
// (stream:stream.Stream, options?:LineStreamOptions):LineStream; // same as createStream(stream, options?):LineStream
export declare function createStream(): LineStream;
export declare function createStream(stream: NodeJS.ReadableStream, options?: LineStreamOptions): LineStream;
export declare var LineStream: LineStreamCreatable;
+4 -4
View File
@@ -385,10 +385,10 @@ declare namespace c3 {
* - d is the data where mouse cursor moves out. In this callback, this will be the Chart object.
*/
onmouseout?: (d: any, element?: any) => void;
// onselected?: any;
// onunselected?: any;
// ondragstart?: any;
// ondragend?: any;
onselected?: (d: any, element?: any) => void;
onunselected?: (d: any, element?: any) => void;
}
interface Axis {
+68 -43
View File
@@ -7,19 +7,20 @@
declare class CamlBuilder {
constructor();
/** Generate CAML Query, starting from <Where> tag */
public Where(): CamlBuilder.IFieldExpression;
Where(): CamlBuilder.IFieldExpression;
/** Generate <View> tag for SP.CamlQuery
@param viewFields If omitted, default view fields are requested; otherwise, only values for the fields with the specified internal names are returned.
Specifying view fields is a good practice, as it decreases traffic between server and client. */
public View(viewFields?: string[]): CamlBuilder.IView;
@param viewFields If omitted, default view fields are requested; otherwise, only values for the fields with the specified internal names are returned.
Specifying view fields is a good practice, as it decreases traffic between server and client. */
View(viewFields?: string[]): CamlBuilder.IView;
/** Generate <ViewFields> tag for SPServices */
public ViewFields(viewFields: string[]): CamlBuilder.IFinalizableToString;
ViewFields(viewFields: string[]): CamlBuilder.IFinalizableToString;
/** Use for:
1. SPServices CAMLQuery attribute
2. Creating partial expressions
3. In conjunction with Any & All clauses
*/
1. SPServices CAMLQuery attribute
2. Creating partial expressions
3. In conjunction with Any & All clauses
*/
static Expression(): CamlBuilder.IFieldExpression;
static FromXml(xml: string): CamlBuilder.IRawQuery;
}
declare namespace CamlBuilder {
interface IView extends IJoinable, IFinalizable {
@@ -29,24 +30,24 @@ declare namespace CamlBuilder {
}
interface IJoinable {
/** Join the list you're querying with another list.
Joins are only allowed through a lookup field relation.
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
@alias alias for the joined list */
Joins are only allowed through a lookup field relation.
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
@alias alias for the joined list */
InnerJoin(lookupFieldInternalName: string, alias: string): IJoin;
/** Join the list you're querying with another list.
Joins are only allowed through a lookup field relation.
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
@alias alias for the joined list */
Joins are only allowed through a lookup field relation.
@param lookupFieldInternalName Internal name of the lookup field, that points to the list you're going to join in.
@alias alias for the joined list */
LeftJoin(lookupFieldInternalName: string, alias: string): IJoin;
}
interface IJoin extends IJoinable {
/** Select projected field for using in the main Query body
@param remoteFieldAlias By this alias, the field can be used in the main Query body. */
@param remoteFieldAlias By this alias, the field can be used in the main Query body. */
Select(remoteFieldInternalName: string, remoteFieldAlias: string): IProjectableView;
}
interface IProjectableView extends IView {
/** Select projected field for using in the main Query body
@param remoteFieldAlias By this alias, the field can be used in the main Query body. */
@param remoteFieldAlias By this alias, the field can be used in the main Query body. */
Select(remoteFieldInternalName: string, remoteFieldAlias: string): IProjectableView;
}
enum ViewScope {
@@ -57,7 +58,7 @@ declare namespace CamlBuilder {
/** */
FilesOnly = 2,
}
interface IQuery {
interface IQuery extends IGroupable {
Where(): IFieldExpression;
}
interface IFinalizableToString {
@@ -70,21 +71,21 @@ declare namespace CamlBuilder {
}
interface ISortable extends IFinalizable {
/** Adds OrderBy clause to the query
@param fieldInternalName Internal field of the first field by that the data will be sorted (ascending)
@param override This is only necessary for large lists. DON'T use it unless you know what it is for!
@param useIndexForOrderBy This is only necessary for large lists. DON'T use it unless you know what it is for!
@param fieldInternalName Internal field of the first field by that the data will be sorted (ascending)
@param override This is only necessary for large lists. DON'T use it unless you know what it is for!
@param useIndexForOrderBy This is only necessary for large lists. DON'T use it unless you know what it is for!
*/
OrderBy(fieldInternalName: string, override?: boolean, useIndexForOrderBy?: boolean): ISortedQuery;
/** Adds OrderBy clause to the query (using descending order for the first field).
@param fieldInternalName Internal field of the first field by that the data will be sorted (descending)
@param override This is only necessary for large lists. DON'T use it unless you know what it is for!
@param useIndexForOrderBy This is only necessary for large lists. DON'T use it unless you know what it is for!
@param fieldInternalName Internal field of the first field by that the data will be sorted (descending)
@param override This is only necessary for large lists. DON'T use it unless you know what it is for!
@param useIndexForOrderBy This is only necessary for large lists. DON'T use it unless you know what it is for!
*/
OrderByDesc(fieldInternalName: string, override?: boolean, useIndexForOrderBy?: boolean): ISortedQuery;
}
interface IGroupable extends ISortable {
/** Adds GroupBy clause to the query.
@param collapse If true, only information about the groups is retrieved, otherwise items are also retrieved. */
@param collapse If true, only information about the groups is retrieved, otherwise items are also retrieved. */
GroupBy(fieldInternalName: any): IGroupedQuery;
}
interface IExpression extends IGroupable {
@@ -134,17 +135,19 @@ declare namespace CamlBuilder {
DateField(internalName: string): IDateTimeFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is DateTime */
DateTimeField(internalName: string): IDateTimeFieldExpression;
/** Specifies that a condition will be tested against the field with the specified internal name, and the type of this field is ModStat (moderation status) */
ModStatField(internalName: string): IModStatFieldExpression;
/** Used in queries for retrieving recurring calendar events.
NOTICE: DateRangesOverlap with overlapType other than Now cannot be used with SP.CamlQuery, because it doesn't support
CalendarDate and ExpandRecurrence query options. Lists.asmx, however, supports them, so you can still use DateRangesOverlap
with SPServices.
@param overlapType Defines type of overlap: return all events for a day, for a week, for a month or for a year
@param calendarDate Defines date that will be used for determining events for which exactly day/week/month/year will be returned.
This value is ignored for overlapType=Now, but for the other overlap types it is mandatory.
@param eventDateField Internal name of "Start Time" field (default: "EventDate" - all OOTB Calendar lists use this name)
@param endDateField Internal name of "End Time" field (default: "EndDate" - all OOTB Calendar lists use this name)
@param recurrenceIDField Internal name of "Recurrence ID" field (default: "RecurrenceID" - all OOTB Calendar lists use this name)
*/
NOTICE: DateRangesOverlap with overlapType other than Now cannot be used with SP.CamlQuery, because it doesn't support
CalendarDate and ExpandRecurrence query options. Lists.asmx, however, supports them, so you can still use DateRangesOverlap
with SPServices.
@param overlapType Defines type of overlap: return all events for a day, for a week, for a month or for a year
@param calendarDate Defines date that will be used for determining events for which exactly day/week/month/year will be returned.
This value is ignored for overlapType=Now, but for the other overlap types it is mandatory.
@param eventDateField Internal name of "Start Time" field (default: "EventDate" - all OOTB Calendar lists use this name)
@param endDateField Internal name of "End Time" field (default: "EndDate" - all OOTB Calendar lists use this name)
@param recurrenceIDField Internal name of "Recurrence ID" field (default: "RecurrenceID" - all OOTB Calendar lists use this name)
*/
DateRangesOverlap(overlapType: DateRangesOverlapType, calendarDate: string, eventDateField?: string, endDateField?: string, recurrenceIDField?: string): IExpression;
}
interface IBooleanFieldExpression {
@@ -201,25 +204,25 @@ declare namespace CamlBuilder {
/** Checks whether the value of the field is equal to one of the specified values */
In(arrayOfValues: Date[]): IExpression;
/** Checks whether the value of the field is equal to the specified value.
The datetime value should be defined in ISO 8601 format! */
The datetime value should be defined in ISO 8601 format! */
EqualTo(value: string): IExpression;
/** Checks whether the value of the field is not equal to the specified value.
The datetime value should be defined in ISO 8601 format! */
The datetime value should be defined in ISO 8601 format! */
NotEqualTo(value: string): IExpression;
/** Checks whether the value of the field is greater than the specified value.
The datetime value should be defined in ISO 8601 format! */
The datetime value should be defined in ISO 8601 format! */
GreaterThan(value: string): IExpression;
/** Checks whether the value of the field is less than the specified value.
The datetime value should be defined in ISO 8601 format! */
The datetime value should be defined in ISO 8601 format! */
LessThan(value: string): IExpression;
/** Checks whether the value of the field is greater than or equal to the specified value.
The datetime value should be defined in ISO 8601 format! */
The datetime value should be defined in ISO 8601 format! */
GreaterThanOrEqualTo(value: string): IExpression;
/** Checks whether the value of the field is less than or equal to the specified value.
The datetime value should be defined in ISO 8601 format! */
The datetime value should be defined in ISO 8601 format! */
LessThanOrEqualTo(value: string): IExpression;
/** Checks whether the value of the field is equal to one of the specified values.
The datetime value should be defined in ISO 8601 format! */
The datetime value should be defined in ISO 8601 format! */
In(arrayOfValues: string[]): IExpression;
}
interface ITextFieldExpression {
@@ -322,6 +325,27 @@ declare namespace CamlBuilder {
/** DEPRECATED: "Neq" operation in CAML works exactly the same as "NotIncludes". To avoid confusion, please use NotIncludes. */
NotEqualTo(value: any): IExpression;
}
interface IModStatFieldExpression {
/** Represents moderation status ID. */
ModStatId(): INumberFieldExpression;
/** Checks whether the value of the field is Approved - same as ModStatId.EqualTo(0) */
IsApproved(): IExpression;
/** Checks whether the value of the field is Rejected - same as ModStatId.EqualTo(1) */
IsRejected(): IExpression;
/** Checks whether the value of the field is Pending - same as ModStatId.EqualTo(2) */
IsPending(): IExpression;
/** Represents moderation status as localized text. In most cases it is better to use ModStatId in the queries instead of ValueAsText. */
ValueAsText(): ITextFieldExpression;
}
interface IRawQuery {
/** Change Where clause */
ReplaceWhere(): IFieldExpression;
ModifyWhere(): IRawQueryModify;
}
interface IRawQueryModify {
AppendOr(): IFieldExpression;
AppendAnd(): IFieldExpression;
}
enum DateRangesOverlapType {
/** Returns events for today */
Now = 0,
@@ -330,7 +354,7 @@ declare namespace CamlBuilder {
/** Returns events for one week, specified by CalendarDate in QueryOptions */
Week = 2,
/** Returns events for one month, specified by CalendarDate in QueryOptions.
Caution: usually also returns few days from previous and next months */
Caution: usually also returns few days from previous and next months */
Month = 3,
/** Returns events for one year, specified by CalendarDate in QueryOptions */
Year = 4,
@@ -340,6 +364,7 @@ declare namespace CamlBuilder {
static createViewFields(viewFields: string[]): IFinalizableToString;
static createWhere(): IFieldExpression;
static createExpression(): IFieldExpression;
static createRawQuery(xml: string): IRawQuery;
}
class CamlValues {
/** Dynamic value that represents Id of the current user */
+4 -2
View File
@@ -8,10 +8,12 @@ import {
} from 'canvas-gauges';
let linearOptions: LinearGaugeOptions = {
renderTo: document.createElement('canvas')
renderTo: document.createElement('canvas'),
fontNumbersStyle: 'italic'
};
let radialOptions: RadialGaugeOptions = {
renderTo: 'gauge-id'
renderTo: 'gauge-id',
fontNumbersWeight: 'bold'
};
new LinearGauge(linearOptions);
+16 -2
View File
@@ -1,9 +1,13 @@
// Type definitions for canvas-gauges
// Type definitions for canvas-gauges v2.0.8
// Project: https://github.com/Mikhus/canvas-gauges
// Definitions by: Mikhus <https://github.com/Mikhus>
// Definitions: https://github.com/Mikhus/DefinitelyTyped
declare namespace CanvasGauges {
export type FontStyle = 'normal' | 'italic' | 'oblique';
export type FontWeight = 'normal' | 'bold' | 'bolder' | 'lighter' |
'100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
export type RenderTarget = string|HTMLElement;
export interface AnimationRule {
@@ -74,11 +78,13 @@ declare namespace CanvasGauges {
borderInnerWidth?: number,
borderShadowWidth?: number,
valueBox?: boolean,
valueBoxWidth?: number,
valueBoxStroke?: number,
valueText?: string,
valueTextShadow?: boolean,
valueBoxBorderRadius?: number,
highlights?: Highlight[],
highlightsWidth?: number,
fontNumbers?: string,
fontTitle?: string,
fontUnits?: string,
@@ -86,7 +92,15 @@ declare namespace CanvasGauges {
fontTitleSize?: number,
fontValueSize?: number,
fontUnitsSize?: number,
fontNumbersSize?: number
fontNumbersSize?: number,
fontTitleStyle?: FontStyle,
fontValueStyle?: FontStyle,
fontUnitsStyle?: FontStyle,
fontNumbersStyle?: FontStyle,
fontTitleWeight?: FontWeight,
fontValueWeight?: FontWeight,
fontUnitsWeight?: FontWeight,
fontNumbersWeight?: FontWeight
}
export interface RadialGaugeOptions extends GenericOptions {
+30 -14
View File
@@ -376,7 +376,7 @@ declare namespace CanvasJS {
dataSeriesIndex: number;
}
interface ChartAxisXOptions {
interface ChartAxisOptions {
/**
* Sets the Axis Title.
* Default: null
@@ -472,18 +472,6 @@ declare namespace CanvasJS {
*/
valueFormatString?: string;
/**
* Sets the minimum value of Axis. Values smaller than minimum are clipped.
* Default: Automatically Calculated based on the data
* Example: 100, 350..
*/
minimum?: number;
/**
* Sets the maximum value permitted on Axis. Values greater than maximum are clipped.
* Default: Automatically Calculated based on the data
* Example: 100, 350..
*/
maximum?: number;
/**
* Sets the distance between Tick Marks, Grid Lines and Interlaced Colors.
* Default: Automatically Calculated
* Example: 50, 75..
@@ -638,13 +626,41 @@ declare namespace CanvasJS {
labelFontStyle?: string;
}
interface ChartAxisYOptions extends ChartAxisXOptions {
interface ChartAxisXOptions extends ChartAxisOptions {
/**
* Sets the minimum value of Axis. Values smaller than minimum are clipped.
* Default: Automatically Calculated based on the data
* Example: 100, 350..
*/
minimum?: number | Date;
/**
* Sets the maximum value permitted on Axis. Values greater than maximum are clipped.
* Default: Automatically Calculated based on the data
* Example: 100, 350..
*/
maximum?: number | Date;
}
interface ChartAxisYOptions extends ChartAxisOptions {
/**
* When includeZero is set to true, axisY sets the range in such a way that Zero is a part of it. It is set to true by default. But, whenever y values are very big and difference among dataPoints are hard to judge, setting includeZero to false makes axisY to set a range that makes the differences prominently visible.
* Default: true
* Example: true, false
*/
includeZero?: boolean;
/**
* Sets the minimum value of Axis. Values smaller than minimum are clipped.
* Default: Automatically Calculated based on the data
* Example: 100, 350..
*/
minimum?: number;
/**
* Sets the maximum value permitted on Axis. Values greater than maximum are clipped.
* Default: Automatically Calculated based on the data
* Example: 100, 350..
*/
maximum?: number;
}
interface ChartToolTipOptions {
+495
View File
@@ -0,0 +1,495 @@
// Type definitions for Cash
// Project: https://github.com/kenwheeler/cash
// Definitions by: Ashok Vishwakarma <https://github.com/akvlko>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* OffsetType
* return type for cash.offset(), cash.position()
*/
interface OffsetType {
top: number;
left: number;
}
/**
* CashStatic
* Static declaration for CashJs accessible directly using Cash object or $
*/
interface CashStatic {
/**
* isArray
* Check if the argument is an array.
* @type method
* @argument any
* @return boolean
*/
isArray(n: any): boolean;
/**
* isFunction
* Check if the argument is a function.
* @type method
* @argument any
* @return boolean
*/
isFunction(n: any): boolean;
/**
* isNumeric
* Check if the argument is numeric.
* @type method
* @type method
* @argument any
* @return boolean
*/
isNumeric(n: any): boolean;
/**
* isString
* Check if the argument is a string.
* @type method
* @argument str any
* @return boolean
*/
isString(str: any): boolean;
/**
* extend
* Extends target object with properties from the source object. If no target is provided, cash itself will be extended.
* @type method
* @argument target any, source any
*/
extend(target: any, source: any): any;
/**
* matches
* Checks a selector against an element, returning a boolean value for match.
* @type method
* @argument element Cash, selector string
* @return boolean
*/
matches(element: Cash, selector: string): boolean;
/**
* parseHTML
* Returns a collection from an HTML string.
* @type method
* @argument htmlString string
* @return Cash
*/
parseHTML(htmlString: string): Cash;
/**
* each
* Iterates through a collection and calls the callback method on each.
* @type method
* @argument collection Array, callback Function
* @return Array
*/
each(collection: Array<any>, callback: Function): Array<any>;
/**
* fn: use to extend cash for plugin development
* @type property
*/
fn: any;
/**
* selector declaration for Cash to use $(<argument>)
*/
(selector: string, context?: Element|Cash): Cash;
(element: Element): Cash;
(elementArray: Element[]): Cash;
}
/**
* Cash
* Interface for CashJs
* Refer https://github.com/kenwheeler/cash for documentation and uses of the methods and properties
*/
interface Cash {
/**
* add
* Returns a new collection with the element(s) added to the end.
*/
add(selector: string|Cash|Element, context?: Element): Cash;
/**
* addClass
* Adds the className argument to collection elements.
*/
addClass(c: string): Cash;
/**
* after
* Inserts content or elements after the collection.
*/
after(selector: Element|String): Cash;
/**
* append
* Appends the target element to the each element in the collection.
*/
append(content: string|Element|Cash): Cash;
/**
* appendTo
* Adds the elements in a collection to the target element(s).
*/
appendTo(parent: string|Element|Cash): Cash;
/**
* attr
* Without attrValue, returns the attribute value of the first element in the collection.
* With attrValue, sets the attribute value of each element of the collection.
*/
attr(name: string): any;
attr(name: string, value: string): Cash;
/**
* before
* Inserts content or elements before the collection.
*/
before(selector: string|Element): Cash;
/**
* children
* Without a selector specified, returns a collection of child elements.
* With a selector, returns child elements that match the selector.
*/
children(selector?: string): Cash;
/**
* closest
* Returns the closest matching selector up the DOM tree.
*/
closest(selector?: string): Cash;
/**
* clone
* Returns a clone of the collection.
*/
clone(): Cash;
/**
* css
* Returns a CSS property value when just property is supplied.
* Sets a CSS property when property and value are supplied, and set multiple properties when an object is supplied.
* Properties will be autoprefixed if needed for the user's browser.
*/
css(prop: any): any;
css(prop: string, value: any): Cash;
/**
* data
* Link some data (string, object, array, etc.) to an element when both key and value are supplied.
* If only a key is supplied, returns the linked data and falls back to data attribute value if no data is already linked.
* Multiple data can be set when an object is supplied.
*/
data(name: any): any;
data(name: string, value: any): Cash;
/**
* each
* Iterates over a collection with callback(value, index, array).
*/
each(callback: Function): Cash;
/**
* empty
* Empties an elements interior markup.
*/
empty(): Cash;
/**
* eq
* Returns a collection with the element at index.
*/
eq(index: number): Cash;
/**
* extend
* Adds properties to the cash collection prototype.
*/
extend(target: any): any;
/**
* filter
* Returns the collection that results from applying the filter method.
*/
filter(selector: Function): Cash;
/**
* find
* Returns selector match descendants from the first element in the collection.
*/
find(selector: string): Cash;
/**
* first
* Returns the first element in the collection.
*/
first(): Cash;
/**
* get
* Returns the element at the index.
*/
get(index: number): HTMLElement;
/**
* has
* Returns boolean result of the selector argument against the collection.
*/
has(selector: string): boolean;
/**
* hasClass
* Returns the boolean result of checking if the first element in the collection has the className attribute.
*/
hasClass(c: string): boolean;
/**
* height
* Returns the height of the element.
*/
height(): number;
/**
* html
* Returns the HTML text of the first element in the collection, sets the HTML if provided.
*/
html(): string;
html(content: string): Cash;
/**
* index
* Returns the index of the element in its parent if an element or selector isn't provided.
* Returns index within element or selector if it is.
*/
index(elem?: Element): number;
/**
* innerHeight
* Returns the height of the element + padding.
*/
innerHeight(): number;
/**
* innerWidth
* Returns the width of the element + padding.
*/
innerWidth(): number;
/**
* insertAfter
* Inserts collection after specified element.
*/
insertAfter(selector: string|Element|Cash): Cash;
/**
* insertBefore
* Inserts collection before specified element.
*/
insertBefore(selector: string|Element|Cash): Cash;
/**
* is
* Returns whether the provided selector, element or collection matches any element in the collection.
*/
is(selector: string|Element|Cash): boolean;
/**
* last
* Returns last element in the collection.
*/
last(): Cash;
/**
* next
* Returns next sibling.
*/
next(): Cash;
/**
* not
* Filters collection by false match on selector.
*/
not(selector: string|Element|Cash): Cash;
/**
* off
* Removes event listener from collection elements.
*/
off(eventName: string, callback: Function): Cash;
/**
* offset
* Get the coordinates of the first element in a collection relative to the document.
*/
offset(): OffsetType;
/**
* offsetParent
* Get the first element's ancestor that's positioned.
*/
offsetParent(): OffsetType;
/**
* on
* Adds event listener to collection elements. Event is delegated if delegate is supplied.
*/
on(eventName: string|Array<string>, delegate: any, callback?: Function, runOnce?: boolean): Cash;
/**
* one
* Adds event listener to collection elements that only triggers once for each element.
* Event is delegated if delegate is supplied.
*/
one(eventName: string|Array<string>, delegate: any, callback?: Function, runOnce?: boolean): Cash;
/**
* outerHeight
* Returns the outer height of the element. Includes margins if margin is set to true.
*/
outerHeight(flag?: boolean): number;
/**
* outerWidth
* Returns the outer width of the element. Includes margins if margin is set to true.
*/
outerWidth(flag?: boolean): number;
/**
* parent
* Returns parent element.
*/
parent(): Cash;
/**
* parents
* Returns collection of elements who are parents of element. Optionally filtering by selector.
*/
parents(selector?: string): Cash;
/**
* position
* Get the coordinates of the first element in a collection relative to its offsetParent.
*/
position(): OffsetType;
/**
* prepend
* Prepends element to the each element in collection.
*/
prepend(content: string): Cash;
/**
* prependTo
* Prepends elements in a collection to the target element(s).
*/
prependTo(parent: string|Element|Cash): Cash;
/**
* prev
* Returns the previous adjacent element.
*/
prev(): Cash;
/**
* prop
* Returns a property value when just property is supplied.
* Sets a property when property and value are supplied, and sets multiple properties when an object is supplied.
*/
prop(name: string): any;
prop(name: string, value: string): Cash;
/**
* ready
* Calls callback method on DOMContentLoaded.
*/
ready(fn: Function): void;
/**
* remove
* Removes collection elements from the DOM.
*/
remove(): Cash;
/**
* removeAttr
* Removes attribute from collection elements.
*/
removeAttr(name: string): Cash;
/**
* removeClass
* Removes className from collection elements.
* Accepts space-separated classNames for removing multiple classes.
* Providing no arguments will remove all classes.
*/
removeClass(c?: string): Cash;
/**
* removeData
* Removes linked data and data-attributes from collection elements.
*/
removeData(key: string): Cash;
/**
* removeProp
* Removes property from collection elements.
*/
removeProp(name: string): Cash;
/**
* serialize
* When called on a form, serializes and returns form data.
*/
serialize(): string;
/**
* siblings
* Returns a collection of sibling elements.
*/
siblings(): Cash;
/**
* text
* Returns the inner text of the first element in the collection, sets the text if textContent is provided.
*/
text(): string;
text(content?: string): Cash;
/**
* toggleClass
* Adds or removes className from collection elements based on if the element already has the class.
* Accepts space-separated classNames for toggling multiple classes, and an optional force boolean to ensure classes are added (true) or removed (false).
*/
toggleClass(c: string, state?: boolean): Cash;
/**
* trigger
* Triggers supplied event on elements in collection. Data can be passed along as the second parameter.
*/
trigger(eventName: string, data?: any): Cash;
/**
* val
* Returns an inputs value. If value is supplied, sets all inputs in collection's value to the value argument.
*/
val(): any;
val(value?: string): Cash;
/**
* width
* Returns the width of the element.
*/
width(): number;
}
declare module "cash" {
export = CashStatic;
}
declare var cash: CashStatic;
@@ -6,6 +6,6 @@ import * as util from 'util';
var client = new cassandra.Client({ contactPoints: ['h1', 'h2'], keyspace: 'ks1'});
var query = 'SELECT email, last_name FROM user_profiles WHERE key=?';
client.execute(query, ['guy'], {}, function(err, result) {
console.log('got user profile with email ' + result.rows[0].get("email"));
client.execute(query, ['guy'], function(err: any, result: any) {
console.log('got user profile with email ' + result.rows[0].email);
});
+2 -2
View File
@@ -134,7 +134,7 @@ export namespace types {
var LocalTime: LocalTimeStatic;
var Long: _Long;
var ResultSet: ResultSetStatic;
var ResultStream: ResultStreamStatic;
// var ResultStream: ResultStreamStatic;
var Row: RowStatic;
var TimeUuid: TimeUuidStatic;
var Tuple: TupleStatic;
@@ -365,7 +365,7 @@ export namespace types {
buffer: Buffer;
paused: boolean;
_read(): void;
// _read(): void;
_valve(readNext: Function): void;
add(chunk: Buffer): void;
}
+1 -1
View File
@@ -14,6 +14,6 @@
},
"files": [
"index.d.ts",
"cassandra-driver.tests.ts"
"cassandra-driver-tests.ts"
]
}
+8 -2
View File
@@ -5,13 +5,19 @@
declare namespace Chance {
interface Seeded {
seed: number;
}
type SeededChance = Chance & Seeded;
interface ChanceStatic {
(): Chance
(seed: number): Chance
(seed: number): SeededChance
(generator: () => any): Chance
new(): Chance;
new(seed: number): Chance;
new(seed: number): SeededChance;
new(generator: () => any): Chance;
}
+8 -6
View File
@@ -345,6 +345,7 @@ interface ChartXAxe {
stacked?: boolean;
categoryPercentage?: number;
barPercentage?: number;
barThickness?: number;
gridLines?: GridLineOptions;
position?: string;
ticks?: TickOptions;
@@ -379,7 +380,7 @@ interface TimeScale extends ChartScales {
parser?: string | ((arg: any) => any);
round?: string;
tooltipFormat?: string;
unit?: TimeUnit;
unit?: string | TimeUnit;
unitStepSize?: number;
}
@@ -390,11 +391,12 @@ interface RadialLinearScale {
ticks?: TickOptions;
}
declare var Chart: {
new (context: CanvasRenderingContext2D, options: ChartConfiguration): {};
declare class Chart {
constructor (context: CanvasRenderingContext2D, options: ChartConfiguration);
config: ChartConfiguration;
destroy: () => {};
update: (duration: any, lazy: any) => {};
render: (duration: any, lazy: any) => {};
update: (duration?: any, lazy?: any) => {};
render: (duration?: any, lazy?: any) => {};
stop: () => {};
resize: () => {};
clear: () => {};
@@ -407,4 +409,4 @@ declare var Chart: {
defaults: {
global: ChartOptions;
}
};
}
+63
View File
@@ -0,0 +1,63 @@
/// <reference path="cheap-ruler.d.ts"/>
import * as cheapRuler from 'cheap-ruler'
// -- Fixtures --
const bbox = [30.5, 50.5, 31, 51]
const point1 = [30.5, 50.5]
const point2 = [30.51, 50.49]
const unit = 'miles'
const lineString = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[-77.031669, 38.878605],
[-77.029609, 38.881946],
[-77.020339, 38.884084],
[-77.025661, 38.885821],
[-77.021884, 38.889563],
[-77.019824, 38.892368]
]
}
}
const line = lineString.geometry.coordinates
const polygon = [[
[-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534],
[-66.929, 50.458], [-67.031, 50.458]
]]
const points = [
[-67.031, 50.458], [-67.031, 50.534],
[-66.929, 50.534], [-66.929, 50.458]
]
// -- Test initiators --
cheapRuler(35.05)
cheapRuler(35.05, 'miles')
cheapRuler(35.05, unit)
cheapRuler.fromTile(1567, 12)
cheapRuler.fromTile(1567, 12, 'miles')
cheapRuler.fromTile(1567, 12, unit)
// -- Test units --
cheapRuler.units
cheapRuler.units.miles
cheapRuler.units.kilometers
50 * cheapRuler.units.yards / cheapRuler.units.meters
// -- Test cheapRuler --
const ruler = cheapRuler(35.05)
ruler.distance(point1, point2)
ruler.bearing(point1, point2)
ruler.destination(point1, 0.1, 90)
ruler.lineDistance(points)
ruler.area(polygon)
ruler.along(line, 2.5)
ruler.pointOnLine(line, point1).point
ruler.lineSlice(point1, point2, line)
ruler.lineSliceAlong(10, 20, line)
ruler.bufferPoint(point1, 0.01)
ruler.bufferBBox(bbox, 0.2)
ruler.insideBBox(point1, bbox)
+216
View File
@@ -0,0 +1,216 @@
// Type definitions for cheap-ruler 2.4.1
// Project: https://github.com/mapbox/cheap-ruler
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module "cheap-ruler" {
type BBox = [number, number, number, number] | number[]
type Point = [number, number] | number[]
type Line = Array<Point>
type Points = Array<Point>
type Polygon = Array<Array<Point>>
interface TemplateUnits {
kilometers: number
miles: number
nauticalmiles: number
meters: number
metres: number
yards: number
feet: number
inches: number
}
interface InterfacePointOnLine {
point: Point
index: number
t: number
}
class CheapRuler {
/**
* Given two points of the form [longitude, latitude], returns the distance.
*
* @param {Point} a point [longitude, latitude]
* @param {Point} b point [longitude, latitude]
* @returns {number} distance
* @example
* var distance = ruler.distance([30.5, 50.5], [30.51, 50.49]);
* //=distance
*/
distance(a: Point, b: Point): number;
/**
* Returns the bearing between two points in angles.
*
* @param {Point} a point [longitude, latitude]
* @param {Point} b point [longitude, latitude]
* @returns {number} bearing
* @example
* var bearing = ruler.bearing([30.5, 50.5], [30.51, 50.49]);
* //=bearing
*/
bearing(a: Point, b: Point): number;
/**
* Returns a new point given distance and bearing from the starting point.
*
* @param {Point} p point [longitude, latitude]
* @param {number} dist distance
* @param {number} bearing
* @returns {Point} point [longitude, latitude]
* @example
* var point = ruler.destination([30.5, 50.5], 0.1, 90);
* //=point
*/
destination(p: Point, dist: number, bearing: number): Point;
/**
* Given a line (an array of points), returns the total line distance.
*
* @param {Points} points [longitude, latitude]
* @returns {number} total line distance
* @example
* var length = ruler.lineDistance([
* [-67.031, 50.458], [-67.031, 50.534],
* [-66.929, 50.534], [-66.929, 50.458]
* ]);
* //=length
*/
lineDistance(points: Points): number;
/**
* Given a polygon (an array of rings, where each ring is an array of points), returns the area.
*
* @param {Polygon} polygon
* @returns {number} area value in the specified units (square kilometers by default)
* @example
* var area = ruler.area([[
* [-67.031, 50.458], [-67.031, 50.534], [-66.929, 50.534],
* [-66.929, 50.458], [-67.031, 50.458]
* ]]);
* //=area
*/
area(polygon: Polygon): number;
/**
* Returns the point at a specified distance along the line.
*
* @param {Line} line
* @param {number} dist distance
* @returns {Point} point [longitude, latitude]
* @example
* var point = ruler.along(line, 2.5);
* //=point
*/
along(line: Line, dist: number): Point
/**
* Returns an object of the form {point, index} where point is closest point on the line from the given point, and index is the start index of the segment with the closest point.
*
* @pointOnLine
* @param {Line} line
* @param {Point} p point [longitude, latitude]
* @returns {Object} {point, index}
* @example
* var point = ruler.pointOnLine(line, [-67.04, 50.5]).point;
* //=point
*/
pointOnLine(line: Line, p: Point): InterfacePointOnLine
/**
* Returns a part of the given line between the start and the stop points (or their closest points on the line).
*
* @param {Point} start point [longitude, latitude]
* @param {Point} stop point [longitude, latitude]
* @param {Line} line
* @returns {Line} line part of a line
* @example
* var line2 = ruler.lineSlice([-67.04, 50.5], [-67.05, 50.56], line1);
* //=line2
*/
lineSlice(start: Point, stop: Point, line: Line): Line
/**
* Returns a part of the given line between the start and the stop points indicated by distance along the line.
*
* @param {number} start distance
* @param {number} stop distance
* @param {Line} line
* @returns {Line} line part of a line
* @example
* var line2 = ruler.lineSliceAlong(10, 20, line1);
* //=line2
*/
lineSliceAlong(start: number, stop: number, line: Line): Line
/**
* Given a point, returns a bounding box object ([w, s, e, n]) created from the given point buffered by a given distance.
*
* @param {Point} p point [longitude, latitude]
* @param {number} buffer
* @returns {BBox} box object ([w, s, e, n])
* @example
* var bbox = ruler.bufferPoint([30.5, 50.5], 0.01);
* //=bbox
*/
bufferPoint(p: Point, buffer: number): BBox
/**
* Given a bounding box, returns the box buffered by a given distance.
*
* @param {BBox} box object ([w, s, e, n])
* @param {number} buffer
* @returns {BBox} box object ([w, s, e, n])
* @example
* var bbox = ruler.bufferBBox([30.5, 50.5, 31, 51], 0.2);
* //=bbox
*/
bufferBBox(bbox: BBox, buffer: number): BBox
/**
* Returns true if the given point is inside in the given bounding box, otherwise false.
*
* @param {Point} p point [longitude, latitude]
* @param {Point} box object ([w, s, e, n])
* @returns {boolean}
* @example
* var inside = ruler.insideBBox([30.5, 50.5], [30, 50, 31, 51]);
* //=inside
*/
insideBBox(p: Point, bbox: BBox): boolean
}
/**
* A collection of very fast approximations to common geodesic measurements. Useful for performance-sensitive code that measures things on a city scale.
*
* @param {number} lat latitude
* @param {string} [units='kilometers']
* @returns {CheapRuler}
* @example
* var ruler = cheapRuler(35.05, 'miles');
* //=ruler
*/
function cheapRuler(lat: number, units?: string): CheapRuler;
namespace cheapRuler {
/**
* Multipliers for converting between units.
*
* @example
* // convert 50 meters to yards
* 50 * cheapRuler.units.yards / cheapRuler.units.meters;
*/
const units: TemplateUnits
/**
* Creates a ruler object from tile coordinates (y and z). Convenient in tile-reduce scripts.
*
* @param {number} y
* @param {number} z
* @param {string} [units='kilometers']
* @returns {CheapRuler}
* @example
* var ruler = cheapRuler.fromTile(1567, 12);
* //=ruler
*/
function fromTile(y: number, z: number, units?: string): CheapRuler;
}
export = cheapRuler
}
+6
View File
@@ -20,6 +20,12 @@ cheerio(html);
cheerio('ul', html);
cheerio('li', 'ul', html);
const $fromElement = cheerio.load($("ul").get(0));
if ($fromElement("ul > li").length !== 3) {
throw new Error("Expecting 3 elements when passing `CheerioElement` to `load()`");
}
$ = cheerio.load(html, {
normalizeWhitespace: true,
xmlMode: true
+1
View File
@@ -259,6 +259,7 @@ interface CheerioElement {
interface CheerioAPI extends CheerioSelector {
load(html: string, options?: CheerioOptionsInterface): CheerioStatic;
load(element: CheerioElement, options?: CheerioOptionsInterface): CheerioStatic;
}
declare var cheerio:CheerioAPI;
+21
View File
@@ -0,0 +1,21 @@
/// <reference path="chunked-dc.d.ts" />
// Chunker
let chunker = new Chunker(1337, Uint8Array.of(1,2,3), 2);
for (let chunk of chunker) {
// Do smoething with chunk
}
while (chunker.hasNext) {
let chunk = chunker.next().value;
}
// Unchunker
let unchunker = new Unchunker();
unchunker.onMessage = (message: Uint8Array, context: any[]) => {
// Do something with the received message
};
let chunk = Uint8Array.of(1,2).buffer;
unchunker.add(chunk);
unchunker.gc(1024);
+55
View File
@@ -0,0 +1,55 @@
// Type definitions for chunked-dc v0.1.2
// Project: https://github.com/saltyrtc/chunked-dc-js
// Definitions by: Danilo Bargen <https://github.com/dbrgn/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Interfaces
declare namespace chunkedDc {
/** common.ts **/
interface CommonStatic {
HEADER_LENGTH: number;
}
/** chunker.ts **/
interface Chunker extends IterableIterator<Uint8Array> {
hasNext: boolean;
next(): IteratorResult<Uint8Array>;
[Symbol.iterator](): IterableIterator<Uint8Array>;
}
interface ChunkerStatic {
new(id: number, message: Uint8Array, chunkSize: number): Chunker
}
/** unchunker.ts **/
type MessageListener = (message: Uint8Array, context?: any) => void;
interface Unchunker {
onMessage: MessageListener;
add(chunk: ArrayBuffer, context?: any): void;
gc(maxAge: number): number;
}
interface UnchunkerStatic {
new(): Unchunker
}
/** main.ts **/
interface Standalone {
Chunker: ChunkerStatic,
Unchunker: UnchunkerStatic,
}
}
// Entry point for the packed ES5 version:
declare var chunkedDc: chunkedDc.Standalone;
// Entry point for the ES2015 version:
declare var Chunker: chunkedDc.ChunkerStatic;
declare var Unchunker: chunkedDc.UnchunkerStatic;
+1
View File
@@ -0,0 +1 @@
--target es2015 --noImplicitAny
+63
View File
@@ -37,6 +37,23 @@ function test_CKEDITOR() {
CKEDITOR.replaceAll((textarea, config) => false);
}
function test_config() {
var config1: CKEDITOR.config = {
toolbar: 'basic',
};
var config2: CKEDITOR.config = {
toolbar: [
[ 'mode', 'document', 'doctools' ],
[ 'clipboard', 'undo' ],
'/',
[ 'find', 'selection', 'spellchecker' ],
[ 'basicstyles', 'cleanup' ],
'/',
[ 'list', 'indent', 'blocks', 'align', 'bidi' ],
],
};
}
function test_dom_comment() {
var type = CKEDITOR.NODE_COMMENT;
var nativeNode = document.createComment('Example');
@@ -300,3 +317,49 @@ function test_adding_widget() {
});
}
}
function test_focusManager() {
var textarea = document.createElement('textarea');
var instance = CKEDITOR.replace(textarea);
var element = CKEDITOR.document.getById('myElement');
instance.focusManager.focus();
instance.focusManager.focus(element);
instance.focusManager.lock();
instance.focusManager.unlock();
instance.focusManager.blur();
instance.focusManager.blur(true);
instance.focusManager.add(element, true);
instance.focusManager.remove(element);
var focusManager = new CKEDITOR.focusManager(instance);
var object: CKEDITOR.dom.domObject = focusManager.currentActive;
var bool: boolean = focusManager.hasFocus;
}
function test_basicWriter() {
var writer = new CKEDITOR.htmlParser.basicWriter();
writer.openTag('p', {});
writer.attribute('class', 'MyClass');
writer.openTagClose('p', false);
writer.text('Hello');
writer.closeTag('p');
alert(writer.getHtml(true)); // '<p class="MyClass">Hello</p>'
}
function test_htmlWriter() {
var writer = new CKEDITOR.htmlWriter();
writer.openTag('p', {});
writer.attribute('class', 'MyClass');
writer.openTagClose('p', false);
writer.text('Hello');
writer.closeTag('p');
alert(writer.getHtml(true)); // '<p class="MyClass">Hello</p>'
writer.indentationChars = '\t';
writer.lineBreakChars = '\r\n';
writer.selfClosingEnd = '>';
writer.indentation();
writer.lineBreak();
writer.setRules('img', {breakBeforeOpen: true, breakAfterOpen: true});
}
+33 -2
View File
@@ -544,8 +544,19 @@ declare namespace CKEDITOR {
}
interface focusManager {
class focusManager {
// Properties
currentActive: dom.domObject;
hasFocus: boolean;
// Methods
constructor(editor: editor);
focus(currentActive?: dom.element): void;
lock(): void;
unlock(): void;
blur(noDelay?: boolean): void;
add(element: dom.element, isCapture: boolean): void;
remove(element: dom.element): void;
}
interface keystrokeHandler {
@@ -796,7 +807,7 @@ declare namespace CKEDITOR {
templates_files?: Object;
templates_replaceContent?: boolean;
title?: string | boolean;
toolbar?: string | (string[])[];
toolbar?: string | (string | string[])[];
toolbarCanCollapse?: boolean;
toolbarGroupCycling?: boolean;
toolbarGroups?: toolbarGroups[];
@@ -1259,6 +1270,16 @@ declare namespace CKEDITOR {
toHtml(data: string, fixForBody?: string): void;
}
class htmlDataProcessor {
dataFilter: htmlParser.filter;
htmlFilter: htmlParser.filter;
writer: htmlParser.basicWriter;
constructor(editor: editor);
toDataFormat(html: string, options?: Object): string;
toHtml(data: string, options?: Object): string;
}
class event {
constructor();
@@ -1792,6 +1813,16 @@ declare namespace CKEDITOR {
}
class htmlWriter extends htmlParser.basicWriter {
indentationChars: string;
lineBreakChars: string;
selfClosingEnd: string;
indentation(): void;
lineBreak(): void;
setRules(tagName: string, rules: Object): void;
}
namespace tools {
var callFunction: Function;
+6
View File
@@ -0,0 +1,6 @@
/// <reference path="clipboard-js.d.ts" />
clipboard.copy("Hello World");
clipboard.copy(document.body).then(() => console.log("success"));
clipboard.paste().then(val => console.log(val));
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for clipboard-js 0.3.1
// Project: https://github.com/lgarron/clipboard.js
// Definitions by: Mark Wong Siang Kai <https://github.com/markwongsk>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace clipboard {
interface IClipboardJsStatic {
copy(val: string | Element): Promise<void>;
paste(): Promise<string>;
}
}
declare var clipboard: clipboard.IClipboardJsStatic;
declare module 'clipboard-js' {
export = clipboard;
}
+1 -1
View File
@@ -430,7 +430,7 @@ declare namespace CodeMirror {
/** Replace the part of the document between from and to with the given string.
from and to must be {line, ch} objects. to can be left off to simply insert the string at position from. */
replaceRange(replacement: string, from: CodeMirror.Position, to: CodeMirror.Position): void;
replaceRange(replacement: string, from: CodeMirror.Position, to?: CodeMirror.Position): void;
/** Get the content of line n. */
getLine(n: number): string;
+85
View File
@@ -0,0 +1,85 @@
// Color Test
// ================================================================================
/// <reference path="color.d.ts"/>
// Imports
// --------------------------------------------------------------------------------
import * as Color from "color"
var color: Color.Color = Color("white")
var colorOther: Color.Color = Color("black")
var colorRGB: Color.Color = color.rgb(0, 0, 0)
var colorRGB: Color.Color = color.rgb([0, 0, 0])
var rgb: Color.RGBColor = color.rgb()
var colorHSL: Color.Color = color.hsl([0, 0, 0])
var hsl: Color.HSLColor = color.hsl()
var colorHSV: Color.Color = color.hsv([0, 0, 0])
var hsv: Color.HSVColor = color.hsv()
var colorHBW: Color.Color = color.hbw([0, 0, 0])
var hbw: Color.HBWColor = color.hbw()
var colorCMYK: Color.Color = color.cmyk([0, 0, 0, 0])
var cmyk: Color.CMYKColor = color.cmyk()
var hex: string = color.hexString()
var percent: string = color.percentString()
var keyword: string | void = color.keyword()
var alpha: number = color.alpha()
var red: number = color.red()
var green: number = color.green()
var blue: number = color.blue()
var hue: number = color.hue()
var saturation: number = color.saturation()
var lightness: number = color.lightness()
var saturationv: number = color.saturationv()
var value: number = color.value()
var whiteness: number = color.whiteness()
var blackness: number = color.blackness()
var cyan: number = color.cyan()
var magenta: number = color.magenta()
var yellow: number = color.yellow()
var black: number = color.black()
var luminosity: number = color.luminosity()
var contrast: number = color.contrast(colorOther)
var dark: boolean = color.dark()
var light: boolean = color.light()
var level: string = color.level(colorOther)
var chain: Color.Color = color
.rgb(0, 0, 0)
.hsl([0, 0, 0])
.hsv([0, 0, 0])
.hbw([0, 0, 0])
.cmyk([0, 0, 0 ,0])
.alpha(0)
.red(0)
.green(0)
.blue(0)
.hue(0)
.saturation(0)
.lightness(0)
.saturationv(0)
.value(0)
.whiteness(0)
.blackness(0)
.cyan(0)
.magenta(0)
.yellow(0)
.black(0)
.negate()
.lighten(0)
.darken(0)
.saturate(0)
.desaturate(0)
.greyscale()
.whiten(0)
.blacken(0)
.clearer(0)
.opaquer(0)
.rotate(0)
.mix(colorOther, 0)
.clone()
+162
View File
@@ -0,0 +1,162 @@
// Type definitions for color v0.12.0
// Project: https://github.com/qix-/color
// Definitions by: Karol Janyst <https://github.com/LKay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace Color {
interface RGBColor {
r: number
g: number
b: number
a?: number
}
interface FullRGBColor {
red: number
green: number
blue: number
alpha?: number
}
interface HSLColor {
h: number
s: number
l: number
a?: number
}
interface FullHSLColor {
hue: number
saturation: number
lightness: number
alpha?: number
}
interface HSVColor {
h: number
s: number
v: number
}
interface FullHSVColor {
hue: number
saturation: number
value: number
}
interface HBWColor {
h: number
b: number
w: number
}
interface FullHBWColor {
hue: number
whiteness: number
blackness: number
}
interface CMYKColor {
c: number
m: number
y: number
k: number
}
interface FullCMYKColor {
cyan: number
magenta: number
yellow: number
black: number
}
type ColorParam = string | RGBColor | FullRGBColor | HSLColor | FullHSLColor | HSVColor
| FullHSVColor | HBWColor | FullHBWColor | CMYKColor | FullCMYKColor
interface Color {
(color: ColorParam | Color) : Color
rgb(values: Array<number>): Color
rgb(r: number, g: number, b: number, a?: number): Color
rgb(values: RGBColor): Color
rgb(values: FullRGBColor): Color
rgb(): RGBColor
rgbArray(): Array<number>
rgbString(): string
rgbaString(): string
rgbNumber(): number
hsl(values: Array<number>): Color
hsl(): HSLColor
hslArray(): Array<number>
hslString(): string
hslaString(): string
hsv(values: Array<number>): Color
hsv(): HSVColor
hsvArray(): Array<number>
hsvString(): string
hbw(values: Array<number>): Color
hbw(): HBWColor
hbwArray(): Array<number>
hbwString(): string
cmyk(values: Array<number>): Color
cmyk(): CMYKColor
cmykArray(): Array<number>
cmykString(): string
hexString(): string
percentString(): string
keyword(): string | void
alpha(alpha: number): Color
alpha(): number
red(red: number): Color
red(): number
green(green: number): Color
green(): number
blue(blue: number): Color
blue(): number
hue(hue: number): Color
hue(): number
saturation(saturation: number): Color
saturation(): number
lightness(lightness: number): Color
lightness(): number
saturationv(saturationv: number): Color
saturationv(): number
value(value: number): Color
value(): number
whiteness(whiteness: number): Color
whiteness(): number
blackness(blackness: number): Color
blackness(): number
cyan(cyan: number): Color
cyan(): number
magenta(magenta: number): Color
magenta(): number
yellow(yellow: number): Color
yellow(): number
black(black: number): Color
black(): number
luminosity(): number
contrast(color: Color): number
dark(): boolean
light(): boolean
negate(): Color
lighten(value: number): Color
darken(value: number): Color
saturate(value: number): Color
desaturate(value: number): Color
greyscale(): Color
whiten(value: number): Color
blacken(value: number): Color
clearer(value: number): Color
opaquer(value: number): Color
rotate(value: number): Color
mix(color: Color, value?: number): Color
level(color: Color): string
clone(): Color
}
}
declare module "color" {
const Color: Color.Color
export = Color
}
+5
View File
@@ -74,6 +74,11 @@ declare namespace connectMongo {
* (Default: 10)
*/
autoRemoveInterval?: number;
/**
* don't save session if unmodified
*/
touchAfter?: number;
}
export interface MongoUrlOptions extends DefaultOptions {
@@ -0,0 +1,121 @@
/// <reference path='./cordova-plugin-ble-central.d.ts' />
var log = (msg : string) => {};
var devices: BLECentralPlugin.PeripheralData[] = [];
var demoDevice :BLECentralPlugin.PeripheralData = {
"name": "Battery Demo",
"id": "20:FF:D0:FF:D1:C0",
"advertising": [2,1,6,3,3,15,24,8,9,66,97,116,116,101,114,121],
"rssi": -55
};
devices.push(demoDevice);
var demoExtendedData : BLECentralPlugin.PeripheralDataExtended = {
"name": "Battery Demo",
"id": "20:FF:D0:FF:D1:C0",
"advertising": [2,1,6,3,3,15,24,8,9,66,97,116,116,101,114,121],
"rssi": -55,
"services": [
"1800",
"1801",
"180f"
],
"characteristics": [
{
"service": "1800",
"characteristic": "2a00",
"properties": [
"Read"
]
},
{
"service": "1800",
"characteristic": "2a01",
"properties": [
"Read"
]
},
{
"service": "1801",
"characteristic": "2a05",
"properties": [
"Read"
]
},
{
"service": "180f",
"characteristic": "2a19",
"properties": [
"Read"
],
"descriptors": [
{
"uuid": "2901"
},
{
"uuid": "2904"
}
]
}
]
};
//get updates about the bluethooth states
ble.startStateNotifications((state) => log(`BLE state ${state}`));
ble.isEnabled(()=> log(`bluetooth is enabled`), ()=>log(`bluetooth is not enabled`));
//here we try to enable bluetooth
ble.enable(() => log(`yes it worked, or it was already enabled `), () => log(`nope it didn't work, the user pressed cancel, or we are in iOS`));
ble.showBluetoothSettings(() => log(`yes it worked`), () => log(`nope it didn't work`))
//stop getting updates about the bluethooth states
ble.stopStateNotifications()
//scan 5 seconds
ble.scan([], 5000, (data) => { devices.push(data); }, ()=> log('couldn\'t connect') );
//scan continously
ble.startScan([], (data) => { devices.push(data); }, ()=> log('couldn\'t connect') )
////scan continously
ble.startScanWithOptions([], {reportDuplicates:false }, (data) => { devices.push(data); }, ()=> log('couldn\'t connect') )
//stop scanning
ble.stopScan(()=> log('all good'), ()=> log('couldn\'t stop scanning'));
//are we conenected to that device?
ble.isConnected(demoDevice.id, () => log(`already connected to this device`), ()=> log(`not yet connected to that device`));
//connect to a specific device
var extendedData : BLECentralPlugin.PeripheralDataExtended;
ble.connect(demoDevice.id, (data)=> extendedData = data, () => log(`couldn't connect to the device`) );
//read some data from a characteristic
var charsOfOneOfItsServices = demoExtendedData.characteristics.filter((value) => value.service == demoExtendedData.services[0]);
ble.read(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, (data) => log(`we've received some data`), ()=> log(`couldn't read any data`));
//read the rssi
ble.readRSSI(demoDevice.id, (rssi)=>log(`Device ${demoDevice.name} has an RSSI of ${rssi}`));
var notificationsReceived : number = 0;
//get notified of changes for that characteristic
ble.startNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, (data)=> notificationsReceived++, ()=> log(`darn`));
//write some data
ble.write(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`), ()=> log(`could't write`));
//write some data without getting notified
ble.writeWithoutResponse(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic, new ArrayBuffer(40), ()=> log(`all good`), ()=> log(`could't write`));
//stop getting notified of changes.
ble.stopNotification(demoDevice.id, charsOfOneOfItsServices[0].service, charsOfOneOfItsServices[0].characteristic);
//notificationsReceived == 1
//just disconnect
ble.disconnect(demoDevice.id);
@@ -0,0 +1,108 @@
// Type definitions for cordova-plugin-ble-central 1.1.2
// Project: https://github.com/don/cordova-plugin-ble-central
// Definitions by: Gidon Junge <https://github.com/gjunge>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace BLECentralPlugin {
interface PeripheralCharacteristic {
service: string;
characteristic: string;
properties: string[];
descriptors?: any[];
}
interface PeripheralData {
name: string;
id: string;
rssi: number
advertising: ArrayBuffer|any;
}
interface PeripheralDataExtended extends PeripheralData{
services: string[];
characteristics: PeripheralCharacteristic[]
}
interface StartScanOptions {
reportDuplicates?: boolean;
}
export interface BLECentralPluginStatic {
scan(services: string[], seconds: number, success : (data: PeripheralData) => any): void;
scan(services: string[], seconds: number, success : (data: PeripheralData) => any, failure : () => any): void;
startScan(services: string[], success: (data: PeripheralData) => any): void;
startScan(services: string[], success: (data: PeripheralData) => any, failure: () => any): void;
startScanWithOptions(services: string[], options: StartScanOptions, success: (data: PeripheralData) => any): void;
startScanWithOptions(services: string[], options: StartScanOptions, success: (data: PeripheralData) => any, failure: () => any): void;
stopScan(): void;
stopScan(success: () => any): void;
stopScan(success: () => any, failure: () => any): void;
connect(device_id:string, success: (data: PeripheralDataExtended) => any, failure: () => any): void;
disconnect(device_id:string): void;
disconnect(device_id:string, success: () => any): void;
disconnect(device_id:string, success: () => any, failure: () => any): void;
read(device_id: string, service_uuid:string, characteristic_uuid:string): void;
read(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any): void;
read(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any, failure: () => any): void;
write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer): void;
write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any): void;
write(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any, failure: () => any): void;
/* Writes data to a characteristic without a response from the peripheral. You are not notified if the write fails in the BLE stack.
The success callback is be called when the characteristic is written.*/
writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer): void;
writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any): void;
writeWithoutResponse(device_id: string, service_uuid:string, characteristic_uuid:string, data: ArrayBuffer, success : () => any, failure: () => any): void;
/* Register to be notified when the value of a characteristic changes. */
startNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any): void;
startNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: (rawData: ArrayBuffer) => any, failure: () => any): void;
stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string): void;
stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: () => any): void;
stopNotification(device_id: string, service_uuid:string, characteristic_uuid:string, success: () => any, failure: () => any): void;
/* Reports if bluetooth is enabled. */
isEnabled(success: () => any , failure: () => any): void;
/* Calls the success callback when the peripheral is connected and the failure callback when not connected. */
isConnected(device_id: string, success: () => any): void;
isConnected(device_id: string, success: () => any, failure: () => any): void;
startStateNotifications(success: (state: string) => any): void;
startStateNotifications(success: (state: string) => any, failure: () => any): void;
stopStateNotifications(): void;
stopStateNotifications(success: () => any): void;
stopStateNotifications(success: () => any, failure: () => any): void;
/* Opens the Bluetooth settings for the operating systems.
[iOS] showBluetoothSettings is not supported on iOS. */
showBluetoothSettings(): void;
showBluetoothSettings(success: () => any): void;
showBluetoothSettings(success: () => any, failure: () => any): void;
/* Enable Bluetooth on the device.
[iOS] enable is not supported on iOS. */
enable(success: () => any, failure: () => any): void;
readRSSI(device_id:string, success: (rssi: number) => any): void;
readRSSI(device_id:string, success: (rssi: number) => any, failure: () => any): void;
}
}
declare var ble: BLECentralPlugin.BLECentralPluginStatic;
@@ -0,0 +1,534 @@
/// <reference path='../cordova/cordova.d.ts' />
/// <reference path="cordova.plugins.diagnostic.d.ts" />
cordova.plugins.diagnostic.isLocationAvailable(function(available){
console.log("Location is " + (available ? "available" : "not available"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isWifiAvailable(function(available){
console.log("WiFi is " + (available ? "available" : "not available"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isCameraAvailable(function(available){
console.log("Camera is " + (available ? "available" : "not available"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isBluetoothAvailable(function(available){
console.log("Bluetooth is " + (available ? "available" : "not available"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.switchToLocationSettings();
cordova.plugins.diagnostic.switchToMobileDataSettings();
cordova.plugins.diagnostic.switchToBluetoothSettings();
cordova.plugins.diagnostic.switchToWifiSettings();
cordova.plugins.diagnostic.isWifiEnabled(function(enabled){
console.log("WiFi is " + (enabled ? "enabled" : "disabled"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.setWifiState(function(){
console.log("Wifi was enabled");
}, function(error){
console.error("The following error occurred: "+error);
}, true
);
cordova.plugins.diagnostic.setBluetoothState(function(){
console.log("Bluetooth was enabled");
}, function(error){
console.error("The following error occurred: "+error);
}, true
);
cordova.plugins.diagnostic.isLocationEnabled(function(enabled){
console.log("Location setting is " + (enabled ? "enabled" : "disabled"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isLocationAuthorized(function(enabled){
console.log("Location authorization is " + (enabled ? "enabled" : "disabled"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getLocationAuthorizationStatus(function(status){
switch(status){
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission not requested");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied");
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted always");
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE:
console.log("Permission granted only when in use");
break;
}
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.requestLocationAuthorization(function(status){
switch(status){
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission not requested");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied");
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted always");
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE:
console.log("Permission granted only when in use");
break;
}
}, function(error){
console.error(error);
}, cordova.plugins.diagnostic.locationAuthorizationMode.ALWAYS);
cordova.plugins.diagnostic.isCameraPresent(function(present){
console.log("Camera is " + (present ? "present" : "absent"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isCameraAuthorized(function(authorized){
console.log("App is " + (authorized ? "authorized" : "denied") + " access to the camera");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getCameraAuthorizationStatus(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Camera use is authorized");
}
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.requestCameraAuthorization(function(status){
console.log("Authorization request for camera use was " + (status == cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied"));
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.isMicrophoneAuthorized(function(authorized){
console.log("App is " + (authorized ? "authorized" : "denied") + " access to the microphone");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getMicrophoneAuthorizationStatus(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Microphone use is authorized");
}
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.requestMicrophoneAuthorization(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Microphone use is authorized");
}
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.isContactsAuthorized(function(authorized){
console.log("App is " + (authorized ? "authorized" : "denied") + " access to contacts");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getContactsAuthorizationStatus(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Contacts use is authorized");
}
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.requestContactsAuthorization(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Contacts use is authorized");
}
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.isCalendarAuthorized(function(authorized){
console.log("App is " + (authorized ? "authorized" : "denied") + " access to calendar");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getCalendarAuthorizationStatus(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Calendar use is authorized");
}
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.requestCalendarAuthorization(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Calendar use is authorized");
}
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.switchToSettings(function(){
console.log("Successfully switched to Settings app");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getBluetoothState(function(state){
if(state === cordova.plugins.diagnostic.bluetoothState.POWERED_ON){
console.log("Bluetooth is able to connect");
}
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.registerBluetoothStateChangeHandler(function(state){
if(state === cordova.plugins.diagnostic.bluetoothState.POWERED_ON){
console.log("Bluetooth is able to connect");
}
});
cordova.plugins.diagnostic.registerLocationStateChangeHandler(function(state){
if((device.platform === "Android" && state !== cordova.plugins.diagnostic.locationMode.LOCATION_OFF)
|| (device.platform === "iOS") && ( state === cordova.plugins.diagnostic.permissionStatus.GRANTED
|| state === cordova.plugins.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE
)){
console.log("Location is available");
}
});
cordova.plugins.diagnostic.getLocationMode(function(locationMode){
switch(locationMode){
case cordova.plugins.diagnostic.locationMode.HIGH_ACCURACY:
console.log("High accuracy");
break;
case cordova.plugins.diagnostic.locationMode.BATTERY_SAVING:
console.log("Battery saving");
break;
case cordova.plugins.diagnostic.locationMode.DEVICE_ONLY:
console.log("Device only");
break;
case cordova.plugins.diagnostic.locationMode.LOCATION_OFF:
console.log("Location off");
break;
}
},function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isGpsLocationAvailable(function(available){
console.log("GPS location is " + (available ? "available" : "not available"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isGpsLocationEnabled(function(enabled){
console.log("GPS location is " + (enabled ? "enabled" : "disabled"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isNetworkLocationAvailable(function(available){
console.log("Network location is " + (available ? "available" : "not available"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isNetworkLocationEnabled(function(enabled){
console.log("Network location is " + (enabled ? "enabled" : "disabled"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getLocationMode(function(locationMode){
switch(locationMode){
case cordova.plugins.diagnostic.locationMode.HIGH_ACCURACY:
console.log("High accuracy");
break;
case cordova.plugins.diagnostic.locationMode.BATTERY_SAVING:
console.log("Battery saving");
break;
case cordova.plugins.diagnostic.locationMode.DEVICE_ONLY:
console.log("Device only");
break;
case cordova.plugins.diagnostic.locationMode.LOCATION_OFF:
console.log("Location off");
break;
}
},function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getPermissionAuthorizationStatus(function(status){
switch(status){
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted to use the camera");
break;
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission to use the camera has not been requested yet");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied to use the camera - ask again?");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use the camera - guess we won't be using it then!");
break;
}
}, function(error){
console.error("The following error occurred: "+error);
}, cordova.plugins.diagnostic.permission.CAMERA);
cordova.plugins.diagnostic.getPermissionsAuthorizationStatus(function(statuses){
for (var permission in statuses){
switch(statuses[permission]){
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted to use "+permission);
break;
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission to use "+permission+" has not been requested yet");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied to use "+permission+" - ask again?");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use "+permission+" - guess we won't be using it then!");
break;
}
}
}, function(error){
console.error("The following error occurred: "+error);
},[
cordova.plugins.diagnostic.permission.ACCESS_FINE_LOCATION,
cordova.plugins.diagnostic.permission.ACCESS_COARSE_LOCATION
]);
cordova.plugins.diagnostic.requestRuntimePermission(function(status){
switch(status){
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted to use the camera");
break;
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission to use the camera has not been requested yet");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied to use the camera - ask again?");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use the camera - guess we won't be using it then!");
break;
}
}, function(error){
console.error("The following error occurred: "+error);
}, cordova.plugins.diagnostic.permission.CAMERA);
cordova.plugins.diagnostic.requestRuntimePermissions(function(statuses){
for (var permission in statuses){
switch(statuses[permission]){
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted to use "+permission);
break;
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission to use "+permission+" has not been requested yet");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied to use "+permission+" - ask again?");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use "+permission+" - guess we won't be using it then!");
break;
}
}
}, function(error){
console.error("The following error occurred: "+error);
},[
cordova.plugins.diagnostic.permission.ACCESS_FINE_LOCATION,
cordova.plugins.diagnostic.permission.ACCESS_COARSE_LOCATION
]);
if(!cordova.plugins.diagnostic.isRequestingPermission()){
console.log("Request some permissions");
}else{
cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(function(statuses){
cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(null); // de-register handler after single call
console.log("Request some permissions");
});
}
function onPermissionRequestComplete(statuses:any){
console.info("Permission request complete");
for (var permission in statuses){
switch(statuses[permission]){
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted to use "+permission);
break;
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission to use "+permission+" has not been requested yet");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied to use "+permission);
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
console.log("Permission permanently denied to use "+permission);
break;
}
}
cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(null); // de-register handler
}
cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(onPermissionRequestComplete)
cordova.plugins.diagnostic.isBluetoothEnabled(function(enabled){
console.log("Bluetooth is " + (enabled ? "enabled" : "disabled"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.hasBluetoothSupport(function(supported){
console.log("Bluetooth is " + (supported ? "supported" : "unsupported"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.hasBluetoothLESupport(function(supported){
console.log("Bluetooth LE is " + (supported ? "supported" : "unsupported"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.hasBluetoothLEPeripheralSupport(function(supported){
console.log("Bluetooth LE Peripheral Mode is " + (supported ? "supported" : "unsupported"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isCameraRollAuthorized(function(authorized){
console.log("App is " + (authorized ? "authorized" : "denied") + " access to the camera roll");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getCameraRollAuthorizationStatus(function(status){
switch(status){
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
console.log("Permission not requested");
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
console.log("Permission denied");
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
console.log("Permission granted");
break;
}
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.requestCameraRollAuthorization(function(status){
console.log("Authorization request for camera roll was " + (status == cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied"));
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.isRemoteNotificationsEnabled(function(enabled){
console.log("Remote notifications are " + (enabled ? "enabled" : "disabled"));
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isRegisteredForRemoteNotifications(function(registered){
console.log("Device " + (registered ? "is" : "isn't") + " registered for remote notifications");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getRemoteNotificationTypes(function(types){
for(var type in types){
console.log(type + " is " + (types[type] ? "enabled" : "disabled"));
}
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isRemindersAuthorized(function(authorized){
console.log("App is " + (authorized ? "authorized" : "denied") + " access to reminders");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getRemindersAuthorizationStatus(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Reminders authorization allowed");
}
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.requestRemindersAuthorization(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Reminders authorization allowed");
}
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.isBackgroundRefreshAuthorized(function(authorized){
console.log("App is " + (authorized ? "authorized" : "not authorized") + " to perform background refresh");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.getBackgroundRefreshStatus(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Background refresh is allowed");
}
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.requestBluetoothAuthorization(function(){
console.log("Bluetooth authorization requested");
}, function(error){
console.error(error);
});
cordova.plugins.diagnostic.isMotionAvailable(function(available){
console.log("Motion tracking is " + (available ? "available" : "not available") + " on this device");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.isMotionRequestOutcomeAvailable(function(available){
console.log("Motion tracking request outcome is " + (available ? "available" : "not available") + " on this device");
}, function(error){
console.error("The following error occurred: "+error);
});
cordova.plugins.diagnostic.requestAndCheckMotionAuthorization(function(status){
console.log("Motion authorization is " +status);
}, function(error){
console.error(error);
});
@@ -0,0 +1,737 @@
// Type definitions for cordova.plugins.diagnostic v3.3.0
// Project: https://github.com/dpa99c/cordova-diagnostic-plugin
// Definitions by: Dave Alden <https://github.com/dpa99c/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Checks whether device hardware features are enabled or available to the app, e.g. camera, GPS, wifi
*/
interface Diagnostic {
/**
* ANDROID ONLY
* "Dangerous" permissions that need to be requested at run-time (Android 6.0/API 23 and above)
* See http://developer.android.com/guide/topics/security/permissions.html#perm-groups
* @type {Object}
*/
permission?: any;
/**
* ANDROID ONLY
* Permission groups indicate which associated permissions will also be requested if a given permission is requested.
* See http://developer.android.com/guide/topics/security/permissions.html#perm-groups
* @type {Object}
*/
permissionGroups?: any;
/**
* ANDROID and iOS ONLY
* Constants for requesting and reporting the various permission states.
* @type {Object}
*/
permissionStatus?: any;
/**
* iOS ONLY
* Location authorization mode
* @type {Object}
*/
locationAuthorizationMode?: any;
/**
* ANDROID ONLY
* Constants for the various location modes on Android.
* @type {Object}
*/
locationMode?: any;
/**
* ANDROID and iOS ONLY
* Constants for the various Bluetooth hardware states.
* @type {Object}
*/
bluetoothState?: any;
/**
* Checks if app is able to access device location.
* @param successCallback
* @param errorCallback
*/
isLocationAvailable: (
successCallback: (available: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* Checks if Wifi is available.
* On iOS this returns true if the device is connected to a network by WiFi.
* On Android and Windows 10 Mobile this returns true if the WiFi setting is set to enabled, and is the same as isWifiEnabled()
* @param successCallback
* @param errorCallback
*/
isWifiAvailable: (
successCallback: (available: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* Checks if camera is available.
* On Android & iOS this returns true if the device has a camera AND the application is authorized to use it.
* On Windows 10 Mobile this returns true if the device has a rear-facing camera.
* @param successCallback
* @param errorCallback
*/
isCameraAvailable: (
successCallback: (available: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* Checks if Bluetooth is available to the app.
* Returns true if the device has Bluetooth capabilities AND if Bluetooth setting is switched on (same on Android, iOS and Windows 10 Mobile)
* @param successCallback
* @param errorCallback
*/
isBluetoothAvailable: (
successCallback: (available: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and WINDOWS ONLY
* Displays the device location settings to allow user to enable location services/change location mode.
*/
switchToLocationSettings?: () => void;
/**
* ANDROID and WINDOWS ONLY
* Displays mobile settings to allow user to enable mobile data.
*/
switchToMobileDataSettings?: () => void;
/**
* ANDROID and WINDOWS ONLY
* Displays Bluetooth settings to allow user to enable Bluetooth.
*/
switchToBluetoothSettings?: () => void;
/**
* ANDROID and WINDOWS ONLY
* Displays WiFi settings to allow user to enable WiFi.
*/
switchToWifiSettings?: () => void;
/**
* ANDROID and WINDOWS ONLY
* Returns true if the WiFi setting is set to enabled, and is the same as isWifiAvailable()
* @param successCallback
* @param errorCallback
*/
isWifiEnabled?: (
successCallback: (enabled: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and WINDOWS ONLY
* Enables/disables WiFi on the device.
* @param successCallback
* @param errorCallback
* @param state
*/
setWifiState?: (
successCallback: (enabled: boolean) => void,
errorCallback: (error: string) => void,
state: boolean
) => void;
/**
* ANDROID and WINDOWS ONLY
* Enables/disables Bluetooth on the device.
* @param successCallback
* @param errorCallback
* @param state
*/
setBluetoothState?: (
successCallback: (enabled: boolean) => void,
errorCallback: (error: string) => void,
state: boolean
) => void;
/**
* ANDROID and iOS ONLY
* Returns true if the device setting for location is on.
* On Android this returns true if Location Mode is switched on.
* On iOS this returns true if Location Services is switched on.
* @param successCallback
* @param errorCallback
*/
isLocationEnabled?: (
successCallback: (enabled: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Checks if the application is authorized to use location.
* @param successCallback
* @param errorCallback
*/
isLocationAuthorized?: (
successCallback: (authorized: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Returns the location authorization status for the application.
* @param successCallback
* @param errorCallback
*/
getLocationAuthorizationStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Requests location authorization for the application.
* @param successCallback
* @param errorCallback
* @param mode - (iOS-only / optional) location authorization mode specified as a locationAuthorizationMode constant. If not specified, defaults to WHEN_IN_USE.
*/
requestLocationAuthorization?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void,
mode?: string
) => void;
/**
* ANDROID and iOS ONLY
* Checks if camera hardware is present on device.
* @param successCallback
* @param errorCallback
*/
isCameraPresent?: (
successCallback: (present: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Checks if the application is authorized to use the camera.
* @param successCallback
* @param errorCallback
*/
isCameraAuthorized?: (
successCallback: (authorized: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Returns the camera authorization status for the application.
* @param successCallback
* @param errorCallback
*/
getCameraAuthorizationStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Requests camera authorization for the application.
* @param successCallback
* @param errorCallback
*/
requestCameraAuthorization?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Checks if the application is authorized to use the microphone.
* @param successCallback
* @param errorCallback
*/
isMicrophoneAuthorized?: (
successCallback: (authorized: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Returns the microphone authorization status for the application.
* @param successCallback
* @param errorCallback
*/
getMicrophoneAuthorizationStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Requests microphone authorization for the application.
* @param successCallback
* @param errorCallback
*/
requestMicrophoneAuthorization?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Checks if the application is authorized to use contacts (address book).
* @param successCallback
* @param errorCallback
*/
isContactsAuthorized?: (
successCallback: (authorized: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Returns the contacts authorization status for the application.
* @param successCallback
* @param errorCallback
*/
getContactsAuthorizationStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Requests contacts authorization for the application.
* @param successCallback
* @param errorCallback
*/
requestContactsAuthorization?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Checks if the application is authorized to use the calendar.
* @param successCallback
* @param errorCallback
*/
isCalendarAuthorized?: (
successCallback: (authorized: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Returns the calendar authorization status for the application.
* @param successCallback
* @param errorCallback
*/
getCalendarAuthorizationStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Requests calendar authorization for the application.
* @param successCallback
* @param errorCallback
*/
requestCalendarAuthorization?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Opens settings page for this app.
* On Android, this opens the "App Info" page in the Settings app.
* On iOS, this opens the app settings page in the Settings app. This works only on iOS 8+ - iOS 7 and below will invoke the errorCallback.
*/
switchToSettings?: (
successCallback: () => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Returns the state of Bluetooth on the device.
* @param successCallback
* @param errorCallback
*/
getBluetoothState?: (
successCallback: (state: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Registers a function to be called when a change in Bluetooth state occurs. Pass in a falsey value to de-register the currently registered function.
* @param successCallback
*/
registerBluetoothStateChangeHandler?: (
successCallback: (state: string) => void
) => void;
/**
* ANDROID and iOS ONLY
* Registers a function to be called when a change in Location state occurs. Pass in a falsey value to de-register the currently registered function.
* On Android, this occurs when the Location Mode is changed.
* On iOS, this occurs when location authorization status is changed. This can be triggered either by the user's response to a location permission authorization dialog, by the user turning on/off Location Services, or by the user changing the Location authorization state specifically for your app.
* @param successCallback
*/
registerLocationStateChangeHandler?: (
successCallback: (state: string) => void
) => void;
/**
* ANDROID ONLY
* Checks if high-accuracy locations are available to the app from GPS hardware.
* Returns true if Location mode is enabled and is set to "Device only" or "High accuracy" AND if the app is authorised to use location.
* @param successCallback
* @param errorCallback
*/
isGpsLocationAvailable?: (
successCallback: (available: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID ONLY
* Checks if the device location setting is set to return high-accuracy locations from GPS hardware.
* Returns true if Location mode is enabled and is set to either Device only or High accuracy
* @param successCallback
* @param errorCallback
*/
isGpsLocationEnabled?: (
successCallback: (enabled: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID ONLY
* Checks if low-accuracy locations are available to the app from network triangulation/WiFi access points.
* Returns true if Location mode is enabled and is set to "Battery saving" or "High accuracy" AND if the app is authorised to use location.
* @param successCallback
* @param errorCallback
*/
isNetworkLocationAvailable?: (
successCallback: (available: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID ONLY
* Checks if the device location setting is set to return high-accuracy locations from GPS hardware.
* Returns true if Location mode is enabled and is set to either Battery saving or High accuracy
* @param successCallback
* @param errorCallback
*/
isNetworkLocationEnabled?: (
successCallback: (enabled: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID ONLY
* Returns the current location mode setting for the device.
* @param successCallback
* @param errorCallback
*/
getLocationMode?: (
successCallback: (mode: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID ONLY
* Returns the current authorisation status for a given permission.
* @param successCallback
* @param errorCallback
* @param permission
*/
getPermissionAuthorizationStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void,
permission: string
) => void;
/**
* ANDROID ONLY
* Returns the current authorisation status for multiple permissions.
* @param successCallback
* @param errorCallback
* @param permissions
*/
getPermissionsAuthorizationStatus?: (
successCallback: (status: string[]) => void,
errorCallback: (error: string) => void,
permissions: string[]
) => void;
/**
* ANDROID ONLY
* Requests app to be granted authorisation for a runtime permission.
* @param successCallback
* @param errorCallback
* @param permission
*/
requestRuntimePermission?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void,
permission: string
) => void;
/**
* ANDROID ONLY
* Requests app to be granted authorisation for multiple runtime permissions.
* @param successCallback
* @param errorCallback
* @param permissions
*/
requestRuntimePermissions?: (
successCallback: (status: string[]) => void,
errorCallback: (error: string) => void,
permissions: string[]
) => void;
/**
* ANDROID ONLY
* Indicates if the plugin is currently requesting a runtime permission via the native API.
*/
isRequestingPermission?: () => boolean;
/**
* ANDROID ONLY
* Registers a function to be called when a runtime permission request has completed. Pass in a falsey value to de-register the currently registered function.
* @param successCallback
*/
registerPermissionRequestCompleteHandler?: (
successCallback: (statuses: any) => void
) => void;
/**
* ANDROID ONLY
* Checks if the device setting for Bluetooth is switched on.
* @param successCallback
* @param errorCallback
*/
isBluetoothEnabled?: (
successCallback: (enabled: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID ONLY
* Checks if the device has Bluetooth capabilities.
* @param successCallback
* @param errorCallback
*/
hasBluetoothSupport?: (
successCallback: (supported: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID ONLY
* Checks if the device has Bluetooth Low Energy (LE) capabilities.
* @param successCallback
* @param errorCallback
*/
hasBluetoothLESupport?: (
successCallback: (supported: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* ANDROID ONLY
* Checks if the device supports Bluetooth Low Energy (LE) Peripheral mode.
* @param successCallback
* @param errorCallback
*/
hasBluetoothLEPeripheralSupport?: (
successCallback: (supported: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Checks if the application is authorized to use the Camera Roll in Photos app.
* @param successCallback
* @param errorCallback
*/
isCameraRollAuthorized?: (
successCallback: (authorized: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Returns the authorization status for the application to use the Camera Roll in Photos app.
* @param successCallback
* @param errorCallback
*/
getCameraRollAuthorizationStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Requests camera roll authorization for the application.
* @param successCallback
* @param errorCallback
*/
requestCameraRollAuthorization?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Checks if remote (push) notifications are enabled.
* @param successCallback
* @param errorCallback
*/
isRemoteNotificationsEnabled?: (
successCallback: (enabled: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Indicates if the app is registered for remote (push) notifications on the device.
* @param successCallback
* @param errorCallback
*/
isRegisteredForRemoteNotifications?: (
successCallback: (registered: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Indicates the current setting of notification types for the app in the Settings app.
* @param successCallback
* @param errorCallback
*/
getRemoteNotificationTypes?: (
successCallback: (types: any) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Checks if the application is authorized to use reminders.
* @param successCallback
* @param errorCallback
*/
isRemindersAuthorized?: (
successCallback: (authorized: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Returns the reminders authorization status for the application.
* @param successCallback
* @param errorCallback
*/
getRemindersAuthorizationStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Requests reminders authorization for the application.
* @param successCallback
* @param errorCallback
*/
requestRemindersAuthorization?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Checks if the application is authorized for background refresh.
* @param successCallback
* @param errorCallback
*/
isBackgroundRefreshAuthorized?: (
successCallback: (authorized: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Returns the background refresh authorization status for the application.
* @param successCallback
* @param errorCallback
*/
getBackgroundRefreshStatus?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Requests Bluetooth authorization for the application.
* @param successCallback
* @param errorCallback
*/
requestBluetoothAuthorization?: (
successCallback: () => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Checks if motion tracking is available on the current device.
* @param successCallback
* @param errorCallback
*/
isMotionAvailable?: (
successCallback: (available: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Checks if it's possible to determine the outcome of a motion authorization request on the current device.
* @param successCallback
* @param errorCallback
*/
isMotionRequestOutcomeAvailable?: (
successCallback: (available: boolean) => void,
errorCallback: (error: string) => void
) => void;
/**
* iOS ONLY
* Requests and checks motion authorization for the application.
* @param successCallback
* @param errorCallback
*/
requestAndCheckMotionAuthorization?: (
successCallback: (status: string) => void,
errorCallback: (error: string) => void
) => void;
}
interface CordovaPlugins {
diagnostic: Diagnostic
}
@@ -0,0 +1,11 @@
// Credit Card Type Test
// ================================================================================
///<reference path="credit-card-type.d.ts"/>
// Imports
// --------------------------------------------------------------------------------
import * as creditCardType from "credit-card-type"
var cardTypes: Array<CreditCardType.CreditCardTypeInfo> = creditCardType("")
var cardInfo: CreditCardType.CreditCardTypeInfo = creditCardType.getTypeInfo("")
var types: { [type: string]: string } = creditCardType.types
+32
View File
@@ -0,0 +1,32 @@
// Type definitions for Credit Card Type v5.0.0
// Project: https://github.com/braintree/credit-card-type
// Definitions by: Karol Janyst <https://github.com/LKay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace CreditCardType {
type CardBrand = "american-express" | "diners-club" | "discover" | "jcb" | "maestro" | "master-card" | "unionpay" | "visa"
interface CreditCardTypeInfo {
niceType?: string
type?: CardBrand
pattern?: RegExp
gaps?: Array<number>
lengths?: Array<number>
code?: {
name?: string
size?: number
}
}
interface CreditCardType {
(number: string): Array<CreditCardTypeInfo>
getTypeInfo (type: string): CreditCardTypeInfo
types: { [type: string]: string }
}
}
declare module "credit-card-type" {
const creditCardType: CreditCardType.CreditCardType
export = creditCardType
}
+1 -1
View File
@@ -1,4 +1,4 @@
import * as Cropper from 'cropperjs';
import Cropper from 'cropperjs';
var image = <HTMLImageElement>document.getElementById('image');
var cropper = new Cropper(image, {
+4 -3
View File
@@ -465,6 +465,7 @@ declare class cropperjs {
}
export = cropperjs;
export as namespace Cropper;
declare module "cropperjs" {
const Cropper: typeof cropperjs;
export default Cropper;
}

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