From e75ec21986ce5ae7ffb8aba1245585bcd7a321f4 Mon Sep 17 00:00:00 2001 From: Dmitriy Mozgovoy Date: Fri, 16 Oct 2020 11:42:37 +0300 Subject: [PATCH] Fixed docs; --- README.md | 35 ++++++++++++++++------------------- jsdoc2md/README.hbs.md | 8 ++++---- lib/c-promise.js | 22 +++++++++++----------- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 03d6e2e..b9cdc0e 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,7 @@ You can use generators as a replacement for async: import CPromise from "c-promise2"; const chain= CPromise.from(function*(){ - yield 1000; // wait for 1000ms- converts to CPromise.delay(1000) + yield CPromise.delay(1000); // wait for 1000ms- converts to CPromise.delay(1000) return "It works!"; }).then(message=> console.log(`Done: ${message}`)); @@ -195,9 +195,9 @@ import CPromise from "c-promise2"; const promise= CPromise.from(function*(x, y, z){ this.captureProgress(4); //optionally set the expected total progress score of the chain - yield 1000; // wait for 1000ms- converts to CPromise.delay(1000) - yield [1000, 1500] // resolve chains using CPromise.all([...chains]); - yield [[1000, 1500]] // resolve chains using CPromise.race([...chains]); + yield CPromise.delay(1000); // wait for 1000ms- converts to CPromise.delay(1000) + yield [CPromise.delay(1000), CPromise.delay(1500)] // resolve chains using CPromise.all([...chains]); + yield [[CPromise.delay(1000), CPromise.delay(1500)]] // resolve chains using CPromise.race([...chains]); const status= yield new Promise(resolve=> resolve(true)); // any thenable object will be resolved return "It works!"; //return statement supports resolving only thenable objects ot plain values }, [1, 2, 3]).then(message=> console.log(`Done: ${message}`)); @@ -215,6 +215,7 @@ Cancellable Promise with extra features * [.signal](#module_CPromise..CPromiseScope+signal) : AbortSignal * [.isPending](#module_CPromise..CPromiseScope+isPending) ⇒ Boolean * [.isCanceled](#module_CPromise..CPromiseScope+isCanceled) ⇒ Boolean + * [.isCaptured](#module_CPromise..CPromiseScope+isCaptured) ⇒ boolean * [.onCancel(listener)](#module_CPromise..CPromiseScope+onCancel) ⇒ CPromiseScope * [.totalWeight([weight])](#module_CPromise..CPromiseScope+totalWeight) ⇒ Number \| CPromiseScope * [.innerWeight([weight])](#module_CPromise..CPromiseScope+innerWeight) ⇒ Number \| CPromiseScope @@ -253,7 +254,6 @@ Cancellable Promise with extra features * [~onRejected](#module_CPromise..onRejected) : function * [~OnCancelListener](#module_CPromise..OnCancelListener) : function * [~CPromiseExecutorFn](#module_CPromise..CPromiseExecutorFn) : function - * [~CPromiseExecutorFn](#module_CPromise..CPromiseExecutorFn) : function * [~CPromiseOptions](#module_CPromise..CPromiseOptions) : PromiseScopeOptions \| String \| Number * [~AllOptions](#module_CPromise..AllOptions) : object @@ -271,6 +271,7 @@ Scope for CPromises instances * [.signal](#module_CPromise..CPromiseScope+signal) : AbortSignal * [.isPending](#module_CPromise..CPromiseScope+isPending) ⇒ Boolean * [.isCanceled](#module_CPromise..CPromiseScope+isCanceled) ⇒ Boolean + * [.isCaptured](#module_CPromise..CPromiseScope+isCaptured) ⇒ boolean * [.onCancel(listener)](#module_CPromise..CPromiseScope+onCancel) ⇒ CPromiseScope * [.totalWeight([weight])](#module_CPromise..CPromiseScope+totalWeight) ⇒ Number \| CPromiseScope * [.innerWeight([weight])](#module_CPromise..CPromiseScope+innerWeight) ⇒ Number \| CPromiseScope @@ -317,6 +318,12 @@ indicates if the promise is pending #### cPromiseScope.isCanceled ⇒ Boolean indicates if the promise is pending +**Kind**: instance property of [CPromiseScope](#module_CPromise..CPromiseScope) + + +#### cPromiseScope.isCaptured ⇒ boolean +indicates if the promise progress is captured + **Kind**: instance property of [CPromiseScope](#module_CPromise..CPromiseScope) @@ -483,9 +490,9 @@ Executes the promise executor in the PromiseScope context | Param | Type | | --- | --- | | executor | CPromiseExecutorFn | -| resolve | | -| reject | | -| options | | +| resolve | function | +| reject | function | +| options | Object | @@ -724,16 +731,6 @@ Converts thing to CPromise using the following rules: - CPromise instance return | reject | function | | scope | CPromiseScope | - - -### CPromise~CPromiseExecutorFn : function -**Kind**: inner typedef of [CPromise](#module_CPromise) - -| Param | Type | -| --- | --- | -| resolve | function | -| reject | function | - ### CPromise~CPromiseOptions : PromiseScopeOptions \| String \| Number @@ -748,7 +745,7 @@ If value is a number it will be considered as the value for timeout option If va | Name | Type | Description | | --- | --- | --- | -| limit | number | concurrency of promise being run simultaneously | +| concurrency | number | limit concurrency of promise being run simultaneously | | mapper | function | mapper function to map each element | | ignoreResults | boolean | do not collect results | | signatures | boolean | use advanced signatures for vales resolving | diff --git a/jsdoc2md/README.hbs.md b/jsdoc2md/README.hbs.md index 7e58b9d..cd82dcd 100644 --- a/jsdoc2md/README.hbs.md +++ b/jsdoc2md/README.hbs.md @@ -165,7 +165,7 @@ You can use generators as a replacement for async: import CPromise from "c-promise2"; const chain= CPromise.from(function*(){ - yield 1000; // wait for 1000ms- converts to CPromise.delay(1000) + yield CPromise.delay(1000); // wait for 1000ms- converts to CPromise.delay(1000) return "It works!"; }).then(message=> console.log(`Done: ${message}`)); @@ -195,9 +195,9 @@ import CPromise from "c-promise2"; const promise= CPromise.from(function*(x, y, z){ this.captureProgress(4); //optionally set the expected total progress score of the chain - yield 1000; // wait for 1000ms- converts to CPromise.delay(1000) - yield [1000, 1500] // resolve chains using CPromise.all([...chains]); - yield [[1000, 1500]] // resolve chains using CPromise.race([...chains]); + yield CPromise.delay(1000); // wait for 1000ms- converts to CPromise.delay(1000) + yield [CPromise.delay(1000), CPromise.delay(1500)] // resolve chains using CPromise.all([...chains]); + yield [[CPromise.delay(1000), CPromise.delay(1500)]] // resolve chains using CPromise.race([...chains]); const status= yield new Promise(resolve=> resolve(true)); // any thenable object will be resolved return "It works!"; //return statement supports resolving only thenable objects ot plain values }, [1, 2, 3]).then(message=> console.log(`Done: ${message}`)); diff --git a/lib/c-promise.js b/lib/c-promise.js index 5530a79..e2a1488 100644 --- a/lib/c-promise.js +++ b/lib/c-promise.js @@ -629,6 +629,11 @@ class CPromiseScope extends TinyEventEmitter { return this[_isCanceled]; } + /** + * indicates if the promise progress is captured + * @return {boolean} + */ + get isCaptured(){ return this[_shadow].captured; } @@ -753,9 +758,9 @@ class CPromiseScope extends TinyEventEmitter { /** * Executes the promise executor in the PromiseScope context * @param {CPromiseExecutorFn} executor - * @param resolve - * @param reject - * @param options + * @param {Function?} resolve + * @param {Function?} reject + * @param {Object?} options * @returns {CPromiseScope} */ @@ -785,12 +790,6 @@ class CPromiseScope extends TinyEventEmitter { * @param {CPromiseScope} scope */ -/** - * @typedef {Function} CPromiseExecutorFn - * @param {Function} resolve - * @param {Function} reject - */ - /** * If value is a number it will be considered as the value for timeout option * If value is a string it will be considered as a label @@ -974,7 +973,7 @@ class CPromise extends Promise { /** * @typedef {object} AllOptions - * @property {number} limit concurrency of promise being run simultaneously + * @property {number} concurrency limit concurrency of promise being run simultaneously * @property {function} mapper mapper function to map each element * @property {boolean} ignoreResults do not collect results * @property {boolean} signatures use advanced signatures for vales resolving @@ -1315,8 +1314,9 @@ class CPromise extends Promise { */ /** + * AbortController class * @name CPromise.AbortController - * @constructor + * @class */ }