Merge pull request #3 from DefinitelyTyped/master

update fork
This commit is contained in:
Nikolaj Kappler
2018-10-23 13:29:51 +02:00
committed by GitHub
357 changed files with 41312 additions and 33858 deletions
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/epoberezkin/ajv-errors
// Definitions by: Afshawn Lotfi <https://github.com/afshawnlotfi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { Ajv } from "ajv";
+84 -59
View File
@@ -1,85 +1,110 @@
// Tests for Amplitude SDK TypeScript definitions
module Amplitude.Tests {
function all() {
amplitude.init('YOUR_API_KEY_HERE', null, {
// optional configuration options
var client: amplitude.AmplitudeClient = new amplitude.AmplitudeClient();
var identify: amplitude.Identify = new amplitude.Identify();
var revenue: amplitude.Revenue = new amplitude.Revenue();
client = amplitude.getInstance();
client = amplitude.getInstance('some name');
amplitude.__VERSION__ === '1.2.3';
amplitude.options.logLevel = 'WARN';
amplitude.init('API_KEY', 'USER_ID', {
saveEvents: true,
includeUtm: true,
includeReferrer: true,
batchEvents: true,
eventUploadThreshold: 50
});
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE', null, () => {});
}, function () { });
amplitude.init('API_KEY', 'USER_ID', { includeReferrer: true, includeUtm: true });
amplitude.init('API_KEY', 'USER_ID');
amplitude.init('API_KEY');
amplitude.logEvent('EVENT_IDENTIFIER_HERE');
amplitude.setUserId('USER_ID_HERE');
amplitude.init('YOUR_API_KEY_HERE', 'USER_ID_HERE');
amplitude.setUserId(null); // not string 'null'
amplitude.setVersionName('VERSION_NAME_HERE');
amplitude.regenerateDeviceId();
amplitude.setDeviceId('CUSTOM_DEVICE_ID');
amplitude.logEvent('EVENT_IDENTIFIER_HERE', {
'color': 'blue',
'age': 20,
'key': 'value'
});
amplitude.logEvent('Clicked Homepage Button', { 'finished_flow': false, 'clicks': 15 });
amplitude.logEvent('EVENT_IDENTIFIER_HERE', { 'color': 'blue', 'age': 20, 'key': 'value' });
amplitude.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { });
amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
amplitude.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0');
amplitude.setDomain('.amplitude.com');
amplitude.setGroup('orgId', '15');
amplitude.setGroup('orgId', ['15', '16']);
amplitude.setUserId('joe@gmail.com');
amplitude.setUserProperties({ 'gender': 'female', 'sign_up_complete': true })
amplitude.setVersionName('1.12.3');
amplitude.isNewSession();
amplitude.getSessionId() === 123;
let identify = new amplitude.Identify().set('gender', 'female').set('age', 20);
amplitude.identify(identify);
amplitude.logRevenue(3.99, 1, 'product_1234');
amplitude.logRevenueV2(revenue);
identify = new amplitude.Identify().setOnce('sign_up_date', '08/24/2015');
amplitude.identify(identify);
identify = new amplitude.Identify().setOnce('sign_up_date', '09/14/2015');
amplitude.identify(identify);
client.init('API_KEY', 'USER_ID', {
saveEvents: true,
includeUtm: true,
includeReferrer: true,
batchEvents: true,
eventUploadThreshold: 50
}, function () { });
client.init('API_KEY', 'USER_ID', { includeReferrer: true, includeUtm: true });
client.init('API_KEY', 'USER_ID');
client.init('API_KEY');
identify = new amplitude.Identify().unset('gender').unset('age');
amplitude.identify(identify);
client.logEvent('Clicked Homepage Button', { 'finished_flow': false, 'clicks': 15 });
client.logEvent('EVENT_IDENTIFIER_HERE', { 'color': 'blue', 'age': 20, 'key': 'value' });
client.logEvent("EVENT_IDENTIFIER_HERE", null, (httpCode, response) => { });
client.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
client.logEventWithTimestamp('EVENT_IDENTIFIER_HERE', { 'key': 'value' }, 1505430378000, (httpCode, response) => { });
client.setDeviceId('45f0954f-eb79-4463-ac8a-233a6f45a8f0');
client.setDomain('.amplitude.com');
client.setUserId('joe@gmail.com');
client.setOptOut(true);
client.setGroup('type', 'name');
client.setGroup('type', ['name', 'name2']);
client.setUserProperties({ 'gender': 'female', 'sign_up_complete': true });
client.setGlobalUserProperties({ 'gender': 'female', 'sign_up_complete': true });
client.setVersionName('1.12.3');
client.setSessionId(1505430378000);
client.options.logLevel = 'WARN';
client.getSessionId() === 123;
client.isNewSession() === true;
client.regenerateDeviceId();
client.clearUserProperties();
client.identify(identify);
client.logRevenue(3.99, 1, 'product_1234');
client.logRevenueV2(revenue);
identify = new amplitude.Identify().set('colors', ['rose', 'gold']).add('karma', 1).setOnce('sign_up_date', '2016-03-31');
identify = new amplitude.Identify().add('karma', 1).add('friends', 1);
amplitude.identify(identify);
identify = new amplitude.Identify().append('ab-tests', 'new-user-test').append('some_list', [1, 2, 3, 4, 'values']);
amplitude.identify(identify);
identify = new amplitude.Identify().prepend('ab-tests', 'new-user-test').prepend('some_list', [1, 2, 3, 4, 'values']);
amplitude.identify(identify);
identify = new amplitude.Identify()
.set('karma', 10)
.add('karma', 1)
.unset('karma');
amplitude.identify(identify);
identify = new amplitude.Identify().set('karma', 10).add('karma', 1).unset('karma');
identify = new amplitude.Identify().append('ab-tests', 'new-user-tests');
identify.append('some_list', [1, 2, 3, 4, 'values']);
identify = new amplitude.Identify().prepend('ab-tests', 'new-user-tests');
identify.prepend('some_list', [1, 2, 3, 4, 'values']);
identify = new amplitude.Identify().set('user_type', 'beta');
identify.set('name', { 'first': 'John', 'last': 'Doe' });
identify = new amplitude.Identify().setOnce('sign_up_date', '2016-04-01');
identify = new amplitude.Identify().unset('user_type').unset('age');
identify = new amplitude.Identify()
.set('colors', ['rose', 'gold'])
.append('ab-tests', 'campaign_a')
.append('existing_list', [4, 5]);
amplitude.identify(identify);
amplitude.setUserProperties({
gender: 'female',
age: 20
});
amplitude.clearUserProperties();
amplitude.setOptOut(true);
amplitude.setOptOut(false);
amplitude.setGroup('orgId', '15');
amplitude.setGroup('sport', ['soccer', 'tennis']);
// TODO: Implement those.
/*
var revenue = new amplitude.Revenue().setProductId('com.company.productId').setPrice(3.99).setQuantity(3);
amplitude.logRevenueV2(revenue);
amplitude.logEventWithGroups('initialize_game', { 'key': 'value' }, { 'sport': 'soccer' });
*/
revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99);
revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setEventProperties({ 'city': 'San Francisco' });
revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setQuantity(5);
revenue = new amplitude.Revenue().setProductId('productIdentifier').setPrice(10.99).setRevenueType('purchase');
}
}
+97 -12
View File
@@ -1,61 +1,146 @@
// Type definitions for Amplitude SDK 2.12.1
// Type definitions for Amplitude SDK 4.4.0
// Project: https://github.com/amplitude/Amplitude-Javascript
// Definitions by: Arvydas Sidorenko <https://github.com/Asido>
// Definitions: https://github.com/Asido/DefinitelyTyped
// Dan Manastireanu <https://github.com/danmana>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module amplitude {
type Callback = (responseCode: number, responseBody: string, details?: { reason: string; }) => void;
type LogReturn = number | void;
interface Config {
apiEndpoint?: string;
batchEvents?: boolean;
cookieExpiration?: number;
cookieName?: string;
userId?: string;
deviceId?: string;
deviceIdFromUrlParam?: boolean;
domain?: string;
eventUploadPeriodMillis?: number;
eventUploadThreshold?: number;
forceHttps?: boolean;
includeGclid?: boolean;
includeReferrer?: boolean;
includeUtm?: boolean;
language?: string;
logLevel?: 'DISABLE' | 'ERROR' | 'WARN' | 'INFO';
optOut?: boolean;
platform?: string;
saveEvents?: boolean;
savedMaxCount?: number;
saveParamsReferrerOncePerSession?: boolean;
sessionTimeout?: number;
trackingOptions?: {
city?: boolean;
country?: boolean;
device_model?: boolean;
dma?: boolean;
ip_address?: boolean;
language?: boolean;
os_name?: boolean;
os_version?: boolean;
platform?: boolean;
region?: boolean;
version_name?: boolean;
},
unsentKey?: string;
unsentIdentifyKey?: string;
uploadBatchSize?: number;
}
export class Identify {
set(key: string, value: any): Identify;
setOnce(key: string, value: any): Identify;
add(key: string, value: number): Identify;
add(key: string, value: number | string): Identify;
append(key: string, value: any): Identify;
prepend(key: string, value: any): Identify;
unset(key: string): Identify;
}
export function init(apiKey: string): void;
export function init(apiKey: string, userId: string): void;
export function init(apiKey: string, userId: string, options: Config): void;
export function init(apiKey: string, userId: string, options: Config, callback: () => void): void;
export class Revenue {
setProductId(productId: string): Revenue;
setQuantity(quantity: number): Revenue;
setPrice(price: number): Revenue;
setRevenueType(revenueType: string): Revenue;
setEventProperties(eventProperties: any): Revenue;
}
export class AmplitudeClient {
constructor(instanceName?: string);
options: Config;
init(apiKey: string, userId?: string, config?: Config, callback?: (client: AmplitudeClient) => void): void;
setVersionName(versionName: string): void;
isNewSession(): boolean;
setSessionId(sessionId: number): void;
getSessionId(): number;
setDomain(domain: string): void;
setUserId(userId: string): void;
setDeviceId(id: string): void;
regenerateDeviceId(): void;
identify(identify_obj: Identify, opt_callback?: Callback): void;
setUserProperties(properties: any): void;
setGlobalUserProperties(properties: any): void;
clearUserProperties(): void;
setOptOut(enable: boolean): void;
setGroup(groupType: string, groupName: string | string[]): void;
logEvent(event: string, data?: any, callback?: Callback): LogReturn;
logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn;
logRevenueV2(revenue_obj: Revenue): LogReturn;
logRevenue(pric: number, quantity: number, product: string): LogReturn;
logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn;
}
// Proxy methods that get executed on the default AmplitudeClient instance (not all client methods are proxied)
export function init(apiKey: string, userId?: string, options?: Config, callback?: (client: AmplitudeClient) => void): void;
export function setVersionName(version: string): void;
export function isNewSession(): boolean;
export function getSessionId(): number;
export function setDomain(domain: string): void;
export function setUserId(userId: string): void;
export function setDeviceId(id: string): void;
export function regenerateDeviceId(): void;
export function identify(identify: Identify): void;
export function identify(identify: Identify, callback?: Callback): void;
export function setUserProperties(properties: Object): void;
export function setUserProperties(properties: any): void;
export function setGlobalUserProperties(properties: any): void;
export function clearUserProperties(): void;
export function setOptOut(optOut: boolean): void;
export function setGroup(groupType: string, groupName: string | string[]): void;
export function logEvent(event: string): void;
export function logEvent(event: string, data: Object): void;
export function logEvent(event: string, data: Object, callback: (httpCode: number, response: any) => void): void;
export function logEvent(event: string, data?: any, callback?: Callback): LogReturn;
export function logEventWithGroups(event: string, data?: any, groups?: any, callback?: Callback): LogReturn;
export function logRevenueV2(revenue_obj: Revenue): LogReturn;
export function logRevenue(pric: number, quantity: number, product: string): LogReturn;
export function logEventWithTimestamp(event: string, data?: any, timestamp?: number, callback?: Callback): LogReturn;
export function getInstance(instanceName?: string): AmplitudeClient;
export const __VERSION__: string;
export var options: Config;
}
+1 -1
View File
@@ -3,7 +3,7 @@
// Definitions by: bryn austin bellomy <https://github.com/brynbellomy>
// plylrnsdy <https://github.com/plylrnsdy>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import { EscapeCode } from './escape-code';
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/jaydenseric/apollo-upload-client#readme
// Definitions by: Edward Sammut Alessi <https://github.com/Slessi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
// TypeScript Version: 2.6
import { ApolloLink } from "apollo-link";
import { HttpOptions } from "apollo-link-http-common";
+3 -1
View File
@@ -2,7 +2,9 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6", "dom"
"es6",
"dom",
"esnext.asynciterable"
],
"noImplicitAny": true,
"noImplicitThis": true,
+50
View File
@@ -0,0 +1,50 @@
// Type definitions for astring 1.3
// Project: https://github.com/davidbonnet/astring
// Definitions by: Nikolaj Kappler <https://github.com/nkappler>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as ESTree from 'estree';
import 'node';
import { Stream } from 'stream';
export interface Options {
/** string to use for indentation (defaults to " ") */
indent?: string;
/** string to use for line endings (defaults to "\n") */
lineEnd?: string;
/** indent level to start from (defaults to 0) */
startingIndentLevel?: number;
/** generate comments if true (defaults to false) */
comments?: boolean;
/** custom code generator (defaults to astring.baseGenerator) */
generator?: object;
/** source map generator (defaults to null), see https://github.com/mozilla/source-map#sourcemapgenerator */
sourceMap?: any;
}
/** Returns a string representing the rendered code of the provided AST `node`. However, if an `output` stream is provided in the options, it writes to that stream and returns it. */
export function generate(node: ESTree.Node, options?: Options): string;
/** Returns a string representing the rendered code of the provided AST `node`. However, if an `output` stream is provided in the options, it writes to that stream and returns it. */
export function generate(node: ESTree.Node, options: Options & {
/** output stream to write the rendered code to (defaults to null) */
output: Stream;
}): Stream;
/**
* A code generator consists of a mapping of node names and functions that take two arguments: `node` and `state`.
* The `node` points to the node from which to generate the code and the `state` exposes the `write` method that takes generated code strings.
*/
export type Generator = { [key in ESTree.Node["type"]]: (node: Extract<ESTree.Node, { type: key }>, state: { write(s: string): void }) => void };
/** Base generator that can be used to extend Astring. See https://github.com/davidbonnet/astring#extending */
export const baseGenerator: Generator;
declare global {
interface astring {
generate: typeof generate;
/** Base generator that can be used to extend Astring. See https://github.com/davidbonnet/astring#extending */
baseGenerator: Generator;
}
const astring: astring;
}
@@ -0,0 +1,5 @@
// global scope function
astring.generate(null);
// global scope function
astring.baseGenerator.Program(null, { write(s: string) { return; } });
+32
View File
@@ -0,0 +1,32 @@
import { baseGenerator, generate } from "astring";
import { FunctionExpression, MemberExpression, Program } from "estree";
import { Stream } from "stream";
const ast: Program = null;
const functionE: FunctionExpression = null;
const memberE: MemberExpression = null;
// should accept different nodes
generate(ast);
generate(functionE);
generate(memberE);
// options without output option should generate string
const string: string = generate(ast, {
comments: true,
generator: baseGenerator,
indent: "\t",
lineEnd: "\n",
startingIndentLevel: 42,
sourceMap: null
});
// options with output option should return Stream
const stream: Stream = generate(ast, {
output: new Stream()
});
// Generator should map node types to functions whose first parameter is same node type
baseGenerator.Program(ast, { write(s: string) { return; } });
baseGenerator.FunctionExpression(functionE, { write(s: string) { return; } });
baseGenerator.MemberExpression(memberE, { write(s: string) { return; } });
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"test/astring.test.ts",
"test/astring-global.test.ts"
]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
+77 -77
View File
@@ -2,34 +2,34 @@
// Project: https://github.com/caolan/async
// Definitions by: Boris Yankov <https://github.com/borisyankov>, Arseniy Maximov <https://github.com/kern0>, Joe Herman <https://github.com/Penryn>, Angus Fenying <https://github.com/fenying>, Pascal Martin <https://github.com/pascalmartin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.3
export as namespace async;
export interface Dictionary<T> { [key: string]: T; }
export type IterableCollection<T> = T[] | IterableIterator<T> | Dictionary<T>
export interface ErrorCallback<T> { (err?: T): void; }
export interface AsyncBooleanResultCallback<E> { (err?: E, truthValue?: boolean): void; }
export interface AsyncResultCallback<T, E> { (err?: E, result?: T): void; }
export interface AsyncResultArrayCallback<T, E> { (err?: E, results?: Array<T | undefined>): void; }
export interface AsyncResultObjectCallback<T, E> { (err: E | undefined, results: Dictionary<T | undefined>): void; }
export interface ErrorCallback<E = Error> { (err?: E | null): void; }
export interface AsyncBooleanResultCallback<E = Error> { (err?: E | null, truthValue?: boolean): void; }
export interface AsyncResultCallback<T, E = Error> { (err?: E | null, result?: T): void; }
export interface AsyncResultArrayCallback<T, E = Error> { (err?: E | null, results?: Array<T | undefined>): void; }
export interface AsyncResultObjectCallback<T, E = Error> { (err: E | undefined, results: Dictionary<T | undefined>): void; }
export interface AsyncFunction<T, E> { (callback: (err?: E, result?: T) => void): void; }
export interface AsyncFunctionEx<T, E> { (callback: (err?: E, ...results: T[]) => void): void; }
export interface AsyncIterator<T, E> { (item: T, callback: ErrorCallback<E>): void; }
export interface AsyncForEachOfIterator<T, E> { (item: T, key: number|string, callback: ErrorCallback<E>): void; }
export interface AsyncResultIterator<T, R, E> { (item: T, callback: AsyncResultCallback<R, E>): void; }
export interface AsyncMemoIterator<T, R, E> { (memo: R | undefined, item: T, callback: AsyncResultCallback<R, E>): void; }
export interface AsyncBooleanIterator<T, E> { (item: T, callback: AsyncBooleanResultCallback<E>): void; }
export interface AsyncFunction<T, E = Error> { (callback: (err?: E | null, result?: T) => void): void; }
export interface AsyncFunctionEx<T, E = Error> { (callback: (err?: E | null, ...results: T[]) => void): void; }
export interface AsyncIterator<T, E = Error> { (item: T, callback: ErrorCallback<E>): void; }
export interface AsyncForEachOfIterator<T, E = Error> { (item: T, key: number|string, callback: ErrorCallback<E>): void; }
export interface AsyncResultIterator<T, R, E = Error> { (item: T, callback: AsyncResultCallback<R, E>): void; }
export interface AsyncMemoIterator<T, R, E = Error> { (memo: R | undefined, item: T, callback: AsyncResultCallback<R, E>): void; }
export interface AsyncBooleanIterator<T, E = Error> { (item: T, callback: AsyncBooleanResultCallback<E>): void; }
export interface AsyncWorker<T, E> { (task: T, callback: ErrorCallback<E>): void; }
export interface AsyncVoidFunction<E> { (callback: ErrorCallback<E>): void; }
export interface AsyncWorker<T, E = Error> { (task: T, callback: ErrorCallback<E>): void; }
export interface AsyncVoidFunction<E = Error> { (callback: ErrorCallback<E>): void; }
export type AsyncAutoTasks<R extends Dictionary<any>, E> = { [K in keyof R]: AsyncAutoTask<R[K], R, E> }
export type AsyncAutoTask<R1, R extends Dictionary<any>, E> = AsyncAutoTaskFunctionWithoutDependencies<R1, E> | (keyof R | AsyncAutoTaskFunction<R1, R, E>)[];
export interface AsyncAutoTaskFunctionWithoutDependencies<R1, E> { (cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
export interface AsyncAutoTaskFunction<R1, R extends Dictionary<any>, E> { (results: R, cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
export interface AsyncAutoTaskFunctionWithoutDependencies<R1, E = Error> { (cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
export interface AsyncAutoTaskFunction<R1, R extends Dictionary<any>, E = Error> { (results: R, cb: AsyncResultCallback<R1, E> | ErrorCallback<E>): void; }
export interface AsyncQueue<T> {
length(): number;
@@ -37,9 +37,8 @@ export interface AsyncQueue<T> {
running(): number;
idle(): boolean;
concurrency: number;
push<E>(task: T | T[], callback?: ErrorCallback<E>): void;
push<R,E>(task: T, callback?: AsyncResultCallback<R, E>): void;
unshift<E>(task: T | T[], callback?: ErrorCallback<E>): void;
push<R,E = Error>(task: T | T[], callback?: AsyncResultCallback<R, E>): void;
unshift<E = Error>(task: T | T[], callback?: ErrorCallback<E>): void;
saturated: () => any;
empty: () => any;
drain: () => any;
@@ -61,7 +60,7 @@ export interface AsyncPriorityQueue<T> {
concurrency: number;
started: boolean;
paused: boolean;
push<R,E>(task: T | T[], priority: number, callback?: AsyncResultArrayCallback<R, E>): void;
push<R,E = Error>(task: T | T[], priority: number, callback?: AsyncResultArrayCallback<R, E>): void;
saturated: () => any;
empty: () => any;
drain: () => any;
@@ -94,112 +93,113 @@ export interface AsyncCargo {
}
// Collections
export function each<T, E>(arr: IterableCollection<T>, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
export function each<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
export const eachSeries: typeof each;
export function eachLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
export function eachLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncIterator<T, E>, callback?: ErrorCallback<E>): void;
export const forEach: typeof each;
export const forEachSeries: typeof each;
export const forEachLimit: typeof eachLimit;
export function forEachOf<T, E>(obj: IterableCollection<T>, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
export function forEachOf<T, E = Error>(obj: IterableCollection<T>, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
export const forEachOfSeries: typeof forEachOf;
export function forEachOfLimit<T, E>(obj: IterableCollection<T>, limit: number, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
export function forEachOfLimit<T, E = Error>(obj: IterableCollection<T>, limit: number, iterator: AsyncForEachOfIterator<T, E>, callback?: ErrorCallback<E>): void;
export const eachOf: typeof forEachOf;
export const eachOfSeries: typeof forEachOf;
export const eachOfLimit: typeof forEachOfLimit;
export function map<T, R, E>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function map<T, R, E>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function map<T, R, E = Error>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function map<T, R, E = Error>(arr: Dictionary<T>, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export const mapSeries: typeof map;
export function mapLimit<T, R, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function mapValuesLimit<T, R, E>(obj: Dictionary<T>, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
export function mapValues<T, R, E>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
export function mapLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R, E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function mapValuesLimit<T, R, E = Error>(obj: Dictionary<T>, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
export function mapValues<T, R, E = Error>(obj: Dictionary<T>, iteratee: (value: T, key: string, callback: AsyncResultCallback<R, E>) => void, callback: AsyncResultObjectCallback<R, E>): void;
export const mapValuesSeries: typeof mapValues;
export function filter<T, E>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
export function filter<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
export const filterSeries: typeof filter;
export function filterLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
export function filterLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultArrayCallback<T, E>): void;
export const select: typeof filter;
export const selectSeries: typeof filter;
export const selectLimit: typeof filterLimit;
export const reject: typeof filter;
export const rejectSeries: typeof filter;
export const rejectLimit: typeof filterLimit;
export function reduce<T, R, E>(arr: T[] | IterableIterator<T>, memo: R, iterator: AsyncMemoIterator<T, R, E>, callback?: AsyncResultCallback<R, E>): void;
export function reduce<T, R, E = Error>(arr: T[] | IterableIterator<T>, memo: R, iterator: AsyncMemoIterator<T, R, E>, callback?: AsyncResultCallback<R, E>): void;
export const inject: typeof reduce;
export const foldl: typeof reduce;
export const reduceRight: typeof reduce;
export const foldr: typeof reduce;
export function detect<T, E>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
export function detect<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
export const detectSeries: typeof detect;
export function detectLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
export function detectLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncResultCallback<T, E>): void;
export const find: typeof detect;
export const findSeries: typeof detect;
export const findLimit: typeof detectLimit;
export function sortBy<T, V, E>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, V, E>, callback?: AsyncResultArrayCallback<T, E>): void;
export function some<T, E>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
export function sortBy<T, V, E = Error>(arr: T[] | IterableIterator<T>, iterator: AsyncResultIterator<T, V, E>, callback?: AsyncResultArrayCallback<T, E>): void;
export function some<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
export const someSeries: typeof some;
export function someLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
export function someLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
export const any: typeof some;
export const anySeries: typeof someSeries;
export const anyLimit: typeof someLimit;
export function every<T, E>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
export function every<T, E = Error>(arr: IterableCollection<T>, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
export const everySeries: typeof every;
export function everyLimit<T, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
export function everyLimit<T, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncBooleanIterator<T, E>, callback?: AsyncBooleanResultCallback<E>): void;
export const all: typeof every;
export const allSeries: typeof every;
export const allLimit: typeof everyLimit;
export function concat<T, R, E>(arr: IterableCollection<T>, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function concatLimit<T, R, E>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function concat<T, R, E = Error>(arr: IterableCollection<T>, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
export function concatLimit<T, R, E = Error>(arr: IterableCollection<T>, limit: number, iterator: AsyncResultIterator<T, R[], E>, callback?: AsyncResultArrayCallback<R, E>): void;
export const concatSeries: typeof concat;
// Control Flow
export function series<T, E>(tasks: AsyncFunction<T, E>[], callback?: AsyncResultArrayCallback<T, E>): void;
export function series<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
export function parallel<T, E>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
export function parallel<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
export function parallelLimit<T, E>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
export function parallelLimit<T, E>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
export function whilst<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doWhilst<T, E>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
export function until<E>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doUntil<T, E>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
export function during<E>(test: (testCallback : AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doDuring<E>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
export function forever<E>(next: (next : ErrorCallback<E>) => void, errBack: ErrorCallback<E>) : void;
export function waterfall<T, E>(tasks: Function[], callback?: AsyncResultCallback<T, E | Error>): void;
export function series<T, E = Error>(tasks: AsyncFunction<T, E>[], callback?: AsyncResultArrayCallback<T, E>): void;
export function series<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
export function parallel<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, callback?: AsyncResultArrayCallback<T, E>): void;
export function parallel<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, callback?: AsyncResultObjectCallback<T, E>): void;
export function parallelLimit<T, E = Error>(tasks: Array<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultArrayCallback<T, E>): void;
export function parallelLimit<T, E = Error>(tasks: Dictionary<AsyncFunction<T, E>>, limit: number, callback?: AsyncResultObjectCallback<T, E>): void;
export function whilst<E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doWhilst<T, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
export function until<E = Error>(test: () => boolean, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doUntil<T, E = Error>(fn: AsyncFunctionEx<T, E>, test: (...results: T[]) => boolean, callback: ErrorCallback<E>): void;
export function during<E = Error>(test: (testCallback : AsyncBooleanResultCallback<E>) => void, fn: AsyncVoidFunction<E>, callback: ErrorCallback<E>): void;
export function doDuring<E = Error>(fn: AsyncVoidFunction<E>, test: (testCallback: AsyncBooleanResultCallback<E>) => void, callback: ErrorCallback<E>): void;
export function forever<E = Error>(next: (next : ErrorCallback<E>) => void, errBack: ErrorCallback<E>) : void;
export function waterfall<T, E = Error>(tasks: Function[], callback?: AsyncResultCallback<T, E>): void;
export function compose(...fns: Function[]): Function;
export function seq(...fns: Function[]): Function;
export function applyEach(fns: Function[], ...argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
export function applyEachSeries(fns: Function[], ...argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional.
export function queue<T, E>(worker: AsyncWorker<T, E>, concurrency?: number): AsyncQueue<T>;
export function queue<T, R, E>(worker: AsyncResultIterator<T, R, E>, concurrency?: number): AsyncQueue<T>;
export function priorityQueue<T, E>(worker: AsyncWorker<T, E>, concurrency: number): AsyncPriorityQueue<T>;
export function cargo<E>(worker : (tasks: any[], callback : ErrorCallback<E>) => void, payload? : number) : AsyncCargo;
export function auto<R extends Dictionary<any>, E>(tasks: AsyncAutoTasks<R, E>, concurrency?: number, callback?: AsyncResultCallback<R, E>): void;
export function autoInject<E>(tasks: any, callback?: AsyncResultCallback<any, E>): void;
export function retry<T, E>(opts: number, task: (callback : AsyncResultCallback<T, E>, results: any) => void, callback: AsyncResultCallback<any, E | Error>): void;
export function retry<T, E>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T, E>, results : any) => void, callback: AsyncResultCallback<any, E | Error>): void;
export function retryable<T, E>(opts: number | {times: number, interval: number}, task: AsyncFunction<T, E>): AsyncFunction<T, E | Error>;
export function apply<E>(fn: Function, ...args: any[]): AsyncFunction<any,E | Error>;
export function queue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency?: number): AsyncQueue<T>;
export function queue<T, R, E = Error>(worker: AsyncResultIterator<T, R, E>, concurrency?: number): AsyncQueue<T>;
export function priorityQueue<T, E = Error>(worker: AsyncWorker<T, E>, concurrency: number): AsyncPriorityQueue<T>;
export function cargo<E = Error>(worker : (tasks: any[], callback : ErrorCallback<E>) => void, payload? : number) : AsyncCargo;
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, concurrency?: number, callback?: AsyncResultCallback<R, E>): void;
export function auto<R extends Dictionary<any>, E = Error>(tasks: AsyncAutoTasks<R, E>, callback?: AsyncResultCallback<R, E>): void;
export function autoInject<E = Error>(tasks: any, callback?: AsyncResultCallback<any, E>): void;
export function retry<T, E = Error>(opts: number, task: (callback : AsyncResultCallback<T, E>, results: any) => void, callback: AsyncResultCallback<any, E>): void;
export function retry<T, E = Error>(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback<T, E>, results : any) => void, callback: AsyncResultCallback<any, E>): void;
export function retryable<T, E = Error>(opts: number | {times: number, interval: number}, task: AsyncFunction<T, E>): AsyncFunction<T, E>;
export function apply<E = Error>(fn: Function, ...args: any[]): AsyncFunction<any,E>;
export function nextTick(callback: Function, ...args: any[]): void;
export const setImmediate: typeof nextTick;
export function reflect<T, E>(fn: AsyncFunction<T, E>) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void;
export function reflectAll<T, E>(tasks: AsyncFunction<T, E>[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[];
export function reflect<T, E = Error>(fn: AsyncFunction<T, E>) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void;
export function reflectAll<T, E = Error>(tasks: AsyncFunction<T, E>[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[];
export function timeout<T, E>(fn: AsyncFunction<T, E>, milliseconds: number, info?: any): AsyncFunction<T, E | Error>;
export function timeout<T, R, E>(fn: AsyncResultIterator<T, R, E>, milliseconds: number, info?: any): AsyncResultIterator<T, R, E | Error>;
export function timeout<T, E = Error>(fn: AsyncFunction<T, E>, milliseconds: number, info?: any): AsyncFunction<T, E>;
export function timeout<T, R, E = Error>(fn: AsyncResultIterator<T, R, E>, milliseconds: number, info?: any): AsyncResultIterator<T, R, E>;
export function times<T, E> (n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function timesSeries<T, E>(n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function timesLimit<T, E>(n: number, limit: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function timesSeries<T, E = Error>(n: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function timesLimit<T, E = Error>(n: number, limit: number, iterator: AsyncResultIterator<number, T, E>, callback: AsyncResultArrayCallback<T, E>): void;
export function transform<T, R, E>(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
export function transform<T, R, E>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
export function transform<T, R, E = Error>(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
export function transform<T, R, E = Error>(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback<T, E>): void;
export function transform<T, R, E>(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
export function transform<T, R, E>(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
export function transform<T, R, E = Error>(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
export function transform<T, R, E = Error>(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback<T, E>): void;
export function race<T, E>(tasks: (AsyncFunction<T, E>)[], callback: AsyncResultCallback<T, E | Error>) : void;
export function race<T, E = Error>(tasks: (AsyncFunction<T, E>)[], callback: AsyncResultCallback<T, E>) : void;
// Utils
export function memoize(fn: Function, hasher?: Function): Function;
+79 -46
View File
@@ -114,7 +114,7 @@ async.series([
],
function (err, results) { });
async.series<string,Error>([
async.series<string>([
function (callback) {
callback(undefined, 'one');
},
@@ -138,7 +138,7 @@ async.series({
},
function (err, results) { });
async.series<number,Error>({
async.series<number>({
one: function (callback) {
setTimeout(function () {
callback(undefined, 1);
@@ -178,7 +178,7 @@ async.parallel([
],
function (err, results) { });
async.parallel<string,Error>([
async.parallel<string>([
function (callback) {
setTimeout(function () {
callback(undefined, 'one');
@@ -207,7 +207,7 @@ async.parallel({
},
function (err, results) { });
async.parallel<number,Error>({
async.parallel<number>({
one: function (callback) {
setTimeout(function () {
callback(undefined, 1);
@@ -273,7 +273,7 @@ async.waterfall([
], function (err, result) { });
var q = async.queue<any,Error>(function (task: any, callback: (err?:Error,msg?:string) => void) {
var q = async.queue<any>(function (task: any, callback: (err?:Error,msg?:string) => void) {
console.log('hello ' + task.name);
callback(undefined,'a message.');
}, 2);
@@ -293,7 +293,7 @@ q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (err) {
console.log('finished processing bar');
});
q.push<string,Error>({name: 'foo'}, function (err,msg) {
q.push<string>({name: 'foo'}, function (err, msg) {
console.log('foo finished with a message "'+ msg! + '"');
});
@@ -330,7 +330,7 @@ q.resume();
q.kill();
// tests for strongly typed tasks
var q2 = async.queue<string,Error>(function (task: string, callback: () => void) {
var q2 = async.queue<string>(function (task: string, callback: () => void) {
console.log('Task: ' + task);
callback();
}, 1);
@@ -356,7 +356,7 @@ q2.unshift(['task3', 'task4', 'task5'], function (error) {
});
var aq = async.queue<number, number, Error>(function (level: number, callback: (error?: Error, newLevel?: number) => void) {
var aq = async.queue<number, number>(function (level: number, callback: (error?: Error, newLevel?: number) => void) {
console.log('hello ' + level);
callback(undefined, level+1);
});
@@ -387,14 +387,47 @@ cargo.push({ name: 'baz' }, function (err: Error) {
var filename = '';
async.auto({
get_data: function (callback: any) { },
make_folder: function (callback: any) { },
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: any) {
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: any, results: any) { }]
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
});
async.auto({
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
}, function (err, results) {
console.log('finished auto');
});
interface A {
get_data: any;
make_folder: any;
write_file: any;
email_link: any;
}
async.auto<A>({
get_data: function (callback: AsyncResultCallback<any>) { },
make_folder: function (callback: AsyncResultCallback<any>) { },
//arrays with different types are not accepted by TypeScript.
write_file: ['get_data', 'make_folder', <any>function (callback: AsyncResultCallback<any>) {
callback(null, filename);
}],
//arrays with different types are not accepted by TypeScript.
email_link: ['write_file', <any>function (callback: AsyncResultCallback<any>, results: any) { }]
}, 1, function (err, results) {
console.log('finished auto');
});
async.retry(3, function (callback, results) { }, function (err, result) { });
@@ -459,10 +492,10 @@ async.dir(function (name: string, callback: any) {
// each
async.each<number,Error>({
async.each<number>({
"a": 1,
"b": 2
}, function(val: number, next: ErrorCallback<Error>): void {
}, function(val: number, next: ErrorCallback): void {
setTimeout(function(): void {
@@ -478,10 +511,10 @@ async.each<number,Error>({
});
async.eachSeries<number, Error>({
async.eachSeries<number>({
"a": 1,
"b": 2
}, function(val: number, next: ErrorCallback<Error>): void {
}, function(val: number, next: ErrorCallback): void {
setTimeout(function(): void {
@@ -497,14 +530,14 @@ async.eachSeries<number, Error>({
});
async.eachLimit<number, Error>({
async.eachLimit<number>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, next: ErrorCallback<Error>): void {
}, 2, function(val: number, next: ErrorCallback): void {
setTimeout(function(): void {
@@ -522,10 +555,10 @@ async.eachLimit<number, Error>({
// forEachOf/eachOf
async.eachOf<number, Error>({
async.eachOf<number>({
"a": 1,
"b": 2
}, function(val: number, key: string, next: ErrorCallback<Error>): void {
}, function(val: number, key: string, next: ErrorCallback): void {
setTimeout(function(): void {
@@ -541,10 +574,10 @@ async.eachOf<number, Error>({
});
async.forEachOfSeries<number, Error>({
async.forEachOfSeries<number>({
"a": 1,
"b": 2
}, function(val: number, key: string, next: ErrorCallback<Error>): void {
}, function(val: number, key: string, next: ErrorCallback): void {
setTimeout(function(): void {
@@ -560,14 +593,14 @@ async.forEachOfSeries<number, Error>({
});
async.forEachOfLimit<number, Error>({
async.forEachOfLimit<number>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, key: string, next: ErrorCallback<Error>): void {
}, 2, function(val: number, key: string, next: ErrorCallback): void {
setTimeout(function(): void {
@@ -585,11 +618,11 @@ async.forEachOfLimit<number, Error>({
// map
async.map<number, string, Error>({
async.map<number, string>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncResultCallback<string, Error>): void {
}, function(val: number, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
@@ -605,11 +638,11 @@ async.map<number, string, Error>({
});
async.mapSeries<number, string, Error>({
async.mapSeries<number, string>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncResultCallback<string, Error>): void {
}, function(val: number, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
@@ -625,14 +658,14 @@ async.mapSeries<number, string, Error>({
});
async.mapLimit<number, string, Error>({
async.mapLimit<number, string>({
"a": 1,
"b": 2,
"c": 3,
"d": 4,
"e": 5,
"f": 6
}, 2, function(val: number, next: AsyncResultCallback<string, Error>): void {
}, 2, function(val: number, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
@@ -650,11 +683,11 @@ async.mapLimit<number, string, Error>({
// mapValues
async.mapValues<number, string, Error>({
async.mapValues<number, string>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, key: string, next: AsyncResultCallback<string, Error>): void {
}, function(val: number, key: string, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
@@ -670,11 +703,11 @@ async.mapValues<number, string, Error>({
});
async.mapValuesSeries<number, string, Error>({
async.mapValuesSeries<number, string>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, key: string, next: AsyncResultCallback<string, Error>): void {
}, function(val: number, key: string, next: AsyncResultCallback<string>): void {
setTimeout(function(): void {
@@ -692,11 +725,11 @@ async.mapValuesSeries<number, string, Error>({
// filter/select/reject
async.filter<number, Error>({
async.filter<number>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncBooleanResultCallback<Error>): void {
}, function(val: number, next: AsyncBooleanResultCallback): void {
setTimeout(function(): void {
@@ -712,11 +745,11 @@ async.filter<number, Error>({
});
async.reject<number, Error>({
async.reject<number>({
"a": 1,
"b": 2,
"c": 3
}, function(val: number, next: AsyncBooleanResultCallback<Error>): void {
}, function(val: number, next: AsyncBooleanResultCallback): void {
setTimeout(function(): void {
@@ -734,11 +767,11 @@ async.reject<number, Error>({
// concat
async.concat<string, string, Error>({
async.concat<string, string>({
"a": "1",
"b": "2",
"c": "3"
}, function(item: string, next: AsyncResultCallback<string[], Error>): void {
}, function(item: string, next: AsyncResultCallback<string[]>): void {
console.log(`async.concat: ${item}`);
@@ -752,11 +785,11 @@ async.concat<string, string, Error>({
// detect/find
async.detect<number, Error>({
async.detect<number>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
}, function(item: number, next: AsyncBooleanResultCallback): void {
console.log(`async.detect/find: ${item}`);
@@ -777,11 +810,11 @@ async.detect<number, Error>({
// every/all
async.every<number,Error>({
async.every<number>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
}, function(item: number, next: AsyncBooleanResultCallback): void {
console.log(`async.every/all: ${item}`);
@@ -795,11 +828,11 @@ async.every<number,Error>({
// some/any
async.some<number, Error>({
async.some<number>({
"a": 1,
"b": 2,
"c": 3
}, function(item: number, next: AsyncBooleanResultCallback<Error>): void {
}, function(item: number, next: AsyncBooleanResultCallback): void {
console.log(`async.some/any: ${item}`);
+1 -1
View File
@@ -3,7 +3,7 @@ declare class Session {
readonly token: string;
readonly createdAt: Date;
readonly expiresAt: Date;
constructor(token: string, createdAt: Date, expiresAt: Date);
toCrowd(): SessionObj;
static fromCrowd(obj: SessionObj): Session;
+1 -1
View File
@@ -3,7 +3,7 @@ export interface Settings {
readonly application: {
readonly name: string;
readonly password: string;
}
};
readonly nesting?: boolean;
readonly sessionTimeout?: number;
readonly debug?: boolean;
+6
View File
@@ -0,0 +1,6 @@
import * as auth from 'auth-header';
const basic: string = auth.format('Basic');
const basic2: string = auth.format({scheme: 'Basic'});
const parsed: {scheme: string, token: null | string | string[]} = auth.parse('');
+27
View File
@@ -0,0 +1,27 @@
// Type definitions for auth-header 1.0
// Project: https://github.com/izaakschroeder/auth-header
// Definitions by: ForbesLindesay <https://github.com/ForbesLindesay>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
type Params =
| Array<[string, string | ReadonlyArray<string>]>
| {[key: string]: string | ReadonlyArray<string>};
export {Params};
export interface TokenOptions {
scheme: string;
token?: string;
params?: Params;
}
export interface Token {
scheme: string;
params: {[key: string]: string | string[]};
token: null | string | string[];
}
export function format(token: TokenOptions): string;
export function format(scheme: string, token?: string, params?: Params): string;
export function parse(header: string): Token;
+23
View File
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"auth-header-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+2 -1
View File
@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/sandrinodimattia/axios-token-interceptor#readme
// Definitions by: Mike Dodge <https://github.com/innovation-team>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { AxiosRequestConfig } from 'axios';
+9 -2
View File
@@ -2,14 +2,21 @@
"extends": "dtslint/dt.json",
"rules": {
// All are TODOs
"eofline": false,
"adjacent-overload-signatures": false,
"array-type": false,
"ban-types": false,
"comment-format": false,
"dt-header": false,
"eofline": false,
"max-line-length": false,
"member-access": false,
"no-consecutive-blank-lines": false,
"no-empty-interface": false,
"no-namespace": false,
"no-unnecessary-class": false,
"no-useless-files": false,
"no-var": false,
"semicolon": false
"semicolon": false,
"space-before-function-paren": false
}
}
@@ -0,0 +1,21 @@
import express = require('express');
import basicAuth = require('basicauth-middleware');
const app = express();
app.use(basicAuth("username", "password", "realm"));
app.use(basicAuth([["username", "password"]]));
function checkSync(username: string, password: string): boolean {
return username === "user" && password === "pass";
}
function checkCallback(username: string, password: string, callback: (err: Error|null, authorized: boolean) => void): void {
callback(null, username === "user" && password === "pass");
}
function checkPromise(username: string, password: string): Promise<boolean> {
return Promise.resolve(true);
}
app.use(basicAuth(checkSync));
app.use(basicAuth(checkCallback));
app.use(basicAuth(checkPromise));
+16
View File
@@ -0,0 +1,16 @@
// Type definitions for basicauth-middleware 3.1
// Project: https://github.com/nchaulet/basicauth-middleware
// Definitions by: My Self <https://github.com/nchaulet>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
import { RequestHandler } from "express";
type checkFunctionSync = (username: string, password: string) => boolean;
type checkFunctionCallback = (username: string, password: string, callback: (err: Error|null, authorized: boolean) => void) => void;
type checkFunctionPromise = (username: string, password: string) => PromiseLike<boolean>;
type CheckFunction = checkFunctionSync | checkFunctionPromise | checkFunctionCallback;
declare function basicAuth(checkFnOrUsers: Array<[string, string]>|CheckFunction, realm?: string): RequestHandler;
declare function basicAuth(username: string, password: string, realm?: string): RequestHandler;
export = basicAuth;
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"basicauth-middleware-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/hapijs/bell
// Definitions by: Simon Schick <https://github.com/SimonSchick>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.7
// TypeScript Version: 2.8
import { Server, Request, Plugin, AuthCredentials } from 'hapi';
+5 -4
View File
@@ -144,12 +144,12 @@ const boomifiedError = Boom.boomify(new Error('test'), { statusCode: 400, messag
// isBoom
const isBoomError = new Boom('test')
const isBoomError = new Boom('test');
Boom.isBoom(isBoomError);
const maybeBoom = <any>new Boom('test');
if(Boom.isBoom(maybeBoom)) {
const maybeBoom = <any> new Boom('test');
if (Boom.isBoom(maybeBoom)) {
// isBoom is a type guard that allows accessing these properties:
maybeBoom.output.headers;
}
@@ -183,7 +183,8 @@ interface CustomPayload extends Boom.Payload {
/**
* Test assignment of custom error data:
*/
const errorWithData = Boom.badImplementation('', { custom1: 'test', customType: 'Custom1', isCustom: true } as CustomData1);
// tslint:disable-next-line:no-object-literal-type-assertion
const errorWithData = Boom.badImplementation('', <CustomData1> { custom1: 'test', customType: 'Custom1', isCustom: true });
const errorWithNoExplicitDataType: Boom = errorWithData; // can assign to error without explicit data type
const errorWithExplicitType: Boom<CustomData> = errorWithData; // can assign to union data type
const errorWithConcreteCustomData: Boom<CustomData1> = errorWithData; // can assign to concrete data type
+86 -63
View File
@@ -1,4 +1,4 @@
// Type definitions for boom 7.2.0
// Type definitions for boom 7.2
// Project: https://github.com/hapijs/boom
// Definitions by: Igor Rogatty <https://github.com/rogatty>
// AJP <https://github.com/AJamesPhillips>
@@ -10,28 +10,31 @@
export = Boom;
/**
* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties:
* @see {@link https://github.com/hapijs/boom#boom}
*/
* boom provides a set of utilities for returning HTTP errors. Each utility returns a Boom error response object (instance of Error) which includes the following properties:
* @see {@link https://github.com/hapijs/boom#boom}
*/
declare class Boom<Data = any> extends Error {
/** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */
constructor(message?: string | Error, options?: Boom.Options<Data>);
/** isBoom - if true, indicates this is a Boom object instance. */
isBoom: boolean;
/** isServer - convenience bool indicating status code >= 500. */
isServer: boolean;
/** message - the error message. */
message: string;
/** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */
output: Boom.Output;
/** reformat() - rebuilds error.output using the other object properties. */
reformat: () => string;
/** "If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object." mentioned in @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes} */
isMissing?: boolean;
/** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */
data: Data;
}
/** Creates a new Boom object using the provided message and then calling boomify() to decorate the error with the Boom properties. */
constructor(message?: string | Error, options?: Boom.Options<Data>);
/** isBoom - if true, indicates this is a Boom object instance. */
isBoom: boolean;
/** isServer - convenience bool indicating status code >= 500. */
isServer: boolean;
/** message - the error message. */
message: string;
/** output - the formatted response. Can be directly manipulated after object construction to return a custom error response. Allowed root keys: */
output: Boom.Output;
/** reformat() - rebuilds error.output using the other object properties. */
reformat(): string;
/**
* "If message is unset, the 'error' segment of the header will not be present and
* isMissing will be true on the error object." mentioned in
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
*/
isMissing?: boolean;
/** https://github.com/hapijs/boom#createstatuscode-message-data and https://github.com/hapijs/boom/blob/v4.3.0/lib/index.js#L99 */
data: Data;
}
declare namespace Boom {
interface Options<Data> {
/** statusCode - the HTTP status code. Defaults to 500 if no status code is already set. */
@@ -44,20 +47,32 @@ declare namespace Boom {
ctor?: any;
/** message - error message string. If the error already has a message, the provided message is added as a prefix. Defaults to no message. */
message?: string;
/** override - if false, the err provided is a Boom object, and a statusCode or message are provided, the values are ignored. Defaults to true (apply the provided statusCode and message options to the error regardless of its type, Error or Boom object). */
/**
* override - if false, the err provided is a Boom object, and a statusCode or message are
* provided, the values are ignored. Defaults to true (apply the provided statusCode and
* message options to the error regardless of its type, Error or Boom object).
*/
override?: boolean;
}
interface Output {
/** statusCode - the HTTP status code (typically 4xx or 5xx). */
statusCode: number;
/** headers - an object containing any HTTP headers where each key is a header name and value is the header content. (Limited value type to string https://github.com/hapijs/boom/issues/151 ) */
/**
* headers - an object containing any HTTP headers where each key is a header name and
* value is the header content. (Limited value type to string
* https://github.com/hapijs/boom/issues/151 )
*/
headers: {[index: string]: string};
/** payload - the formatted object used as the response payload (stringified). Can be directly manipulated but any changes will be lost if reformat() is called. Any content allowed and by default includes the following content: */
/**
* payload - the formatted object used as the response payload (stringified).
* Can be directly manipulated but any changes will be lost if reformat() is called.
* Any content allowed and by default includes the following content:
*/
payload: Payload;
}
interface Payload {
interface Payload {
/** statusCode - the HTTP status code, derived from error.output.statusCode. */
statusCode: number;
/** error - the HTTP status message (e.g. 'Bad Request', 'Internal Server Error') derived from statusCode. */
@@ -79,13 +94,13 @@ declare namespace Boom {
* @param options optional additional options
* @see {@link https://github.com/hapijs/boom#boomifyerror-options}
*/
function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom<null>;
function boomify(error: Error, options?: { statusCode?: number, message?: string, override?: boolean }): Boom<null>;
/**
* Identifies whether an error is a Boom object. Same as calling instanceof Boom.
* @param error the error object to identify.
*/
function isBoom(error: Error): error is Boom
function isBoom(error: Error): error is Boom;
// 4xx
/**
@@ -94,7 +109,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombadrequestmessage-data}
*/
function badRequest<Data = null>(message?: string, data?: Data): Boom<Data>;
function badRequest<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 401 Unauthorized error
@@ -102,13 +117,21 @@ declare namespace Boom {
* @param scheme can be one of the following:
* * an authentication scheme name
* * an array of string values. These values will be separated by ', ' and set to the 'WWW-Authenticate' header.
* @param attributes an object of values to use while setting the 'WWW-Authenticate' header. This value is only used when scheme is a string, otherwise it is ignored. Every key/value pair will be included in the 'WWW-Authenticate' in the format of 'key="value"' as well as in the response payload under the attributes key. Alternatively value can be a string which is use to set the value of the scheme, for example setting the token value for negotiate header. If string is used message parameter must be null. null and undefined will be replaced with an empty string. If attributes is set, message will be used as the 'error' segment of the 'WWW-Authenticate' header. If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object.
* @param attributes an object of values to use while setting the 'WWW-Authenticate' header.
* This value is only used when scheme is a string, otherwise it is ignored.
* Every key/value pair will be included in the 'WWW-Authenticate' in the format of
* 'key="value"' as well as in the response payload under the attributes key.
* Alternatively value can be a string which is use to set the value of the scheme,
* for example setting the token value for negotiate header.
* If string is used message parameter must be null.
* null and undefined will be replaced with an empty string. If attributes is set,
* message will be used as the 'error' segment of the 'WWW-Authenticate' header.
* If message is unset, the 'error' segment of the header will not be present and isMissing will be true on the error object.
* @see {@link https://github.com/hapijs/boom#boomunauthorizedmessage-scheme-attributes}
*/
function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom<null>;
function unauthorized(message?: string, scheme?: string[]): Boom<null>;
function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom<null>;
function unauthorized(message?: null, scheme?: string[]): Boom<null>;
function unauthorized(message?: string, scheme?: string, attributes?: {[index: string]: string}): Boom<null>;
function unauthorized(message?: string, scheme?: string[]): Boom<null>;
function unauthorized(message?: null, scheme?: string, attributes?: {[index: string]: string} | string): Boom<null>;
/**
* Returns a 402 Payment Required error
@@ -116,7 +139,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boompaymentrequiredmessage-data}
*/
function paymentRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
function paymentRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 403 Forbidden error
@@ -124,7 +147,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomforbiddenmessage-data}
*/
function forbidden<Data = null>(message?: string, data?: Data): Boom<Data>;
function forbidden<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 404 Not Found error
@@ -132,7 +155,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomnotfoundmessage-data}
*/
function notFound<Data = null>(message?: string, data?: Data): Boom<Data>;
function notFound<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 405 Method Not Allowed error
@@ -141,7 +164,7 @@ declare namespace Boom {
* @param allow optional string or array of strings (to be combined and separated by ', ') which is set to the 'Allow' header.
* @see {@link https://github.com/hapijs/boom#boommethodnotallowedmessage-data-allow}
*/
function methodNotAllowed<Data = null>(message?: string, data?: Data, allow?: string | string[]): Boom<Data>;
function methodNotAllowed<Data = null>(message?: string, data?: Data, allow?: string | string[]): Boom<Data>;
/**
* Returns a 406 Not Acceptable error
@@ -149,7 +172,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomnotacceptablemessage-data}
*/
function notAcceptable<Data = null>(message?: string, data?: Data): Boom<Data>;
function notAcceptable<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 407 Proxy Authentication Required error
@@ -157,7 +180,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomproxyauthrequiredmessage-data}
*/
function proxyAuthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
function proxyAuthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 408 Request Time-out error
@@ -165,7 +188,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomclienttimeoutmessage-data}
*/
function clientTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
function clientTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 409 Conflict error
@@ -173,7 +196,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomconflictmessage-data}
*/
function conflict<Data = null>(message?: string, data?: Data): Boom<Data>;
function conflict<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 410 Gone error
@@ -181,7 +204,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomresourcegonemessage-data}
*/
function resourceGone<Data = null>(message?: string, data?: Data): Boom<Data>;
function resourceGone<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 411 Length Required error
@@ -189,7 +212,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomlengthrequiredmessage-data}
*/
function lengthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
function lengthRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 412 Precondition Failed error
@@ -197,7 +220,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boompreconditionfailedmessage-data}
*/
function preconditionFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
function preconditionFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 413 Request Entity Too Large error
@@ -205,7 +228,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomentitytoolargemessage-data}
*/
function entityTooLarge<Data = null>(message?: string, data?: Data): Boom<Data>;
function entityTooLarge<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 414 Request-URI Too Large error
@@ -213,7 +236,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomuritoolongmessage-data}
*/
function uriTooLong<Data = null>(message?: string, data?: Data): Boom<Data>;
function uriTooLong<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 415 Unsupported Media Type error
@@ -221,7 +244,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomunsupportedmediatypemessage-data}
*/
function unsupportedMediaType<Data = null>(message?: string, data?: Data): Boom<Data>;
function unsupportedMediaType<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 416 Requested Range Not Satisfiable error
@@ -229,7 +252,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomrangenotsatisfiablemessage-data}
*/
function rangeNotSatisfiable<Data = null>(message?: string, data?: Data): Boom<Data>;
function rangeNotSatisfiable<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 417 Expectation Failed error
@@ -237,7 +260,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomexpectationfailedmessage-data}
*/
function expectationFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
function expectationFailed<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 418 I'm a Teapot error
@@ -245,7 +268,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomteapotmessage-data}
*/
function teapot<Data = null>(message?: string, data?: Data): Boom<Data>;
function teapot<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 422 Unprocessable Entity error
@@ -253,7 +276,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombaddatamessage-data}
*/
function badData<Data = null>(message?: string, data?: Data): Boom<Data>;
function badData<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 423 Locked error
@@ -261,7 +284,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomlockedmessage-data}
*/
function locked<Data = null>(message?: string, data?: Data): Boom<Data>;
function locked<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 424 Failed Dependency error
@@ -269,7 +292,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomfaileddependencymessage-data}
*/
function failedDependency<Data = null>(message?: string, data?: Data): Boom<Data>;
function failedDependency<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 428 Precondition Required error
@@ -277,7 +300,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boompreconditionrequiredmessage-data}
*/
function preconditionRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
function preconditionRequired<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 429 Too Many Requests error
@@ -285,7 +308,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomtoomanyrequestsmessage-data}
*/
function tooManyRequests<Data = null>(message?: string, data?: Data): Boom<Data>;
function tooManyRequests<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 451 Unavailable For Legal Reasons error
@@ -293,7 +316,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomillegalmessage-data}
*/
function illegal<Data = null>(message?: string, data?: Data): Boom<Data>;
function illegal<Data = null>(message?: string, data?: Data): Boom<Data>;
// 5xx
/**
@@ -303,7 +326,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
*/
function badImplementation<Data = null>(message?: string, data?: Data): Boom<Data>;
function badImplementation<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 500 Internal Server Error error
@@ -312,7 +335,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombadimplementationmessage-data---alias-internal}
*/
function internal<Data = null>(message?: string, data?: Data): Boom<Data>;
function internal<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 501 Not Implemented error with your error message to the user
@@ -320,7 +343,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomnotimplementedmessage-data}
*/
function notImplemented<Data = null>(message?: string, data?: Data): Boom<Data>;
function notImplemented<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 502 Bad Gateway error with your error message to the user
@@ -328,7 +351,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boombadgatewaymessage-data}
*/
function badGateway<Data = null>(message?: string, data?: Data): Boom<Data>;
function badGateway<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 503 Service Unavailable error with your error message to the user
@@ -336,7 +359,7 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomserverunavailablemessage-data}
*/
function serverUnavailable<Data = null>(message?: string, data?: Data): Boom<Data>;
function serverUnavailable<Data = null>(message?: string, data?: Data): Boom<Data>;
/**
* Returns a 504 Gateway Time-out error with your error message to the user
@@ -344,5 +367,5 @@ declare namespace Boom {
* @param data optional additional error data.
* @see {@link https://github.com/hapijs/boom#boomgatewaytimeoutmessage-data}
*/
function gatewayTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
function gatewayTimeout<Data = null>(message?: string, data?: Data): Boom<Data>;
}
+1 -77
View File
@@ -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"
}
-1
View File
@@ -1,5 +1,4 @@
import Boom = require('boom');
import * as Hapi from 'hapi';
// 4xx and data type
+1 -1
View File
@@ -25,4 +25,4 @@
"index.d.ts",
"boom-tests.ts"
]
}
}
@@ -0,0 +1,46 @@
import Plugin = require('broccoli-plugin');
declare function copySync(src: string, dest: string): void;
declare function setTimeout(callback: () => void, duration: number): void;
class SlowItDown extends Plugin {
constructor(private readonly waitInMS: number) {
super([], {
annotation: `${waitInMS} ms`,
needsCache: false
});
}
async build() {
await new Promise(resolve => setTimeout(resolve, this.waitInMS));
}
}
class FileCopier extends Plugin {
constructor(inputNodes: Plugin.BroccoliNode[]) {
super(inputNodes, {
name: 'CopyFiles',
persistentOutput: true
});
}
build() {
for (const input of this.inputPaths) {
copySync(input, this.outputPath);
}
}
getCallbackObject() {
return this;
}
}
new FileCopier([
new SlowItDown(5000),
'src',
'assets'
]);
new Plugin(); // $ExpectError
new Plugin([{}]); // $ExpectError
new Plugin([], { foo: 'bar' }); // $ExpectError
+78
View File
@@ -0,0 +1,78 @@
// Type definitions for broccoli-plugin 1.3
// Project: https://github.com/broccolijs/broccoli-plugin
// Definitions by: Dan Freeman <https://github.com/dfreeman>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
export = BroccoliPlugin;
declare namespace BroccoliPlugin {
type BroccoliNode = BroccoliPlugin | string;
interface BroccoliPluginOptions {
/**
* The name of this plugin. Defaults to `this.constructor.name`.
*/
name?: string;
/**
* A descriptive annotation. Useful for debugging, to tell multiple
* instances of the same plugin apart.
*/
annotation?: string;
/**
* If `true`, the output directory is not automatically emptied between
* builds. Defaults to `false`.
*/
persistentOutput?: boolean;
/**
* If `true`, a cache directory is created automatically and the path is
* set at `cachePath`. If `false`, a cache directory is not created and
* `this.cachePath` is `undefined`. Defaults to `true`.
*/
needsCache?: boolean;
}
}
declare class BroccoliPlugin {
constructor(inputNodes: BroccoliPlugin.BroccoliNode[], options?: BroccoliPlugin.BroccoliPluginOptions);
/**
* An array of paths on disk corresponding to each node in `inputNodes`.
* Your plugin will read files from these paths.
*/
readonly inputPaths: ReadonlyArray<string>;
/**
* The path on disk corresponding to this plugin instance (this node).
* Your plugin will write files to this path. This directory is emptied by
* Broccoli before each build, unless the `persistentOutput` options is
* `true`.
*/
readonly outputPath: string;
/**
* The path on disk to an auxiliary cache directory. Use this to store
* files that you want preserved between builds. This directory will
* only be deleted when Broccoli exits. If a cache directory is not
* needed, set `needsCache` to false when calling `broccoli-plugin`
* constructor.
*/
readonly cachePath?: string;
/**
* Override this method in your subclass. It will be called on each
* (re-)build. All paths stay the same between builds.
* To perform asynchronous work, return a promise.
*/
build(): void | Promise<any>;
/**
* Advanced usage only.
* Return the object on which Broccoli will call `obj.build()`. Called
* once after instantiation. By default, returns `this`.
*/
getCallbackObject(): { build(): void | Promise<any> };
}
+23
View 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",
"broccoli-plugin-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+51 -1
View File
@@ -125,6 +125,7 @@ videoQueue.add({ video: 'http://example.com/video1.mov' }, { jobId: 1 })
pdfQueue
.on('error', (err: Error) => undefined)
.on('active', (job: Queue.Job, jobPromise: Queue.JobPromise) => jobPromise.cancel())
.on('waiting', (jobId: Queue.JobId) => undefined)
.on('active', (job: Queue.Job) => undefined)
.on('stalled', (job: Queue.Job) => undefined)
.on('progress', (job: Queue.Job) => undefined)
@@ -132,4 +133,53 @@ pdfQueue
.on('failed', (job: Queue.Job) => undefined)
.on('paused', () => undefined)
.on('resumed', () => undefined)
.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatus) => undefined);
.on('cleaned', (jobs: Queue.Job[], status: Queue.JobStatus) => undefined)
.on('drained', () => undefined)
.on('removed', (job: Queue.Job) => undefined);
// test different process methods
const profileQueue = new Queue('profile');
// Max concurrency for requestProfile is 100
profileQueue.process('requestProfile', 100, () => {});
profileQueue.process(100, () => {});
// other tests
const myQueue = new Queue('myQueue', {
settings: {
drainDelay: 5
},
defaultJobOptions: {
stackTraceLimit: 1,
}
});
myQueue.on('active', (job: Queue.Job) => {
job.moveToCompleted();
job.moveToCompleted('done');
job.moveToCompleted('done', true);
job.moveToCompleted('done', true).then(val => {
if (val) {
const nextJobData: any = val[0];
const nextJobId: Queue.JobId = val[1];
}
});
job.moveToFailed({ message: "Call to external service failed!" }, true);
job.moveToFailed(new Error('test error'), true);
job.moveToFailed(new Error('test error'), true).then(val => {
if (val) {
const nextJobData: any = val[0];
const nextJobId: Queue.JobId = val[1];
}
});
job.discard();
});
// test all constructor options:
new Queue('profile');
new Queue('profile', 'url');
new Queue('profile', { prefix: 'test' });
new Queue('profile', 'url', { prefix: 'test' });
+57 -3
View File
@@ -1,4 +1,4 @@
// Type definitions for bull 3.3
// Type definitions for bull 3.4
// Project: https://github.com/OptimalBits/bull
// Definitions by: Bruno Grieder <https://github.com/bgrieder>
// Cameron Crothers <https://github.com/JProgrammer>
@@ -10,6 +10,7 @@
// Bond Akinmade <https://github.com/bondz>
// Wuha Team <https://github.com/wuha-team>
// Alec Brunelle <https://github.com/aleccool213>
// Dan Manastireanu <https://github.com/danmana>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
@@ -23,9 +24,9 @@ import * as Promise from "bluebird";
*/
declare const Bull: {
(queueName: string, opts?: Bull.QueueOptions): Bull.Queue;
(queueName: string, url?: string): Bull.Queue; // tslint:disable-line unified-signatures
(queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures
new (queueName: string, opts?: Bull.QueueOptions): Bull.Queue;
new (queueName: string, url?: string): Bull.Queue; // tslint:disable-line unified-signatures
new (queueName: string, url: string, opts?: Bull.QueueOptions): Bull.Queue; // tslint:disable-line unified-signatures
};
declare namespace Bull {
@@ -92,6 +93,12 @@ declare namespace Bull {
backoffStrategies?: {
[key: string]: (attemptsMade: number, err: typeof Error) => number;
};
/**
* A timeout for when the queue is in `drained` state (empty waiting for jobs).
* It is used when calling `queue.getNextJob()`, which will pass it to `.brpoplpush` on the Redis client.
*/
drainDelay?: number;
}
type DoneCallback = (error?: Error | null, value?: any) => void;
@@ -141,6 +148,11 @@ declare namespace Bull {
*/
retry(): Promise<void>;
/**
* Ensure this job is never ran again even if attemptsMade is less than job.attempts.
*/
discard(): Promise<void>;
/**
* Returns a promise that resolves to the returned data when the job has been finished.
* TODO: Add a watchdog to check if the job has finished periodically.
@@ -148,6 +160,18 @@ declare namespace Bull {
*/
finished(): Promise<any>;
/**
* Moves a job to the `completed` queue. Pulls a job from 'waiting' to 'active'
* and returns a tuple containing the next jobs data and id. If no job is in the `waiting` queue, returns null.
*/
moveToCompleted(returnValue?: string, ignoreLock?: boolean): Promise<[any, JobId] | null>;
/**
* Moves a job to the `failed` queue. Pulls a job from 'waiting' to 'active'
* and returns a tuple containing the next jobs data and id. If no job is in the `waiting` queue, returns null.
*/
moveToFailed(errorInfo: { message: string; }, ignoreLock?: boolean): Promise<[any, JobId] | null>;
/**
* Promotes a job that is currently "delayed" to the "waiting" state and executed as soon as possible.
*/
@@ -205,6 +229,11 @@ declare namespace Bull {
* Cron pattern specifying when the job should execute
*/
cron: string;
/**
* Start date when the repeat job should start repeating (only with cron).
*/
startDate?: Date | string | number;
}
interface EveryRepeatOptions extends RepeatOptions {
@@ -273,6 +302,11 @@ declare namespace Bull {
* Default behavior is to keep the job in the completed set.
*/
removeOnFail?: boolean;
/**
* Limits the amount of stack trace lines that will be recorded in the stacktrace.
*/
stackTraceLimit?: number;
}
interface JobCounts {
@@ -618,6 +652,11 @@ declare namespace Bull {
*/
on(event: 'error', callback: ErrorEventCallback): this;
/**
* A Job is waiting to be processed as soon as a worker is idling.
*/
on(event: 'waiting', callback: WaitingEventCallback): this;
/**
* A job has started. You can use `jobPromise.cancel()` to abort it
*/
@@ -654,6 +693,11 @@ declare namespace Bull {
*/
on(event: 'resumed', callback: EventCallback): this; // tslint:disable-line unified-signatures
/**
* A job successfully removed.
*/
on(event: 'removed', callback: RemovedEventCallback<T>): this;
/**
* Old jobs have been cleaned from the queue.
* `jobs` is an array of jobs that were removed, and `type` is the type of those jobs.
@@ -661,6 +705,12 @@ declare namespace Bull {
* @see Queue#clean() for details
*/
on(event: 'cleaned', callback: CleanedEventCallback<T>): this;
/**
* Emitted every time the queue has processed all the waiting jobs
* (even if there can be some delayed jobs not yet processed)
*/
on(event: 'drained', callback: EventCallback): this; // tslint:disable-line unified-signatures
}
type EventCallback = () => void;
@@ -685,6 +735,10 @@ declare namespace Bull {
type FailedEventCallback<T = any> = (job: Job<T>, error: Error) => void;
type CleanedEventCallback<T = any> = (jobs: Array<Job<T>>, status: JobStatus) => void;
type RemovedEventCallback<T = any> = (job: Job<T>) => void;
type WaitingEventCallback = (jobId: JobId) => void;
}
export = Bull;
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/gluwer/bunyan-winston-adapter
// Definitions by: Steve Hipwell <https://github.com/stevehipwell>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.2
import * as bunyan from "bunyan";
import { Logger } from "winston";
+6 -1
View File
@@ -1,6 +1,6 @@
import * as CatbotRedis from 'catbox-redis';
const cache = new CatbotRedis({
const cache = new CatbotRedis<string>({
host: 'localhost',
partition: 'test',
port: 2018,
@@ -10,3 +10,8 @@ cache.get({
segment: 'test',
id: 'test',
});
cache.set({
segment: 'test',
id: 'test',
}, 'test', 123);
+1 -1
View File
@@ -53,7 +53,7 @@ declare module 'catbox-redis' {
sentinelName?: string;
}
}
class CatboxRedis extends Client {
class CatboxRedis<T> extends Client<T> {
constructor(options: CatboxRedis.CatboxRedisOptions);
}
export = CatboxRedis;
+17 -3
View File
@@ -1,16 +1,22 @@
import { CacheItem, Client, Policy, EnginePrototypeOrObject } from "catbox";
import { Client, Policy, EnginePrototypeOrObject, DecoratedResult, CachedObject } from "catbox";
const Memory: EnginePrototypeOrObject = {
async start(): Promise<void> {},
stop(): void {},
async get(): Promise<null | CacheItem> {},
async get(): Promise<null | CachedObject<string>> {
return {
item: 'asd',
stored: 12,
ttl: 123,
};
},
async set(): Promise<void> {},
async drop(): Promise<void> {},
isReady(): boolean { return true; },
validateSegmentName(segment: string): null { return null; },
};
const client = new Client(Memory, { partition: 'cache' });
const client = new Client<string>(Memory, { partition: 'cache' });
const cache = new Policy({
expiresIn: 5000,
@@ -25,3 +31,11 @@ cache.drop('foo').then(() => {});
cache.isReady();
cache.stats();
const decoratedCache = new Policy({
getDecoratedValue: true,
}, client, 'cache2');
decoratedCache.get('test').then((a: DecoratedResult<string>) => {
const res: string = a.value;
});
+63 -78
View File
@@ -4,7 +4,7 @@
// AJP <https://github.com/AJamesPhillips>
// Rodrigo Saboya <https://github.com/saboya>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
// TypeScript Version: 2.8
/**
* Client
@@ -17,7 +17,7 @@
* the Riak bucket, or as a key prefix in Redis and Memcached. To share the cache across multiple clients, use the same partition name.
* @see {@link https://github.com/hapijs/catbox#client}
*/
export class Client implements ClientApi {
export class Client<T> implements ClientApi<T> {
constructor(engine: EnginePrototypeOrObject, options: ClientOptions);
/** start() - creates a connection to the cache server. Must be called before any other method is available. */
@@ -28,14 +28,14 @@ export class Client implements ClientApi {
* get(key, callback) - retrieve an item from the cache engine if found where:
* * key - a cache key object (see [ICacheKey]).
*/
get(key: CacheKey): Promise<null | CachedObject>;
get(key: CacheKey): Promise<null | CachedObject<T>>;
/**
* set(key, value, ttl, callback) - store an item in the cache for a specified length of time, where:
* * key - a cache key object (see [ICacheKey]).
* * value - the string or object value to be stored.
* * ttl - a time-to-live value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
*/
set(key: CacheKey, value: CacheItem, ttl: number): Promise<void>;
set(key: CacheKey, value: T, ttl: number): Promise<void>;
/**
* drop(key, callback) - remove an item from cache where:
* * key - a cache key object (see [ICacheKey]).
@@ -47,13 +47,13 @@ export class Client implements ClientApi {
validateSegmentName(segment: string): null | Error;
}
export type EnginePrototypeOrObject = EnginePrototype | ClientApi;
export type EnginePrototypeOrObject = EnginePrototype<any> | ClientApi<any>;
/**
* A prototype CatBox engine function
*/
export interface EnginePrototype {
new(settings: ClientOptions): ClientApi;
export interface EnginePrototype<T> {
new(settings: ClientOptions): ClientApi<T>;
}
/**
@@ -61,7 +61,7 @@ export interface EnginePrototype {
* The Client object provides the following methods:
* @see {@link https://github.com/hapijs/catbox#api}
*/
export interface ClientApi {
export interface ClientApi<T> {
/** start() - creates a connection to the cache server. Must be called before any other method is available. */
start(): Promise<void>;
/** stop() - terminates the connection to the cache server. */
@@ -70,14 +70,14 @@ export interface ClientApi {
* get(key, callback) - retrieve an item from the cache engine if found where:
* * key - a cache key object (see [ICacheKey]).
*/
get(key: CacheKey): Promise<null | CachedObject>;
get(key: CacheKey): Promise<null | CachedObject<T>>;
/**
* set(key, value, ttl) - store an item in the cache for a specified length of time, where:
* * key - a cache key object (see [ICacheKey]).
* * value - the string or object value to be stored.
* * ttl - a time-to-live value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
*/
set(key: CacheKey, value: CacheItem, ttl: number): Promise<void>;
set(key: CacheKey, value: T, ttl: number): Promise<void>;
/**
* drop(key) - remove an item from cache where:
* * key - a cache key object (see [ICacheKey]).
@@ -100,17 +100,15 @@ export interface CacheKey {
}
/** Cached object contains the following: */
export interface CachedObject {
export interface CachedObject<T> {
/** item - the value stored in the cache using set(). */
item: any;
item: T;
/** stored - the timestamp when the item was stored in the cache (in milliseconds). */
stored: number;
/** ttl - the remaining time-to-live (not the original value used when storing the object). */
ttl: number;
}
export type CacheItem = any;
export interface ClientOptions {
/**
* this will store items under keys that start with this value.
@@ -118,89 +116,69 @@ export interface ClientOptions {
partition: string;
}
export type PolicyOptionVariants<T> = PolicyOptions<T> | DecoratedPolicyOptions<T>;
/**
* The Policy object provides a convenient cache interface by setting a global policy which is automatically applied to every storage action.
* The Policy object provides a convenient cache interface by setting a
* global policy which is automatically applied to every storage action.
* The object is constructed using new Policy(options, [cache, segment]) where:
* * options - an object with the IPolicyOptions structure
* * cache - a Client instance (which has already been started).
* * segment - required when cache is provided. The segment name used to isolate cached items within the cache partition.
* * segment - required when cache is provided. The segment name used to
* isolate cached items within the cache partition.
* @see {@link https://github.com/hapijs/catbox#policy}
*/
export class Policy implements PolicyAPI {
constructor(options: PolicyOptions, cache: Client, segment: string);
export class Policy<T, O extends PolicyOptionVariants<T>> {
constructor(options: O, cache: Client<T>, segment: string);
/**
* get(id) - retrieve an item from the cache. If the item is not found and the generateFunc method was provided,
* a new value is generated, stored in the cache, and returned. Multiple concurrent requests are queued and processed once. The method arguments are:
* * id - the unique item identifier (within the policy segment). Can be a string or an object with the required 'id' key.
* retrieve an item from the cache. If the item is not
* found and the generateFunc method was provided,
* a new value is generated, stored in the cache, and returned.
* Multiple concurrent requests are queued and processed once. The method arguments are:
* @param id the unique item identifier (within the policy segment).
* Can be a string or an object with the required 'id' key.
*/
get(id: string | { id: string }): Promise<PolicyGetPromiseResult | null>;
get(id: string | { id: string }): Promise<O extends DecoratedPolicyOptions<T> ? DecoratedResult<T> : T | null>;
/**
* set(id, value, ttl) - store an item in the cache where:
* * id - the unique item identifier (within the policy segment).
* * value - the string or object value to be stored.
* * ttl - a time-to-live override value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
* store an item in the cache where:
* @param id - the unique item identifier (within the policy segment).
* @param value - the string or object value to be stored.
* @param ttl - a time-to-live override value in milliseconds after which the item is automatically
* removed from the cache (or is marked invalid).
* This should be set to 0 in order to use the caching rules configured when creating the Policy object.
*/
set(id: string | { id: string }, value: CacheItem, ttl: number | null): Promise<void>;
set(id: string | { id: string }, value: T, ttl?: number): Promise<void>;
/**
* drop(id) - remove the item from cache where:
* * id - the unique item identifier (within the policy segment).
* remove the item from cache where:
* @param id the unique item identifier (within the policy segment).
*/
drop(id: string | { id: string }): Promise<void>;
/** ttl(created) - given a created timestamp in milliseconds, returns the time-to-live left based on the configured rules. */
/**
* given a created timestamp in milliseconds, returns the time-to-live left
* based on the configured rules.
*/
ttl(created: number): number;
/** rules(options) - changes the policy rules after construction (note that items already stored will not be affected) */
rules(options: PolicyOptions): void;
/** isReady() - returns true if cache engine determines itself as ready, false if it is not ready or if there is no cache engine set. */
/** changes the policy rules after construction (note that items already stored will not be affected) */
rules(options: PolicyOptions<T>): void;
/**
* returns true if cache engine determines itself as ready, false if it is not ready or if
* here is no cache engine set.
*/
isReady(): boolean;
/** stats - an object with cache statistics */
/** an object with cache statistics */
stats(): CacheStatisticsObject;
}
/**
* Policy API
* The Policy object provides the following methods:
* @see {@link https://github.com/hapijs/catbox#api-1}
*/
export interface PolicyAPI {
/**
* get(id) - retrieve an item from the cache. If the item is not found and the generateFunc method was provided,
* a new value is generated, stored in the cache, and returned. Multiple concurrent requests are queued and processed once. The method arguments are:
* * id - the unique item identifier (within the policy segment). Can be a string or an object with the required 'id' key.
*/
get(id: string | { id: string }): Promise<PolicyGetPromiseResult | null>;
/**
* set(id, value, ttl) - store an item in the cache where:
* * id - the unique item identifier (within the policy segment).
* * value - the string or object value to be stored.
* * ttl - a time-to-live override value in milliseconds after which the item is automatically removed from the cache (or is marked invalid).
* This should be set to 0 in order to use the caching rules configured when creating the Policy object.
*/
set(id: string | { id: string }, value: CacheItem, ttl: number | null): Promise<void>;
/**
* drop(id) - remove the item from cache where:
* * id - the unique item identifier (within the policy segment).
*/
drop(id: string | { id: string }): Promise<void>;
/** ttl(created) - given a created timestamp in milliseconds, returns the time-to-live left based on the configured rules. */
ttl(created: number): number;
/** rules(options) - changes the policy rules after construction (note that items already stored will not be affected) */
rules(options: PolicyOptions): void;
/** isReady() - returns true if cache engine determines itself as ready, false if it is not ready or if there is no cache engine set. */
isReady(): boolean;
/** stats - an object with cache statistics */
stats(): CacheStatisticsObject;
}
export interface PolicyGetPromiseResult {
value: CacheItem;
cached: PolicyGetCachedOptions;
export interface DecoratedResult<T> {
value: T;
cached: PolicyGetCachedOptions<T>;
report: PolicyGetReportLog;
}
export interface PolicyGetCachedOptions {
export interface PolicyGetCachedOptions<T> {
/** item - the cached value. */
item: CacheItem;
item: T;
/** stored - the timestamp when the item was stored in the cache. */
stored: number;
/** ttl - the cache ttl value for the record. */
@@ -212,13 +190,13 @@ export interface PolicyGetCachedOptions {
/**
* @see {@link https://github.com/hapijs/catbox#policy}
*/
export interface PolicyOptions {
export interface PolicyOptions<T> {
/** expiresIn - relative expiration expressed in the number of milliseconds since the item was saved in the cache. Cannot be used together with expiresAt. */
expiresIn?: number;
/** expiresAt - time of day expressed in 24h notation using the 'HH:MM' format, at which point all cache records for the route expire. Uses local time. Cannot be used together with expiresIn. */
expiresAt?: string;
/** generateFunc - a function used to generate a new cache item if one is not found in the cache when calling get(). The method's signature is function(id, next) where: */
generateFunc?: GenerateFunc;
generateFunc?: GenerateFunc<T>;
/**
* staleIn - number of milliseconds to mark an item stored in cache as stale and attempt to regenerate it when generateFunc is provided.
* Must be less than expiresIn. Alternatively function that returns staleIn value in milliseconds. The function signature is function(stored, ttl) where:
@@ -242,11 +220,18 @@ export interface PolicyOptions {
generateIgnoreWriteError?: boolean;
/**
* pendingGenerateTimeout - number of milliseconds while generateFunc call is in progress for a given id, before a subsequent generateFunc call is allowed.
* Defaults to 0, no blocking of concurrent generateFunc calls beyond staleTimeout.
* @default 0, no blocking of concurrent generateFunc calls beyond staleTimeout.
*/
pendingGenerateTimeout?: number;
}
export interface DecoratedPolicyOptions<T> extends PolicyOptions<T> {
/**
* @default false
*/
getDecoratedValue?: boolean;
}
export interface GenerateFuncFlags {
ttl: number;
}
@@ -262,7 +247,7 @@ export interface GenerateFuncFlags {
* * ttl - the cache ttl value in milliseconds. Set to 0 to skip storing in the cache. Defaults to the cache global policy.
* @see {@link https://github.com/hapijs/catbox#policy}
*/
export type GenerateFunc = (id: string, flags: GenerateFuncFlags) => Promise<CacheItem>;
export type GenerateFunc<T> = (id: string, flags: GenerateFuncFlags) => Promise<T>;
/**
* An object with logging information about the generation operation containing the following keys (as relevant):
+1 -1
View File
@@ -1,6 +1,6 @@
// Type definitions for chai-fs 2.0
// Project: https://github.com/chaijs/chai-fs
// Definitions by: Dimitar Danailov <https://github.com/Nemo157>
// Definitions by: Dimitar Danailov <https://github.com/dimitardanailov>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
+6 -2
View File
@@ -10,7 +10,6 @@
// Guillaume Rodriguez <https://github.com/guillaume-ro-fr>
// Simon Archer <https://github.com/archy-bold>
// Ken Elkabany <https://github.com/braincore>
// Slavik Nychkalo <https://github.com/gebeto>
// Francesco Benedetto <https://github.com/frabnt>
// Alexandros Dorodoulis <https://github.com/alexdor>
// Manuel Heidrich <https://github.com/mahnuh>
@@ -481,7 +480,12 @@ declare namespace Chart {
fontStyle?: string;
}
interface TickOptions {
interface TickOptions extends NestedTickOptions {
minor?: NestedTickOptions | false;
major?: NestedTickOptions | false;
}
interface NestedTickOptions {
autoSkip?: boolean;
autoSkipPadding?: number;
backdropColor?: ChartColor;
+1
View File
@@ -197,6 +197,7 @@ new Chartist.Bar('.ct-chart', {
}, {
// Default mobile configuration
stackBars: true,
stackMode: 'accumulate',
axisX: {
labelInterpolationFnc: (value: string) => {
return value.split(/\s+/).map((word: string) => {
+1
View File
@@ -283,6 +283,7 @@ declare namespace Chartist {
* If set to true this property will cause the series bars to be stacked and form a total for each series point. This will also influence the y-axis and the overall bounds of the chart. In stacked mode the seriesBarDistance property will have no effect.
*/
stackBars?: boolean;
stackMode?: 'overlap' | 'accumulate';
horizontalBars?: boolean;
distributeSeries?: boolean;
+4 -4
View File
@@ -1,5 +1,5 @@
export interface Map {
[key: string]: any
[key: string]: any;
}
export interface CursorParams {
page?: number;
@@ -15,9 +15,9 @@ export interface Cursor {
total_pages?: number;
}
export interface Entries<T> extends Cursor {
entries: T[]
entries: T[];
}
interface Summary {
export interface Summary {
current: number;
previous: number;
['percentage-change']: number;
@@ -25,4 +25,4 @@ interface Summary {
export interface EntriesSummary<T> {
entries: T[];
summary: Summary;
}
}
+12 -10
View File
@@ -260,16 +260,7 @@ declare namespace CodeMirror {
line should be either an integer or a line handle, and node should be a DOM node, which will be displayed below the given line.
options, when given, should be an object that configures the behavior of the widget.
Note that the widget node will become a descendant of nodes with CodeMirror-specific CSS classes, and those classes might in some cases affect it. */
addLineWidget(line: any, node: HTMLElement, options?: {
/** Whether the widget should cover the gutter. */
coverGutter?: boolean;
/** Whether the widget should stay fixed in the face of horizontal scrolling. */
noHScroll?: boolean;
/** Causes the widget to be placed above instead of below the text of the line. */
above?: boolean;
/** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */
showIfHidden?: boolean;
}): CodeMirror.LineWidget;
addLineWidget(line: any, node: HTMLElement, options?: CodeMirror.LineWidgetOptions): CodeMirror.LineWidget;
/** Programatically set the size of the editor (overriding the applicable CSS rules).
@@ -728,6 +719,17 @@ declare namespace CodeMirror {
changed(): void;
}
interface LineWidgetOptions {
/** Whether the widget should cover the gutter. */
coverGutter?: boolean;
/** Whether the widget should stay fixed in the face of horizontal scrolling. */
noHScroll?: boolean;
/** Causes the widget to be placed above instead of below the text of the line. */
above?: boolean;
/** When true, will cause the widget to be rendered even if the line it is associated with is hidden. */
showIfHidden?: boolean;
}
interface EditorChange {
/** Position (in the pre-change coordinate system) where the change started. */
from: CodeMirror.Position;
+15
View File
@@ -0,0 +1,15 @@
import * as consola from 'consola';
consola.start('TEST');
consola.info('TEST');
consola.success('TEST');
consola.error('TEST');
const logger = new consola.Consola({
level: 30,
});
logger.start('TEST');
logger.info('TEST');
logger.success('TEST');
logger.error('TEST');
+39
View File
@@ -0,0 +1,39 @@
// Type definitions for consola 1.x
// Project: https://github.com/nuxt/consola
// Definitions by: Jungwoo An <https://github.com/Jungwoo-An>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
export interface LevelType {
level: number;
color: string;
isError?: boolean;
}
export interface Reporter {
log(logObj: any): void;
}
export interface Option {
level?: number;
types?: LevelType;
reporters?: Reporter[];
}
export class Consola {
constructor(option?: Option);
add(reporter: Reporter): Consola;
remove(reporter: Reporter): Consola;
clear(): Consola;
withScope(scope: string): void;
start(...arguments: string[]): void;
success(...arguments: string[]): void;
info(...arguments: string[]): void;
error(...arguments: Array<string | Error>): void;
}
export function start(...arguments: string[]): void;
export function success(...arguments: string[]): void;
export function info(...arguments: string[]): void;
export function error(...arguments: Array<string | Error>): void;
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noEmit": true,
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "consola-tests.ts"]
}
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "dtslint/dt.json"
}
@@ -0,0 +1,10 @@
import Critters from 'critters-webpack-plugin';
new Critters({
compress: true,
external: true,
inlineFonts: false,
preloadFonts: true,
keyframes: 'critical',
noscriptFallback: true,
});
+65
View File
@@ -0,0 +1,65 @@
// Type definitions for critters-webpack-plugin 1.3
// Project: https://github.com/GoogleChromeLabs/critters
// Definitions by: Juan José González Giraldo <https://github.com/JuanJoseGonGi>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { Plugin } from 'webpack';
export default Critters;
declare class Critters extends Plugin {
constructor(options?: Critters.CrittersOptions);
}
declare namespace Critters {
interface CrittersOptions {
/**
* Inline styles from external stylesheets.
* @default true
*/
external?: boolean;
/**
* The mechanism to use for lazy-loading stylesheets. [JS] indicates that a strategy requires JavaScript (falls back to <noscript>).
* - default: Move stylesheet links to the end of the document and insert preload meta tags in their place.
* - "body": Move all external stylesheet links to the end of the document.
* - "media": Load stylesheets asynchronously by adding media="not x" and removing once loaded. [JS]
* - "swap": Convert stylesheet links to preloads that swap to rel="stylesheet" once loaded. [JS]
* - "js": Inject an asynchronous CSS loader similar to LoadCSS and use it to load stylesheets. [JS]
* - "js-lazy": Like "js", but the stylesheet is disabled until fully loaded.
*/
preload?: 'body' | 'media' | 'swap' | 'js' | 'js-lazy';
/**
* Add <noscript> fallback to JS-based strategies
*/
noscriptFallback?: boolean;
/**
* Inline critical font-face rules.
* @default false
*/
inlineFonts?: boolean;
/**
* Preloads critical fonts.
* @default true
*/
preloadFonts?: boolean;
/**
* Shorthand for setting inlineFonts+preloadFonts - Values:
* - true to inline critical font-face rules and preload the fonts.
* - false to don"t inline any font-face rules and don"t preload fonts.
*/
fonts?: boolean;
/**
* Controls which keyframes rules are inlined. - Values:
* - "critical": Inline keyframes rules used by the critical CSS.
* - "all" Inline all keyframes rules.
* - "none" Remove all keyframes rules
* @default "critical"
*/
keyframes?: 'critical' | 'all' | 'none';
/**
* Compress resulting critical CSS.
* @default true
*/
compress?: boolean;
}
}
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "critters-webpack-plugin-tests.ts"]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
+8 -1
View File
@@ -1,6 +1,9 @@
// Type definitions for D3JS d3 standard bundle 5.0
// Project: https://github.com/d3/d3
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
// Alex Ford <https://github.com/gustavderdrache>
// Boris Yankov <https://github.com/borisyankov>
// denisname <https://github.com/denisname>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -11,7 +14,11 @@
export as namespace d3;
/**
* Version number in format _Major.Minor.BugFix_, like 5.0.0.
*/
export const version: string;
export * from 'd3-array';
export * from 'd3-axis';
export * from 'd3-brush';
+1 -1
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
+8 -1
View File
@@ -1,6 +1,9 @@
// Type definitions for D3JS d3 standard bundle 4.13
// Project: https://github.com/d3/d3
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>, Alex Ford <https://github.com/gustavderdrache>, Boris Yankov <https://github.com/borisyankov>
// Definitions by: Tom Wanzek <https://github.com/tomwanzek>
// Alex Ford <https://github.com/gustavderdrache>
// Boris Yankov <https://github.com/borisyankov>
// denisname <https://github.com/denisname>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
@@ -8,7 +11,11 @@
export as namespace d3;
/**
* Version number in format _Major.Minor.BugFix_, like 4.13.0.
*/
export const version: string;
export * from 'd3-array';
export * from 'd3-axis';
export * from 'd3-brush';
+1 -1
View File
@@ -7,7 +7,7 @@
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": false,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
+2
View File
@@ -2,6 +2,8 @@
// Project: https://github.com/rochdev/datadog-tracer-js#readme
// Definitions by: Dinesh Saravanan Kumaraswamy <https://github.com/dineshsaravanan>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
import * as opentracing from "opentracing";
import { EventEmitter } from "events";
+1 -1
View File
@@ -22,7 +22,7 @@ interface SpanContextLike {
trace?: {
started: number[],
finished: number[]
}
};
}
export = DatadogSpanContext;
+13
View File
@@ -0,0 +1,13 @@
import devIp = require("dev-ip");
const ips = devIp();
function main() {
if (typeof ips === "boolean") {
return;
}
ips.map(ip => `ip: ${ip}`);
}
main();
+11
View File
@@ -0,0 +1,11 @@
// Type definitions for dev-ip 1.0
// Project: https://github.com/shakyshane/dev-ip
// Definitions by: Mike Engel <https://github.com/mike-engel>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* Returns either an array of IP addresses or false if none can be found (offline, etc)
*/
declare function devIp(): string[] | boolean;
export = devIp;
+16
View File
@@ -0,0 +1,16 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": ["../"],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": ["index.d.ts", "dev-ip-tests.ts"]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }
-1
View File
@@ -2,7 +2,6 @@
// Project: https://github.com/rolodato/dotenv-safe
// Definitions by: Stan Goldmann <https://github.com/krenor>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import env = require("dotenv")
+1 -1
View File
@@ -2,7 +2,7 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es5"
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/eggjs/egg-mock
// Definitions by: Eward Song <https://github.com/sheperdwind>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
// TypeScript Version: 2.8
import { Application, Context } from 'egg';
+2 -1
View File
@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
+9 -1
View File
@@ -1 +1,9 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
// All are TODOs
"ban-types": false,
"interface-name": false,
"strict-export-declare-modifiers": false
}
}
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/blainesch/electron-notifications
// Definitions by: Daniel Pereira <https://github.com/djpereira>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.2
import * as Electron from 'electron';
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/hankbao/electron-notify
// Definitions by: Daniel Pereira <https://github.com/djpereira>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.2
/// <reference types="electron" />
+1
View File
@@ -2,6 +2,7 @@
// Project: https://github.com/paulcbetts/electron-spellchecker
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="electron"/>
+2 -1
View File
@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
+1 -1
View File
@@ -2,7 +2,7 @@
// Project: https://github.com/mawie81/electron-window-state
// Definitions by: rhysd <https://github.com/rhysd>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.1
// TypeScript Version: 2.2
/// <reference types="electron" />
@@ -1,5 +1,6 @@
import Features from 'ember-feature-flags';
import 'ember-feature-flags/tests/helpers/with-feature';
import 'ember-feature-flags/test-support';
/** Static assertion that `value` has type `T` */
// Disable tslint here b/c the generic is used to let us do a type coercion and
@@ -24,4 +25,5 @@ const setup = {
};
features.setup(setup); // $ExpectType void
withFeature('new-homepage'); // $ExpectType void
enableFeature('new-homepage'); // $ExpectType void
assertType<boolean>(features.get('someFeature'));
+1
View File
@@ -0,0 +1 @@
declare function enableFeature(name: string): void;
+1
View File
@@ -47,6 +47,7 @@
"files": [
"index.d.ts",
"tests/helpers/with-feature.d.ts",
"test-support/index.d.ts",
"ember-feature-flags-tests.ts"
]
}
+2 -1
View File
@@ -2,7 +2,8 @@
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
+8 -8
View File
@@ -1,4 +1,4 @@
// Type definitions for expo 27.0
// Type definitions for expo 30.0
// Project: https://github.com/expo/expo-sdk
// Definitions by: Konstantin Kai <https://github.com/KonstantinKai>
// Martynas Kadiša <https://github.com/martynaskadisa>
@@ -1403,8 +1403,8 @@ export namespace FileSystem {
}
/** Use TouchID/FaceID (iOS) or the Fingerprint API (Android) to authenticate the user with a fingerprint scan. */
export namespace Fingerprint {
type FingerprintAuthenticationResult = {
export namespace LocalAuthentication {
type LocalAuthenticationResult = {
success: true
} | {
success: false,
@@ -1413,10 +1413,10 @@ export namespace Fingerprint {
error: string
};
/** Determine whether the Fingerprint scanner is available on the device. */
/** Determine whether a face or fingerprint scanner is available on the device. */
function hasHardwareAsync(): Promise<boolean>;
/** Determine whether the device has saved fingerprints to use for authentication. */
/** Determine whether the device has saved fingerprints or facial data to use for authentication. */
function isEnrolledAsync(): Promise<boolean>;
/**
@@ -1424,7 +1424,7 @@ export namespace Fingerprint {
*
* @param promptMessage A message that is shown alongside the TouchID/FaceID prompt. (iOS only)
*/
function authenticateAsync(promptMessageIOS?: string): Promise<FingerprintAuthenticationResult>;
function authenticateAsync(promptMessageIOS?: string): Promise<LocalAuthenticationResult>;
/** Cancels the fingerprint authentication flow. (Android only) */
function cancelAuthenticate(): void;
@@ -2422,10 +2422,10 @@ export namespace Calendar {
recurrenceRule?: RecurrenceRule;
/** Date object or string representing the time when the event starts */
startDate?: string;
startDate?: string | Date;
/** Date object or string representing the time when the event ends */
endDate?: string;
endDate?: string | Date;
/** For recurring events, the start date for the first (original) instance of the event */
originalStartDate?: string; // iOS
+949
View File
@@ -0,0 +1,949 @@
import * as React from 'react';
import { Text } from 'react-native';
import {
Accelerometer,
AdMobAppEvent,
AdMobBanner,
AdMobInterstitial,
AdMobRewarded,
Amplitude,
Asset,
AuthSession,
Audio,
AppLoading,
BarCodeScanner,
BlurViewProps,
BlurView,
Brightness,
Camera,
CameraObject,
DocumentPicker,
Facebook,
FacebookAds,
FileSystem,
ImagePicker,
ImageManipulator,
FaceDetector,
Linking,
Svg,
IntentLauncherAndroid,
KeepAwake,
LinearGradient,
Permissions,
PublisherBanner,
registerRootComponent,
ScreenOrientation,
SQLite,
Calendar,
MailComposer,
Location,
Updates,
MediaLibrary,
Haptic,
Constants
} from 'expo';
const reverseGeocode: Promise<Location.GeocodeData[]> = Location.reverseGeocodeAsync({
latitude: 0,
longitude: 0
});
Accelerometer.addListener((obj) => {
obj.x;
obj.y;
obj.z;
});
Accelerometer.removeAllListeners();
Accelerometer.setUpdateInterval(1000);
() => (
<AdMobBanner
bannerSize="leaderboard"
adUnitID="ca-app-pub-3940256099942544/6300978111"
testDeviceID="EMULATOR"
didFailToReceiveAdWithError={(error: string) => console.log(error)}
style={{ flex: 1 }}
/>
);
() => (
<PublisherBanner
bannerSize="leaderboard"
adUnitID="ca-app-pub-3940256099942544/6300978111"
testDeviceID="EMULATOR"
didFailToReceiveAdWithError={(error: string) => console.log(error)}
onAdMobDispatchAppEvent={(event: AdMobAppEvent) => console.log(event)}
style={{ flex: 1 }}
/>
);
AdMobInterstitial.setAdUnitID('ca-app-pub-3940256099942544/1033173712'); // Test ID, Replace with your-admob-unit-id
AdMobInterstitial.setTestDeviceID('EMULATOR');
async () => {
await AdMobInterstitial.requestAdAsync();
await AdMobInterstitial.showAdAsync();
};
AdMobRewarded.setAdUnitID('ca-app-pub-3940256099942544/1033173712'); // Test ID, Replace with your-admob-unit-id
AdMobRewarded.setTestDeviceID('EMULATOR');
async () => {
await AdMobRewarded.requestAdAsync();
await AdMobRewarded.showAdAsync();
};
Amplitude.initialize('key');
Amplitude.setUserId('userId');
Amplitude.setUserProperties({key: 1});
Amplitude.clearUserProperties();
Amplitude.logEvent('name');
Amplitude.logEventWithProperties('event', {key: 'value'});
Amplitude.setGroup('type', ['value']);
const asset = Asset.fromModule(1);
asset.downloadAsync();
Asset.loadAsync(1);
Asset.loadAsync([1, 2, 3]);
const asset1 = new Asset({
uri: 'uri',
type: 'type',
name: 'name',
hash: 'hash',
width: 122,
height: 122
});
const url = AuthSession.getRedirectUrl();
AuthSession.dismiss();
AuthSession.startAsync({
authUrl: 'url1',
returnUrl: 'url2'
}).then(result => {
switch (result.type) {
case 'success':
result.event;
result.params;
break;
case 'error':
result.errorCode;
result.params;
result.event;
break;
case 'dismissed':
case 'cancel':
result.type;
break;
}
});
AuthSession.startAsync({
authUrl: 'url1',
returnUrl: undefined
});
Audio.setAudioModeAsync({
shouldDuckAndroid: false,
playsInSilentModeIOS: true,
interruptionModeIOS: 2,
interruptionModeAndroid: 1,
allowsRecordingIOS: true
});
Audio.setIsEnabledAsync(true);
Audio.INTERRUPTION_MODE_IOS_MIX_WITH_OTHERS === 0;
Audio.INTERRUPTION_MODE_IOS_DO_NOT_MIX === 1;
Audio.INTERRUPTION_MODE_IOS_DUCK_OTHERS === 2;
Audio.INTERRUPTION_MODE_ANDROID_DO_NOT_MIX === 1;
Audio.INTERRUPTION_MODE_ANDROID_DUCK_OTHERS === 2;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_DEFAULT === 0;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_THREE_GPP === 1;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG_4 === 2;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_NB === 3;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AMR_WB === 4;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADIF === 5;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_AAC_ADTS === 6;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_RTP_AVP === 7;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_MPEG2TS === 8;
Audio.RECORDING_OPTION_ANDROID_OUTPUT_FORMAT_WEBM === 9;
Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_DEFAULT === 0;
Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_NB === 1;
Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AMR_WB === 2;
Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC === 3;
Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_HE_AAC === 4;
Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_AAC_ELD === 5;
Audio.RECORDING_OPTION_ANDROID_AUDIO_ENCODER_VORBIS === 6;
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_LINEARPCM === 'lpcm';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AC3 === 'ac-3';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_60958AC3 === 'cac3';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLEIMA4 === 'ima4';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC === 'aac ';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4CELP === 'celp';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4HVXC === 'hvxc';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4TWINVQ === 'twvq';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE3 === 'MAC3';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MACE6 === 'MAC6';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_ULAW === 'ulaw';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_ALAW === 'alaw';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN === 'QDMC';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_QDESIGN2 === 'QDM2';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_QUALCOMM === 'Qclp';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER1 === '.mp1';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER2 === '.mp2';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEGLAYER3 === '.mp3';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_APPLELOSSLESS === 'alac';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE === 'aach';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_LD === 'aacl';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD === 'aace';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_SBR === 'aacf';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_ELD_V2 === 'aacg';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_HE_V2 === 'aacp';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MPEG4AAC_SPATIAL === 'aacs';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR === 'samr';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AMR_WB === 'sawb';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AUDIBLE === 'AUDB';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_ILBC === 'ilbc';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_DVIINTELIMA === 0x6d730011;
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_MICROSOFTGSM === 0x6d730031;
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_AES3 === 'aes3';
Audio.RECORDING_OPTION_IOS_OUTPUT_FORMAT_ENHANCEDAC3 === 'ec-3';
Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MIN === 0;
Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_LOW === 0x20;
Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MEDIUM === 0x40;
Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_HIGH === 0x60;
Audio.RECORDING_OPTION_IOS_AUDIO_QUALITY_MAX === 0x7f;
Audio.RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_CONSTANT === 0;
Audio.RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_LONG_TERM_AVERAGE === 1;
Audio.RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE_CONSTRAINED === 2;
Audio.RECORDING_OPTION_IOS_BIT_RATE_STRATEGY_VARIABLE === 3;
Audio.RECORDING_OPTIONS_PRESET_HIGH_QUALITY;
Audio.RECORDING_OPTIONS_PRESET_LOW_QUALITY;
async () => {
const result = await Audio.Sound.create({uri: 'uri'}, {
volume: 0.55,
rate: 16.5
}, null, true);
const sound = result.sound;
const status = result.status;
if (!status.isLoaded) {
status.error;
} else {
status.didJustFinish;
// etc.
}
const _status = await sound.getStatusAsync();
await sound.loadAsync({uri: 'uri'});
};
() => (
<AppLoading
startAsync={() => Promise.resolve()}
onFinish={() => {}}
onError={(error) => console.log(error)} />
);
() => (
<AppLoading />
);
const barcodeReadCallback = () => {};
() => (
<BarCodeScanner
type="front"
torchMode="off"
barCodeTypes={[BarCodeScanner.Constants.BarCodeType.aztec]}
onBarCodeRead={barcodeReadCallback} />
);
() => (
<BlurView
tint="dark"
intensity={2} />
);
async () => {
await Brightness.setBrightnessAsync(0.65);
await Brightness.setSystemBrightnessAsync(0.75);
const br1 = await Brightness.getBrightnessAsync();
const br2 = await Brightness.getSystemBrightnessAsync();
};
Camera.Constants.AutoFocus;
Camera.Constants.Type;
Camera.Constants.FlashMode;
Camera.Constants.WhiteBalance;
Camera.Constants.VideoQuality;
Camera.Constants.BarCodeType;
() => {
return(<Camera ref={(component: any) => {
if (component) {
component.recordAsync();
}
}} />);
};
async (camera: CameraObject) => {
const picture = await camera.takePictureAsync({
quality: 0.5,
base64: true,
exif: true
});
picture.uri;
picture.width;
picture.height;
picture.exif;
picture.base64;
camera.takePictureAsync({
quality: 1,
onPictureSaved: pic => {
pic.uri;
pic.width;
pic.height;
pic.exif;
pic.base64;
}
});
};
async () => {
const result = await DocumentPicker.getDocumentAsync();
if (result.type === 'success') {
result.name;
result.uri;
result.size;
}
};
async () => {
const { type, expires, token } = await Facebook.logInWithReadPermissionsAsync("appId");
};
() => (
<FacebookAds.BannerView
type="large"
placementId="str"
onPress={() => {}}
onError={() => {}} />
);
async () => {
const info = await FileSystem.getInfoAsync('file');
info.exists;
info.isDirectory;
if (info.exists) {
info.md5;
info.uri;
info.size;
info.modificationTime;
}
const string: string = await FileSystem.readAsStringAsync('file');
await FileSystem.writeAsStringAsync('file', 'content');
await FileSystem.deleteAsync('file');
await FileSystem.moveAsync({ from: 'from', to: 'to'});
await FileSystem.copyAsync({ from: 'from', to: 'to' });
await FileSystem.makeDirectoryAsync('dir');
const dirs: string[] = await FileSystem.readDirectoryAsync('dir');
const result = await FileSystem.downloadAsync('from', 'to');
result.headers;
result.status;
result.uri;
result.md5;
};
async () => {
// Video test
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Videos,
});
if (!result.cancelled) {
result.uri;
result.width;
result.height;
result.duration;
result.type;
}
};
async () => {
// Image test
const result = await ImagePicker.launchImageLibraryAsync({
mediaTypes: ImagePicker.MediaTypeOptions.Images,
base64: true,
aspect: [4, 3],
quality: 1,
exif: true,
});
if (!result.cancelled) {
result.uri;
result.width;
result.height;
result.exif;
result.base64;
result.type;
}
};
async () => {
const result = await ImageManipulator.manipulate('url', [
{ rotate: 90 },
{ resize: { width: 300 } },
{ resize: { height: 300 } },
{ resize: { height: 300, width: 300 } },
], {
compress: 0.75
});
result.height;
result.uri;
result.width;
};
FaceDetector.Constants.Mode.fast;
FaceDetector.Constants.Mode.accurate;
FaceDetector.Constants.Landmarks.all;
FaceDetector.Constants.Landmarks.none;
FaceDetector.Constants.Classifications.all;
FaceDetector.Constants.Classifications.none;
async () => {
const result = await FaceDetector.detectFaces('url', {
mode: FaceDetector.Constants.Mode.fast,
detectLandmarks: FaceDetector.Constants.Landmarks.all,
runClassifications: FaceDetector.Constants.Classifications.none
});
result.faces[0];
};
async () => {
function isBoolean(x: boolean) {
}
function isString(x: string) {
}
// Two examples of members inherited from react-native Linking
// to prove that inheritence is working.
Linking.addEventListener('url', (e) => {
e.url === '';
});
isBoolean(await Linking.canOpenURL('expo://'));
// Extensions added by expo.
isString(Linking.makeUrl('path'));
isString(Linking.makeUrl('path', { q: 2, u: 'ery', }));
const {
path,
queryParams,
} = Linking.parse('');
isString(path);
isString(queryParams['x'] || '');
const {
path: path2,
queryParams: queryParams2,
} = await Linking.parseInitialURLAsync();
isString(path2);
isString(queryParams2['y'] || '');
};
() => (
<Svg width={100} height={50}>
<Svg.Rect
x={25}
y={5}
width={150}
height={50}
fill='rgb(0,0,255)'
strokeWidth={3}
stroke='rgb(0,0,0)'
transform="translate(0, 0)"
/>
<Svg.Circle
cx={50}
cy={50}
r={50}
fill="pink"
transform="translate(0, 0)"
/>
<Svg.Ellipse
cx={55}
cy={55}
rx={50}
ry={30}
stroke="purple"
strokeWidth={2}
fill="yellow"
transform="translate(0, 0)"
/>
<Svg.Line
x1={0}
y1={0}
x2={100}
y2={100}
stroke="red"
strokeWidth={2}
transform="translate(0, 0)"
/>
<Svg.Polygon
points="40,5 70,80 25,95"
fill="lime"
stroke="purple"
strokeWidth={1}
transform="translate(0, 0)"
/>
<Svg.Polyline
points="10,10 20,12 30,20 40,60 60,70 95,90"
fill="none"
stroke="black"
strokeWidth={3}
transform="translate(0, 0)"
/>
<Svg.Text
fill="none"
stroke="purple"
fontSize={20}
fontWeight="bold"
x={100}
y={20}
textAnchor="middle"
transform="translate(0, 0)"
>
STROKED TEXT
</Svg.Text>
<Svg.Defs>
<Svg.Path
id="path"
d=""
/>
</Svg.Defs>
<Svg.G transform="translate(0, 0)" y={20}>
<Svg.Text fill="blue" transform={{ translateX: 0, translateY: 0 }}>
<Svg.TextPath href="#path" startOffset="-10%">
We go up and down,
<Svg.TSpan fill="red" dy="5,5,5">then up again</Svg.TSpan>
</Svg.TextPath>
</Svg.Text>
<Svg.Path
d=""
fill="none"
stroke="red"
strokeWidth={1}
/>
</Svg.G>
<Svg.Use href="#shape" transform="translate(0, 0)" x="20" y="0" />
<Svg.Use href="#shape" transform={{ translateX: 0, translateY: 0 }} x="20" y="0" width="20" height="20"/>
<Svg.Symbol id="symbol" viewBox="0 0 150 110" width="100" height="50">
<Svg.Circle cx="50" cy="50" r="40" strokeWidth="8" stroke="red" fill="red"/>
<Svg.Circle cx="90" cy="60" r="40" strokeWidth="8" stroke="green" fill="white"/>
</Svg.Symbol>
<Svg.Defs>
<Svg.ClipPath id="clip">
<Svg.Circle cx="50%" cy="50%" r="40%"/>
</Svg.ClipPath>
<Svg.RadialGradient id="grad" cx="50%" cy="50%" rx="50%" ry="50%" fx="50%" fy="50%" gradientUnits="userSpaceOnUse">
<Svg.Stop
offset="0%"
stopColor="#ff0"
stopOpacity="1"
/>
</Svg.RadialGradient>
<Svg.LinearGradient id="grad" x1="0" y1="0" x2="170" y2="0">
<Svg.Stop offset="1" stopColor="red" stopOpacity="1" />
</Svg.LinearGradient>
</Svg.Defs>
</Svg>
);
IntentLauncherAndroid.ACTION_ACCESSIBILITY_SETTINGS === 'android.settings.ACCESSIBILITY_SETTINGS';
IntentLauncherAndroid.ACTION_APP_NOTIFICATION_REDACTION === 'android.settings.ACTION_APP_NOTIFICATION_REDACTION';
IntentLauncherAndroid.ACTION_CONDITION_PROVIDER_SETTINGS === 'android.settings.ACTION_CONDITION_PROVIDER_SETTINGS';
IntentLauncherAndroid.ACTION_NOTIFICATION_LISTENER_SETTINGS === 'android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS';
IntentLauncherAndroid.ACTION_PRINT_SETTINGS === 'android.settings.ACTION_PRINT_SETTINGS';
IntentLauncherAndroid.ACTION_ADD_ACCOUNT_SETTINGS === 'android.settings.ADD_ACCOUNT_SETTINGS';
IntentLauncherAndroid.ACTION_AIRPLANE_MODE_SETTINGS === 'android.settings.AIRPLANE_MODE_SETTINGS';
IntentLauncherAndroid.ACTION_APN_SETTINGS === 'android.settings.APN_SETTINGS';
IntentLauncherAndroid.ACTION_APPLICATION_DETAILS_SETTINGS === 'android.settings.APPLICATION_DETAILS_SETTINGS';
IntentLauncherAndroid.ACTION_APPLICATION_DEVELOPMENT_SETTINGS === 'android.settings.APPLICATION_DEVELOPMENT_SETTINGS';
IntentLauncherAndroid.ACTION_APPLICATION_SETTINGS === 'android.settings.APPLICATION_SETTINGS';
IntentLauncherAndroid.ACTION_APP_NOTIFICATION_SETTINGS === 'android.settings.APP_NOTIFICATION_SETTINGS';
IntentLauncherAndroid.ACTION_APP_OPS_SETTINGS === 'android.settings.APP_OPS_SETTINGS';
IntentLauncherAndroid.ACTION_BATTERY_SAVER_SETTINGS === 'android.settings.BATTERY_SAVER_SETTINGS';
IntentLauncherAndroid.ACTION_BLUETOOTH_SETTINGS === 'android.settings.BLUETOOTH_SETTINGS';
IntentLauncherAndroid.ACTION_CAPTIONING_SETTINGS === 'android.settings.CAPTIONING_SETTINGS';
IntentLauncherAndroid.ACTION_CAST_SETTINGS === 'android.settings.CAST_SETTINGS';
IntentLauncherAndroid.ACTION_DATA_ROAMING_SETTINGS === 'android.settings.DATA_ROAMING_SETTINGS';
IntentLauncherAndroid.ACTION_DATE_SETTINGS === 'android.settings.DATE_SETTINGS';
IntentLauncherAndroid.ACTION_DEVICE_INFO_SETTINGS === 'android.settings.DEVICE_INFO_SETTINGS';
IntentLauncherAndroid.ACTION_DEVICE_NAME === 'android.settings.DEVICE_NAME';
IntentLauncherAndroid.ACTION_DISPLAY_SETTINGS === 'android.settings.DISPLAY_SETTINGS';
IntentLauncherAndroid.ACTION_DREAM_SETTINGS === 'android.settings.DREAM_SETTINGS';
IntentLauncherAndroid.ACTION_HARD_KEYBOARD_SETTINGS === 'android.settings.HARD_KEYBOARD_SETTINGS';
IntentLauncherAndroid.ACTION_HOME_SETTINGS === 'android.settings.HOME_SETTINGS';
IntentLauncherAndroid.ACTION_IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS === 'android.settings.IGNORE_BACKGROUND_DATA_RESTRICTIONS_SETTINGS';
IntentLauncherAndroid.ACTION_IGNORE_BATTERY_OPTIMIZATION_SETTINGS === 'android.settings.IGNORE_BATTERY_OPTIMIZATION_SETTINGS';
IntentLauncherAndroid.ACTION_INPUT_METHOD_SETTINGS === 'android.settings.INPUT_METHOD_SETTINGS';
IntentLauncherAndroid.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS === 'android.settings.INPUT_METHOD_SUBTYPE_SETTINGS';
IntentLauncherAndroid.ACTION_INTERNAL_STORAGE_SETTINGS === 'android.settings.INTERNAL_STORAGE_SETTINGS';
IntentLauncherAndroid.ACTION_LOCALE_SETTINGS === 'android.settings.LOCALE_SETTINGS';
IntentLauncherAndroid.ACTION_LOCATION_SOURCE_SETTINGS === 'android.settings.LOCATION_SOURCE_SETTINGS';
IntentLauncherAndroid.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS === 'android.settings.MANAGE_ALL_APPLICATIONS_SETTINGS';
IntentLauncherAndroid.ACTION_MANAGE_APPLICATIONS_SETTINGS === 'android.settings.MANAGE_APPLICATIONS_SETTINGS';
IntentLauncherAndroid.ACTION_MANAGE_DEFAULT_APPS_SETTINGS === 'android.settings.MANAGE_DEFAULT_APPS_SETTINGS';
IntentLauncherAndroid.ACTION_MEMORY_CARD_SETTINGS === 'android.settings.MEMORY_CARD_SETTINGS';
IntentLauncherAndroid.ACTION_MONITORING_CERT_INFO === 'android.settings.MONITORING_CERT_INFO';
IntentLauncherAndroid.ACTION_NETWORK_OPERATOR_SETTINGS === 'android.settings.NETWORK_OPERATOR_SETTINGS';
IntentLauncherAndroid.ACTION_NFCSHARING_SETTINGS === 'android.settings.NFCSHARING_SETTINGS';
IntentLauncherAndroid.ACTION_NFC_PAYMENT_SETTINGS === 'android.settings.NFC_PAYMENT_SETTINGS';
IntentLauncherAndroid.ACTION_NFC_SETTINGS === 'android.settings.NFC_SETTINGS';
IntentLauncherAndroid.ACTION_NIGHT_DISPLAY_SETTINGS === 'android.settings.NIGHT_DISPLAY_SETTINGS';
IntentLauncherAndroid.ACTION_NOTIFICATION_POLICY_ACCESS_SETTINGS === 'android.settings.NOTIFICATION_POLICY_ACCESS_SETTINGS';
IntentLauncherAndroid.ACTION_NOTIFICATION_SETTINGS === 'android.settings.NOTIFICATION_SETTINGS';
IntentLauncherAndroid.ACTION_PAIRING_SETTINGS === 'android.settings.PAIRING_SETTINGS';
IntentLauncherAndroid.ACTION_PRIVACY_SETTINGS === 'android.settings.PRIVACY_SETTINGS';
IntentLauncherAndroid.ACTION_QUICK_LAUNCH_SETTINGS === 'android.settings.QUICK_LAUNCH_SETTINGS';
IntentLauncherAndroid.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS === 'android.settings.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS';
IntentLauncherAndroid.ACTION_SECURITY_SETTINGS === 'android.settings.SECURITY_SETTINGS';
IntentLauncherAndroid.ACTION_SETTINGS === 'android.settings.SETTINGS';
IntentLauncherAndroid.ACTION_SHOW_ADMIN_SUPPORT_DETAILS === 'android.settings.SHOW_ADMIN_SUPPORT_DETAILS';
IntentLauncherAndroid.ACTION_SHOW_INPUT_METHOD_PICKER === 'android.settings.SHOW_INPUT_METHOD_PICKER';
IntentLauncherAndroid.ACTION_SHOW_REGULATORY_INFO === 'android.settings.SHOW_REGULATORY_INFO';
IntentLauncherAndroid.ACTION_SHOW_REMOTE_BUGREPORT_DIALOG === 'android.settings.SHOW_REMOTE_BUGREPORT_DIALOG';
IntentLauncherAndroid.ACTION_SOUND_SETTINGS === 'android.settings.SOUND_SETTINGS';
IntentLauncherAndroid.ACTION_STORAGE_MANAGER_SETTINGS === 'android.settings.STORAGE_MANAGER_SETTINGS';
IntentLauncherAndroid.ACTION_SYNC_SETTINGS === 'android.settings.SYNC_SETTINGS';
IntentLauncherAndroid.ACTION_SYSTEM_UPDATE_SETTINGS === 'android.settings.SYSTEM_UPDATE_SETTINGS';
IntentLauncherAndroid.ACTION_TETHER_PROVISIONING_UI === 'android.settings.TETHER_PROVISIONING_UI';
IntentLauncherAndroid.ACTION_TRUSTED_CREDENTIALS_USER === 'android.settings.TRUSTED_CREDENTIALS_USER';
IntentLauncherAndroid.ACTION_USAGE_ACCESS_SETTINGS === 'android.settings.USAGE_ACCESS_SETTINGS';
IntentLauncherAndroid.ACTION_USER_DICTIONARY_INSERT === 'android.settings.USER_DICTIONARY_INSERT';
IntentLauncherAndroid.ACTION_USER_DICTIONARY_SETTINGS === 'android.settings.USER_DICTIONARY_SETTINGS';
IntentLauncherAndroid.ACTION_USER_SETTINGS === 'android.settings.USER_SETTINGS';
IntentLauncherAndroid.ACTION_VOICE_CONTROL_AIRPLANE_MODE === 'android.settings.VOICE_CONTROL_AIRPLANE_MODE';
IntentLauncherAndroid.ACTION_VOICE_CONTROL_BATTERY_SAVER_MODE === 'android.settings.VOICE_CONTROL_BATTERY_SAVER_MODE';
IntentLauncherAndroid.ACTION_VOICE_CONTROL_DO_NOT_DISTURB_MODE === 'android.settings.VOICE_CONTROL_DO_NOT_DISTURB_MODE';
IntentLauncherAndroid.ACTION_VOICE_INPUT_SETTINGS === 'android.settings.VOICE_INPUT_SETTINGS';
IntentLauncherAndroid.ACTION_VPN_SETTINGS === 'android.settings.VPN_SETTINGS';
IntentLauncherAndroid.ACTION_VR_LISTENER_SETTINGS === 'android.settings.VR_LISTENER_SETTINGS';
IntentLauncherAndroid.ACTION_WEBVIEW_SETTINGS === 'android.settings.WEBVIEW_SETTINGS';
IntentLauncherAndroid.ACTION_WIFI_IP_SETTINGS === 'android.settings.WIFI_IP_SETTINGS';
IntentLauncherAndroid.ACTION_WIFI_SETTINGS === 'android.settings.WIFI_SETTINGS';
IntentLauncherAndroid.ACTION_WIRELESS_SETTINGS === 'android.settings.WIRELESS_SETTINGS';
IntentLauncherAndroid.ACTION_ZEN_MODE_AUTOMATION_SETTINGS === 'android.settings.ZEN_MODE_AUTOMATION_SETTINGS';
IntentLauncherAndroid.ACTION_ZEN_MODE_EVENT_RULE_SETTINGS === 'android.settings.ZEN_MODE_EVENT_RULE_SETTINGS';
IntentLauncherAndroid.ACTION_ZEN_MODE_EXTERNAL_RULE_SETTINGS === 'android.settings.ZEN_MODE_EXTERNAL_RULE_SETTINGS';
IntentLauncherAndroid.ACTION_ZEN_MODE_PRIORITY_SETTINGS === 'android.settings.ZEN_MODE_PRIORITY_SETTINGS';
IntentLauncherAndroid.ACTION_ZEN_MODE_SCHEDULE_RULE_SETTINGS === 'android.settings.ZEN_MODE_SCHEDULE_RULE_SETTINGS';
IntentLauncherAndroid.ACTION_ZEN_MODE_SETTINGS === 'android.settings.ZEN_MODE_SETTINGS';
KeepAwake.activate();
KeepAwake.deactivate();
() => (
<LinearGradient
colors={['#fff']}
start={[1, 1]} />
);
() => (
<LinearGradient
colors={['#fff']}
style={{ flex: 1 }} />
);
Permissions.CAMERA === 'camera';
Permissions.CAMERA_ROLL === 'cameraRoll';
Permissions.AUDIO_RECORDING === 'audioRecording';
Permissions.CONTACTS === 'contacts';
Permissions.NOTIFICATIONS === 'remoteNotifications';
Permissions.REMOTE_NOTIFICATIONS === 'remoteNotifications';
Permissions.SYSTEM_BRIGHTNESS === 'systemBrightness';
Permissions.USER_FACING_NOTIFICATIONS === 'userFacingNotifications';
Permissions.REMINDERS === 'reminders';
async () => {
const result = await Permissions.askAsync(Permissions.CAMERA);
result.status === 'granted';
result.status === 'denied';
result.status === 'undetermined';
result.expires === 'never';
};
ScreenOrientation.Orientation.ALL;
ScreenOrientation.allow(ScreenOrientation.Orientation.ALL);
class __TestEntry__ extends React.Component {
render() {
return(
<Text>test</Text>
);
}
}
registerRootComponent(__TestEntry__);
Calendar.EntityTypes.EVENT === 'event';
Calendar.EntityTypes.REMINDER === 'reminder';
Calendar.CalendarType.LOCAL === 'local';
Calendar.CalendarType.CALDAV === 'caldav';
Calendar.CalendarType.EXCHANGE === 'exchange';
Calendar.CalendarType.SUBSCRIBED === 'subscribed';
Calendar.CalendarType.BIRTHDAYS === 'birthdays';
async () => {
const result = await Calendar.getCalendarsAsync(Calendar.EntityTypes.EVENT);
result.length;
const calendar = result[0];
calendar.id === '';
calendar.title === '';
calendar.sourceId === '';
calendar.type === Calendar.CalendarType.BIRTHDAYS;
calendar.color === '';
calendar.entityType === Calendar.EntityTypes.EVENT;
calendar.allowsModifications === true;
calendar.allowedAvailabilities === [''];
calendar.isPrimary === true;
calendar.name === '';
calendar.ownerAccount === '';
calendar.timeZone === '';
calendar.allowedReminders === [''];
calendar.allowedAttendeeTypes === [''];
calendar.isVisible === false;
calendar.isSynced === false;
calendar.accessLevel === Calendar.CalendarAccessLevel.CONTRIBUTOR;
if (calendar.source) {
calendar.source.id === '';
calendar.source.type === '';
calendar.source.name === '';
calendar.source.isLocalAccount === false;
}
const id1 = await Calendar.createCalendarAsync({
accessLevel: Calendar.CalendarAccessLevel.EDITOR
});
id1 === '';
const id2 = await Calendar.updateCalendarAsync('1234', {
isVisible: false
});
id2 === '';
const id3 = await Calendar.updateCalendarAsync('1234', null);
await Calendar.deleteCalendarAsync('1234');
const events = await Calendar.getEventsAsync(
['123', '124'],
new Date(),
new Date()
);
const event1 = events[0];
event1.accessLevel === Calendar.EventAccessLevel.CONFIDENTIAL;
event1.alarms === [];
event1.allDay === true;
event1.availability === Calendar.Availability.FREE;
event1.calendarId === '';
event1.creationDate === '';
event1.endDate === '';
event1.endTimeZone === '';
event1.guestsCanInviteOthers === true;
event1.guestsCanModify === true;
event1.guestsCanSeeGuests === false;
event1.id === '';
event1.instanceId === '';
event1.isDetached === false;
const event2 = await Calendar.getEventAsync('123', {
futureEvents: true
});
const eventId1 = await Calendar.createEventAsync('123');
const eventId2 = await Calendar.updateEventAsync('1234');
await Calendar.deleteEventAsync('1234');
const attendees = await Calendar.getAttendeesForEventAsync('123');
const aId1 = await Calendar.createAttendeeAsync('123');
const aId2 = await Calendar.updateAttendeeAsync('123');
await Calendar.deleteAttendeeAsync('123');
const reminders = await Calendar.getRemindersAsync(['123']);
const reminder = await Calendar.getReminderAsync('123');
const remId1 = await Calendar.createReminderAsync('123');
const remId2 = await Calendar.updateReminderAsync('123');
await Calendar.deleteReminderAsync('123');
const sources = await Calendar.getSourcesAsync();
const source = await Calendar.getSourceAsync('123');
Calendar.openEventInCalendar('123');
};
async () => {
const result = await MailComposer.composeAsync({
subject: 'sss'
});
result.status === 'saved';
};
async () => {
const updateEventListener: Updates.UpdateEventListener = ({ type, manifest, message }) => {
switch (type) {
case Updates.EventType.DOWNLOAD_STARTED:
case Updates.EventType.DOWNLOAD_PROGRESS:
case Updates.EventType.DOWNLOAD_FINISHED:
case Updates.EventType.NO_UPDATE_AVAILABLE:
case Updates.EventType.ERROR:
return true;
}
};
Updates.reload();
Updates.reloadFromCache();
Updates.addListener(updateEventListener);
const updateCheckResult = await Updates.checkForUpdateAsync();
if (updateCheckResult.isAvailable) {
console.log(updateCheckResult.manifest);
}
Updates.fetchUpdateAsync({ eventListener: updateEventListener });
const bundleFetchResult = await Updates.fetchUpdateAsync();
if (bundleFetchResult.isNew) {
console.log(bundleFetchResult.manifest);
}
};
async () => {
const asset: MediaLibrary.Asset = await MediaLibrary.createAssetAsync('some-url');
const getAssetsOptions: MediaLibrary.GetAssetsOptions = {
first: 0,
after: 'lastAssetId',
album: 'albumId',
sortBy: MediaLibrary.SortBy.creationTime,
mediaType: MediaLibrary.MediaType.photo
};
const assetsList: MediaLibrary.GetAssetsResult = await MediaLibrary.getAssetsAsync(getAssetsOptions);
const endCursor: string = assetsList.endCursor;
const hasNextPage: boolean = assetsList.hasNextPage;
const totalCount: number = assetsList.totalCount;
const asset1: MediaLibrary.Asset = await MediaLibrary.getAssetInfoAsync(asset);
if (await MediaLibrary.deleteAssetsAsync(assetsList.assets)) {
console.log('assets deleted');
}
const albums: MediaLibrary.Album[] = await MediaLibrary.getAlbumsAsync();
const album: MediaLibrary.Album | null = await MediaLibrary.getAlbumAsync('albumName');
const album1: MediaLibrary.Album = await MediaLibrary.createAlbumAsync('albumName', asset1);
if (await MediaLibrary.addAssetsToAlbumAsync([asset, asset1], album1, true)) {
console.log('assets added');
}
const moments: MediaLibrary.Album[] = await MediaLibrary.getMomentsAsync();
switch (getAssetsOptions.mediaType) {
case MediaLibrary.MediaType.audio:
case MediaLibrary.MediaType.photo:
case MediaLibrary.MediaType.video:
case MediaLibrary.MediaType.unknow:
return true;
}
switch (getAssetsOptions.sortBy) {
case MediaLibrary.SortBy.default:
case MediaLibrary.SortBy.id:
case MediaLibrary.SortBy.creationTime:
case MediaLibrary.SortBy.modificationTime:
case MediaLibrary.SortBy.mediaType:
case MediaLibrary.SortBy.width:
case MediaLibrary.SortBy.height:
case MediaLibrary.SortBy.duration:
return true;
}
};
// #region MediaLibrary
async () => {
const mlAsset: MediaLibrary.Asset = await MediaLibrary.createAssetAsync('localUri');
const mlAssetResult: MediaLibrary.GetAssetsResult = await MediaLibrary.getAssetsAsync({
first: 0,
after: '',
album: 'Album',
sortBy: MediaLibrary.SortBy.creationTime,
mediaType: MediaLibrary.MediaType.photo
});
const mlAsset1: MediaLibrary.Asset = await MediaLibrary.getAssetInfoAsync(mlAsset);
const areDeleted: boolean = await MediaLibrary.deleteAssetsAsync([mlAsset]);
const albums: MediaLibrary.Album[] = await MediaLibrary.getAlbumsAsync();
const album: MediaLibrary.Album = await MediaLibrary.getAlbumAsync('album');
const album1: MediaLibrary.Album = await MediaLibrary.createAlbumAsync('album', mlAsset);
const areAddedToAlbum: boolean = await MediaLibrary.addAssetsToAlbumAsync([mlAsset, mlAsset1], 'album');
const areDeletedFromAlbum: boolean = await MediaLibrary.removeAssetsFromAlbumAsync([mlAsset, mlAsset1], 'album');
const momuents: MediaLibrary.Album[] = await MediaLibrary.getMomentsAsync();
};
//#endregion
// #region Haptic
Haptic.impact(Haptic.ImpactStyles.Heavy);
Haptic.impact(Haptic.ImpactStyles.Light);
Haptic.impact(Haptic.ImpactStyles.Medium);
Haptic.notification(Haptic.NotificationType.Error);
Haptic.notification(Haptic.NotificationType.Success);
Haptic.notification(Haptic.NotificationType.Error);
Haptic.selection();
// #endregion
// #region Constants
async () => {
const appOwnerShip = Constants.appOwnership;
const expoVersion = Constants.expoVersion;
const installationId = Constants.installationId;
const deviceId = Constants.deviceId;
const deviceName = Constants.deviceName;
const deviceYearClass = Constants.deviceYearClass;
const isDevice = Constants.isDevice;
const platform = Constants.platform;
const sessionId = Constants.sessionId;
const statusBarHeight = Constants.statusBarHeight;
const systemFonts = Constants.systemFonts;
const manifest = Constants.manifest;
const linkingUri = Constants.linkingUri;
const userAgent: string = await Constants.getWebViewUserAgentAsync();
};
// #endregion
+3146
View File
File diff suppressed because it is too large Load Diff
+30
View File
@@ -0,0 +1,30 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": ["es6"],
"jsx": "react",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../../",
"typeRoots": [
"../../"
],
"paths": {
"expo": [
"expo/v27"
],
"expo/*": [
"expo/v27/*"
]
},
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"expo-tests.tsx"
]
}
+7
View File
@@ -0,0 +1,7 @@
{
"extends": "dtslint/dt.json",
"rules": {
"void-return": false,
"max-line-length": false
}
}
+1 -4
View File
@@ -1,10 +1,7 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"dom",
"es6"
],
"lib": ["es6"],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
+12 -2
View File
@@ -1,14 +1,24 @@
{
"extends": "dtslint/dt.json",
"rules": {
// TODOs
// All are TODOs
"adjacent-overload-signatures": false,
"ban-types": false,
"interface-name": false,
"jsdoc-format": false,
"no-any-union": false,
"no-consecutive-blank-lines": false,
"no-empty-interface": false,
"no-padding": false,
"no-redundant-jsdoc-2": false,
"no-unnecessary-class": false,
"one-line": false,
"semicolon": false,
"space-within-parens": false,
"strict-export-declare-modifiers": false,
"unified-signatures": false
"trim-file": false,
"typedef-whitespace": false,
"unified-signatures": false,
"whitespace": false
}
}
+1 -1
View File
@@ -3,4 +3,4 @@
"dependencies": {
"fastify": "^1.11.2"
}
}
}
+1
View File
@@ -2,6 +2,7 @@
// Project: http://feathersjs.com/
// Definitions by: Abraao Alves <https://github.com/AbraaoAlves>, Jan Lohage <https://github.com/j2L4e>
// Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript
// TypeScript Version: 2.3
import { Hook } from '@feathersjs/feathers';
import * as self from '@feathersjs/authentication';
+5
View File
@@ -161,6 +161,11 @@ export const FFI_FIRST_ABI: number;
export const FFI_LAST_ABI: number;
export const FFI_SYSV: number;
export const FFI_UNIX64: number;
export const FFI_WIN64: number;
export const FFI_VFP: number;
export const FFI_STDCALL: number;
export const FFI_THISCALL: number;
export const FFI_FASTCALL: number;
export const RTLD_LAZY: number;
export const RTLD_NOW: number;
export const RTLD_LOCAL: number;
+127 -127
View File
@@ -7,7 +7,7 @@
* *
***************************************************************************/
/**
/**
* @author Richard <richardo2016@gmail.com>
*
*/
@@ -23,252 +23,252 @@
*/
declare class Class_UrlObject extends Class__object {
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的完整 url 地址描述,此描述由其他所有属性组装而成
*
*
*
*
*
*
* @type String
*/
href: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的协议名称
*
*
*
*
*
*
* @type String
*/
protocol: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象是否包含双斜杠
*
*
*
*
*
*
* @type Boolean
*/
slashes: boolean
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的完整验证字符串,由 username 和 password 属性组装而成
*
*
*
*
*
*
* @type String
*/
auth: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的验证用户
*
*
*
*
*
*
* @type String
*/
username: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的验证密码
*
*
*
*
*
*
* @type String
*/
password: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的完整主机描述,由 hastname 和 port 组装而成
*
*
*
*
*
*
* @type String
*/
host: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的主机名
*
*
*
*
*
*
* @type String
*/
hostname: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的端口号
*
*
*
*
*
*
* @type String
*/
port: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求完整路径(含请求),由 pathname 和 query 组装而成
*
*
*
*
*
*
* @type String
*/
path: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的路径
*
*
*
*
*
*
* @type String
*/
pathname: string
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求字符串(含“?”),等效于“?”+query
*
*
*
*
*
*
* @type String
*/
search: string
/**
* class prop
* class prop
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求字符串( 不含“?”)
*
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求字符串( 不含“?”)
*
*
*
* @type Value
*/
query: any
/**
* class prop
* class prop
*
*
*
* @brief 查询和设置当前 UrlObject 对象中的请求锚点(含“\#”)
*
*
*
*
*
*
* @type String
*/
hash: string
/**
*
*
* @brief UrlObject 对象构造函数,使用参数构造
* @param args 指定构造参数的字典对象,支持的字段有:protocol, slashes, username, password, hostname, port, pathname, query, hash
*
*
*
*
*
*
*/
constructor(args: object);
/**
*
*
* @brief UrlObject 对象构造函数,使用 url 字符串构造
* @param url 指定构造 url 字符串
* @param parseQueryString 指定是否解析 query
* @param slashesDenoteHost 默认为false, 如果设置为true,则从字符串'//'之后到下一个'/'之前的字符串会被解析为host,例如'//foo/bar', 结果应该是{host: 'foo', pathname: '/bar'}而不是{pathname: '//foo/bar'}
*
*
*
*
*
*
*/
constructor(url?: string/** = ""*/, parseQueryString?: boolean/** = false*/, slashesDenoteHost?: boolean/** = false*/);
/**
*
*
* @brief 解析一个 url 字符串
* @param url 指定需要解析的 url 字符串
* @param parseQueryString 指定是否解析 query
* @param slashesDenoteHost 默认为false, 如果设置为true,则从字符串'//'之后到下一个'/'之前的字符串会被解析为host,例如'//foo/bar', 结果应该是{host: 'foo', pathname: '/bar'}而不是{pathname: '//foo/bar'}
*
*
*
*
*
*
*/
parse(url: string, parseQueryString?: boolean/** = false*/, slashesDenoteHost?: boolean/** = false*/): void;
/**
*
*
* @brief 使用指定的参数构造 UrlObject
* @param args 指定构造参数的字典对象,支持的字段有:protocol, slashes, username, password, hostname, port, pathname, query, hash
*
*
*
*
*
*
*/
format(args: object): void;
/**
*
*
* @brief 重定位 url 路径,自动识别新路径为相对路径还是绝对路径
* @param url 指定新的路径
* @return 返回包含重定位数据的对象
*
*
*
*
*
*
*/
resolve(url: string): Class_UrlObject;
/**
*
*
* @brief 标准化路径
*
*
*
*
*
*
*/
normalize(): void;
+32 -33
View File
@@ -7,7 +7,7 @@
* *
***************************************************************************/
/**
/**
* @author Richard <richardo2016@gmail.com>
*
*/
@@ -194,44 +194,43 @@
declare module __bson {
/**
*
* @brief 以 bson 格式编码变量
* @param data 要编码的变量
* @return 返回编码的二进制数据
*
*
*
*/
export function encode(data: object): Class_Buffer;
/**
*
* @brief 以 bson 方式解码字符串为一个变量
* @param data 要解码的二进制数据
* @return 返回解码的变量
*
*
*
*/
export function decode(data: Class_Buffer): object;
} /** end of `module bson` */
/** module Or Internal Object */
/**
* @brief bson 编码与解码模块
* @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var bson = encoding.bson;,```,或者,```JavaScript,var bson = require('bson');,```
*/
declare module "bson" {
module bson {
/**
*
* @brief 以 bson 格式编码变量
* @param data 要编码的变量
* @return 返回编码的二进制数据
*
*
*
*/
export function encode(data: object): Class_Buffer;
/**
*
* @brief 以 bson 方式解码字符串为一个变量
* @param data 要解码的二进制数据
* @return 返回解码的变量
*
*
*
*/
export function decode(data: Class_Buffer): object;
} /** end of `module bson` */
export = bson
export = __bson
}
/** endof `module Or Internal Object` */
+64 -66
View File
@@ -7,7 +7,7 @@
* *
***************************************************************************/
/**
/**
* @author Richard <richardo2016@gmail.com>
*
*/
@@ -214,129 +214,127 @@
* @detail 引用方式:,```JavaScript,var encoding = require('encoding');,```
*/
declare module "encoding" {
import base32NS = require('base32')
import base64NS = require('base64')
import base64vlqNS = require('base64vlq')
import hexNS = require('hex')
import iconvNS = require('iconv')
import jsonNS = require('json')
import bsonNS = require('bson')
module encoding {
/**
*
*
* @brief base32 编码与解码模块
*
*
*
*
*/
export const base32: typeof base32NS
/**
*
*
* @brief base64 编码与解码模块
*
*
*
*
*/
export const base64: typeof base64NS
/**
*
*
* @brief base64vlq 编码与解码模块
*
*
*
*
*/
export const base64vlq: typeof base64vlqNS
/**
*
*
* @brief hex 编码与解码模块
*
*
*
*
*/
export const hex: typeof hexNS
/**
*
*
* @brief iconv 编码与解码模块
*
*
*
*
*/
export const iconv: typeof iconvNS
export const iconv: typeof __iconv
/**
*
*
* @brief json 编码与解码模块
*
*
*
*
*/
export const json: typeof jsonNS
/**
*
*
* @brief bson 编码与解码模块
*
*
*
*
*/
export const bson: typeof bsonNS
export const bson: typeof __bson
/**
*
*
* @brief 将字符串编码为 javascript 转义字符串,用以在 javascript 代码中包含文本
* @param str 要编码的字符串
* @param json 是否生成json兼容字符串
* @return 返回编码的字符串
*
*
*
*
*
*
*/
export function jsstr(str: string, json?: boolean/** = false*/): string;
/**
*
*
* @brief url 字符串安全编码
* @param url 要编码的 url
* @return 返回编码的字符串
*
*
*
*
*
*
*/
export function encodeURI(url: string): string;
/**
*
*
* @brief url 部件字符串安全编码
* @param url 要编码的 url
* @return 返回编码的字符串
*
*
*
*
*
*
*/
export function encodeURIComponent(url: string): string;
/**
*
*
* @brief url 安全字符串解码
* @param url 要解码的 url
* @return 返回解码的字符串
*
*
*
*
*
*
*/
export function decodeURI(url: string): string;
} /** end of `module encoding` */
export = encoding
}
+38 -46
View File
@@ -7,7 +7,7 @@
* *
***************************************************************************/
/**
/**
* @author Richard <richardo2016@gmail.com>
*
*/
@@ -194,57 +194,49 @@
declare module __iconv {
/**
*
* @brief 用 iconv 将文本转换为二进制数据
* @param charset 指定字符集
* @param data 要转换的文本
* @return 返回解码的二进制数据
*
*
*
*/
export function encode(charset: string, data: string): Class_Buffer;
/**
*
* @brief 用 iconv 将 Buffer 内容转换为文本
* @param charset 指定字符集
* @param data 要转换的二进制数据
* @return 返回编码的字符串
*
*
*
*/
export function decode(charset: string, data: Class_Buffer): string;
/**
*
* @brief 检测字符集是否被支持
* @param charset 指定字符集
* @return 返回是否支持该字符集
*
*
*
*/
export function isEncoding(charset: string): boolean;
} /** end of `module iconv` */
/** module Or Internal Object */
/**
* @brief iconv 编码与解码模块
* @detail 引用方式:,```JavaScript,var encoding = require('encoding');,var iconv = encoding.iconv;,```,或者,```JavaScript,var iconv = require('iconv');,```
*/
declare module "iconv" {
module iconv {
/**
*
* @brief 用 iconv 将文本转换为二进制数据
* @param charset 指定字符集
* @param data 要转换的文本
* @return 返回解码的二进制数据
*
*
*
*/
export function encode(charset: string, data: string): Class_Buffer;
/**
*
* @brief 用 iconv 将 Buffer 内容转换为文本
* @param charset 指定字符集
* @param data 要转换的二进制数据
* @return 返回编码的字符串
*
*
*
*/
export function decode(charset: string, data: Class_Buffer): string;
/**
*
* @brief 检测字符集是否被支持
* @param charset 指定字符集
* @return 返回是否支持该字符集
*
*
*
*/
export function isEncoding(charset: string): boolean;
} /** end of `module iconv` */
export = iconv
export = __iconv
}
/** endof `module Or Internal Object` */
+3 -3
View File
@@ -7,7 +7,7 @@
* *
***************************************************************************/
/**
/**
* @author Richard <richardo2016@gmail.com>
*
*/
@@ -63,8 +63,8 @@
/// <reference path="xml.d.ts" />
/// <reference path="constants.d.ts" />
import _Global from 'global';
import _Process from 'process';
import _Global = require('global');
import _Process = require('process');
type GlobalExportsType = any;
interface ModuleType {
+7 -7
View File
@@ -1,8 +1,8 @@
import assert = require('assert');
// import assert = require('assert'); // TODO: this brings in ../types/assert
import base32 = require('base32');
import base64 = require('base64');
import base64vlq = require('base64vlq');
import bson = require('bson');
// import bson = require('bson'); // TODO: this brings in ../types/bson
import console = require('console');
import constants = require('constants');
import coroutine = require('coroutine');
@@ -18,7 +18,7 @@ import gui = require('gui');
import hash = require('hash');
import hex = require('hex');
import http = require('http');
import iconv = require('iconv');
// import iconv = require('iconv'); // TODO: this brings in ../types/iconv
import io = require('io');
import json = require('json');
import mq = require('mq');
@@ -39,10 +39,10 @@ import timers = require('timers');
import tty = require('tty');
import url = require('url');
import util = require('util');
import uuid = require('uuid');
// import uuid = require('uuid'); // TODO: this brings in ../types/uuid
import vm = require('vm');
import ws = require('ws');
import xml = require('xml');
// import ws = require('ws'); // TODO: this brings in ../types/ws
// import xml = require('xml'); // TODO: this brings in ../types/xml
import zip = require('zip');
import zlib = require('zlib');
import zmq = require('zmq');
// import zmq = require('zmq'); // TODO: this brings in ../types/zmq
+1
View File
@@ -2,5 +2,6 @@
// Project: https://github.com/fibjs/fibjs
// Definitions by: richardo2016 <https://github.com/richardo2016>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference path="declare/index.d.ts" />
+19 -1
View File
@@ -1 +1,19 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
// All are TODOs
"ban-types": false,
"max-line-length": false,
"no-consecutive-blank-lines": false,
"no-internal-module": false,
"no-padding": false,
"no-redundant-jsdoc-2": false,
"no-single-declare-module": false,
"no-trailing-whitespace": false,
"jsdoc-format": false,
"semicolon": false,
"strict-export-declare-modifiers": false,
"trim-file": false,
"unified-signatures": false
}
}
+14 -1
View File
@@ -1 +1,14 @@
{ "extends": "dtslint/dt.json" }
{
"extends": "dtslint/dt.json",
"rules": {
// All are TODOs
"ban-types": false,
"interface-name": false,
"no-consecutive-blank-lines": false,
"no-padding": false,
"one-line": false,
"semicolon": false,
"strict-export-declare-modifiers": false,
"whitespace": false
}
}

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