mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-04 09:10:09 +00:00
Merge branch 'master' into master
This commit is contained in:
45
types/ansicolors/index.d.ts
vendored
45
types/ansicolors/index.d.ts
vendored
@@ -1,8 +1,45 @@
|
||||
// Type definitions for ansicolors
|
||||
// Project: https://github.com/thlorenz/ansicolors
|
||||
// Definitions by: rogierschouten <https://github.com/rogierschouten>
|
||||
// Definitions by: Benjamin Arthur Lupton <https://github.com/balupton>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
|
||||
declare var colors: { [index: string]: (s: string) => string; };
|
||||
export = colors;
|
||||
interface Colors extends String {
|
||||
(value: string): string
|
||||
white: this
|
||||
black: this
|
||||
blue: this
|
||||
cyan: this
|
||||
green: this
|
||||
magenta: this
|
||||
red: this
|
||||
yellow: this
|
||||
brightBlack: this
|
||||
brightRed: this
|
||||
brightGreen: this
|
||||
brightYellow: this
|
||||
brightBlue: this
|
||||
brightMagenta: this
|
||||
brightCyan: this
|
||||
brightWhite: this
|
||||
bgBlack: this
|
||||
bgRed: this
|
||||
bgGreen: this
|
||||
bgYellow: this
|
||||
bgBlue: this
|
||||
bgMagenta: this
|
||||
bgCyan: this
|
||||
bgWhite: this
|
||||
bgBrightBlack: this
|
||||
bgBrightRed: this
|
||||
bgBrightGreen: this
|
||||
bgBrightYellow: this
|
||||
bgBrightBlue: this
|
||||
bgBrightMagenta: this
|
||||
bgBrightCyan: this
|
||||
bgBrightWhite: this
|
||||
open: this
|
||||
close: this
|
||||
colors: this
|
||||
}
|
||||
declare const colors: Colors
|
||||
export default colors
|
||||
|
||||
@@ -47,7 +47,8 @@ appInsights = {
|
||||
startTrackEvent(name: string) { return null; },
|
||||
stopTrackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null; },
|
||||
trackEvent(name: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }) { return null; },
|
||||
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number) { return null; },
|
||||
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean,
|
||||
resultCode: number, properties?: { [name: string]: string }, measurements?: { [name: string]: number }) { return null; },
|
||||
trackException(exception: Error, handledAt?: string, properties?: { [name: string]: string; }, measurements?: { [name: string]: number; }, severityLevel?: AI.SeverityLevel) { return null; },
|
||||
trackMetric(name: string, average: number, sampleCount?: number, min?: number, max?: number, properties?: { [name: string]: string; }) { return null; },
|
||||
trackTrace(message: string, properties?: { [name: string]: string; }, severityLevel?: AI.SeverityLevel) { return null; },
|
||||
@@ -86,7 +87,7 @@ appInsights.trackTrace("message", null);
|
||||
appInsights.trackTrace("message", { a: '1', b: '2' }, AI.SeverityLevel.Error);
|
||||
|
||||
// trackDependency
|
||||
appInsights.trackDependency("id", "POST", "http://example.com/test/abc", "/test/abc", null, true, null);
|
||||
appInsights.trackDependency("id", "POST", "http://example.com/test/abc", "/test/abc", null, true, null, {prop1: 'abc'}, {meas1: 4.5});
|
||||
|
||||
// flush
|
||||
appInsights.flush();
|
||||
|
||||
23
types/applicationinsights-js/index.d.ts
vendored
23
types/applicationinsights-js/index.d.ts
vendored
@@ -670,14 +670,16 @@ declare module Microsoft.ApplicationInsights {
|
||||
context: ITelemetryContext;
|
||||
queue: Array<() => void>;
|
||||
/**
|
||||
* Starts timing how long the user views a page or other item. Call this when the page opens.
|
||||
* This method doesn't send any telemetry. Call {@link stopTrackTelemetry} to log the page when it closes.
|
||||
* Starts the timer for tracking a page load time. Use this instead of `trackPageView` if you want to control when the page view timer starts and stops,
|
||||
* but don't want to calculate the duration yourself. This method doesn't send any telemetry. Call `stopTrackPage` to log the end of the page view
|
||||
* and send the event.
|
||||
* @param name A string that idenfities this item, unique within this HTML document. Defaults to the document title.
|
||||
*/
|
||||
startTrackPage(name?: string): any;
|
||||
/**
|
||||
* Logs how long a page or other item was visible, after {@link startTrackPage}. Call this when the page closes.
|
||||
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
|
||||
* Stops the timer that was started by calling `startTrackPage` and sends the pageview load time telemetry with the specified properties and measurements.
|
||||
* The duration of the page view will be the time between calling `startTrackPage` and `stopTrackPage`.
|
||||
* @param name The string you used as the name in `startTrackPage`. Defaults to the document title.
|
||||
* @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
|
||||
* @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
@@ -689,7 +691,7 @@ declare module Microsoft.ApplicationInsights {
|
||||
measurements?: { [name: string]: number }): any;
|
||||
/**
|
||||
* Logs that a page or other item was viewed.
|
||||
* @param name The string you used as the name in startTrackPage. Defaults to the document title.
|
||||
* @param name The string you used as the name in `startTrackPage`. Defaults to the document title.
|
||||
* @param url String - a relative or absolute URL that identifies the page or other item. Defaults to the window location.
|
||||
* @param properties map[string, string] - additional data used to filter pages and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this page, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
@@ -701,13 +703,13 @@ declare module Microsoft.ApplicationInsights {
|
||||
properties?: { [name: string]: string },
|
||||
measurements?: { [name: string]: number }, duration?: number): any;
|
||||
/**
|
||||
* Start timing an extended event. Call {@link stopTrackEvent} to log the event when it ends.
|
||||
* Start timing an extended event. Call `stopTrackEvent` to log the event when it ends.
|
||||
* @param name A string that identifies this event uniquely within the document.
|
||||
*/
|
||||
startTrackEvent(name: string): any;
|
||||
/**
|
||||
* Log an extended event that you started timing with {@link startTrackEvent}.
|
||||
* @param name The string you used to identify this event in startTrackEvent.
|
||||
* Log an extended event that you started timing with `startTrackEvent`.
|
||||
* @param name The string you used to identify this event in `startTrackEvent`.
|
||||
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
*/
|
||||
@@ -734,8 +736,11 @@ declare module Microsoft.ApplicationInsights {
|
||||
* @param totalTime total request time
|
||||
* @param success indicates if the request was sessessful
|
||||
* @param resultCode response code returned by the dependency request
|
||||
* @param properties map[string, string] - additional data used to filter events and metrics in the portal. Defaults to empty.
|
||||
* @param measurements map[string, number] - metrics associated with this event, displayed in Metrics Explorer on the portal. Defaults to empty.
|
||||
*/
|
||||
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number): any;
|
||||
trackDependency(id: string, method: string, absoluteUrl: string, pathName: string, totalTime: number, success: boolean, resultCode: number,
|
||||
properties?: { [name: string]: string }, measurements?: { [name: string]: number }): any;
|
||||
/**
|
||||
* Log an exception you have caught.
|
||||
* @param exception An Error from a catch clause, or the string error message.
|
||||
|
||||
@@ -4,10 +4,14 @@ import * as t from "@babel/types";
|
||||
// Examples from: https://github.com/thejameskyle/babel-handbook/blob/master/translations/en/plugin-handbook.md
|
||||
const MyVisitor: Visitor = {
|
||||
Identifier: {
|
||||
enter() {
|
||||
enter(path) {
|
||||
// $ExpectType NodePath<Identifier>
|
||||
path;
|
||||
console.log("Entered!");
|
||||
},
|
||||
exit() {
|
||||
exit(path) {
|
||||
// $ExpectType NodePath<Identifier>
|
||||
path;
|
||||
console.log("Exited!");
|
||||
}
|
||||
}
|
||||
@@ -109,3 +113,40 @@ const BindingKindTest: Visitor = {
|
||||
kind === 'anythingElse';
|
||||
},
|
||||
};
|
||||
|
||||
interface SomeVisitorState { someState: string; }
|
||||
|
||||
const VisitorStateTest: Visitor<SomeVisitorState> = {
|
||||
enter(path, state) {
|
||||
// $ExpectType SomeVisitorState
|
||||
state;
|
||||
// $ExpectType SomeVisitorState
|
||||
this;
|
||||
},
|
||||
exit(path, state) {
|
||||
// $ExpectType SomeVisitorState
|
||||
state;
|
||||
// $ExpectType SomeVisitorState
|
||||
this;
|
||||
},
|
||||
Identifier(path, state) {
|
||||
// $ExpectType SomeVisitorState
|
||||
state;
|
||||
// $ExpectType SomeVisitorState
|
||||
this;
|
||||
},
|
||||
FunctionDeclaration: {
|
||||
enter(path, state) {
|
||||
// $ExpectType SomeVisitorState
|
||||
state;
|
||||
// $ExpectType SomeVisitorState
|
||||
this;
|
||||
},
|
||||
exit(path, state) {
|
||||
// $ExpectType SomeVisitorState
|
||||
state;
|
||||
// $ExpectType SomeVisitorState
|
||||
this;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
14
types/babel__traverse/index.d.ts
vendored
14
types/babel__traverse/index.d.ts
vendored
@@ -143,17 +143,17 @@ export class Binding {
|
||||
constantViolations: NodePath[];
|
||||
}
|
||||
|
||||
export type Visitor<S = Node> = VisitNodeObject<Node> & {
|
||||
[P in Node["type"]]?: VisitNode<S, Extract<Node, { type: P; }>>;
|
||||
export type Visitor<S = {}> = VisitNodeObject<S, Node> & {
|
||||
[Type in Node["type"]]?: VisitNode<S, Extract<Node, { type: Type; }>>;
|
||||
};
|
||||
|
||||
export type VisitNode<T, P> = VisitNodeFunction<T, P> | VisitNodeObject<T>;
|
||||
export type VisitNode<S, P> = VisitNodeFunction<S, P> | VisitNodeObject<S, P>;
|
||||
|
||||
export type VisitNodeFunction<T, P> = (this: T, path: NodePath<P>, state: any) => void;
|
||||
export type VisitNodeFunction<S, P> = (this: S, path: NodePath<P>, state: S) => void;
|
||||
|
||||
export interface VisitNodeObject<T> {
|
||||
enter?(path: NodePath<T>, state: any): void;
|
||||
exit?(path: NodePath<T>, state: any): void;
|
||||
export interface VisitNodeObject<S, P> {
|
||||
enter?: VisitNodeFunction<S, P>;
|
||||
exit?: VisitNodeFunction<S, P>;
|
||||
}
|
||||
|
||||
export class NodePath<T = Node> {
|
||||
|
||||
2007
types/baidu-app/baidu-app-tests.ts
Normal file
2007
types/baidu-app/baidu-app-tests.ts
Normal file
File diff suppressed because it is too large
Load Diff
4758
types/baidu-app/index.d.ts
vendored
Normal file
4758
types/baidu-app/index.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
types/baidu-app/tsconfig.json
Normal file
24
types/baidu-app/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"dom",
|
||||
"esnext"
|
||||
],
|
||||
"strictFunctionTypes": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"baidu-app-tests.ts"
|
||||
]
|
||||
}
|
||||
7
types/baidu-app/tslint.json
Normal file
7
types/baidu-app/tslint.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-console": false,
|
||||
"semicolon": true
|
||||
}
|
||||
}
|
||||
2
types/bip39/index.d.ts
vendored
2
types/bip39/index.d.ts
vendored
@@ -17,7 +17,7 @@ export const wordlists: {
|
||||
spanish: string[];
|
||||
};
|
||||
|
||||
export function entropyToMnemonic(entropyHex: string, wordlist?: string[]): string;
|
||||
export function entropyToMnemonic(entropyHex: Buffer | string, wordlist?: string[]): string;
|
||||
|
||||
export function generateMnemonic(strength?: number, rng?: (size: number) => Buffer, wordlist?: string[]): string;
|
||||
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
'use strict';
|
||||
|
||||
import xor = require('bitwise-xor');
|
||||
|
||||
"use strict";
|
||||
let b: Buffer;
|
||||
|
||||
import xor = require("bitwise-xor");
|
||||
|
||||
var b: Buffer;
|
||||
|
||||
b = xor("a", "b");
|
||||
b = xor(new Buffer("a"), new Buffer("b"));
|
||||
b = xor('a', 'b');
|
||||
b = xor(new Buffer('a'), new Buffer('b'));
|
||||
|
||||
7
types/bitwise-xor/index.d.ts
vendored
7
types/bitwise-xor/index.d.ts
vendored
@@ -1,15 +1,14 @@
|
||||
// Type definitions for bitwise-xor 0.0.0
|
||||
// Type definitions for bitwise-xor 0.0
|
||||
// Project: https://github.com/czzarr/node-bitwise-xor
|
||||
// Definitions by: Rogier Schouten <https://github.com/rogierschouten>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
/**
|
||||
* Bitwise XOR between two Buffers or Strings, returns a Buffer
|
||||
*/
|
||||
declare function xor(b1: Buffer, b2: Buffer): Buffer;
|
||||
declare function xor(s1: string, s2: string): Buffer;
|
||||
declare function xor(a: Buffer | string, b: Buffer | string): Buffer;
|
||||
|
||||
export = xor;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
@@ -20,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"bitwise-xor-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
3
types/bull/index.d.ts
vendored
3
types/bull/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for bull 3.4
|
||||
// Type definitions for bull 3.5
|
||||
// Project: https://github.com/OptimalBits/bull
|
||||
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
|
||||
// Cameron Crothers <https://github.com/JProgrammer>
|
||||
@@ -17,7 +17,6 @@
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as Redis from "ioredis";
|
||||
import * as Promise from "bluebird";
|
||||
|
||||
/**
|
||||
* This is the Queue constructor.
|
||||
|
||||
7
types/cached-path-relative/cached-path-relative-tests.ts
Normal file
7
types/cached-path-relative/cached-path-relative-tests.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import cachedPathRelative = require("cached-path-relative");
|
||||
|
||||
function browserifyTest() {
|
||||
const file = "file.txt";
|
||||
const m1: string = cachedPathRelative("./", file).replace(/\\/g, '/');
|
||||
return m1;
|
||||
}
|
||||
13
types/cached-path-relative/index.d.ts
vendored
Normal file
13
types/cached-path-relative/index.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Type definitions for cached-path-relative 1.0
|
||||
// Project: https://github.com/ashaffer/cached-path-relative
|
||||
// Definitions by: TeamworkGuy2 <https://github.com/TeamworkGuy2>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Memoize the results of the path.relative function. path.relative can be an expensive operation
|
||||
* if it happens a lot, and its results shouldn't change for the same arguments.
|
||||
* Use it just like your normal path.relative, but it's memoized.
|
||||
*/
|
||||
declare function cachedPathRelative(from: string, to: string): string;
|
||||
|
||||
export = cachedPathRelative;
|
||||
23
types/cached-path-relative/tsconfig.json
Normal file
23
types/cached-path-relative/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cached-path-relative-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/cached-path-relative/tslint.json
Normal file
1
types/cached-path-relative/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
12
types/cfn-response/cfn-response-tests.ts
Normal file
12
types/cfn-response/cfn-response-tests.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import * as cfn from "cfn-response";
|
||||
import { CloudFormationCustomResourceEvent, Context } from "aws-lambda";
|
||||
|
||||
declare const event: CloudFormationCustomResourceEvent;
|
||||
declare const context: Context;
|
||||
|
||||
// $ExpectType void
|
||||
cfn.send(event, context, cfn.SUCCESS, { sample: 123 }, "abc");
|
||||
// $ExpectType void
|
||||
cfn.send(event, context, "SUCCESS");
|
||||
// $ExpectError
|
||||
cfn.send(event, context, "", {});
|
||||
19
types/cfn-response/index.d.ts
vendored
Normal file
19
types/cfn-response/index.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// Type definitions for cfn-response 1.0
|
||||
// Project: https://github.com/LukeMizuhashi/cfn-response
|
||||
// Definitions by: Ivo Murrell <https://github.com/ivoisbelongtous>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { CloudFormationCustomResourceEvent, Context } from "aws-lambda";
|
||||
|
||||
export type ResponseStatus = "SUCCESS" | "FAILED";
|
||||
export const SUCCESS: ResponseStatus;
|
||||
export const FAILED: ResponseStatus;
|
||||
|
||||
export function send(
|
||||
event: CloudFormationCustomResourceEvent,
|
||||
context: Context,
|
||||
responseStatus: ResponseStatus,
|
||||
responseData?: object,
|
||||
physicalResourceId?: string
|
||||
): void;
|
||||
23
types/cfn-response/tsconfig.json
Normal file
23
types/cfn-response/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cfn-response-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/cfn-response/tslint.json
Normal file
1
types/cfn-response/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -5,6 +5,7 @@ let value: any;
|
||||
let key: string;
|
||||
let num: number;
|
||||
let object: any;
|
||||
let path: string;
|
||||
|
||||
cs.set(key, value);
|
||||
value = cs.get(key);
|
||||
@@ -13,4 +14,12 @@ cs.delete(key);
|
||||
object = cs.all;
|
||||
cs.all = object;
|
||||
num = cs.size;
|
||||
key = cs.path;
|
||||
path = cs.path;
|
||||
|
||||
const csWithPathOption = new Configstore('foo', null, { configPath: path });
|
||||
|
||||
csWithPathOption.set(key, value);
|
||||
value = csWithPathOption.get(key);
|
||||
csWithPathOption.delete(key);
|
||||
|
||||
key = csWithPathOption.path;
|
||||
|
||||
3
types/configstore/index.d.ts
vendored
3
types/configstore/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for configstore 2.1
|
||||
// Type definitions for configstore 4.0
|
||||
// Project: https://github.com/yeoman/configstore
|
||||
// Definitions by: ArcticLight <https://github.com/ArcticLight>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -67,5 +67,6 @@ declare class Configstore {
|
||||
declare namespace Configstore {
|
||||
interface ConfigstoreOptions {
|
||||
globalConfigPath?: boolean;
|
||||
configPath?: string;
|
||||
}
|
||||
}
|
||||
|
||||
9
types/create-hmac/create-hmac-tests.ts
Normal file
9
types/create-hmac/create-hmac-tests.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import createHmac = require('create-hmac');
|
||||
|
||||
const hmac = createHmac('sha224', Buffer.from('secret key'));
|
||||
|
||||
hmac.update('synchronous write');
|
||||
hmac.digest();
|
||||
hmac.write('write to it as a stream');
|
||||
hmac.end();
|
||||
hmac.read();
|
||||
26
types/create-hmac/index.d.ts
vendored
Normal file
26
types/create-hmac/index.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for create-hmac 1.1
|
||||
// Project: https://github.com/crypto-browserify/createHmac
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
import { Hmac } from 'crypto';
|
||||
|
||||
export = createHmac;
|
||||
|
||||
declare function createHmac(algo: createHmac.Algorithm, key: string | Buffer): Hmac;
|
||||
|
||||
declare namespace createHmac {
|
||||
type Algorithm =
|
||||
| 'rmd160'
|
||||
| 'ripemd160'
|
||||
| 'md5'
|
||||
| 'sha'
|
||||
| 'sha1'
|
||||
| 'sha224'
|
||||
| 'sha256'
|
||||
| 'sha384'
|
||||
| 'sha512';
|
||||
}
|
||||
23
types/create-hmac/tsconfig.json
Normal file
23
types/create-hmac/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"create-hmac-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/create-hmac/tslint.json
Normal file
1
types/create-hmac/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
47
types/crumb/crumb-tests.ts
Normal file
47
types/crumb/crumb-tests.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as hapi from 'hapi';
|
||||
import * as crumb from 'crumb';
|
||||
|
||||
const server = new hapi.Server({ port: 8000 });
|
||||
|
||||
server.register({
|
||||
plugin: crumb,
|
||||
options: {
|
||||
key: 'csrf-token',
|
||||
size: 50,
|
||||
autoGenerate: true,
|
||||
addToViewContext: true,
|
||||
cookieOptions: {
|
||||
path: '/',
|
||||
},
|
||||
headerName: 'X-CSRF-Token',
|
||||
restful: true,
|
||||
skip: () => false,
|
||||
enforce: true,
|
||||
logUnauthorized: false,
|
||||
}
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: 'get',
|
||||
path: '/',
|
||||
handler: async (_, h) => {
|
||||
return h.continue;
|
||||
},
|
||||
});
|
||||
|
||||
server.route({
|
||||
method: 'get',
|
||||
path: '/custom',
|
||||
options: {
|
||||
plugins: {
|
||||
crumb: {
|
||||
key: 'x-csrf-token',
|
||||
source: 'query',
|
||||
restful: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
handler: async (_, h) => {
|
||||
return h.continue;
|
||||
},
|
||||
});
|
||||
114
types/crumb/index.d.ts
vendored
Normal file
114
types/crumb/index.d.ts
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
// Type definitions for crumb 7.2
|
||||
// Project: https://github.com/hapijs/crumb
|
||||
// Definitions by: Silas Rech <https://github.com/lenovouser>
|
||||
// Simon Schick <https://github.com/SimonSchick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Request, Plugin, ResponseToolkit, ServerStateCookieOptions } from 'hapi';
|
||||
|
||||
declare module 'hapi' {
|
||||
interface PluginSpecificConfiguration {
|
||||
crumb?: boolean | {
|
||||
/**
|
||||
* The name of the cookie to store the CSRF crumb into.
|
||||
*/
|
||||
key?: string;
|
||||
|
||||
/**
|
||||
* Specifies how the crumb will be sent in requests.
|
||||
*
|
||||
* @default 'payload'
|
||||
*/
|
||||
source?: 'payload' | 'query';
|
||||
|
||||
/**
|
||||
* Override for the server's 'restful' setting
|
||||
*/
|
||||
restful?: boolean;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
declare namespace crumb {
|
||||
type SkipFunction = (request?: Request, h?: ResponseToolkit) => boolean;
|
||||
|
||||
interface RegisterOptions {
|
||||
/**
|
||||
* The name of the cookie to store the CSRF crumb into.
|
||||
*
|
||||
* @default 'crumb'
|
||||
*/
|
||||
key?: string;
|
||||
|
||||
/**
|
||||
* The length of the crumb to generate.
|
||||
* See {@link https://github.com/hapijs/cryptiles cryptiles} for more information.
|
||||
*
|
||||
* @default 43
|
||||
*/
|
||||
size?: number;
|
||||
|
||||
/**
|
||||
* Whether to automatically generate a new crumb for requests.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
autoGenerate?: boolean;
|
||||
|
||||
/**
|
||||
* Whether to automatically add the crumb to view contexts as the given key.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
addToViewContext?: boolean;
|
||||
|
||||
/**
|
||||
* Storage options for the cookie containing the crumb
|
||||
*
|
||||
* @default { path: '/' }
|
||||
*/
|
||||
cookieOptions?: ServerStateCookieOptions;
|
||||
|
||||
/**
|
||||
* Specify the name of the custom CSRF header.
|
||||
*
|
||||
* @default 'X-CSRF-Token'
|
||||
*/
|
||||
headerName?: string;
|
||||
|
||||
/**
|
||||
* RESTful mode that validates crumb tokens from 'X-CSRF-Token' request header for POST, PUT, PATCH and DELETE server routes.
|
||||
* Disables payload/query crumb validation.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
restful?: boolean;
|
||||
|
||||
/**
|
||||
* A function which when provided, is called for every request.
|
||||
* If the provided function returns true, validation and generation of crumb is skipped.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
skip?: boolean | SkipFunction;
|
||||
|
||||
/**
|
||||
* Using enforce with false will set the CSRF header cookie but won't execute the validation.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
enforce?: boolean;
|
||||
|
||||
/**
|
||||
* Whether to add to the request log with tag 'crumb' and data 'validation failed'.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
logUnauthorized?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare const crumb: Plugin<crumb.RegisterOptions>;
|
||||
|
||||
export = crumb;
|
||||
23
types/crumb/tsconfig.json
Normal file
23
types/crumb/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"crumb-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/crumb/tslint.json
Normal file
1
types/crumb/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
5
types/cson-parser/cson-parser-tests.ts
Normal file
5
types/cson-parser/cson-parser-tests.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import * as CSON from 'cson-parser';
|
||||
|
||||
CSON.parse('[ 1, 2, a: "str" ]');
|
||||
|
||||
CSON.stringify({ domain: 'typescript.org' }, null, 4);
|
||||
25
types/cson-parser/index.d.ts
vendored
Normal file
25
types/cson-parser/index.d.ts
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Type definitions for cson-parser 4.0
|
||||
// Project: https://github.com/groupon/cson-parser
|
||||
// Definitions by: Silas Rech <https://github.com/lenovouser>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export type ReplacerFunction = (key: string, value: any) => any;
|
||||
|
||||
/**
|
||||
* Converts a CSON string into an object.
|
||||
* @param text A valid CSON string.
|
||||
* @param reviver A function that transforms the results. This function is called for each member of the object.
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
export function parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
|
||||
/**
|
||||
* Converts a JavaScript value to a CSON string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results or an array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value CSON text to make it easier to read.
|
||||
*/
|
||||
export function stringify(value: any, replacer?: ReplacerFunction | Array<(number | string)> | null, space?: string | number): string;
|
||||
23
types/cson-parser/tsconfig.json
Normal file
23
types/cson-parser/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"cson-parser-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/cson-parser/tslint.json
Normal file
1
types/cson-parser/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -14,6 +14,9 @@ const imm1: number = (debounce((x: number) => x * 2, 100, true))(2);
|
||||
const clearable = debounce(doThings);
|
||||
clearable.clear();
|
||||
|
||||
const flushable = debounce(doThings);
|
||||
flushable.flush();
|
||||
|
||||
// Intentionally asserts that the member variable has all the same benefits as the direct export.
|
||||
// Eventually, if debounce stop supporting the CommonJS-only module calling (`require("debounce")(...)`),
|
||||
// we can remove this and change the top import&require to `import { debounce } from "debounce";`.
|
||||
|
||||
6
types/debounce/index.d.ts
vendored
6
types/debounce/index.d.ts
vendored
@@ -1,13 +1,15 @@
|
||||
// Type definitions for debounce 3.0
|
||||
// Type definitions for debounce 1.2
|
||||
// Project: https://github.com/component/debounce
|
||||
// Definitions by: Denis Sokolov <https://github.com/denis-sokolov>
|
||||
// Josh Goldberg <https://github.com/joshuakgoldberg>
|
||||
// Wayne Carson <https://github.com/wcarson>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace _debounce {
|
||||
const debounce: typeof _debounce;
|
||||
}
|
||||
|
||||
declare function _debounce<A extends Function>(f: A, interval?: number, immediate?: boolean): A & { clear(): void; };
|
||||
declare function _debounce<A extends Function>(f: A, interval?: number, immediate?: boolean): A & { clear(): void; }
|
||||
& { flush(): void };
|
||||
|
||||
export = _debounce;
|
||||
|
||||
9
types/deprecate/deprecate-tests.ts
Normal file
9
types/deprecate/deprecate-tests.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import deprecate = require('deprecate');
|
||||
|
||||
deprecate('someMethod');
|
||||
deprecate('someMethod', 'This is deprecated');
|
||||
deprecate('someMethod', 'This is deprecated', 'foo', 'bar');
|
||||
|
||||
deprecate.color = '\x1b[31;1m';
|
||||
deprecate.silence = true;
|
||||
deprecate.stream = process.stderr;
|
||||
33
types/deprecate/index.d.ts
vendored
Normal file
33
types/deprecate/index.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
// Type definitions for deprecate 1.1
|
||||
// Project: https://github.com/brianc/node-deprecate
|
||||
// Definitions by: Toilal <https://github.com/Toilal>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare namespace deprecate {
|
||||
/**
|
||||
* Set to false to not output a color. Defaults to '\x1b[31;1m' which is red.
|
||||
*/
|
||||
let color: string;
|
||||
|
||||
/**
|
||||
* Set to false to do nothing at all when the deprecate method is called. Useful in tests of the library you're deprecating things within.
|
||||
*/
|
||||
let silence: boolean;
|
||||
|
||||
/**
|
||||
* The stream to which output is written. Defaults to process.stderr
|
||||
*/
|
||||
let stream: NodeJS.WriteStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call deprecate within a function you are deprecating.
|
||||
*
|
||||
* It will spit out all the messages to the console the first time and only the first time the method is called.
|
||||
*/
|
||||
declare function deprecate(methodName: string, ...message: string[]): void;
|
||||
|
||||
export = deprecate;
|
||||
23
types/deprecate/tsconfig.json
Normal file
23
types/deprecate/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"deprecate-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/deprecate/tslint.json
Normal file
3
types/deprecate/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
48
types/diffie-hellman/diffie-hellman-tests.ts
Normal file
48
types/diffie-hellman/diffie-hellman-tests.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import * as dh from 'diffie-hellman';
|
||||
|
||||
const dh1 = dh.getDiffieHellman('modp1');
|
||||
// $ExpectType DiffieHellman
|
||||
dh1;
|
||||
// $ExpectType Buffer
|
||||
dh1.generateKeys();
|
||||
// $ExpectType string
|
||||
dh1.generateKeys('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getPrime();
|
||||
// $ExpectType string
|
||||
dh1.getPrime('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getGenerator();
|
||||
// $ExpectType string
|
||||
dh1.getGenerator('hex');
|
||||
const pk = dh1.getPublicKey();
|
||||
// $ExpectType Buffer
|
||||
pk;
|
||||
// $ExpectType string
|
||||
dh1.getPublicKey('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.getPrivateKey();
|
||||
// $ExpectType string
|
||||
dh1.getPrivateKey('hex');
|
||||
// $ExpectType Buffer
|
||||
dh1.computeSecret(pk);
|
||||
// $ExpectType Buffer
|
||||
dh1.computeSecret(pk.toString('hex'), 'hex');
|
||||
// $ExpectType string
|
||||
dh1.computeSecret(pk.toString('hex'), 'hex', 'hex');
|
||||
|
||||
const dh2 = dh.createDiffieHellman(new Buffer([5]));
|
||||
// $ExpectType DiffieHellman
|
||||
dh2;
|
||||
dh.createDiffieHellman('prime', 'hex');
|
||||
dh.createDiffieHellman('prime', 'hex', new Buffer([5]));
|
||||
dh.createDiffieHellman('prime', 'hex', 5);
|
||||
dh.createDiffieHellman('prime', 'hex', 'generator', 'hex');
|
||||
dh.createDiffieHellman(1);
|
||||
dh.createDiffieHellman(1, 1);
|
||||
dh.createDiffieHellman(1, new Buffer([5]));
|
||||
|
||||
dh2.setPublicKey(pk);
|
||||
dh2.setPublicKey(pk.toString('hex'), 'hex');
|
||||
dh2.setPrivateKey(pk);
|
||||
dh2.setPrivateKey(pk.toString('hex'), 'hex');
|
||||
8
types/diffie-hellman/index.d.ts
vendored
Normal file
8
types/diffie-hellman/index.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
// Type definitions for diffie-hellman 5.0
|
||||
// Project: https://github.com/crypto-browserify/diffie-hellman
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
export { createDiffieHellman, getDiffieHellman, DiffieHellman } from 'crypto';
|
||||
23
types/diffie-hellman/tsconfig.json
Normal file
23
types/diffie-hellman/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"diffie-hellman-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/diffie-hellman/tslint.json
Normal file
1
types/diffie-hellman/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -29,6 +29,9 @@ result = ejs.render(template, data, options);
|
||||
result = ejs.renderFile(fileName, SimpleCallback);
|
||||
result = ejs.renderFile(fileName, data, SimpleCallback);
|
||||
result = ejs.renderFile(fileName, data, options, SimpleCallback);
|
||||
asyncResult = ejs.renderFile(fileName);
|
||||
asyncResult = ejs.renderFile(fileName, data);
|
||||
asyncResult = ejs.renderFile(fileName, data, options);
|
||||
|
||||
ejsFunction = ejs.compile('');
|
||||
ejsFunction = ejs.compile(read(fileName, "utf8"));
|
||||
|
||||
2
types/ejs/index.d.ts
vendored
2
types/ejs/index.d.ts
vendored
@@ -54,6 +54,8 @@ export type RenderFileCallback<T> = (err: Error, str?: string) => T;
|
||||
export function renderFile<T>(path: string, cb: RenderFileCallback<T>): T;
|
||||
export function renderFile<T>(path: string, data: Data, cb: RenderFileCallback<T>): T;
|
||||
export function renderFile<T>(path: string, data: Data, opts: Options, cb: RenderFileCallback<T>): T;
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
export function renderFile<T>(path: string, data?: Data, opts?: Options): Promise<T>;
|
||||
|
||||
/**
|
||||
* Clear intermediate JavaScript cache. Calls {@link Cache#reset}.
|
||||
|
||||
@@ -480,7 +480,10 @@ cli.addPlugin('my-fancy-plugin', {});
|
||||
|
||||
cli.isPathIgnored('./dist/index.js');
|
||||
|
||||
const formatter = cli.getFormatter('codeframe');
|
||||
let formatter: CLIEngine.Formatter;
|
||||
|
||||
formatter = cli.getFormatter('codeframe');
|
||||
formatter = cli.getFormatter();
|
||||
|
||||
formatter(cliReport.results);
|
||||
|
||||
|
||||
2
types/eslint/index.d.ts
vendored
2
types/eslint/index.d.ts
vendored
@@ -471,7 +471,7 @@ export class CLIEngine {
|
||||
|
||||
isPathIgnored(filePath: string): boolean;
|
||||
|
||||
getFormatter(format: string): CLIEngine.Formatter;
|
||||
getFormatter(format?: string): CLIEngine.Formatter;
|
||||
|
||||
getRules(): Map<string, Rule.RuleModule>;
|
||||
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
import { IncomingMessage, Server, ServerResponse } from "http";
|
||||
import fastifyJwt = require("fastify-jwt");
|
||||
import fastify = require("fastify");
|
||||
import fastifyJwt = require("fastify-jwt");
|
||||
|
||||
const app = fastify();
|
||||
|
||||
app.register<fastifyJwt.FastifyJwtOptions>(fastifyJwt, {
|
||||
secret: "super-secret"
|
||||
secret: "super-secret",
|
||||
});
|
||||
|
||||
app.register<fastifyJwt.FastifyJwtOptions>(fastifyJwt, {
|
||||
secret: (request, reply, callback) => {
|
||||
return "";
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
app.get("/path", (request, reply) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"fastify": "^1.11.2"
|
||||
"fastify": ">=1.13.1 || 2.0.0-rc.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import findVersions = require('find-versions');
|
||||
|
||||
findVersions('node v1.0.0');
|
||||
findVersions('node v1.0.0'); // $ExpectType string[]
|
||||
findVersions('1.0', { loose: true }); // $ExpectType string[]
|
||||
|
||||
5
types/find-versions/index.d.ts
vendored
5
types/find-versions/index.d.ts
vendored
@@ -1,7 +1,8 @@
|
||||
// Type definitions for find-versions 2.0
|
||||
// Type definitions for find-versions 3.0
|
||||
// Project: https://github.com/sindresorhus/find-versions
|
||||
// Definitions by: Leonid Logvinov <https://github.com/LogvinovLeon>
|
||||
// Chris Arnesen <https://github.com/carnesen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function findVersions(version: string): string[];
|
||||
declare function findVersions(version: string, options?: { loose: boolean }): string[];
|
||||
export = findVersions;
|
||||
|
||||
27
types/fuzzy-search/fuzzy-search-tests.ts
Normal file
27
types/fuzzy-search/fuzzy-search-tests.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import FuzzySearch = require('fuzzy-search');
|
||||
|
||||
const f = new FuzzySearch(['1', '2', '3']);
|
||||
|
||||
new FuzzySearch([{ a: 1 }, { a: 2 }, { a: 3 }], ['a']);
|
||||
|
||||
new FuzzySearch([{ a: 1 }, { a: 2 }, { a: 3 }], ['a'], {});
|
||||
|
||||
new FuzzySearch([{ a: 1 }, { a: 2 }, { a: 3 }], ['a'], { caseSensitive: true });
|
||||
|
||||
new FuzzySearch([{ a: 1 }, { a: 2 }, { a: 3 }], ['a'], { sort: true });
|
||||
|
||||
new FuzzySearch([{ a: 1 }, { a: 2 }, { a: 3 }], ['a'], { caseSensitive: true, sort: true });
|
||||
|
||||
let strArr: string[];
|
||||
|
||||
strArr = f.haystack;
|
||||
// $ExpectType string[]
|
||||
f.keys;
|
||||
// $ExpectType Required<Options>
|
||||
f.options;
|
||||
|
||||
strArr = new FuzzySearch(['1', '2', '3']).search();
|
||||
strArr = new FuzzySearch(['1', '2', '3']).search('2');
|
||||
|
||||
// $ExpectType number
|
||||
FuzzySearch.isMatch('1', '1', false);
|
||||
26
types/fuzzy-search/index.d.ts
vendored
Normal file
26
types/fuzzy-search/index.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
// Type definitions for fuzzy-search 2.1
|
||||
// Project: https://github.com/wouter2203/fuzzy-search#readme
|
||||
// Definitions by: Alex Deas <https://github.com/alex-deas>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
declare class FuzzySearch<T extends object | string> {
|
||||
haystack: T[];
|
||||
keys: string[];
|
||||
options: Required<FuzzySearch.Options>;
|
||||
|
||||
static isMatch(item: string, query: string, caseSensitive: boolean): number;
|
||||
|
||||
constructor(haystack: T[], keys?: string[], options?: FuzzySearch.Options);
|
||||
search(needle?: string): T[];
|
||||
}
|
||||
|
||||
declare namespace FuzzySearch {
|
||||
interface Options {
|
||||
caseSensitive?: boolean;
|
||||
sort?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
export = FuzzySearch;
|
||||
23
types/fuzzy-search/tsconfig.json
Normal file
23
types/fuzzy-search/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"fuzzy-search-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/fuzzy-search/tslint.json
Normal file
1
types/fuzzy-search/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
8
types/graphql-fields/graphql-fields-tests.ts
Normal file
8
types/graphql-fields/graphql-fields-tests.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import { GraphQLResolveInfo } from 'graphql';
|
||||
import graphqlFields = require('graphql-fields');
|
||||
|
||||
const info = ({} as any) as GraphQLResolveInfo;
|
||||
|
||||
const fieldsWithSubFieldsArgs = graphqlFields(info, {}, { processArguments: true });
|
||||
const fieldsWithoutTypeName = graphqlFields(info, {}, { excludedFields: ['__typename'] });
|
||||
graphqlFields(info);
|
||||
18
types/graphql-fields/index.d.ts
vendored
Normal file
18
types/graphql-fields/index.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// Type definitions for graphql-fields 1.3
|
||||
// Project: https://github.com/robrichard/graphql-fields#readme
|
||||
// Definitions by: feinoujc <https://github.com/feinoujc>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
import { GraphQLResolveInfo } from 'graphql';
|
||||
|
||||
declare function graphqlFields(info: GraphQLResolveInfo, obj?: object, opts?: graphqlFields.Options): any;
|
||||
|
||||
declare namespace graphqlFields {
|
||||
interface Options {
|
||||
processArguments?: boolean;
|
||||
excludedFields?: string[];
|
||||
}
|
||||
}
|
||||
|
||||
export = graphqlFields;
|
||||
24
types/graphql-fields/tsconfig.json
Normal file
24
types/graphql-fields/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"esnext.asynciterable"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"graphql-fields-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/graphql-fields/tslint.json
Normal file
1
types/graphql-fields/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
6
types/gulp-json-validator/gulp-json-validator-tests.ts
Normal file
6
types/gulp-json-validator/gulp-json-validator-tests.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import gulpJsonValidator = require("gulp-json-validator");
|
||||
|
||||
gulpJsonValidator(); // $ExpectType ReadWriteStream
|
||||
gulpJsonValidator({}); // $ExpectType ReadWriteStream
|
||||
gulpJsonValidator({ allowDuplicatedKeys: true }); // $ExpectType ReadWriteStream
|
||||
gulpJsonValidator({ allowDuplicatedKeys: false }); // $ExpectType ReadWriteStream
|
||||
14
types/gulp-json-validator/index.d.ts
vendored
Normal file
14
types/gulp-json-validator/index.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Type definitions for gulp-json-validator 1.2
|
||||
// Project: https://github.com/jackyjieliu/gulp-json-validator
|
||||
// Definitions by: Peter Safranek <https://github.com/pe8ter>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
interface GulpJsonValidatorOptions {
|
||||
allowDuplicatedKeys?: boolean;
|
||||
}
|
||||
|
||||
declare function gulpJsonValidator(option?: GulpJsonValidatorOptions): NodeJS.ReadWriteStream;
|
||||
|
||||
export = gulpJsonValidator;
|
||||
23
types/gulp-json-validator/tsconfig.json
Normal file
23
types/gulp-json-validator/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"gulp-json-validator-tests.ts"
|
||||
]
|
||||
}
|
||||
6
types/gulp-json-validator/tslint.json
Normal file
6
types/gulp-json-validator/tslint.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"file-name-casing": false
|
||||
}
|
||||
}
|
||||
4
types/hard-source-webpack-plugin/index.d.ts
vendored
4
types/hard-source-webpack-plugin/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for hard-source-webpack-plugin 0.9
|
||||
// Type definitions for hard-source-webpack-plugin 1.0
|
||||
// Project: https://github.com/mzgoddard/hard-source-webpack-plugin#readme
|
||||
// Definitions by: woitechen <https://github.com/woitechen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -15,7 +15,7 @@ declare namespace hard_source_webpack_plugin { }
|
||||
|
||||
interface Options {
|
||||
cacheDirectory?: string;
|
||||
configHash?: (webpackConfig?: webpack.Configuration) => string;
|
||||
configHash?: string | ((webpackConfig?: webpack.Configuration) => string);
|
||||
environmentHash?: {
|
||||
root: string;
|
||||
directories: string[];
|
||||
|
||||
23
types/imap-simple/index.d.ts
vendored
23
types/imap-simple/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for imap-simple v3.1.0
|
||||
// Type definitions for imap-simple v4.2.0
|
||||
// Project: https://github.com/chadxz/imap-simple
|
||||
// Definitions by: Jeffery Grajkowski <https://github.com/pushplay>
|
||||
// Ilari Aarnio <https://github.com/iaarnio>
|
||||
// Definitions: https://github.com/psnider/DefinitelyTyped/imap-simple
|
||||
|
||||
/// <reference types="node" />
|
||||
@@ -42,6 +43,18 @@ export class ImapSimple extends NodeJS.EventEmitter {
|
||||
openBox(boxName: string, callback: (err: Error, boxName: string) => void): void;
|
||||
openBox(boxName: string): Promise<string>;
|
||||
|
||||
/** Create a mailbox, calling the provided callback with signature (err, boxName), or resolves the returned promise with boxName. */
|
||||
addBox(boxName: string, callback: (err: Error, boxName: string) => void): void;
|
||||
addBox(boxName: string): Promise<string>;
|
||||
|
||||
/** Delete a mailbox, calling the provided callback with signature (err, boxName), or resolves the returned promise with boxName. */
|
||||
delBox(boxName: string, callback: (err: Error, boxName: string) => void): void;
|
||||
delBox(boxName: string): Promise<string>;
|
||||
|
||||
/** Returns the full list of mailboxes (folders). Upon success, either the provided callback will be called with signature (err, boxes), or the returned promise will be resolved with boxes. Boxes is the exact object returned from the node-imap getBoxes() result. */
|
||||
getBoxes(callback: (err: Error, boxes: Imap.MailBoxes) => void): void;
|
||||
getBoxes(): Promise<Imap.MailBoxes>;
|
||||
|
||||
/** Search for and retrieve mail in the previously opened mailbox. */
|
||||
search(searchCriteria: any[], fetchOptions: Imap.FetchOptions, callback: (err: Error, messages: Message[]) => void): void;
|
||||
search(searchCriteria: any[], fetchOptions: Imap.FetchOptions): Promise<Message[]>;
|
||||
@@ -57,6 +70,10 @@ export class ImapSimple extends NodeJS.EventEmitter {
|
||||
addMessageLabel(source: string | string[], label: string | string[], callback: (err: Error) => void): void;
|
||||
addMessageLabel(source: string | string[], label: string | string[]): Promise<void>;
|
||||
|
||||
/** Appends the argument message to the currently open mailbox or another mailbox. Message is a RFC-822 compatible MIME message. Valid options are mailbox, flags and date. When completed, either calls the provided callback with signature (err), or resolves the returned promise. */
|
||||
append(message: any, options: Imap.AppendOptions, callback: (err: Error) => void): void;
|
||||
append(message: any, options: Imap.AppendOptions): Promise<void>;
|
||||
|
||||
/** Moves the specified message(s) in the currently open mailbox to another mailbox. source corresponds to a node-imap MessageSource which specifies the messages to be moved. When completed, either calls the provided callback with signature (err), or resolves the returned promise. */
|
||||
moveMessage(source: string | string[], boxName: string, callback: (err: Error) => void): void;
|
||||
moveMessage(source: string | string[], boxName: string): Promise<void>;
|
||||
@@ -66,8 +83,8 @@ export class ImapSimple extends NodeJS.EventEmitter {
|
||||
addFlags(source: string | string[], flag: string | string[]): Promise<void>;
|
||||
|
||||
/** Removes the provided flag(s) from the specified message(s). uid is the uid of the message you want to remove the flag from or an array of uids. flag is either a string or array of strings indicating the flags to remove. */
|
||||
delFlags(source: string | string[], flag: string | string[], callback: (err: Error) => void): void;
|
||||
delFlags(source: string | string[], flag: string | string[]): Promise<void>;
|
||||
delFlags(uid: string | string[], flag: string | string[], callback: (err: Error) => void): void;
|
||||
delFlags(uid: string | string[], flag: string | string[]): Promise<void>;
|
||||
}
|
||||
|
||||
export namespace errors {
|
||||
|
||||
89
types/iri/index.d.ts
vendored
Normal file
89
types/iri/index.d.ts
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
// Type definitions for iri 1.3
|
||||
// Project: https://github.com/awwright/node-iri
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export class IRI {
|
||||
/**
|
||||
* The constructor takes a single argument, a URI or IRI string:
|
||||
*/
|
||||
constructor(iri: string);
|
||||
/**
|
||||
* Returns UTF-16 IRI
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* Returns the IRI without the fragment component. Useful for dereferencing URLs on a network.
|
||||
*/
|
||||
defrag(): IRI;
|
||||
/**
|
||||
* IRIs with a fragment are not absolute.
|
||||
*/
|
||||
isAbsolute(): boolean;
|
||||
/**
|
||||
* Resolves the IRI against itself, having the effect of stripping the fragment and checking that the supplied IRI is valid (absolute).
|
||||
*/
|
||||
toAbsolute(): IRI;
|
||||
/**
|
||||
* Resolves the IRI against itself, having the effect of stripping the fragment and checking that the supplied IRI is valid (absolute).
|
||||
*/
|
||||
authority(): string | null;
|
||||
/**
|
||||
* Returns the fragment component of the IRI.
|
||||
*/
|
||||
fragment(): string | null;
|
||||
/**
|
||||
* Returns the hier-part of the IRI, the hierarchial component: Everything between the scheme and query, including leading `//` for the host, if it exists.
|
||||
*/
|
||||
hierpart(): string;
|
||||
/**
|
||||
* Returns the host component of the URI, either a domain name or string-formatted IP address. Excludes port number and username/password.
|
||||
*/
|
||||
host(): string;
|
||||
/**
|
||||
* Returns the path component of the hier-part. Does not include the authority/host, query, or fragment.
|
||||
*/
|
||||
path(): string;
|
||||
/**
|
||||
* Returns the port component of the authority as a string, or `null` if there is no port.
|
||||
*/
|
||||
port(): string | null;
|
||||
/**
|
||||
* Returns the query component of the IRI including leading "?", or `null` if there is no query component.
|
||||
*/
|
||||
query(): string | null;
|
||||
/**
|
||||
* Resolve the provided URI/IRI reference against this IRI.
|
||||
*/
|
||||
resolveReference(ref: string | IRI): IRI;
|
||||
/**
|
||||
* Returns the scheme of the IRI, e.g. "https", "file", or "urn".
|
||||
*/
|
||||
scheme(): string | null;
|
||||
/**
|
||||
* Returns the username/password component of the IRI.
|
||||
*/
|
||||
userinfo(): string | null;
|
||||
/**
|
||||
* Returns a URI formatted string with only 7-bit characters.
|
||||
*/
|
||||
toURIString(): string;
|
||||
/**
|
||||
* Decodes URI-encoded UTF-8 characters and returns a unicode string (Strings in ECMAScript/JavaScript are UTF-16).
|
||||
*/
|
||||
toIRIString(): string;
|
||||
/**
|
||||
* Returns a new IRI object with URI-encoded UTF-8 characters decoded.
|
||||
*/
|
||||
toIRI(): IRI;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iri.IRI object with UTF-8 escaped characterd decoded.
|
||||
*/
|
||||
export function fromURI(uri: string): IRI;
|
||||
|
||||
/**
|
||||
* Returns an IRI string decoded from the given URI.
|
||||
*/
|
||||
export function toIRIString(uri: string): string;
|
||||
43
types/iri/iri-tests.ts
Normal file
43
types/iri/iri-tests.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { IRI, fromURI, toIRIString } from 'iri';
|
||||
|
||||
const iri = new IRI('iri');
|
||||
// $ExpectType string
|
||||
iri.toString();
|
||||
// $ExpectType IRI
|
||||
iri.defrag();
|
||||
// $ExpectType boolean
|
||||
iri.isAbsolute();
|
||||
// $ExpectType IRI
|
||||
iri.toAbsolute();
|
||||
// $ExpectType string | null
|
||||
iri.authority();
|
||||
// $ExpectType string | null
|
||||
iri.fragment();
|
||||
// $ExpectType string
|
||||
iri.hierpart();
|
||||
// $ExpectType string
|
||||
iri.host();
|
||||
// $ExpectType string
|
||||
iri.path();
|
||||
// $ExpectType string | null
|
||||
iri.port();
|
||||
// $ExpectType string | null
|
||||
iri.query();
|
||||
// $ExpectType IRI
|
||||
iri.resolveReference('ref');
|
||||
iri.resolveReference(iri);
|
||||
// $ExpectType string | null
|
||||
iri.scheme();
|
||||
// $ExpectType string | null
|
||||
iri.userinfo();
|
||||
// $ExpectType string
|
||||
iri.toURIString();
|
||||
// $ExpectType string
|
||||
iri.toIRIString();
|
||||
// $ExpectType IRI
|
||||
iri.toIRI();
|
||||
|
||||
// $ExpectType IRI
|
||||
fromURI('u');
|
||||
// $ExpectType string
|
||||
toIRIString('u');
|
||||
23
types/iri/tsconfig.json
Normal file
23
types/iri/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"iri-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/iri/tslint.json
Normal file
1
types/iri/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
1
types/jasmine/index.d.ts
vendored
1
types/jasmine/index.d.ts
vendored
@@ -639,6 +639,7 @@ declare namespace jasmine {
|
||||
calls: Calls;
|
||||
mostRecentCall: { args: any[]; };
|
||||
argsForCall: any[];
|
||||
withArgs(...args: any[]): Spy;
|
||||
}
|
||||
|
||||
type SpyObj<T> = T & {
|
||||
|
||||
@@ -469,6 +469,40 @@ describe("A spy, when configured with an alternate implementation", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("A spy, when configured with alternate implementations for specified arguments", () => {
|
||||
var foo: any, bar: any, fetchedBar: any;
|
||||
|
||||
beforeEach(() => {
|
||||
foo = {
|
||||
setBar: (value: any) => {
|
||||
bar = value;
|
||||
},
|
||||
getBar: () => {
|
||||
return bar;
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(foo, "getBar")
|
||||
.withArgs(1, "2")
|
||||
.and.callFake(() => 1002);
|
||||
|
||||
foo.setBar(123);
|
||||
fetchedBar = foo.getBar(1, "2");
|
||||
});
|
||||
|
||||
it("tracks that the spy was called", () => {
|
||||
expect(foo.getBar).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("should not effect other functions", () => {
|
||||
expect(bar).toEqual(123);
|
||||
});
|
||||
|
||||
it("when called returns the requested value", () => {
|
||||
expect(fetchedBar).toEqual(1002);
|
||||
});
|
||||
});
|
||||
|
||||
describe("A spy, when configured to throw a value", () => {
|
||||
var foo: any, bar: any;
|
||||
|
||||
|
||||
213
types/jju/index.d.ts
vendored
Normal file
213
types/jju/index.d.ts
vendored
Normal file
@@ -0,0 +1,213 @@
|
||||
// Type definitions for jju 1.4
|
||||
// Project: https://github.com/rlidwka/jju
|
||||
// Definitions by: Elizabeth Craig <https://github.com/ecraig12345>
|
||||
// Alex Kocharin <https://github.com/rlidwka>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// Disabling unified-signatures rule so different documentation can be provided for each signature.
|
||||
// tslint:disable:unified-signatures
|
||||
|
||||
export interface ParseOptions {
|
||||
/**
|
||||
* What to do with reserved keys (default 'ignore').
|
||||
* - "ignore" - ignore reserved keys
|
||||
* - "throw" - throw SyntaxError in case of reserved keys
|
||||
* - "replace" - replace reserved keys, this is the default JSON.parse behaviour, unsafe
|
||||
*/
|
||||
reserved_keys?: 'ignore' | 'throw' | 'replace';
|
||||
|
||||
/**
|
||||
* Create object as `Object.create(null)` instead of `{}`.
|
||||
* - If reserved_keys != 'replace', default is false.
|
||||
* - If reserved_keys == 'replace', default is true.
|
||||
*
|
||||
* It is usually unsafe and not recommended to change this option to false in the last case.
|
||||
*/
|
||||
null_prototype?: boolean;
|
||||
|
||||
/**
|
||||
* Reviver function (follows the JSON spec). This function is called for each member of the object.
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
reviver?: (key: any, value: any) => any;
|
||||
|
||||
/**
|
||||
* Operation mode (default 'json5'). Set to 'json' if you want to throw on non-strict json files.
|
||||
*/
|
||||
mode?: 'json5' | 'json' | 'cjson';
|
||||
}
|
||||
|
||||
export interface StringifyOptions {
|
||||
/**
|
||||
* Output ascii only (default false).
|
||||
* If this option is enabled, output will not have any characters except 0x20-0x7f.
|
||||
*/
|
||||
ascii?: boolean;
|
||||
|
||||
/**
|
||||
* This option follows JSON specification.
|
||||
* @default '\t'
|
||||
*/
|
||||
indent?: string | number | boolean;
|
||||
|
||||
/**
|
||||
* Enquoting char.
|
||||
* - If `mode` is 'json', default is "
|
||||
* - Otherwise, default is '
|
||||
*/
|
||||
quote?: '"' | "'";
|
||||
|
||||
/**
|
||||
* Whether keys quoting in objects is required or not.
|
||||
* If you want `{"q": 1}` instead of `{q: 1}`, set it to true.
|
||||
* - If `mode` is 'json', default is true
|
||||
* - Otherwise, default is false
|
||||
*/
|
||||
quote_keys?: boolean;
|
||||
|
||||
/**
|
||||
* Sort all keys while stringifying.
|
||||
* By default sort order will depend on implementation--with v8 it's insertion order.
|
||||
* If set to true, all keys (but not arrays) will be sorted alphabetically.
|
||||
* You can provide your own sorting function as well.
|
||||
* @default false
|
||||
*/
|
||||
sort_keys?: boolean | ((a: any, b: any) => number);
|
||||
|
||||
/**
|
||||
* Replacer function or array. This option follows JSON specification.
|
||||
* If a function, used to transform the results.
|
||||
* If an array, acts as a approved list for selecting the object properties that will be stringified.
|
||||
*/
|
||||
replacer?: ((key: string, value: any) => any) | Array<number | string>;
|
||||
|
||||
/**
|
||||
* Don't output trailing comma. If this option is set, arrays like `[1,2,3,]` will never be generated.
|
||||
* Otherwise they may be generated for pretty printing.
|
||||
* - If `mode` is JSON, default is true
|
||||
* - Otherwise, default is false
|
||||
*/
|
||||
no_trailing_comma?: boolean;
|
||||
|
||||
/**
|
||||
* Operation mode. Set it to 'json' if you want correct json in the output.
|
||||
* If it is 'json', following options are implied:
|
||||
* - options.quote = '"'
|
||||
* - options.no_trailing_comma = true
|
||||
* - options.quote_keys = true
|
||||
* - '\x' literals are not used
|
||||
*/
|
||||
mode?: 'json' | 'json5' | 'cjson';
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a token in a JSON file.
|
||||
*/
|
||||
export interface Token {
|
||||
/** Raw text of this token. If you join all raws, you will get the original document. */
|
||||
raw: string;
|
||||
/** Type of the token. */
|
||||
type: 'whitespace' | 'comment' | 'key' | 'literal' | 'separator' | 'newline';
|
||||
/** Path to the current token in the syntax tree. */
|
||||
stack: string[];
|
||||
/** Value of the token if token is a key or literal. */
|
||||
value?: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Object defining a programming style in which the JSON document was written.
|
||||
*/
|
||||
export interface JsonStyle {
|
||||
/** Preferred indentation. */
|
||||
indent: string;
|
||||
/** Preferred newline. */
|
||||
newline: string;
|
||||
/** " or ' depending on which quote is preferred. */
|
||||
quote: string;
|
||||
/** True if unquoted keys were used at least once. */
|
||||
quote_keys: boolean;
|
||||
/** True if input has a whitespace token. */
|
||||
has_whitespace: boolean;
|
||||
/** True if input has a comment token. */
|
||||
has_comments: boolean;
|
||||
/** True if input has a newline token. */
|
||||
has_newlines: boolean;
|
||||
/** True if input has at least one trailing comma. */
|
||||
has_trailing_comma: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse json/json5 text and returns a javascript value it corresponds to.
|
||||
* @param text Text to parse
|
||||
* @param options Parser options
|
||||
*/
|
||||
export function parse(text: string, options?: ParseOptions): any;
|
||||
/**
|
||||
* Compatibility syntax (follows JSON specification).
|
||||
* Converts a JavaScript Object Notation (JSON) string into an object.
|
||||
* @param text A valid JSON string.
|
||||
* @param reviver A function that transforms the results. This function is called for each member of the object.
|
||||
* If a member contains nested objects, the nested objects are transformed before the parent object is.
|
||||
*/
|
||||
export function parse(text: string, reviver?: (key: any, value: any) => any): any;
|
||||
|
||||
/**
|
||||
* Convert javascript value to an appropriate json/json5 text.
|
||||
* @param value Value to serialize
|
||||
* @param options Serializer options
|
||||
*/
|
||||
export function stringify(value: any, options?: StringifyOptions): string;
|
||||
/**
|
||||
* Compatibility syntax (follows JSON specification).
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer A function that transforms the results.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
export function stringify(value: any, replacer?: (key: string, value: any) => any, space?: string | number): string;
|
||||
/**
|
||||
* Compatibility syntax (follows JSON specification).
|
||||
* Converts a JavaScript value to a JavaScript Object Notation (JSON) string.
|
||||
* @param value A JavaScript value, usually an object or array, to be converted.
|
||||
* @param replacer An array of strings and numbers that acts as a approved list for selecting the object properties that will be stringified.
|
||||
* @param space Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read.
|
||||
*/
|
||||
export function stringify(value: any, replacer?: Array<number | string> | null, space?: string | number): string;
|
||||
|
||||
/**
|
||||
* Parse json/json5 text and return an array of tokens it consists of.
|
||||
* @param text Text to tokenize
|
||||
* @param options Parser options
|
||||
*/
|
||||
export function tokenize(text: string, options?: ParseOptions): Token[];
|
||||
|
||||
/**
|
||||
* Parse json/json5 text and try to guess indentation, quoting style, etc.
|
||||
* @param text Text to analyze
|
||||
* @param options Parser options
|
||||
*/
|
||||
export function analyze(text: string, options?: ParseOptions): JsonStyle;
|
||||
|
||||
/**
|
||||
* Change json/json5 text, preserving original formatting as much as possible.
|
||||
* @param text Original text
|
||||
* @param new_value New value you want to set
|
||||
* @param options Parser and stringifier options
|
||||
*
|
||||
* @example
|
||||
* // here is your original JSON document:
|
||||
* var input = '{"foo": "bar", "baz": 123}'
|
||||
*
|
||||
* // you need to parse it first:
|
||||
* var json = jju.parse(input, {mode: 'json'})
|
||||
* // json is { foo: 'bar', baz: 123 }
|
||||
*
|
||||
* // then you can change it as you like:
|
||||
* json.foo = 'quux'
|
||||
* json.hello = 'world'
|
||||
*
|
||||
* // then you run an update function to change the original json:
|
||||
* var output = jju.update(input, json, {mode: 'json'})
|
||||
* // output is '{"foo": "quux", "baz": 123, "hello": "world"}'
|
||||
*/
|
||||
export function update(text: string, new_value: any, options?: ParseOptions & StringifyOptions): string;
|
||||
4
types/jju/jju-tests.ts
Normal file
4
types/jju/jju-tests.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
import * as jju from 'jju';
|
||||
|
||||
jju.parse('{}'); // $ExpectType any
|
||||
jju.stringify({}); // $ExpectType string
|
||||
23
types/jju/tsconfig.json
Normal file
23
types/jju/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"jju-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/jju/tslint.json
Normal file
1
types/jju/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
23
types/karma-coverage/index.d.ts
vendored
23
types/karma-coverage/index.d.ts
vendored
@@ -1,27 +1,22 @@
|
||||
// Type definitions for karma-coverage v0.5.3
|
||||
// Type definitions for karma-coverage 1.1
|
||||
// Project: https://github.com/karma-runner/karma-coverage
|
||||
// Definitions by: Tanguy Krotoff <https://github.com/tkrotoff>
|
||||
// Yaroslav Admin <https://github.com/devoto13>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as karma from 'karma';
|
||||
import 'karma';
|
||||
import * as istanbul from 'istanbul';
|
||||
|
||||
declare namespace karmaCoverage {
|
||||
interface Karma extends karma.Karma { }
|
||||
|
||||
interface Config extends karma.Config {
|
||||
set: (config: ConfigOptions) => void;
|
||||
}
|
||||
|
||||
interface ConfigOptions extends karma.ConfigOptions {
|
||||
declare module 'karma' {
|
||||
interface ConfigOptions {
|
||||
/**
|
||||
* See https://github.com/karma-runner/karma-coverage/blob/master/docs/configuration.md
|
||||
*/
|
||||
coverageReporter?: (Reporter | Reporter[]);
|
||||
coverageReporter?: KarmaCoverageReporter & { reporters?: KarmaCoverageReporter[] };
|
||||
}
|
||||
|
||||
interface Reporter {
|
||||
interface KarmaCoverageReporter {
|
||||
type?: string;
|
||||
dir?: string;
|
||||
subdir?: string | ((browser: string) => string);
|
||||
@@ -33,7 +28,3 @@ declare namespace karmaCoverage {
|
||||
[moreSettings: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
declare var karmaCoverage: karmaCoverage.Karma;
|
||||
|
||||
export = karmaCoverage;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as karma from 'karma-coverage';
|
||||
import * as karma from 'karma';
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#basic
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/README.md#basic
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
files: [
|
||||
@@ -20,13 +20,13 @@ module.exports = function(config: karma.Config) {
|
||||
|
||||
// optionally, configure the reporter
|
||||
coverageReporter: {
|
||||
type : 'html',
|
||||
dir : 'coverage/'
|
||||
type: 'html',
|
||||
dir: 'coverage/'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#advanced-multiple-reporters
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/README.md#advanced-multiple-reporters
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
files: [
|
||||
@@ -56,7 +56,7 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/README.md#dont-minify-instrumenter-output
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/README.md#dont-minify-instrumenter-output
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
@@ -67,7 +67,7 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#subdir
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#subdir
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
@@ -93,7 +93,7 @@ module.exports = function(config: karma.Config) {
|
||||
coverageReporter: {
|
||||
dir: 'coverage',
|
||||
subdir: function(browser) {
|
||||
// normalization process to keep a consistent browser name accross different
|
||||
// normalization process to keep a consistent browser name across different
|
||||
// OS
|
||||
return browser.toLowerCase().split(/[ /-]/)[0];
|
||||
}
|
||||
@@ -102,18 +102,18 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#file
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#file
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
type : 'text',
|
||||
dir : 'coverage/',
|
||||
file : 'coverage.txt'
|
||||
type: 'text',
|
||||
dir: 'coverage/',
|
||||
file: 'coverage.txt'
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#check
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#check
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
@@ -146,7 +146,7 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#watermarks
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#watermarks
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
@@ -160,24 +160,36 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#sourcestore
|
||||
module.exports = function(config: karma.Config) {
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#includeallsources
|
||||
module.exports = function (config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
type : 'text',
|
||||
dir : 'coverage/',
|
||||
file : 'coverage.txt',
|
||||
sourceStore : require('istanbul').Store.create('fslookup')
|
||||
type: 'text',
|
||||
dir: 'coverage/',
|
||||
file: 'coverage.txt',
|
||||
includeAllSources: true
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#reporters
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#sourcestore
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
reporters:[
|
||||
{type: 'html', dir:'coverage/'},
|
||||
type: 'text',
|
||||
dir: 'coverage/',
|
||||
file: 'coverage.txt',
|
||||
sourceStore: require('istanbul').Store.create('fslookup')
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#reporters
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
reporters: [
|
||||
{type: 'html', dir: 'coverage/'},
|
||||
{type: 'teamcity'},
|
||||
{type: 'text-summary'}
|
||||
],
|
||||
@@ -185,7 +197,7 @@ module.exports = function(config: karma.Config) {
|
||||
});
|
||||
};
|
||||
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v0.5.3/docs/configuration.md#instrumenter
|
||||
// See https://github.com/karma-runner/karma-coverage/blob/v1.1.2/docs/configuration.md#instrumenter
|
||||
module.exports = function(config: karma.Config) {
|
||||
config.set({
|
||||
coverageReporter: {
|
||||
|
||||
885
types/karma/index.d.ts
vendored
885
types/karma/index.d.ts
vendored
@@ -13,58 +13,55 @@ import Promise = require('bluebird');
|
||||
import https = require('https');
|
||||
import { Appender } from 'log4js';
|
||||
|
||||
declare namespace karma {
|
||||
interface Karma {
|
||||
/**
|
||||
* `start` method is deprecated since 0.13. It will be removed in 0.14.
|
||||
* Please use
|
||||
* <code>
|
||||
* server = new Server(config, [done])
|
||||
* server.start()
|
||||
* </code>
|
||||
* instead.
|
||||
*/
|
||||
server: DeprecatedServer;
|
||||
Server: Server;
|
||||
runner: Runner;
|
||||
stopper: Stopper;
|
||||
launcher: Launcher;
|
||||
VERSION: string;
|
||||
constants: Constants;
|
||||
}
|
||||
/**
|
||||
* `start` method is deprecated since 0.13. It will be removed in 0.14.
|
||||
* Please use
|
||||
* <code>
|
||||
* server = new Server(config, [done])
|
||||
* server.start()
|
||||
* </code>
|
||||
* instead.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
export const server: DeprecatedServer;
|
||||
|
||||
interface Constants {
|
||||
VERSION: string;
|
||||
DEFAULT_PORT: number;
|
||||
DEFAULT_HOSTNAME: string;
|
||||
DEFAULT_LISTEN_ADDR: string;
|
||||
LOG_DISABLE: string;
|
||||
LOG_ERROR: string;
|
||||
LOG_WARN: string;
|
||||
LOG_INFO: string;
|
||||
LOG_DEBUG: string;
|
||||
LOG_LOG: string;
|
||||
LOG_PRIORITIES: string[];
|
||||
COLOR_PATTERN: string;
|
||||
NO_COLOR_PATTERN: string;
|
||||
CONSOLE_APPENDER: {
|
||||
export const runner: Runner;
|
||||
export const stopper: Stopper;
|
||||
|
||||
export const VERSION: string;
|
||||
export const constants: Constants;
|
||||
|
||||
export interface Constants {
|
||||
VERSION: string;
|
||||
DEFAULT_PORT: number;
|
||||
DEFAULT_HOSTNAME: string;
|
||||
DEFAULT_LISTEN_ADDR: string;
|
||||
LOG_DISABLE: string;
|
||||
LOG_ERROR: string;
|
||||
LOG_WARN: string;
|
||||
LOG_INFO: string;
|
||||
LOG_DEBUG: string;
|
||||
LOG_LOG: string;
|
||||
LOG_PRIORITIES: string[];
|
||||
COLOR_PATTERN: string;
|
||||
NO_COLOR_PATTERN: string;
|
||||
CONSOLE_APPENDER: {
|
||||
type: string;
|
||||
layout: {
|
||||
type: string;
|
||||
layout: {
|
||||
type: string;
|
||||
pattern: string;
|
||||
};
|
||||
pattern: string;
|
||||
};
|
||||
EXIT_CODE: string;
|
||||
}
|
||||
};
|
||||
EXIT_CODE: string;
|
||||
}
|
||||
|
||||
interface LauncherStatic {
|
||||
generateId(): string;
|
||||
// TODO: injector should be of type `di.Injector`
|
||||
new (emitter: NodeJS.EventEmitter, injector: any): Launcher;
|
||||
}
|
||||
export namespace launcher {
|
||||
class Launcher {
|
||||
static generateId(): string;
|
||||
|
||||
constructor(emitter: NodeJS.EventEmitter, injector: any);
|
||||
|
||||
interface Launcher {
|
||||
Launcher: LauncherStatic;
|
||||
// TODO: Can this return value ever be typified?
|
||||
launch(names: string[], protocol: string, hostname: string, port: number, urlRoot: string): any[];
|
||||
kill(id: string, callback: () => void): boolean;
|
||||
@@ -73,403 +70,403 @@ declare namespace karma {
|
||||
areAllCaptured(): boolean;
|
||||
markCaptured(id: string): void;
|
||||
}
|
||||
|
||||
interface DeprecatedServer {
|
||||
start(options?: any, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
interface Runner {
|
||||
run(options?: ConfigOptions | ConfigFile, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
interface Stopper {
|
||||
/**
|
||||
* This function will signal a running server to stop. The equivalent of karma stop.
|
||||
*/
|
||||
stop(options?: ConfigOptions, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
interface TestResults {
|
||||
disconnected: boolean;
|
||||
error: boolean;
|
||||
exitCode: number;
|
||||
failed: number;
|
||||
success: number;
|
||||
}
|
||||
|
||||
interface Server extends NodeJS.EventEmitter {
|
||||
// TODO: Figure out how to convert Server to class and remove suppression
|
||||
// tslint:disable-next-line:no-misused-new
|
||||
new (options?: ConfigOptions | ConfigFile, callback?: ServerCallback): Server;
|
||||
/**
|
||||
* Start the server
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Get properties from the injector
|
||||
* @param token
|
||||
*/
|
||||
get(token: string): any;
|
||||
/**
|
||||
* Force a refresh of the file list
|
||||
*/
|
||||
refreshFiles(): Promise<any>;
|
||||
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
|
||||
/**
|
||||
* Listen to the 'run_complete' event.
|
||||
*/
|
||||
on(event: 'run_complete', listener: (browsers: any, results: TestResults) => void): this;
|
||||
|
||||
/**
|
||||
* Backward-compatibility with karma-intellij bundled with WebStorm.
|
||||
* Deprecated since version 0.13, to be removed in 0.14
|
||||
*/
|
||||
// static start(): void;
|
||||
}
|
||||
|
||||
type ServerCallback = (exitCode: number) => void;
|
||||
|
||||
interface Config {
|
||||
set: (config: ConfigOptions) => void;
|
||||
LOG_DISABLE: string;
|
||||
LOG_ERROR: string;
|
||||
LOG_WARN: string;
|
||||
LOG_INFO: string;
|
||||
LOG_DEBUG: string;
|
||||
}
|
||||
|
||||
interface ConfigFile {
|
||||
configFile: string;
|
||||
}
|
||||
|
||||
interface ConfigOptions {
|
||||
/**
|
||||
* @description Enable or disable watching files and executing the tests whenever one of these files changes.
|
||||
* @default true
|
||||
*/
|
||||
autoWatch?: boolean;
|
||||
/**
|
||||
* @description When Karma is watching the files for changes, it tries to batch multiple changes into a single run
|
||||
* so that the test runner doesn't try to start and restart running tests more than it should.
|
||||
* The configuration setting tells Karma how long to wait (in milliseconds) after any changes have occurred
|
||||
* before starting the test process again.
|
||||
* @default 250
|
||||
*/
|
||||
autoWatchBatchDelay?: number;
|
||||
/**
|
||||
* @default ''
|
||||
* @description The root path location that will be used to resolve all relative paths defined in <code>files</code> and <code>exclude</code>.
|
||||
* If the basePath configuration is a relative path then it will be resolved to
|
||||
* the <code>__dirname</code> of the configuration file.
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* @default 2000
|
||||
* @description How long does Karma wait for a browser to reconnect (in ms).
|
||||
* <p>
|
||||
* With a flaky connection it is pretty common that the browser disconnects,
|
||||
* but the actual test execution is still running without any problems. Karma does not treat a disconnection
|
||||
* as immediate failure and will wait <code>browserDisconnectTimeout</code> (ms).
|
||||
* If the browser reconnects during that time, everything is fine.
|
||||
* </p>
|
||||
*/
|
||||
browserDisconnectTimeout?: number;
|
||||
/**
|
||||
* @default 0
|
||||
* @description The number of disconnections tolerated.
|
||||
* <p>
|
||||
* The <code>disconnectTolerance</code> value represents the maximum number of tries a browser will attempt
|
||||
* in the case of a disconnection. Usually any disconnection is considered a failure,
|
||||
* but this option allows you to define a tolerance level when there is a flaky network link between
|
||||
* the Karma server and the browsers.
|
||||
* </p>
|
||||
*/
|
||||
browserDisconnectTolerance?: number;
|
||||
/**
|
||||
* @default 10000
|
||||
* @description How long will Karma wait for a message from a browser before disconnecting from it (in ms).
|
||||
* <p>
|
||||
* If, during test execution, Karma does not receive any message from a browser within
|
||||
* <code>browserNoActivityTimeout</code> (ms), it will disconnect from the browser
|
||||
* </p>
|
||||
*/
|
||||
browserNoActivityTimeout?: number;
|
||||
/**
|
||||
* @default []
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>Chrome (launcher comes installed with Karma)</li>
|
||||
* <li>ChromeCanary (launcher comes installed with Karma)</li>
|
||||
* <li>PhantomJS (launcher comes installed with Karma)</li>
|
||||
* <li>Firefox (launcher requires karma-firefox-launcher plugin)</li>
|
||||
* <li>Opera (launcher requires karma-opera-launcher plugin)</li>
|
||||
* <li>Internet Explorer (launcher requires karma-ie-launcher plugin)</li>
|
||||
* <li>Safari (launcher requires karma-safari-launcher plugin)</li>
|
||||
* </ul>
|
||||
* @description A list of browsers to launch and capture. When Karma starts up, it will also start up each browser
|
||||
* which is placed within this setting. Once Karma is shut down, it will shut down these browsers as well.
|
||||
* You can capture any browser manually by opening the browser and visiting the URL where
|
||||
* the Karma web server is listening (by default it is <code>http://localhost:9876/</code>).
|
||||
*/
|
||||
browsers?: string[];
|
||||
/**
|
||||
* @default 60000
|
||||
* @description Timeout for capturing a browser (in ms).
|
||||
* <p>
|
||||
* The <code>captureTimeout</code> value represents the maximum boot-up time allowed for a
|
||||
* browser to start and connect to Karma. If any browser does not get captured within the timeout, Karma
|
||||
* will kill it and try to launch it again and, after three attempts to capture it, Karma will give up.
|
||||
* </p>
|
||||
*/
|
||||
captureTimeout?: number;
|
||||
client?: ClientOptions;
|
||||
/**
|
||||
* @default true
|
||||
* @description Enable or disable colors in the output (reporters and logs).
|
||||
*/
|
||||
colors?: boolean;
|
||||
/**
|
||||
* @default 'Infinity'
|
||||
* @description How many browsers Karma launches in parallel.
|
||||
* Especially on services like SauceLabs and Browserstack, it makes sense only to launch a limited
|
||||
* amount of browsers at once, and only start more when those have finished. Using this configuration,
|
||||
* you can specify how many browsers should be running at once at any given point in time.
|
||||
*/
|
||||
concurrency?: number;
|
||||
customLaunchers?: { [key: string]: CustomLauncher };
|
||||
/**
|
||||
* @default []
|
||||
* @description List of files/patterns to exclude from loaded files.
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* @default []
|
||||
* @description List of files/patterns to load in the browser.
|
||||
*/
|
||||
files?: Array<FilePattern | string>;
|
||||
/**
|
||||
* @default []
|
||||
* @description List of test frameworks you want to use. Typically, you will set this to ['jasmine'], ['mocha'] or ['qunit']...
|
||||
* Please note just about all frameworks in Karma require an additional plugin/framework library to be installed (via NPM).
|
||||
*/
|
||||
frameworks?: string[];
|
||||
/**
|
||||
* @default 'localhost'
|
||||
* @description Hostname to be used when capturing browsers.
|
||||
*/
|
||||
hostname?: string;
|
||||
/**
|
||||
* @default {}
|
||||
* @description Options object to be used by Node's https class.
|
||||
* Object description can be found in the
|
||||
* [NodeJS.org API docs](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)
|
||||
*/
|
||||
httpsServerOptions?: https.ServerOptions;
|
||||
/**
|
||||
* @default config.LOG_INFO
|
||||
* Possible values:
|
||||
* <ul>
|
||||
* <li>config.LOG_DISABLE</li>
|
||||
* <li>config.LOG_ERROR</li>
|
||||
* <li>config.LOG_WARN</li>
|
||||
* <li>config.LOG_INFO</li>
|
||||
* <li>config.LOG_DEBUG</li>
|
||||
* </ul>
|
||||
* @description Level of logging.
|
||||
*/
|
||||
logLevel?: string;
|
||||
/**
|
||||
* @default [{type: 'console'}]
|
||||
* @description A list of log appenders to be used. See the documentation for [log4js] for more information.
|
||||
*/
|
||||
loggers?: { [name: string]: Appender } | Appender[];
|
||||
/**
|
||||
* @default []
|
||||
* @description List of names of additional middleware you want the
|
||||
* Karma server to use. Middleware will be used in the order listed.
|
||||
* You must have installed the middleware via a plugin/framework
|
||||
* (either inline or via NPM). Additional information can be found in
|
||||
* [plugins](http://karma-runner.github.io/2.0/config/plugins.html).
|
||||
* The plugin must provide an express/connect middleware function
|
||||
* (details about this can be found in the
|
||||
* [Express](http://expressjs.com/guide/using-middleware.html) docs).
|
||||
*/
|
||||
middleware?: string[];
|
||||
/**
|
||||
* @default {}
|
||||
* @description Redefine default mapping from file extensions to MIME-type.
|
||||
* Set property name to required MIME, provide Array of extensions (without dots) as it's value.
|
||||
*/
|
||||
mime?: {[type: string]: string[]};
|
||||
/**
|
||||
* @default ['karma-*']
|
||||
* @description List of plugins to load. A plugin can be a string (in which case it will be required
|
||||
* by Karma) or an inlined plugin - Object.
|
||||
* By default, Karma loads all sibling NPM modules which have a name starting with karma-*.
|
||||
* Note: Just about all plugins in Karma require an additional library to be installed (via NPM).
|
||||
*/
|
||||
plugins?: any[];
|
||||
/**
|
||||
* @default 9876
|
||||
* @description The port where the web server will be listening.
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* @default {'**\/*.coffee': 'coffee'}
|
||||
* @description A map of preprocessors to use.
|
||||
*
|
||||
* Preprocessors can be loaded through [plugins].
|
||||
*
|
||||
* Note: Just about all preprocessors in Karma (other than CoffeeScript and some other defaults)
|
||||
* require an additional library to be installed (via NPM).
|
||||
*
|
||||
* Be aware that preprocessors may be transforming the files and file types that are available at run time. For instance,
|
||||
* if you are using the "coverage" preprocessor on your source files, if you then attempt to interactively debug
|
||||
* your tests, you'll discover that your expected source code is completely changed from what you expected. Because
|
||||
* of that, you'll want to engineer this so that your automated builds use the coverage entry in the "reporters" list,
|
||||
* but your interactive debugging does not.
|
||||
*
|
||||
*/
|
||||
preprocessors?: { [name: string]: string | string[] };
|
||||
/**
|
||||
* @default 'http:'
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>http:</li>
|
||||
* <li>https:</li>
|
||||
* </ul>
|
||||
* @description Protocol used for running the Karma webserver.
|
||||
* Determines the use of the Node http or https class.
|
||||
* Note: Using <code>'https:'</code> requires you to specify <code>httpsServerOptions</code>.
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* @default {}
|
||||
* @description A map of path-proxy pairs.
|
||||
*/
|
||||
proxies?: { [path: string]: string };
|
||||
/**
|
||||
* @default true
|
||||
* @description Whether or not Karma or any browsers should raise an error when an inavlid SSL certificate is found.
|
||||
*/
|
||||
proxyValidateSSL?: boolean;
|
||||
/**
|
||||
* @default 0
|
||||
* @description Karma will report all the tests that are slower than given time limit (in ms).
|
||||
* This is disabled by default (since the default value is 0).
|
||||
*/
|
||||
reportSlowerThan?: number;
|
||||
/**
|
||||
* @default ['progress']
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>dots</li>
|
||||
* <li>progress</li>
|
||||
* </ul>
|
||||
* @description A list of reporters to use.
|
||||
* Additional reporters, such as growl, junit, teamcity or coverage can be loaded through plugins.
|
||||
* Note: Just about all additional reporters in Karma (other than progress) require an additional library to be installed (via NPM).
|
||||
*/
|
||||
reporters?: string[];
|
||||
/**
|
||||
* @default false
|
||||
* @description Continuous Integration mode.
|
||||
* If true, Karma will start and capture all configured browsers, run tests and then exit with an exit code of 0 or 1 depending
|
||||
* on whether all tests passed or any tests failed.
|
||||
*/
|
||||
singleRun?: boolean;
|
||||
/**
|
||||
* @default ['polling', 'websocket']
|
||||
* @description An array of allowed transport methods between the browser and testing server. This configuration setting
|
||||
* is handed off to [socket.io](http://socket.io/) (which manages the communication
|
||||
* between browsers and the testing server).
|
||||
*/
|
||||
transports?: string[];
|
||||
/**
|
||||
* @default '/'
|
||||
* @description The base url, where Karma runs.
|
||||
* All of Karma's urls get prefixed with the urlRoot. This is helpful when using proxies, as
|
||||
* sometimes you might want to proxy a url that is already taken by Karma.
|
||||
*/
|
||||
urlRoot?: string;
|
||||
}
|
||||
|
||||
interface ClientOptions {
|
||||
/**
|
||||
* @default undefined
|
||||
* @description When karma run is passed additional arguments on the command-line, they
|
||||
* are passed through to the test adapter as karma.config.args (an array of strings).
|
||||
* The client.args option allows you to set this value for actions other than run.
|
||||
* How this value is used is up to your test adapter - you should check your adapter's
|
||||
* documentation to see how (and if) it uses this value.
|
||||
*/
|
||||
args?: string[];
|
||||
/**
|
||||
* @default true
|
||||
* @description Run the tests inside an iFrame or a new window
|
||||
* If true, Karma runs the tests inside an iFrame. If false, Karma runs the tests in a new window. Some tests may not run in an
|
||||
* iFrame and may need a new window to run.
|
||||
*/
|
||||
useIframe?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Capture all console output and pipe it to the terminal.
|
||||
*/
|
||||
captureConsole?: boolean;
|
||||
/**
|
||||
* @default false
|
||||
* @description Run the tests on the same window as the client, without using iframe or a new window
|
||||
*/
|
||||
runInParent?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Clear the context window
|
||||
* If true, Karma clears the context window upon the completion of running the tests.
|
||||
* If false, Karma does not clear the context window upon the completion of running the tests.
|
||||
* Setting this to false is useful when embedding a Jasmine Spec Runner Template.
|
||||
*/
|
||||
clearContext?: boolean;
|
||||
}
|
||||
|
||||
interface FilePattern {
|
||||
/**
|
||||
* The pattern to use for matching. This property is mandatory.
|
||||
*/
|
||||
pattern: string;
|
||||
/**
|
||||
* @default true
|
||||
* @description If <code>autoWatch</code> is true all files that have set watched to true will be watched
|
||||
* for changes.
|
||||
*/
|
||||
watched?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Should the files be included in the browser using <script> tag? Use false if you want to
|
||||
* load them manually, eg. using Require.js.
|
||||
*/
|
||||
included?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Should the files be served by Karma's webserver?
|
||||
*/
|
||||
served?: boolean;
|
||||
/**
|
||||
* @default false
|
||||
* @description Should the files be served from disk on each request by Karma's webserver?
|
||||
*/
|
||||
nocache?: boolean;
|
||||
}
|
||||
|
||||
interface CustomLauncher {
|
||||
base: string;
|
||||
browserName?: string;
|
||||
flags?: string[];
|
||||
platform?: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare var karma: karma.Karma;
|
||||
/** @deprecated */
|
||||
export interface DeprecatedServer {
|
||||
/** @deprecated */
|
||||
start(options?: any, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
export = karma;
|
||||
export interface Runner {
|
||||
run(options?: ConfigOptions | ConfigFile, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
export interface Stopper {
|
||||
/**
|
||||
* This function will signal a running server to stop. The equivalent of karma stop.
|
||||
*/
|
||||
stop(options?: ConfigOptions, callback?: ServerCallback): void;
|
||||
}
|
||||
|
||||
export interface TestResults {
|
||||
disconnected: boolean;
|
||||
error: boolean;
|
||||
exitCode: number;
|
||||
failed: number;
|
||||
success: number;
|
||||
}
|
||||
|
||||
export class Server extends NodeJS.EventEmitter {
|
||||
constructor(options?: ConfigOptions | ConfigFile, callback?: ServerCallback);
|
||||
/**
|
||||
* Start the server
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Get properties from the injector
|
||||
* @param token
|
||||
*/
|
||||
get(token: string): any;
|
||||
/**
|
||||
* Force a refresh of the file list
|
||||
*/
|
||||
refreshFiles(): Promise<any>;
|
||||
|
||||
on(event: string, listener: (...args: any[]) => void): this;
|
||||
|
||||
/**
|
||||
* Listen to the 'run_complete' event.
|
||||
*/
|
||||
on(event: 'run_complete', listener: (browsers: any, results: TestResults) => void): this;
|
||||
|
||||
/**
|
||||
* Backward-compatibility with karma-intellij bundled with WebStorm.
|
||||
* Deprecated since version 0.13, to be removed in 0.14
|
||||
*/
|
||||
// static start(): void;
|
||||
}
|
||||
|
||||
export type ServerCallback = (exitCode: number) => void;
|
||||
|
||||
export interface Config {
|
||||
set: (config: ConfigOptions) => void;
|
||||
LOG_DISABLE: string;
|
||||
LOG_ERROR: string;
|
||||
LOG_WARN: string;
|
||||
LOG_INFO: string;
|
||||
LOG_DEBUG: string;
|
||||
}
|
||||
|
||||
export interface ConfigFile {
|
||||
configFile: string;
|
||||
}
|
||||
|
||||
export interface ConfigOptions {
|
||||
/**
|
||||
* @description Enable or disable watching files and executing the tests whenever one of these files changes.
|
||||
* @default true
|
||||
*/
|
||||
autoWatch?: boolean;
|
||||
/**
|
||||
* @description When Karma is watching the files for changes, it tries to batch multiple changes into a single run
|
||||
* so that the test runner doesn't try to start and restart running tests more than it should.
|
||||
* The configuration setting tells Karma how long to wait (in milliseconds) after any changes have occurred
|
||||
* before starting the test process again.
|
||||
* @default 250
|
||||
*/
|
||||
autoWatchBatchDelay?: number;
|
||||
/**
|
||||
* @default ''
|
||||
* @description The root path location that will be used to resolve all relative paths defined in <code>files</code> and <code>exclude</code>.
|
||||
* If the basePath configuration is a relative path then it will be resolved to
|
||||
* the <code>__dirname</code> of the configuration file.
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* @default 2000
|
||||
* @description How long does Karma wait for a browser to reconnect (in ms).
|
||||
* <p>
|
||||
* With a flaky connection it is pretty common that the browser disconnects,
|
||||
* but the actual test execution is still running without any problems. Karma does not treat a disconnection
|
||||
* as immediate failure and will wait <code>browserDisconnectTimeout</code> (ms).
|
||||
* If the browser reconnects during that time, everything is fine.
|
||||
* </p>
|
||||
*/
|
||||
browserDisconnectTimeout?: number;
|
||||
/**
|
||||
* @default 0
|
||||
* @description The number of disconnections tolerated.
|
||||
* <p>
|
||||
* The <code>disconnectTolerance</code> value represents the maximum number of tries a browser will attempt
|
||||
* in the case of a disconnection. Usually any disconnection is considered a failure,
|
||||
* but this option allows you to define a tolerance level when there is a flaky network link between
|
||||
* the Karma server and the browsers.
|
||||
* </p>
|
||||
*/
|
||||
browserDisconnectTolerance?: number;
|
||||
/**
|
||||
* @default 10000
|
||||
* @description How long will Karma wait for a message from a browser before disconnecting from it (in ms).
|
||||
* <p>
|
||||
* If, during test execution, Karma does not receive any message from a browser within
|
||||
* <code>browserNoActivityTimeout</code> (ms), it will disconnect from the browser
|
||||
* </p>
|
||||
*/
|
||||
browserNoActivityTimeout?: number;
|
||||
/**
|
||||
* @default []
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>Chrome (launcher comes installed with Karma)</li>
|
||||
* <li>ChromeCanary (launcher comes installed with Karma)</li>
|
||||
* <li>PhantomJS (launcher comes installed with Karma)</li>
|
||||
* <li>Firefox (launcher requires karma-firefox-launcher plugin)</li>
|
||||
* <li>Opera (launcher requires karma-opera-launcher plugin)</li>
|
||||
* <li>Internet Explorer (launcher requires karma-ie-launcher plugin)</li>
|
||||
* <li>Safari (launcher requires karma-safari-launcher plugin)</li>
|
||||
* </ul>
|
||||
* @description A list of browsers to launch and capture. When Karma starts up, it will also start up each browser
|
||||
* which is placed within this setting. Once Karma is shut down, it will shut down these browsers as well.
|
||||
* You can capture any browser manually by opening the browser and visiting the URL where
|
||||
* the Karma web server is listening (by default it is <code>http://localhost:9876/</code>).
|
||||
*/
|
||||
browsers?: string[];
|
||||
/**
|
||||
* @default 60000
|
||||
* @description Timeout for capturing a browser (in ms).
|
||||
* <p>
|
||||
* The <code>captureTimeout</code> value represents the maximum boot-up time allowed for a
|
||||
* browser to start and connect to Karma. If any browser does not get captured within the timeout, Karma
|
||||
* will kill it and try to launch it again and, after three attempts to capture it, Karma will give up.
|
||||
* </p>
|
||||
*/
|
||||
captureTimeout?: number;
|
||||
client?: ClientOptions;
|
||||
/**
|
||||
* @default true
|
||||
* @description Enable or disable colors in the output (reporters and logs).
|
||||
*/
|
||||
colors?: boolean;
|
||||
/**
|
||||
* @default 'Infinity'
|
||||
* @description How many browsers Karma launches in parallel.
|
||||
* Especially on services like SauceLabs and Browserstack, it makes sense only to launch a limited
|
||||
* amount of browsers at once, and only start more when those have finished. Using this configuration,
|
||||
* you can specify how many browsers should be running at once at any given point in time.
|
||||
*/
|
||||
concurrency?: number;
|
||||
customLaunchers?: { [key: string]: CustomLauncher };
|
||||
/**
|
||||
* @default []
|
||||
* @description List of files/patterns to exclude from loaded files.
|
||||
*/
|
||||
exclude?: string[];
|
||||
/**
|
||||
* @default []
|
||||
* @description List of files/patterns to load in the browser.
|
||||
*/
|
||||
files?: Array<FilePattern | string>;
|
||||
/**
|
||||
* @default []
|
||||
* @description List of test frameworks you want to use. Typically, you will set this to ['jasmine'], ['mocha'] or ['qunit']...
|
||||
* Please note just about all frameworks in Karma require an additional plugin/framework library to be installed (via NPM).
|
||||
*/
|
||||
frameworks?: string[];
|
||||
/**
|
||||
* @default 'localhost'
|
||||
* @description Hostname to be used when capturing browsers.
|
||||
*/
|
||||
hostname?: string;
|
||||
/**
|
||||
* @default {}
|
||||
* @description Options object to be used by Node's https class.
|
||||
* Object description can be found in the
|
||||
* [NodeJS.org API docs](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)
|
||||
*/
|
||||
httpsServerOptions?: https.ServerOptions;
|
||||
/**
|
||||
* @default config.LOG_INFO
|
||||
* Possible values:
|
||||
* <ul>
|
||||
* <li>config.LOG_DISABLE</li>
|
||||
* <li>config.LOG_ERROR</li>
|
||||
* <li>config.LOG_WARN</li>
|
||||
* <li>config.LOG_INFO</li>
|
||||
* <li>config.LOG_DEBUG</li>
|
||||
* </ul>
|
||||
* @description Level of logging.
|
||||
*/
|
||||
logLevel?: string;
|
||||
/**
|
||||
* @default [{type: 'console'}]
|
||||
* @description A list of log appenders to be used. See the documentation for [log4js] for more information.
|
||||
*/
|
||||
loggers?: { [name: string]: Appender } | Appender[];
|
||||
/**
|
||||
* @default []
|
||||
* @description List of names of additional middleware you want the
|
||||
* Karma server to use. Middleware will be used in the order listed.
|
||||
* You must have installed the middleware via a plugin/framework
|
||||
* (either inline or via NPM). Additional information can be found in
|
||||
* [plugins](http://karma-runner.github.io/2.0/config/plugins.html).
|
||||
* The plugin must provide an express/connect middleware function
|
||||
* (details about this can be found in the
|
||||
* [Express](http://expressjs.com/guide/using-middleware.html) docs).
|
||||
*/
|
||||
middleware?: string[];
|
||||
/**
|
||||
* @default {}
|
||||
* @description Redefine default mapping from file extensions to MIME-type.
|
||||
* Set property name to required MIME, provide Array of extensions (without dots) as it's value.
|
||||
*/
|
||||
mime?: {[type: string]: string[]};
|
||||
/**
|
||||
* @default ['karma-*']
|
||||
* @description List of plugins to load. A plugin can be a string (in which case it will be required
|
||||
* by Karma) or an inlined plugin - Object.
|
||||
* By default, Karma loads all sibling NPM modules which have a name starting with karma-*.
|
||||
* Note: Just about all plugins in Karma require an additional library to be installed (via NPM).
|
||||
*/
|
||||
plugins?: any[];
|
||||
/**
|
||||
* @default 9876
|
||||
* @description The port where the web server will be listening.
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* @default {'**\/*.coffee': 'coffee'}
|
||||
* @description A map of preprocessors to use.
|
||||
*
|
||||
* Preprocessors can be loaded through [plugins].
|
||||
*
|
||||
* Note: Just about all preprocessors in Karma (other than CoffeeScript and some other defaults)
|
||||
* require an additional library to be installed (via NPM).
|
||||
*
|
||||
* Be aware that preprocessors may be transforming the files and file types that are available at run time. For instance,
|
||||
* if you are using the "coverage" preprocessor on your source files, if you then attempt to interactively debug
|
||||
* your tests, you'll discover that your expected source code is completely changed from what you expected. Because
|
||||
* of that, you'll want to engineer this so that your automated builds use the coverage entry in the "reporters" list,
|
||||
* but your interactive debugging does not.
|
||||
*
|
||||
*/
|
||||
preprocessors?: { [name: string]: string | string[] };
|
||||
/**
|
||||
* @default 'http:'
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>http:</li>
|
||||
* <li>https:</li>
|
||||
* </ul>
|
||||
* @description Protocol used for running the Karma webserver.
|
||||
* Determines the use of the Node http or https class.
|
||||
* Note: Using <code>'https:'</code> requires you to specify <code>httpsServerOptions</code>.
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* @default {}
|
||||
* @description A map of path-proxy pairs.
|
||||
*/
|
||||
proxies?: { [path: string]: string };
|
||||
/**
|
||||
* @default true
|
||||
* @description Whether or not Karma or any browsers should raise an error when an inavlid SSL certificate is found.
|
||||
*/
|
||||
proxyValidateSSL?: boolean;
|
||||
/**
|
||||
* @default 0
|
||||
* @description Karma will report all the tests that are slower than given time limit (in ms).
|
||||
* This is disabled by default (since the default value is 0).
|
||||
*/
|
||||
reportSlowerThan?: number;
|
||||
/**
|
||||
* @default ['progress']
|
||||
* Possible Values:
|
||||
* <ul>
|
||||
* <li>dots</li>
|
||||
* <li>progress</li>
|
||||
* </ul>
|
||||
* @description A list of reporters to use.
|
||||
* Additional reporters, such as growl, junit, teamcity or coverage can be loaded through plugins.
|
||||
* Note: Just about all additional reporters in Karma (other than progress) require an additional library to be installed (via NPM).
|
||||
*/
|
||||
reporters?: string[];
|
||||
/**
|
||||
* @default false
|
||||
* @description Continuous Integration mode.
|
||||
* If true, Karma will start and capture all configured browsers, run tests and then exit with an exit code of 0 or 1 depending
|
||||
* on whether all tests passed or any tests failed.
|
||||
*/
|
||||
singleRun?: boolean;
|
||||
/**
|
||||
* @default ['polling', 'websocket']
|
||||
* @description An array of allowed transport methods between the browser and testing server. This configuration setting
|
||||
* is handed off to [socket.io](http://socket.io/) (which manages the communication
|
||||
* between browsers and the testing server).
|
||||
*/
|
||||
transports?: string[];
|
||||
/**
|
||||
* @default '/'
|
||||
* @description The base url, where Karma runs.
|
||||
* All of Karma's urls get prefixed with the urlRoot. This is helpful when using proxies, as
|
||||
* sometimes you might want to proxy a url that is already taken by Karma.
|
||||
*/
|
||||
urlRoot?: string;
|
||||
}
|
||||
|
||||
export interface ClientOptions {
|
||||
/**
|
||||
* @default undefined
|
||||
* @description When karma run is passed additional arguments on the command-line, they
|
||||
* are passed through to the test adapter as karma.config.args (an array of strings).
|
||||
* The client.args option allows you to set this value for actions other than run.
|
||||
* How this value is used is up to your test adapter - you should check your adapter's
|
||||
* documentation to see how (and if) it uses this value.
|
||||
*/
|
||||
args?: string[];
|
||||
/**
|
||||
* @default true
|
||||
* @description Run the tests inside an iFrame or a new window
|
||||
* If true, Karma runs the tests inside an iFrame. If false, Karma runs the tests in a new window. Some tests may not run in an
|
||||
* iFrame and may need a new window to run.
|
||||
*/
|
||||
useIframe?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Capture all console output and pipe it to the terminal.
|
||||
*/
|
||||
captureConsole?: boolean;
|
||||
/**
|
||||
* @default false
|
||||
* @description Run the tests on the same window as the client, without using iframe or a new window
|
||||
*/
|
||||
runInParent?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Clear the context window
|
||||
* If true, Karma clears the context window upon the completion of running the tests.
|
||||
* If false, Karma does not clear the context window upon the completion of running the tests.
|
||||
* Setting this to false is useful when embedding a Jasmine Spec Runner Template.
|
||||
*/
|
||||
clearContext?: boolean;
|
||||
}
|
||||
|
||||
export interface FilePattern {
|
||||
/**
|
||||
* The pattern to use for matching. This property is mandatory.
|
||||
*/
|
||||
pattern: string;
|
||||
/**
|
||||
* @default true
|
||||
* @description If <code>autoWatch</code> is true all files that have set watched to true will be watched
|
||||
* for changes.
|
||||
*/
|
||||
watched?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Should the files be included in the browser using <script> tag? Use false if you want to
|
||||
* load them manually, eg. using Require.js.
|
||||
*/
|
||||
included?: boolean;
|
||||
/**
|
||||
* @default true
|
||||
* @description Should the files be served by Karma's webserver?
|
||||
*/
|
||||
served?: boolean;
|
||||
/**
|
||||
* @default false
|
||||
* @description Should the files be served from disk on each request by Karma's webserver?
|
||||
*/
|
||||
nocache?: boolean;
|
||||
}
|
||||
|
||||
export interface CustomLauncher {
|
||||
base: string;
|
||||
browserName?: string;
|
||||
flags?: string[];
|
||||
platform?: string;
|
||||
}
|
||||
|
||||
export namespace config {
|
||||
function parseConfig(configFilePath: string, cliOptions: ConfigOptions): Config;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,6 @@
|
||||
import gulp = require('gulp');
|
||||
import karma = require('karma');
|
||||
|
||||
function runKarma(singleRun: boolean): void {
|
||||
// MEMO: `start` method is deprecated since 0.13. It will be removed in 0.14.
|
||||
karma.server.start({
|
||||
configFile: __dirname + '/karma.conf.js',
|
||||
singleRun
|
||||
});
|
||||
}
|
||||
|
||||
gulp.task('test:unit:karma', gulp.parallel('build:test:unit', () => runKarma(true)));
|
||||
|
||||
// karma.server is deprecated and will eventually be removed
|
||||
karma.server.start({port: 9876}, (exitCode: number) => {
|
||||
console.log('Karma has exited with ' + exitCode);
|
||||
process.exit(exitCode);
|
||||
@@ -54,7 +44,8 @@ karma.runner.run({port: 9876}, (exitCode: number) => {
|
||||
process.exit(exitCode);
|
||||
});
|
||||
|
||||
const captured: boolean = karma.launcher.areAllCaptured();
|
||||
const launcher: karma.launcher.Launcher = null;
|
||||
const captured: boolean = launcher.areAllCaptured();
|
||||
|
||||
// Example of configuration file karma.conf.ts, see http://karma-runner.github.io/latest/config/configuration-file.html
|
||||
module.exports = (config: karma.Config) => {
|
||||
@@ -123,3 +114,10 @@ const foo = (config: karma.Config) => {
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
console.log(karma.constants.DEFAULT_HOSTNAME);
|
||||
console.log(karma.VERSION);
|
||||
|
||||
karma.config.parseConfig('karma.conf.js', {
|
||||
singleRun: true
|
||||
});
|
||||
|
||||
4
types/linkifyjs/html.d.ts
vendored
Normal file
4
types/linkifyjs/html.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { LinkifyOptions } from "./index";
|
||||
|
||||
export function linkifyHtml(input: string, options?: LinkifyOptions): string;
|
||||
export default linkifyHtml;
|
||||
185
types/linkifyjs/index.d.ts
vendored
Normal file
185
types/linkifyjs/index.d.ts
vendored
Normal file
@@ -0,0 +1,185 @@
|
||||
// Type definitions for linkifyjs 2.1
|
||||
// Project: https://github.com/SoapBox/linkifyjs#readme
|
||||
// Definitions by: Sean Zhu <https://github.com/szhu>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export type PossiblyFuncOfHrefAndType<T> =
|
||||
| T
|
||||
| ((href: string, type: string) => T);
|
||||
|
||||
// There's always a possibility that values at a string key can always be
|
||||
// undefined; i.e., if the key does not exist.
|
||||
export type PossiblyByType<T> = T | { [type: string]: T | undefined };
|
||||
|
||||
export type EventHandler = (e: HTMLElement) => void;
|
||||
|
||||
export interface LinkifyOptions {
|
||||
/**
|
||||
* attributes
|
||||
* - Type: Object | Function (String href, String type)
|
||||
* - Default: null
|
||||
*
|
||||
* Object of attributes to add to each new link. Note: the class and target
|
||||
* attributes have dedicated options.
|
||||
*
|
||||
* Also accepts a function that takes the unformatted href, the link type
|
||||
* (e.g., 'url', 'email', etc.) and returns the object.
|
||||
*/
|
||||
attributes?: PossiblyFuncOfHrefAndType<{
|
||||
[attrName: string]: string;
|
||||
}> | null;
|
||||
|
||||
/**
|
||||
* className
|
||||
* - Type: String | Function (String href, String type) | Object
|
||||
* - Default: 'linkified' (may be removed in future releases)
|
||||
*
|
||||
* class attribute to use for newly created links.
|
||||
*
|
||||
* Accepts a function that takes the unformatted href value and link type
|
||||
* (e.g., 'url', 'email', etc.) and returns the string.
|
||||
*
|
||||
* Accepts an object where each key is the link type and each value is the
|
||||
* string or function to use for that type.
|
||||
*/
|
||||
className?: PossiblyByType<PossiblyFuncOfHrefAndType<string | undefined>>;
|
||||
|
||||
/**
|
||||
* defaultProtocol
|
||||
* - Type: String
|
||||
* - Default: 'http'
|
||||
* - Values: 'http', 'https', 'ftp', 'ftps', etc.
|
||||
*
|
||||
* Protocol that should be used in href attributes for URLs without a
|
||||
* protocol (e.g., github.com).
|
||||
*/
|
||||
defaultProtocol?: string;
|
||||
|
||||
/**
|
||||
* events
|
||||
* - *element, jquery interfaces only*
|
||||
* - Type: Object | Function (String href, String type) | Object
|
||||
* - Default: null
|
||||
*
|
||||
* Add event listeners to newly created link elements. Takes a hash where
|
||||
* each key is an standard event name and the value is an event handler.
|
||||
*
|
||||
* Also accepts a function that takes the unformatted href and the link type
|
||||
* (e.g., 'url', 'email', etc.) and returns the hash.
|
||||
*
|
||||
* For React, specify events in the attributes option as standard React
|
||||
* events.
|
||||
*
|
||||
* See the React Event docs and the linkify-react event docs
|
||||
*/
|
||||
events?: PossiblyFuncOfHrefAndType<{
|
||||
[eventName: string]: EventHandler;
|
||||
}> | null;
|
||||
|
||||
/**
|
||||
* format
|
||||
* - Type: Function (String value, String type) | Object
|
||||
* - Default: null
|
||||
*
|
||||
* Format the text displayed by a linkified entity. e.g., truncate a long
|
||||
* URL.
|
||||
*
|
||||
* Accepts an object where each key is the link type (e.g., 'url', 'email',
|
||||
* etc.) and each value is the formatting function to use for that type.
|
||||
*
|
||||
* NOTE: According to the linkifyjs implementation, `format` can be just a
|
||||
* string, but this is not mentioned in the docs, so we exclude it.
|
||||
*/
|
||||
format?: PossiblyByType<(value: string, type: string) => string>;
|
||||
//
|
||||
|
||||
/**
|
||||
* formatHref
|
||||
* - Type: Function (String href, String type) | Object
|
||||
* - Default: null
|
||||
*
|
||||
* Similar to format, except the result of this function will be used as the
|
||||
* href attribute of the new link.
|
||||
*
|
||||
* This is useful when finding hashtags, where you don’t necessarily want
|
||||
* the default to be a link to a named anchor.
|
||||
*
|
||||
* Accepts an object where each key is the link type (e.g., 'url', 'email',
|
||||
* etc.) and each value is the formatting function to use for that type.
|
||||
*
|
||||
* NOTE: According to the linkifyjs implementation, `formatHref` can be just
|
||||
* a string, but this is not mentioned in the docs, so we exclude it.
|
||||
*/
|
||||
formatHref?: PossiblyByType<(href: string, type: string) => string>;
|
||||
|
||||
/**
|
||||
* ignoreTags
|
||||
* - *element, html, and jquery interfaces only*
|
||||
* - Type: Array
|
||||
* - Default: []
|
||||
*
|
||||
* Prevent linkify from trying to parse links in the specified tags. This is
|
||||
* useful when running linkify on arbitrary HTML.
|
||||
*/
|
||||
ignoreTags?: string[];
|
||||
|
||||
/**
|
||||
* nl2br
|
||||
* - Type: Boolean
|
||||
* - Default: false
|
||||
*
|
||||
* If true, \n line breaks will automatically be converted to <br> tags.
|
||||
*
|
||||
*/
|
||||
nl2br?: boolean;
|
||||
|
||||
/**
|
||||
* tagName
|
||||
* - Type: String | Function (String href, String type) | Object
|
||||
* - Default: a
|
||||
*
|
||||
* The tag name to use for each link. For cases where you can’t use anchor
|
||||
* tags.
|
||||
*
|
||||
* Accepts a function that takes the unformatted href, the link type (e.g.,
|
||||
* 'url', 'email', etc.) and returns the tag name.
|
||||
*
|
||||
* Accepts an object where each key is the link type and each value is the
|
||||
* tag name to use for that type.
|
||||
*/
|
||||
tagName?: PossiblyByType<PossiblyFuncOfHrefAndType<string>>;
|
||||
|
||||
/**
|
||||
* target
|
||||
* - Type: String | Function (String href, String type) | Object
|
||||
* - Default: '_blank' for URLs, null for everything else
|
||||
*
|
||||
* target attribute for generated link.
|
||||
*
|
||||
* Accepts a function that takes the unformatted href, the link type (e.g.,
|
||||
* 'url', 'email', etc.) and returns the target
|
||||
*
|
||||
* Accepts an object where each key is the link type and each value is the
|
||||
* target to use for that type.
|
||||
*/
|
||||
target?: PossiblyByType<
|
||||
PossiblyFuncOfHrefAndType<string | null | undefined>
|
||||
>;
|
||||
|
||||
/**
|
||||
* validate
|
||||
* - Type: Boolean | Function (String value, String type) | Object
|
||||
* - Default: null
|
||||
*
|
||||
* If option resolves to false, the given value will not show up as a link.
|
||||
*
|
||||
* Accepts a function that takes a discovered link and the link type (e.g.,
|
||||
* 'url', 'email', etc.) and returns true if the link should be converted
|
||||
* into an anchor tag, and false otherwise.
|
||||
*
|
||||
* Accepts an object where each key is the link type and each value is the
|
||||
* the validation option to use for that type
|
||||
*/
|
||||
validate?: PossiblyByType<PossiblyFuncOfHrefAndType<boolean>>;
|
||||
}
|
||||
141
types/linkifyjs/linkifyjs-tests.ts
Normal file
141
types/linkifyjs/linkifyjs-tests.ts
Normal file
@@ -0,0 +1,141 @@
|
||||
import linkifyHtml from "linkifyjs/html";
|
||||
|
||||
// From the docs here: https://soapbox.github.io/linkifyjs/docs/options.html
|
||||
|
||||
/* attributes */
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
attributes: {
|
||||
rel: "nofollow"
|
||||
}
|
||||
});
|
||||
|
||||
/* className */
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
className: "new-link--url"
|
||||
});
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
className(href, type) {
|
||||
return "new-link--" + type;
|
||||
}
|
||||
});
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
className: {
|
||||
url: "new-link--url",
|
||||
email(href: string) {
|
||||
return "new-link--email";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* events */
|
||||
|
||||
linkifyHtml("", {
|
||||
events: {
|
||||
click(e) {
|
||||
alert("Link clicked!");
|
||||
},
|
||||
mouseover(e) {
|
||||
alert("Link hovered!");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* defaultProtocol */
|
||||
|
||||
/* format */
|
||||
|
||||
linkifyHtml("", {
|
||||
format(value, type) {
|
||||
if (type === "url" && value.length > 50) {
|
||||
value = value.slice(0, 50) + "…";
|
||||
}
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
||||
linkifyHtml("", {
|
||||
format: {
|
||||
url(value) {
|
||||
return value.length > 50 ? value.slice(0, 50) + "…" : value;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* formatHref */
|
||||
|
||||
linkifyHtml("This site is #rad", {
|
||||
formatHref(href, type) {
|
||||
if (type === "hashtag") {
|
||||
href = "https://twitter.com/hashtag/" + href.substring(1);
|
||||
}
|
||||
return href;
|
||||
}
|
||||
});
|
||||
|
||||
linkifyHtml("Hey @dhh, check out issue #23", {
|
||||
formatHref: {
|
||||
mention(href) {
|
||||
return "https://github.com" + href;
|
||||
},
|
||||
ticket(href) {
|
||||
return (
|
||||
"https://github.com/SoapBox/linkifyjs/issues/" +
|
||||
href.substring(1)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* ignoreTags */
|
||||
|
||||
linkifyHtml(
|
||||
// tslint:disable-next-line:prefer-template
|
||||
'Please ignore <script>var a = {}; a.com = "Hi";</script> \n' +
|
||||
"but do <span>b.ca</span>",
|
||||
{
|
||||
ignoreTags: ["script", "style"]
|
||||
}
|
||||
);
|
||||
|
||||
/* nl2br */
|
||||
|
||||
/* tagName */
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
tagName: "span"
|
||||
});
|
||||
|
||||
linkifyHtml("#swag", {
|
||||
tagName: {
|
||||
hashtag: "span"
|
||||
}
|
||||
});
|
||||
|
||||
/* target */
|
||||
|
||||
linkifyHtml("github.com", {
|
||||
target: "_parent"
|
||||
});
|
||||
|
||||
linkifyHtml("test-email@example.com", {
|
||||
target: {
|
||||
url: "_parent",
|
||||
email: null
|
||||
}
|
||||
});
|
||||
|
||||
/* validate */
|
||||
|
||||
// Don't linkify links that don't begin in a protocol
|
||||
// e.g., "http://google.com" will be linkified, but "google.com" will not.
|
||||
linkifyHtml("www.google.com", {
|
||||
validate: {
|
||||
url(value) {
|
||||
return /^(http|ftp)s?:\/\//.test(value);
|
||||
}
|
||||
}
|
||||
});
|
||||
25
types/linkifyjs/tsconfig.json
Normal file
25
types/linkifyjs/tsconfig.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"html.d.ts",
|
||||
"linkifyjs-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/linkifyjs/tslint.json
Normal file
1
types/linkifyjs/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
26
types/ltx/index.d.ts
vendored
26
types/ltx/index.d.ts
vendored
@@ -1,17 +1,17 @@
|
||||
// Type definitions for ltx 2.6
|
||||
// Type definitions for ltx 2.8
|
||||
// Project: github.com/node-xmpp/ltx/
|
||||
// Definitions by: PJakcson <https://github.com/PJakcson>
|
||||
// BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export {Element } from './lib/Element';
|
||||
export {nameEqual, attrsEqual, childrenEqual, equal} from './lib/equal';
|
||||
export {isNode, isElement, isText} from './lib/is';
|
||||
export {clone} from './lib/clone';
|
||||
export {createElement} from './lib/createElement';
|
||||
export {escapeXML, unescapeXML, escapeXMLText, unescapeXMLText} from './lib/escape';
|
||||
export {Parser} from './lib/Parser';
|
||||
export {parse} from './lib/parse';
|
||||
export {tag} from './lib/tag';
|
||||
export {tagString} from './lib/tagString';
|
||||
export {stringify} from './lib/stringify';
|
||||
export * from './lib/Element';
|
||||
export * from './lib/equal';
|
||||
export * from './lib/is';
|
||||
export * from './lib/clone';
|
||||
export * from './lib/createElement';
|
||||
export * from './lib/escape';
|
||||
export * from './lib/Parser';
|
||||
export * from './lib/parse';
|
||||
export * from './lib/tag';
|
||||
export * from './lib/tagString';
|
||||
export * from './lib/stringify';
|
||||
|
||||
97
types/ltx/lib/Element.d.ts
vendored
97
types/ltx/lib/Element.d.ts
vendored
@@ -1,21 +1,26 @@
|
||||
import { clone } from './clone';
|
||||
|
||||
export type Node = Element | TextNode;
|
||||
export type TextNode = string | number;
|
||||
|
||||
/**
|
||||
* Element
|
||||
*
|
||||
* Attributes are in the element.attrs object. Children is a list of
|
||||
* either other Elements or Strings for text content.
|
||||
**/
|
||||
export declare class Element {
|
||||
*/
|
||||
export class Element {
|
||||
name: string;
|
||||
parent: Element;
|
||||
parent: Element | null;
|
||||
children: Element[];
|
||||
attrs: any;
|
||||
attrs: { [attrName: string]: any };
|
||||
|
||||
constructor(name: string, attrs?: any);
|
||||
constructor(name: string, attrs?: string | { [attrName: string]: any });
|
||||
|
||||
/**
|
||||
* if (element.is('message', 'jabber:client')) ...
|
||||
**/
|
||||
is(name: string, xmlns?: any): boolean;
|
||||
*/
|
||||
is(name: string, xmlns?: string): boolean;
|
||||
|
||||
/**
|
||||
* without prefix.
|
||||
@@ -24,50 +29,44 @@ export declare class Element {
|
||||
|
||||
/**
|
||||
* retrieves the namespace of the current element, upwards recursively
|
||||
**/
|
||||
getNS(): any;
|
||||
*/
|
||||
getNS(): string | undefined;
|
||||
|
||||
/**
|
||||
* find the namespace to the given prefix, upwards recursively
|
||||
**/
|
||||
findNS(prefix: string): any;
|
||||
*/
|
||||
findNS(prefix: string): string | undefined;
|
||||
|
||||
/**
|
||||
* Recursiverly gets all xmlns defined, in the form of {url:prefix}
|
||||
**/
|
||||
getXmlns(): any;
|
||||
*/
|
||||
getXmlns(): { [key: string]: string };
|
||||
|
||||
setAttrs(attrs: any): void;
|
||||
setAttrs(attrs: string | { [attrName: string]: any }): void;
|
||||
|
||||
/**
|
||||
* xmlns can be null, returns the matching attribute.
|
||||
**/
|
||||
getAttr(name: string, xmlns?: any): any;
|
||||
* returns the matching attribute.
|
||||
*/
|
||||
getAttr(name: string, xmlns?: string): any;
|
||||
|
||||
/**
|
||||
* xmlns can be null
|
||||
**/
|
||||
getChild(name: string, xmlns?: any): Element;
|
||||
getChild(name: string, xmlns?: string): Element | undefined;
|
||||
|
||||
/**
|
||||
* xmlns can be null
|
||||
**/
|
||||
getChildren(name: string, xmlns?: any): Element[];
|
||||
getChildren(name: string, xmlns?: string): Element[];
|
||||
|
||||
/**
|
||||
* xmlns and recursive can be null
|
||||
**/
|
||||
getChildByAttr(attr: any, val: any, xmlns?: any, recursive?: any): Element;
|
||||
getChildByAttr(
|
||||
attr: string,
|
||||
val: any,
|
||||
xmlns?: string,
|
||||
recursive?: boolean
|
||||
): Element | undefined;
|
||||
|
||||
getChildrenByAttr(attr: string, val: any, xmlns?: string, recursive?: boolean): Element[];
|
||||
|
||||
/**
|
||||
* xmlns and recursive can be null
|
||||
**/
|
||||
getChildrenByAttr(attr: any, val: any, xmlns?: any, recursive?: any): Element[];
|
||||
getChildrenByFilter(filter: (child: Node) => boolean, recursive?: boolean): Element[];
|
||||
|
||||
getText(): string;
|
||||
|
||||
getChildText(name: string, xmlns?: any): string;
|
||||
getChildText(name: string, xmlns?: string): string | null;
|
||||
|
||||
/**
|
||||
* Return all direct descendents that are Elements.
|
||||
@@ -77,37 +76,39 @@ export declare class Element {
|
||||
getChildElements(): Element[];
|
||||
|
||||
/** returns uppermost parent */
|
||||
root(): Element;
|
||||
root(): Element | this;
|
||||
|
||||
tree(): Element;
|
||||
tree(): Element | this;
|
||||
|
||||
/** just parent or itself */
|
||||
up(): Element;
|
||||
up(): Element | this;
|
||||
|
||||
/** create child node and return it */
|
||||
c(name: string, attrs?: any): Element;
|
||||
c(name: string, attrs?: { [key: string]: any }): Element;
|
||||
|
||||
cnode<T extends Element>(child: T): T;
|
||||
|
||||
/** add text node and return element */
|
||||
t(text: string): Element;
|
||||
t(text: TextNode): this;
|
||||
|
||||
/**
|
||||
* Either:
|
||||
* el.remove(childEl)
|
||||
* el.remove('author', 'urn:...')
|
||||
*/
|
||||
remove(el: Element, xmlns?: any): Element;
|
||||
remove(el: Element | string, xmlns?: string): this;
|
||||
|
||||
clone(): Element;
|
||||
clone: typeof clone;
|
||||
|
||||
text(val: string): string;
|
||||
text(val?: string): string;
|
||||
|
||||
attr(attr: any, val: any): any;
|
||||
attr(attr: string, val?: any): any;
|
||||
|
||||
toString(): string;
|
||||
|
||||
toJSON(): any;
|
||||
toJSON(): ElementJson;
|
||||
|
||||
write(writer: any): void;
|
||||
write(writer: (part: string) => void): void;
|
||||
|
||||
nameEquals(el: Element): boolean;
|
||||
|
||||
@@ -117,3 +118,9 @@ export declare class Element {
|
||||
|
||||
equals(el: Element): boolean;
|
||||
}
|
||||
|
||||
export interface ElementJson {
|
||||
name: string;
|
||||
attrs: { [attrName: string]: any };
|
||||
children: Array<ElementJson | TextNode>;
|
||||
}
|
||||
|
||||
14
types/ltx/lib/Parser.d.ts
vendored
14
types/ltx/lib/Parser.d.ts
vendored
@@ -1,5 +1,15 @@
|
||||
/// <reference types="node" />
|
||||
import { EventEmitter } from 'events';
|
||||
export declare class Parser extends EventEmitter {
|
||||
constructor(options?: any);
|
||||
import { Element } from './Element';
|
||||
|
||||
export class Parser extends EventEmitter {
|
||||
constructor(options?: ParserOptions);
|
||||
|
||||
write(data: string): void;
|
||||
end(data: string): void;
|
||||
}
|
||||
|
||||
export interface ParserOptions {
|
||||
Parser?: typeof Parser;
|
||||
Element?: typeof Element;
|
||||
}
|
||||
|
||||
4
types/ltx/lib/clone.d.ts
vendored
4
types/ltx/lib/clone.d.ts
vendored
@@ -1 +1,3 @@
|
||||
export declare function clone(el: any): any;
|
||||
import { Element } from './Element';
|
||||
|
||||
export function clone<T extends Element>(el: T): T;
|
||||
|
||||
8
types/ltx/lib/createElement.d.ts
vendored
8
types/ltx/lib/createElement.d.ts
vendored
@@ -1,2 +1,6 @@
|
||||
import { Element } from './Element';
|
||||
export declare function createElement(name: string, attrs: any): Element;
|
||||
import { Element, Node } from './Element';
|
||||
export function createElement(
|
||||
name: string,
|
||||
attrs?: string | { [attrName: string]: any },
|
||||
...children: Node[]
|
||||
): Element;
|
||||
|
||||
10
types/ltx/lib/equal.d.ts
vendored
10
types/ltx/lib/equal.d.ts
vendored
@@ -1,4 +1,6 @@
|
||||
export declare function nameEqual(a: any, b: any): boolean;
|
||||
export declare function attrsEqual(a: any, b: any): boolean;
|
||||
export declare function childrenEqual(a: any, b: any): boolean;
|
||||
export declare function equal(a: any, b: any): boolean;
|
||||
import { Element } from './Element';
|
||||
|
||||
export function nameEqual(a: Element, b: Element): boolean;
|
||||
export function attrsEqual(a: Element, b: Element): boolean;
|
||||
export function childrenEqual(a: Element, b: Element): boolean;
|
||||
export function equal(a: Element, b: Element): boolean;
|
||||
|
||||
8
types/ltx/lib/escape.d.ts
vendored
8
types/ltx/lib/escape.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
export declare function escapeXML(s: string): string;
|
||||
export declare function unescapeXML(s: string): string;
|
||||
export declare function escapeXMLText(s: string): string;
|
||||
export declare function unescapeXMLText(s: string): string;
|
||||
export function escapeXML(s: string): string;
|
||||
export function unescapeXML(s: string): string;
|
||||
export function escapeXMLText(s: string): string;
|
||||
export function unescapeXMLText(s: string): string;
|
||||
|
||||
8
types/ltx/lib/is.d.ts
vendored
8
types/ltx/lib/is.d.ts
vendored
@@ -1,3 +1,5 @@
|
||||
export declare function isNode(el: any): boolean;
|
||||
export declare function isElement(el: any): boolean;
|
||||
export declare function isText(el: any): boolean;
|
||||
import { Element, Node } from './Element';
|
||||
|
||||
export function isNode(el: any): el is Node;
|
||||
export function isElement(el: any): el is Element;
|
||||
export function isText(el: any): el is string;
|
||||
|
||||
5
types/ltx/lib/parse.d.ts
vendored
5
types/ltx/lib/parse.d.ts
vendored
@@ -1 +1,4 @@
|
||||
export declare function parse(data: any, options?: any): any;
|
||||
import { ParserOptions, Parser } from './Parser';
|
||||
import { Element } from './Element';
|
||||
|
||||
export function parse(data: string, options?: ParserOptions | Parser): Element;
|
||||
|
||||
4
types/ltx/lib/stringify.d.ts
vendored
4
types/ltx/lib/stringify.d.ts
vendored
@@ -1 +1,3 @@
|
||||
export declare function stringify(el: any, indent: any, level: any): string;
|
||||
import { Element } from './Element';
|
||||
|
||||
export function stringify(el: Element, indent?: number, level?: number): string;
|
||||
|
||||
4
types/ltx/lib/tag.d.ts
vendored
4
types/ltx/lib/tag.d.ts
vendored
@@ -1 +1,3 @@
|
||||
export declare function tag(d: any): any;
|
||||
import { Element } from './Element';
|
||||
|
||||
export function tag(literals: string[], ...substitutions: string[]): Element;
|
||||
|
||||
2
types/ltx/lib/tagString.d.ts
vendored
2
types/ltx/lib/tagString.d.ts
vendored
@@ -1 +1 @@
|
||||
export declare function tagString(d: any): string;
|
||||
export function tagString(literals: string[], ...substitutions: string[]): string;
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user