File tree 1 file changed +22
-0
lines changed
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -174,3 +174,25 @@ The first documentation describes how you can call getTheTime without
174
174
any arguments, and the second describes how you can call getTheTime with
175
175
an argument. ` documentation ` will output two documented functions when you
176
176
use this style.
177
+
178
+ ## Promises
179
+
180
+ Promises have become a widely used feature in modern JavaScript. They are
181
+ documented in a similar manner to arrays:
182
+
183
+ ``` js
184
+ /**
185
+ * Find a person's phone number in the database
186
+ * @param {string} name person's name
187
+ * @returns {Promise<string>} promise with the phone number
188
+ */
189
+ function findPersonAge (name ) {
190
+ return new Promise ((resolve , reject ) => {
191
+ db .find ({ name: name })
192
+ .then (object => resolve (object .age ))
193
+ .catch (err => reject (err))
194
+ })
195
+ }
196
+ ```
197
+
198
+ Multiple parameters within the ` resolve ` can be documented like so: ` Promise<string, number> ` .
You can’t perform that action at this time.
0 commit comments