@fbltd/async 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +36 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,10 +1,37 @@
1
- ### R&D async tools ###
1
+ # Async tools
2
2
 
3
- First of all, attention paid to creation of reactive model
4
- leveraging native JavaScript async features like Promises, (async) iterators
5
- and generators.
3
+ ## delay
4
+ delay is a function that can be executed synchronous or asynchronous.
5
+ The behaviour depends on passed arguments:
6
+ ```typescript
7
+ // Returns a promise - asynchrounous running in a non-blocking manner;
8
+ await delay(number);
9
+
10
+ // Returns nothing - synchrounous running in a blocking manner;
11
+ delay(number, true);
12
+ ```
13
+
14
+ ## getPromise
15
+ getPromise is a function that creates and returns promise, its fulfillment functions
16
+ and status flags.
17
+ Returned type is:
18
+ ```typescript
19
+ type IPromiseConfiguration<T> = {
20
+ resolve(arg: T): void, // function that resolves promise
21
+ reject(err: Error): void, // function that rejects promise
22
+ promise: Promise<T>, // promise itself
23
+ readonly isPending: boolean, // promise status flag
24
+ readonly isFulfilled: boolean, // reverted promise status flag
25
+ }
26
+ ```
27
+ There is no any management of passed data for resolving.
28
+ Returned promise is usual ES promise so it is impossible to fulfill promise twice.
6
29
 
7
- The version is 0.0.0 so keep it in mind
30
+ ## DependencyStream
31
+ ### core
32
+ Implementation of reactive model leveraging native JavaScript async features like
33
+ Promises, (async) iterators and generators.
34
+ The version is 0.0.x so keep it in mind
8
35
 
9
36
  ```typescript
10
37
  const counter = new DependencyStream<number>(0);
@@ -32,6 +59,8 @@ setInterval(() => {
32
59
  }, 1000)
33
60
  ```
34
61
 
62
+ ### Framework integrations
63
+ #### React
35
64
  Of course, there is a React integration via useStream hook:
36
65
 
37
66
  ```typescript jsx
@@ -70,4 +99,5 @@ export const Counter: React.FC<ITest> = React.memo(({
70
99
  })
71
100
  ```
72
101
 
73
- Now this package is CommonJS module but should be ESM.
102
+ ## Disclaimer
103
+ Now this package is CommonJS module but should be an ESM.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fbltd/async",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "R&D async tools",
5
5
  "exports": {
6
6
  "require": "./dist/bin/index.js",