Comparing version 1.0.40 to 1.0.41
{ | ||
"name": "js-awe", | ||
"version": "1.0.40", | ||
"version": "1.0.41", | ||
"homepage": "https://github.com/josuamanuel/js-awe", | ||
@@ -5,0 +5,0 @@ "author": "josuamanuel@hotmail.com", |
@@ -5,2 +5,4 @@ # js-awe | ||
## installation | ||
**NodeJS:** | ||
@@ -12,2 +14,14 @@ | ||
supporting import (ES Modules) and require (commonjs) | ||
```javascript | ||
import { plan } from 'js-awe' | ||
``` | ||
or | ||
```javascript | ||
const { plan } = require('js-awe') | ||
``` | ||
**100% compatible with bun:** | ||
@@ -46,2 +60,26 @@ | ||
***The libary handles the mixing of sync and async functions seamlessly*** | ||
```javascript | ||
const { plan } = require("js-awe") | ||
const result = plan().build([ | ||
val1 => Promise.resolve(val1 * 2), // fun1: 3*2 = 6 | ||
[val2 => Promise.resolve(val2 + 1), val3 => val3 + 3], // fun2A: 6 + 1 = 7; fun3: 7 + 3 = 10 | ||
[val2 => Promise.resolve(val2 - 1), val4 => val4 + 2], // fun2B: 6 - 1 = 5; fun4: 5 + 2 = 7 | ||
([val4, val5]) => val4 + val5 // fun5: 10 + 7 = 17; Promise.resolve(17) | ||
])(3) | ||
result.then(result => console.log(result)) //=> 17 | ||
``` | ||
***Simple declarative way to specify running functions sequencially or concurrently*** | ||
```plainText | ||
|-> fun2A -> fun3-| | ||
fun1 --| |-> fun5 | ||
|-> fun2B -> fun4-| | ||
``` | ||
***The purpose:*** | ||
Async await has done a lot to improve the readability of code when compared with callbacks style. But sometimes it is not a good construct, especially if you want to use it in a functional style!!! | ||
@@ -97,3 +135,3 @@ | ||
You can see below is a simple example of its use. This could be part of an API to get the bank balances of all the holdings (savings and loans) for a specific customer: | ||
You can see below a more realistic example of its use. This could be part of an API to get the bank balances of all the holdings (savings and loans) for a specific customer: | ||
@@ -100,0 +138,0 @@ ```javascript |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1130017
306