mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-16 11:02:11 +08:00
steed: Lint
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import steed = require('steed')
|
||||
import steed = require('steed');
|
||||
|
||||
declare var path: {
|
||||
exists: (path: string, callback?: (error: Error, exists: boolean) => any) => void;
|
||||
@@ -10,133 +10,133 @@ function funcStringCbErrBoolean(v: string, cb: (error: Error, res: boolean) => v
|
||||
function callback() { }
|
||||
|
||||
steed.parallel([
|
||||
function () { },
|
||||
function () { }
|
||||
() => {},
|
||||
() => {}
|
||||
], callback);
|
||||
|
||||
steed.series([
|
||||
function () { },
|
||||
function () { }
|
||||
() => {},
|
||||
() => {}
|
||||
]);
|
||||
|
||||
var data: any[] = [];
|
||||
function steedProcess(item: any, callback: (error: Error, result: any) => void) { }
|
||||
steed.map(data, steedProcess, function (error, results) {
|
||||
steed.map(data, steedProcess, (error, results) => {
|
||||
console.log(results);
|
||||
});
|
||||
|
||||
var openFiles = ['file1', 'file2'];
|
||||
|
||||
var saveFile = function (file: string, cb: (error: Error) => void) { }
|
||||
steed.each(openFiles, saveFile, function (error: Error) { });
|
||||
steed.eachSeries(openFiles, saveFile, function (error: Error) { });
|
||||
var saveFile = (file: string, cb: (error: Error) => void) => {};
|
||||
steed.each(openFiles, saveFile, (error: Error) => {});
|
||||
steed.eachSeries(openFiles, saveFile, (error: Error) => {});
|
||||
|
||||
// Control Flow //
|
||||
|
||||
steed.series([
|
||||
function (callback) {
|
||||
callback => {
|
||||
callback(undefined, 'one');
|
||||
},
|
||||
function (callback) {
|
||||
callback => {
|
||||
callback(undefined, 'two');
|
||||
},
|
||||
],
|
||||
function (error, results) { });
|
||||
(error, results) => {});
|
||||
|
||||
steed.series<string, Error>([
|
||||
function (callback) {
|
||||
callback => {
|
||||
callback(undefined, 'one');
|
||||
},
|
||||
function (callback) {
|
||||
callback => {
|
||||
callback(undefined, 'two');
|
||||
},
|
||||
],
|
||||
function (error, results) { });
|
||||
(error, results) => {});
|
||||
|
||||
steed.series({
|
||||
one: function (callback) {
|
||||
setTimeout(function () {
|
||||
one(callback) {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 1);
|
||||
}, 200);
|
||||
},
|
||||
two: function (callback) {
|
||||
setTimeout(function () {
|
||||
two(callback) {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 2);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
function (error, results) { });
|
||||
(error, results) => {});
|
||||
|
||||
steed.series<number, Error>({
|
||||
one: function (callback) {
|
||||
setTimeout(function () {
|
||||
one(callback) {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 1);
|
||||
}, 200);
|
||||
},
|
||||
two: function (callback) {
|
||||
setTimeout(function () {
|
||||
two(callback) {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 2);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
function (error, results) { });
|
||||
(error, results) => {});
|
||||
|
||||
steed.parallel([
|
||||
function (callback) {
|
||||
setTimeout(function () {
|
||||
callback => {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 'one');
|
||||
}, 200);
|
||||
},
|
||||
function (callback) {
|
||||
setTimeout(function () {
|
||||
callback => {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 'two');
|
||||
}, 100);
|
||||
},
|
||||
],
|
||||
function (error, results) { });
|
||||
(error, results) => {});
|
||||
|
||||
steed.parallel<string, Error>([
|
||||
function (callback) {
|
||||
setTimeout(function () {
|
||||
callback => {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 'one');
|
||||
}, 200);
|
||||
},
|
||||
function (callback) {
|
||||
setTimeout(function () {
|
||||
callback => {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 'two');
|
||||
}, 100);
|
||||
},
|
||||
],
|
||||
function (error, results) { });
|
||||
(error, results) => {});
|
||||
|
||||
|
||||
steed.parallel({
|
||||
one: function (callback) {
|
||||
setTimeout(function () {
|
||||
one(callback) {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 1);
|
||||
}, 200);
|
||||
},
|
||||
two: function (callback) {
|
||||
setTimeout(function () {
|
||||
two(callback) {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 2);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
function (error, results) { });
|
||||
(error, results) => {});
|
||||
|
||||
steed.parallel<number, Error>({
|
||||
one: function (callback) {
|
||||
setTimeout(function () {
|
||||
one(callback) {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 1);
|
||||
}, 200);
|
||||
},
|
||||
two: function (callback) {
|
||||
setTimeout(function () {
|
||||
two(callback) {
|
||||
setTimeout(() => {
|
||||
callback(undefined, 2);
|
||||
}, 100);
|
||||
},
|
||||
},
|
||||
function (error, results) { });
|
||||
(error, results) => {});
|
||||
|
||||
function whileFn(callback: any) {
|
||||
count++;
|
||||
@@ -147,100 +147,100 @@ function whileTest() { return count < 5; }
|
||||
var count = 0;
|
||||
|
||||
steed.waterfall([
|
||||
function (callback: any) {
|
||||
(callback: any) => {
|
||||
callback(null, 'one', 'two');
|
||||
},
|
||||
function (arg1: any, arg2: any, callback: any) {
|
||||
(arg1: any, arg2: any, callback: any) => {
|
||||
callback(null, 'three');
|
||||
},
|
||||
function (arg1: any, callback: any) {
|
||||
(arg1: any, callback: any) => {
|
||||
callback(null, 'done');
|
||||
}
|
||||
], function (error, result) { });
|
||||
], (error, result) => {});
|
||||
|
||||
|
||||
var q = steed.queue<any, Error>(function (task: any, callback: () => void) {
|
||||
var q = steed.queue<any, Error>((task: any, callback: () => void) => {
|
||||
console.log('hello ' + task.name);
|
||||
callback();
|
||||
}, 2);
|
||||
|
||||
|
||||
q.drain = function () {
|
||||
q.drain = () => {
|
||||
console.log('all items have been processed');
|
||||
}
|
||||
};
|
||||
|
||||
q.push({ name: 'foo' });
|
||||
|
||||
q.push({ name: 'bar' }, function (err) {
|
||||
q.push({ name: 'bar' }, err => {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (error: Error) {
|
||||
q.push([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], (error: Error) => {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
q.unshift({ name: 'foo' });
|
||||
|
||||
q.unshift({ name: 'bar' }, function (err) {
|
||||
q.unshift({ name: 'bar' }, err => {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
q.unshift([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], function (error: Error) {
|
||||
q.unshift([{ name: 'baz' }, { name: 'bay' }, { name: 'bax' }], (error: Error) => {
|
||||
console.log('finished processing bar');
|
||||
});
|
||||
|
||||
var qLength: number = q.length();
|
||||
var qIsIdle: boolean = q.idle();
|
||||
|
||||
q.saturated = function () {
|
||||
q.saturated = () => {
|
||||
console.log('queue is saturated.');
|
||||
}
|
||||
};
|
||||
|
||||
q.empty = function () {
|
||||
q.empty = () => {
|
||||
console.log('queue is empty.');
|
||||
}
|
||||
};
|
||||
|
||||
q.drain = function () {
|
||||
q.drain = () => {
|
||||
console.log('queue was drained.');
|
||||
}
|
||||
};
|
||||
|
||||
q.pause();
|
||||
q.resume();
|
||||
q.kill();
|
||||
|
||||
// tests for strongly typed tasks
|
||||
var q2 = steed.queue<string, Error>(function (task: string, callback: () => void) {
|
||||
var q2 = steed.queue<string, Error>((task: string, callback: () => void) => {
|
||||
console.log('Task: ' + task);
|
||||
callback();
|
||||
}, 1);
|
||||
|
||||
q2.push('task1');
|
||||
|
||||
q2.push('task2', function (error) {
|
||||
q2.push('task2', error => {
|
||||
console.log('Finished tasks');
|
||||
});
|
||||
|
||||
q2.push(['task3', 'task4', 'task5'], function (error: Error) {
|
||||
q2.push(['task3', 'task4', 'task5'], (error: Error) => {
|
||||
console.log('Finished tasks');
|
||||
});
|
||||
|
||||
q2.unshift('task1');
|
||||
|
||||
q2.unshift('task2', function (error) {
|
||||
q2.unshift('task2', error => {
|
||||
console.log('Finished tasks');
|
||||
});
|
||||
|
||||
q2.unshift(['task3', 'task4', 'task5'], function (error: Error) {
|
||||
q2.unshift(['task3', 'task4', 'task5'], (error: Error) => {
|
||||
console.log('Finished tasks');
|
||||
});
|
||||
|
||||
steed.parallel([
|
||||
function (callback: (error: Error, val: string) => void) { },
|
||||
function (callback) { }
|
||||
(callback: (error: Error, val: string) => void) => { },
|
||||
callback => {}
|
||||
],
|
||||
function (error: Error, results: Array<string>) {
|
||||
(error: Error, results: string[]) => {
|
||||
steed.series([
|
||||
function (callback) { },
|
||||
callback => { },
|
||||
function email_link(callback) { }
|
||||
]);
|
||||
});
|
||||
@@ -248,11 +248,11 @@ steed.parallel([
|
||||
// each
|
||||
|
||||
steed.each<number, Error>({
|
||||
"a": 1,
|
||||
"b": 2
|
||||
}, function (val: number, next: steed.ErrorCallback<Error>): void {
|
||||
a: 1,
|
||||
b: 2
|
||||
}, (val: number, next: steed.ErrorCallback<Error>): void => {
|
||||
|
||||
setTimeout(function (): void {
|
||||
setTimeout((): void => {
|
||||
|
||||
console.log(`steed.each: ${val}`);
|
||||
|
||||
@@ -260,18 +260,18 @@ steed.each<number, Error>({
|
||||
|
||||
}, 500);
|
||||
|
||||
}, function (err?: Error): void {
|
||||
}, (err?: Error): void => {
|
||||
|
||||
console.log("steed.each: done.");
|
||||
|
||||
});
|
||||
|
||||
steed.eachSeries<number, Error>({
|
||||
"a": 1,
|
||||
"b": 2
|
||||
}, function (val: number, next: steed.ErrorCallback<Error>): void {
|
||||
a: 1,
|
||||
b: 2
|
||||
}, (val: number, next: steed.ErrorCallback<Error>): void => {
|
||||
|
||||
setTimeout(function (): void {
|
||||
setTimeout((): void => {
|
||||
|
||||
console.log(`steed.eachSeries: ${val}`);
|
||||
|
||||
@@ -279,7 +279,7 @@ steed.eachSeries<number, Error>({
|
||||
|
||||
}, 500);
|
||||
|
||||
}, function (err?: Error): void {
|
||||
}, (err?: Error): void => {
|
||||
|
||||
console.log("steed.eachSeries: done.");
|
||||
|
||||
@@ -288,12 +288,12 @@ steed.eachSeries<number, Error>({
|
||||
// map
|
||||
|
||||
steed.map<number, string, Error>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function (val: number, next: steed.SteedResultCallback<string, Error>): void {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
}, (val: number, next: steed.SteedResultCallback<string, Error>): void => {
|
||||
|
||||
setTimeout(function (): void {
|
||||
setTimeout((): void => {
|
||||
|
||||
console.log(`steed.map: ${val}`);
|
||||
|
||||
@@ -301,19 +301,19 @@ steed.map<number, string, Error>({
|
||||
|
||||
}, 500);
|
||||
|
||||
}, function (error: Error, results: string[]): void {
|
||||
}, (error: Error, results: string[]): void => {
|
||||
|
||||
console.log("steed.map: done with results", results);
|
||||
|
||||
});
|
||||
|
||||
steed.mapSeries<number, string, Error>({
|
||||
"a": 1,
|
||||
"b": 2,
|
||||
"c": 3
|
||||
}, function (val: number, next: steed.SteedResultCallback<string, Error>): void {
|
||||
a: 1,
|
||||
b: 2,
|
||||
c: 3
|
||||
}, (val: number, next: steed.SteedResultCallback<string, Error>): void => {
|
||||
|
||||
setTimeout(function (): void {
|
||||
setTimeout((): void => {
|
||||
|
||||
console.log(`steed.mapSeries: ${val}`);
|
||||
|
||||
@@ -321,8 +321,8 @@ steed.mapSeries<number, string, Error>({
|
||||
|
||||
}, 500);
|
||||
|
||||
}, function (error: Error, results: string[]): void {
|
||||
}, (error: Error, results: string[]): void => {
|
||||
|
||||
console.log("steed.mapSeries: done with results", results);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,4 +3,4 @@
|
||||
"rules": {
|
||||
"forbidden-types": false
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user