Skip to content

Commit 8dabe51

Browse files
committed
Updated README on Promises
1 parent 215c421 commit 8dabe51

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ bcrypt.hash('bacon', 8, function(err, hash) {
115115
});
116116
```
117117

118+
**Note:** Since bcrypt.js 2.4.0, if the callback argument has been omitted when calling an asynchronous function, the function returns a Promise.
119+
118120
API
119121
---
120122
### setRandomFallback(random)
@@ -152,6 +154,8 @@ Asynchronously generates a salt.
152154
| rounds | *number | function(Error, string=)* | Number of rounds to use, defaults to 10 if omitted
153155
| seed_length | *number | function(Error, string=)* | Not supported.
154156
| callback | *function(Error, string=)* | Callback receiving the error, if any, and the resulting salt
157+
| @returns | *Promise* | If `callback` has been omitted
158+
| **@throws** | *Error* | If the callback argument is present but not a function
155159

156160
### hashSync(s, salt=)
157161

@@ -172,7 +176,9 @@ Asynchronously generates a hash for the given string.
172176
| s | *string* | String to hash
173177
| salt | *number | string* | Salt length to generate or salt to use
174178
| callback | *function(Error, string=)* | Callback receiving the error, if any, and the resulting hash
175-
| progressCallback | *function(number)* | Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms.
179+
| progressCallback | *function(number)* | Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms.
180+
| @returns | *Promise* | If `callback` has been omitted
181+
| **@throws** | *Error* | If the callback argument is present but not a function
176182

177183
### compareSync(s, hash)
178184

@@ -194,8 +200,9 @@ Asynchronously compares the given data against the given hash.
194200
| s | *string* | Data to compare
195201
| hash | *string* | Data to be compared to
196202
| callback | *function(Error, boolean)* | Callback receiving the error, if any, otherwise the result
197-
| progressCallback | *function(number)* | Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms.
198-
| **@throws** | *Error* | If the callback argument is invalid
203+
| progressCallback | *function(number)* | Callback successively called with the percentage of rounds completed (0.0 - 1.0), maximally once per `MAX_EXECUTION_TIME = 100` ms.
204+
| @returns | *Promise* | If `callback` has been omitted
205+
| **@throws** | *Error* | If the callback argument is present but not a function
199206

200207
### getRounds(hash)
201208

0 commit comments

Comments
 (0)