From f713855f033bef0552c3bfc5202fcb1ddc90f3c8 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 26 Sep 2017 08:36:27 -0700 Subject: [PATCH] async: Convert to module (#19870) --- types/async/index.d.ts | 287 ++++++++++++++--------------- types/async/test/es6-generators.ts | 2 +- types/async/test/index.ts | 2 + types/async/tslint.json | 33 ++++ types/i2c-bus/i2c-bus-tests.ts | 3 +- 5 files changed, 177 insertions(+), 150 deletions(-) create mode 100644 types/async/tslint.json diff --git a/types/async/index.d.ts b/types/async/index.d.ts index 139689ea2f..f443ebf627 100644 --- a/types/async/index.d.ts +++ b/types/async/index.d.ts @@ -3,25 +3,27 @@ // Definitions by: Boris Yankov , Arseniy Maximov , Joe Herman , Angus Fenying , Pascal Martin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface Dictionary { [key: string]: T; } +export as namespace async; -interface ErrorCallback { (err?: T): void; } -interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } -interface AsyncResultCallback { (err?: E, result?: T): void; } -interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } -interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } +export interface Dictionary { [key: string]: T; } -interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } -interface AsyncIterator { (item: T, callback: ErrorCallback): void; } -interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } -interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } -interface AsyncMemoIterator { (memo: R | undefined, item: T, callback: AsyncResultCallback): void; } -interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanResultCallback): void; } +export interface ErrorCallback { (err?: T): void; } +export interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } +export interface AsyncResultCallback { (err?: E, result?: T): void; } +export interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } +export interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } -interface AsyncWorker { (task: T, callback: ErrorCallback): void; } -interface AsyncVoidFunction { (callback: ErrorCallback): void; } +export interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } +export interface AsyncIterator { (item: T, callback: ErrorCallback): void; } +export interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } +export interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } +export interface AsyncMemoIterator { (memo: R | undefined, item: T, callback: AsyncResultCallback): void; } +export interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanResultCallback): void; } -interface AsyncQueue { +export interface AsyncWorker { (task: T, callback: ErrorCallback): void; } +export interface AsyncVoidFunction { (callback: ErrorCallback): void; } + +export interface AsyncQueue { length(): number; started: boolean; running(): number; @@ -48,7 +50,7 @@ interface AsyncQueue { buffer: number; } -interface AsyncPriorityQueue { +export interface AsyncPriorityQueue { length(): number; concurrency: number; started: boolean; @@ -73,7 +75,7 @@ interface AsyncPriorityQueue { buffer: number; } -interface AsyncCargo { +export interface AsyncCargo { length(): number; payload?: number; push(task: any, callback? : Function): void; @@ -87,142 +89,133 @@ interface AsyncCargo { kill(): void; } -interface Async { +// Collections +export function each(arr: T[] | IterableIterator, iterator: AsyncIterator, callback?: ErrorCallback): void; +export function each(arr: Dictionary, iterator: AsyncIterator, callback?: ErrorCallback): void; +export const eachSeries: typeof each; +export function eachLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; +export function eachLimit(arr: Dictionary, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; +export const forEach: typeof each; +export const forEachSeries: typeof each; +export const forEachLimit: typeof eachLimit; +export function forEachOf(obj: T[] | IterableIterator, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; +export function forEachOf(obj: Dictionary, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; +export const forEachOfSeries: typeof forEachOf; +export function forEachOfLimit(obj: T[] | IterableIterator, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; +export function forEachOfLimit(obj: Dictionary, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; +export const eachOf: typeof forEachOf; +export const eachOfSeries: typeof forEachOf; +export const eachOfLimit: typeof forEachOfLimit; +export function map(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function map(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export const mapSeries: typeof map; +export function mapLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function mapLimit(arr: Dictionary, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function mapValuesLimit(obj: Dictionary, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; +export function mapValues(obj: Dictionary, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; +export const mapValuesSeries: typeof mapValues; +export function filter(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; +export function filter(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; +export const filterSeries: typeof filter; +export function filterLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; +export function filterLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): 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(arr: T[] | IterableIterator, memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): void; +export const inject: typeof reduce; +export const foldl: typeof reduce; +export const reduceRight: typeof reduce; +export const foldr: typeof reduce; +export function detect(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; +export function detect(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; +export const detectSeries: typeof detect; +export function detectLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; +export function detectLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; +export const find: typeof detect; +export const findSeries: typeof detect; +export const findLimit: typeof detectLimit; +export function sortBy(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function some(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function some(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export const someSeries: typeof some; +export function someLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function someLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export const any: typeof some; +export const anySeries: typeof someSeries; +export const anyLimit: typeof someLimit; +export function every(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function every(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export const everySeries: typeof every; +export function everyLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export function everyLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; +export const all: typeof every; +export const allSeries: typeof every; +export const allLimit: typeof everyLimit; - // Collections - each(arr: T[] | IterableIterator, iterator: AsyncIterator, callback?: ErrorCallback): void; - each(arr: Dictionary, iterator: AsyncIterator, callback?: ErrorCallback): void; - eachSeries: typeof async.each; - eachLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; - eachLimit(arr: Dictionary, limit: number, iterator: AsyncIterator, callback?: ErrorCallback): void; - forEach: typeof async.each; - forEachSeries: typeof async.each; - forEachLimit: typeof async.eachLimit; - forEachOf(obj: T[] | IterableIterator, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; - forEachOf(obj: Dictionary, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; - forEachOfSeries: typeof async.forEachOf; - forEachOfLimit(obj: T[] | IterableIterator, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; - forEachOfLimit(obj: Dictionary, limit: number, iterator: AsyncForEachOfIterator, callback?: ErrorCallback): void; - eachOf: typeof async.forEachOf; - eachOfSeries: typeof async.forEachOf; - eachOfLimit: typeof async.forEachOfLimit; - map(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - map(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - mapSeries: typeof async.map; - mapLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - mapLimit(arr: Dictionary, limit: number, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - mapValuesLimit(obj: Dictionary, limit: number, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; - mapValues(obj: Dictionary, iteratee: (value: T, key: string, callback: AsyncResultCallback) => void, callback: AsyncResultObjectCallback): void; - mapValuesSeries: typeof async.mapValues; - filter(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; - filter(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; - filterSeries: typeof async.filter; - filterLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; - filterLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultArrayCallback): void; - select: typeof async.filter; - selectSeries: typeof async.filter; - selectLimit: typeof async.filterLimit; - reject: typeof async.filter; - rejectSeries: typeof async.filter; - rejectLimit: typeof async.filterLimit; - reduce(arr: T[] | IterableIterator, memo: R, iterator: AsyncMemoIterator, callback?: AsyncResultCallback): void; - inject: typeof async.reduce; - foldl: typeof async.reduce; - reduceRight: typeof async.reduce; - foldr: typeof async.reduce; - detect(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; - detect(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; - detectSeries: typeof async.detect; - detectLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; - detectLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncResultCallback): void; - find: typeof async.detect; - findSeries: typeof async.detect; - findLimit: typeof async.detectLimit; - sortBy(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - some(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - some(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - someSeries: typeof async.some; - someLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - someLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - any: typeof async.some; - anySeries: typeof async.someSeries; - anyLimit: typeof async.someLimit; - every(arr: T[] | IterableIterator, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - every(arr: Dictionary, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - everySeries: typeof async.every; - everyLimit(arr: T[] | IterableIterator, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - everyLimit(arr: Dictionary, limit: number, iterator: AsyncBooleanIterator, callback?: AsyncBooleanResultCallback): void; - all: typeof async.every; - allSeries: typeof async.every; - allLimit: typeof async.everyLimit; +export function concat(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export function concat(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; +export const concatSeries: typeof concat; - concat(arr: T[] | IterableIterator, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - concat(arr: Dictionary, iterator: AsyncResultIterator, callback?: AsyncResultArrayCallback): void; - concatSeries: typeof async.concat; +// Control Flow +export function series(tasks: AsyncFunction[], callback?: AsyncResultArrayCallback): void; +export function series(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; +export function parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; +export function parallel(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; +export function parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; +export function parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; +export function whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; +export function doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; +export function until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; +export function doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; +export function during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; +export function doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; +export function forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; +export function waterfall(tasks: Function[], callback?: AsyncResultCallback): 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(worker: AsyncWorker, concurrency?: number): AsyncQueue; +export function queue(worker: AsyncResultIterator, concurrency?: number): AsyncQueue; +export function priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; +export function cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; +export function auto(tasks: any, concurrency?: number, callback?: AsyncResultCallback): void; +export function autoInject(tasks: any, callback?: AsyncResultCallback): void; +export function retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; +export function retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; +export function retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; +export function apply(fn: Function, ...args: any[]): AsyncFunction; +export function nextTick(callback: Function, ...args: any[]): void; +export const setImmediate: typeof nextTick; - // Control Flow - series(tasks: AsyncFunction[], callback?: AsyncResultArrayCallback): void; - series(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; - parallel(tasks: Array>, callback?: AsyncResultArrayCallback): void; - parallel(tasks: Dictionary>, callback?: AsyncResultObjectCallback): void; - parallelLimit(tasks: Array>, limit: number, callback?: AsyncResultArrayCallback): void; - parallelLimit(tasks: Dictionary>, limit: number, callback?: AsyncResultObjectCallback): void; - whilst(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; - doWhilst(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; - until(test: () => boolean, fn: AsyncVoidFunction, callback: ErrorCallback): void; - doUntil(fn: AsyncVoidFunction, test: () => boolean, callback: ErrorCallback): void; - during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; - doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; - forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; - waterfall(tasks: Function[], callback?: AsyncResultCallback): void; - compose(...fns: Function[]): Function; - seq(...fns: Function[]): Function; - applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. - applyEachSeries(fns: Function[], argsAndCallback: any[]): void; // applyEachSeries(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. - queue(worker: AsyncWorker, concurrency?: number): AsyncQueue; - queue(worker: AsyncResultIterator, concurrency?: number): AsyncQueue; - priorityQueue(worker: AsyncWorker, concurrency: number): AsyncPriorityQueue; - cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; - auto(tasks: any, concurrency?: number, callback?: AsyncResultCallback): void; - autoInject(tasks: any, callback?: AsyncResultCallback): void; - retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; - retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; - retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; - apply(fn: Function, ...arguments: any[]): AsyncFunction; - nextTick(callback: Function, ...args: any[]): void; - setImmediate: typeof async.nextTick; +export function reflect(fn: AsyncFunction) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void; +export function reflectAll(tasks: AsyncFunction[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[]; - reflect(fn: AsyncFunction) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void; - reflectAll(tasks: AsyncFunction[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[]; +export function timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; +export function timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; - timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; - timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; +export function times (n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; +export function timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; +export function timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; - times (n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; - timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; - timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; +export function transform(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; +export function transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; - transform(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; - transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; +export function transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; +export function transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; - transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; - transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; +export function race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; - race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; - - // Utils - memoize(fn: Function, hasher?: Function): Function; - unmemoize(fn: Function): Function; - ensureAsync(fn: (... argsAndCallback: any[]) => void): Function; - constant(...values: any[]): Function; - asyncify(fn: Function): Function; - wrapSync(fn: Function): Function; - log(fn: Function, ...arguments: any[]): void; - dir(fn: Function, ...arguments: any[]): void; -} - -declare var async: Async; - -declare module "async" { - export = async; -} +// Utils +export function memoize(fn: Function, hasher?: Function): Function; +export function unmemoize(fn: Function): Function; +export function ensureAsync(fn: (... argsAndCallback: any[]) => void): Function; +export function constant(...values: any[]): Function; +export function asyncify(fn: Function): Function; +export function wrapSync(fn: Function): Function; +export function log(fn: Function, ...args: any[]): void; +export function dir(fn: Function, ...args: any[]): void; diff --git a/types/async/test/es6-generators.ts b/types/async/test/es6-generators.ts index 2a7328a09a..b67e7daad7 100644 --- a/types/async/test/es6-generators.ts +++ b/types/async/test/es6-generators.ts @@ -1,6 +1,6 @@ function* collectionGenerator(): IterableIterator { } -function funcMapIterator(value: T, callback: AsyncResultCallback) { } +function funcMapIterator(value: T, callback: async.AsyncResultCallback) { } function funcMapComplete(error: E, results: T[]) { } function booleanIterator(v: T, cb: (err: Error, res: boolean) => void) { } diff --git a/types/async/test/index.ts b/types/async/test/index.ts index 60234a0ca4..821ccd0650 100644 --- a/types/async/test/index.ts +++ b/types/async/test/index.ts @@ -1,5 +1,7 @@ /// +import async = require("async"); +import { ErrorCallback, AsyncResultCallback, AsyncBooleanResultCallback, Dictionary } from "async"; import fs = require("fs"); import process = require("process"); diff --git a/types/async/tslint.json b/types/async/tslint.json new file mode 100644 index 0000000000..b1ab4a96cc --- /dev/null +++ b/types/async/tslint.json @@ -0,0 +1,33 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + // TODOs + "arrow-return-shorthand": false, + "array-type": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "max-line-length": false, + "no-consecutive-blank-lines": false, + "no-padding": false, + "no-unnecessary-generics": false, + "no-var-keyword": false, + "no-void-expression": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-const": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "trim-file": false, + "typedef-whitespace": false, + "unified-signatures": false, + "whitespace": false + } +} diff --git a/types/i2c-bus/i2c-bus-tests.ts b/types/i2c-bus/i2c-bus-tests.ts index 1e4c6c8bcb..599e7c6599 100644 --- a/types/i2c-bus/i2c-bus-tests.ts +++ b/types/i2c-bus/i2c-bus-tests.ts @@ -5,8 +5,7 @@ // Tests taken from documentation samples. import { I2cBus, open, openSync } from "i2c-bus"; -import * as asnc from "async"; - +import * as async from "async"; function toCelsius(rawTemp: number): number { const halfDegrees = ((rawTemp & 0xff) << 1) + (rawTemp >> 15);