Skip to content

Commit 7ebd280

Browse files
committed
Docs: Use better names in API documentation & add note about sync functions being unsupported
1 parent dbccd76 commit 7ebd280

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ async-done
55

66
Manage callback, promise, and stream completion
77

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.
99

1010
## Usage
1111

@@ -39,27 +39,27 @@ asyncDone(function(done){
3939

4040
## API
4141

42-
### `asyncDone(executor, onComplete)` : Function
42+
### `asyncDone(fn, callback)`
4343

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`).
4545

46-
#### `executor([done])` : Function
46+
#### `fn([done])`
4747

4848
Optionally takes a callback to call when async tasks are complete.
4949

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.
5151

5252
`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.
5353

5454
`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.
5555

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 function will never complete if the one of the above strategies is not used to signal completion.
5757

58-
#### `onComplete(error, result)` : Function
58+
#### `callback(error, result)`
5959

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.
6161

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.
6363

6464
Errors can be caused by:
6565

0 commit comments

Comments
 (0)