Skip to content

Commit 89e4833

Browse files
committed
add returning promise example for returns tag
1 parent e6dec4b commit 89e4833

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

content/en/tags-returns.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,20 @@ function sum(a, b, retArr) {
7373
}
7474
```
7575
{% endexample %}
76+
77+
{% example "Returns a promise" %}
78+
79+
```js
80+
/**
81+
* Returns the sum of a and b
82+
* @param {Number} a
83+
* @param {Number} b
84+
* @returns {Promise<Number>} Promise object represents the sum of a and b
85+
*/
86+
function sumAsync(a, b) {
87+
return new Promise(function(resolve, reject){
88+
resolve(a + b);
89+
});
90+
}
91+
```
92+
{% endexample %}

tags-returns.html

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,20 @@ <h2 id="examples">Examples</h2>
9090
}
9191
return a + b;
9292
}
93-
</code></pre>
94-
</figure>
93+
</code></pre></figure>
94+
<figure>
95+
<figcaption>Returns a promise</figcaption><pre class="prettyprint lang-js"><code>/**
96+
* Returns the sum of a and b
97+
* @param {Number} a
98+
* @param {Number} b
99+
* @returns {Promise<Number>} Promise object represents the sum of a and b
100+
*/
101+
function sumAsync(a, b) {
102+
return new Promise(function(resolve, reject){
103+
resolve(a + b);
104+
});
105+
}
106+
</code></pre></figure>
95107
<h2 id="related-links">Related Links</h2>
96108
<ul>
97109
<li>

0 commit comments

Comments
 (0)