Skip to content

Commit

Permalink
Refactored test for CPromise.all;
Browse files Browse the repository at this point in the history
  • Loading branch information
DigitalBrainJS committed Nov 30, 2020
1 parent b4ad695 commit 4f28354
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ CPromise class
* _static_
* [.isCanceledError(thing)](#module_CPromise..CPromise.isCanceledError) ⇒ <code>boolean</code>
* [.delay(ms, value)](#module_CPromise..CPromise.delay) ⇒ <code>CPromise</code>
* [.all(iterable, options)](#module_CPromise..CPromise.all) ⇒ <code>CPromise</code>
* [.all(iterable, [options])](#module_CPromise..CPromise.all) ⇒ <code>CPromise</code>
* [.race(thenables)](#module_CPromise..CPromise.race) ⇒ <code>CPromise</code>
* [.allSettled(iterable, options)](#module_CPromise..CPromise.allSettled) ⇒ <code>CPromise</code>
* [.from(thing, [options])](#module_CPromise..CPromise.from) ⇒ <code>CPromise</code>
Expand Down Expand Up @@ -904,15 +904,15 @@ Returns a CPromise that will be resolved after specified timeout

<a name="module_CPromise..CPromise.all"></a>

#### CPromise.all(iterable, options) ⇒ <code>CPromise</code>
#### CPromise.all(iterable, [options]) ⇒ <code>CPromise</code>
Returns a single CPromise that resolves to an array of the results of the input promises.If one fails then other promises will be canceled immediately

**Kind**: static method of [<code>CPromise</code>](#module_CPromise..CPromise)

| Param | Type |
| --- | --- |
| iterable | <code>Iterable</code> \| <code>Generator</code> \| <code>GeneratorFunction</code> |
| options | <code>AllOptions</code> |
| [options] | <code>AllOptions</code> |

**Example**
```js
Expand Down
2 changes: 1 addition & 1 deletion lib/c-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ class CPromise extends Promise {
* Returns a single CPromise that resolves to an array of the results of the input promises.
* If one fails then other promises will be canceled immediately
* @param {Iterable|Generator|GeneratorFunction} iterable
* @param {AllOptions} options
* @param {AllOptions} [options]
* @returns {CPromise}
* @example
* CPromise.all(function*(){
Expand Down
15 changes: 2 additions & 13 deletions test/tests/CPromise.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,23 +543,12 @@ module.exports = {
'should support concurrency': async function () {
let pending = 0;

setTimeout(() => {
assert.equal(pending, 2);
}, 10);

setTimeout(() => {
assert.equal(pending, 2);
}, 110);

setTimeout(() => {
assert.equal(pending, 1);
}, 210);

return CPromise.all(function* () {
for (let i = 0; i < 5; i++) {
pending++;
yield makePromise(100, i).then((v) => {
yield makePromise(500, i).then((v) => {
pending--;
assert.ok(pending < 2);
return v;
});
}
Expand Down

0 comments on commit 4f28354

Please sign in to comment.