-
-
Save reggi/1d4bdb53dc6211f58b56444e4a374603 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The idea is simple, all variables defined within a function are always returned and accessable outside of the function, no variables are ever "locked" inside a function. | |
* If it's called within a Prophesy the values declared within all Prophesys are retained in a shallow object. | |
* If it's called outside a Prophesy only the return property is returned. | |
* If there is no return property all properties are returned. | |
* Everything is maintained in a plain "Object". `{}` | |
```javascript | |
const add = new Prophesy((a, b) => [ | |
() => ({a, b}), | |
() => ({return: a + b}) | |
]) | |
``` | |
```javascript | |
const example = new Prophesy(() => [ | |
() => ({a: 1, b: 2}), | |
({a, b}) => ({addResultAlpha: add(a, b)}) | |
({a, b}) => ({addResultBeta: add(addResultAlpha, b)}) | |
]) | |
``` | |
```json | |
{ | |
"a": 1, | |
"b": 2, | |
"addResultAlpha": 3, | |
"addResultAlpha.a": 1, | |
"addResultAlpha.b": 2, | |
"addResultBeta": 5, | |
"addResultBeta.a": 3, | |
"addResultBeta".b: 2 | |
} | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment