You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+9-9Lines changed: 9 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ async-done
5
5
6
6
Manage callback, promise, and stream completion
7
7
8
-
Will run call the executor function on `nextTick`. This will cause all functions to be async.
8
+
Will run call the function on `nextTick`. This will cause all functions to be async.
9
9
10
10
## Usage
11
11
@@ -39,27 +39,27 @@ asyncDone(function(done){
39
39
40
40
## API
41
41
42
-
### `asyncDone(executor, onComplete)` : Function
42
+
### `asyncDone(fn, callback)`
43
43
44
-
Takes a function to execute (`executor`) and a function to call on completion (`onComplete`).
44
+
Takes a function to execute (`fn`) and a function to call on completion (`callback`).
45
45
46
-
#### `executor([done])` : Function
46
+
#### `fn([done])`
47
47
48
48
Optionally takes a callback to call when async tasks are complete.
49
49
50
-
If a `Stream` (or any instance of `EventEmitter`) or `Promise` is returned from the `executor` function, they will be used to wire up the async resolution.
50
+
If a `Stream` (or any instance of `EventEmitter`) or `Promise` is returned from the `fn` function, they will be used to wire up the async resolution.
51
51
52
52
`Streams` (or any instance of `EventEmitter`) will be wrapped in a domain for error management. The `end` and `close` events will be used to resolve successfully.
53
53
54
54
`Promises` will be listened for on the `then` method. They will use the `onFulfilled` to resolve successfully or the `onRejected` methods to resolve with an error.
55
55
56
-
If you want to write a sync function, it will be executed on `process.nextTick` and the return value will be passed into `onComplete`. If you plan to use a sync function, don't specify any parameters in your function declaration, as we need to rely on function arity to determine the function isn't async.
56
+
__Warning:__ Sync taks are not supported and your functionwill never complete if the one of the above strategies is not used to signal completion.
57
57
58
-
#### `onComplete(error, result)` : Function
58
+
#### `callback(error, result)`
59
59
60
-
If an error doesn't occur in the execution of the `executor` function, the `onComplete` method will receive the results as its second argument.
60
+
If an error doesn't occur in the execution of the `fn` function, the `callback` method will receive the results as its second argument.
61
61
62
-
If an error occurred in the execution of the `executor` function, The `onComplete` method will receive an error as its first argument.
62
+
If an error occurred in the execution of the `fn` function, The `callback` method will receive an error as its first argument.
0 commit comments