funcity 0.4.0 → 0.6.0
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.
- package/README.md +18 -3
- package/dist/index.cjs +681 -480
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +682 -481
- package/dist/index.mjs.map +1 -1
- package/dist/node.cjs +140 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.ts +12 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.mjs +122 -0
- package/dist/node.mjs.map +1 -0
- package/dist/parser.d.ts +12 -12
- package/dist/parser.d.ts.map +1 -1
- package/dist/reducer.d.ts +11 -11
- package/dist/reducer.d.ts.map +1 -1
- package/dist/scripting.d.ts +16 -9
- package/dist/scripting.d.ts.map +1 -1
- package/dist/tokenizer.d.ts +8 -8
- package/dist/tokenizer.d.ts.map +1 -1
- package/dist/types.d.ts +97 -46
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +9 -6
- package/dist/utils.d.ts.map +1 -1
- package/dist/variables/fetch-variables.d.ts +26 -0
- package/dist/variables/fetch-variables.d.ts.map +1 -0
- package/dist/variables/nodejs-variables.d.ts +26 -0
- package/dist/variables/nodejs-variables.d.ts.map +1 -0
- package/dist/{standards.d.ts → variables/standard-variables.d.ts} +14 -6
- package/dist/variables/standard-variables.d.ts.map +1 -0
- package/package.json +14 -9
- package/dist/standards.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# funcity
|
|
2
2
|
|
|
3
|
-
A functional language interpreter with text processing
|
|
3
|
+
A functional language interpreter with text processing, easy embeddable!
|
|
4
4
|
|
|
5
5
|

|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ funcity can be considered a type of [text template processor](https://en.wikiped
|
|
|
18
18
|
For example, entering code like this:
|
|
19
19
|
|
|
20
20
|
```funcity
|
|
21
|
-
Today is {{if weather.sunny}}nice{{else}}bad{{end}}weather.
|
|
21
|
+
Today is {{if weather.sunny}}nice{{else}}bad{{end}} weather.
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
Evaluates the value of the `weather` variable manually bound to the core engine beforehand and generates different text outputs:
|
|
@@ -53,7 +53,22 @@ Today is {{printWeather weather}} weather.
|
|
|
53
53
|
- `fun` defines an anonymous lambda function.
|
|
54
54
|
- `set` performs a mutable binding in the current scope.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
Furthermore, you can easily integrate this interpreter into your application:
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// Input script
|
|
60
|
+
const script = "Today is {{cond weather.sunny ‘nice’ 'bad'}} weather.";
|
|
61
|
+
|
|
62
|
+
// Run the interpreter
|
|
63
|
+
const variables = buildCandidateVariables();
|
|
64
|
+
const logs: FunCityLogEntry[] = [];
|
|
65
|
+
const text = await runScriptOnceToText(script, variables, logs);
|
|
66
|
+
|
|
67
|
+
// Display the result text
|
|
68
|
+
console.log(text);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
In other words, Funcity is a processing system that brings the power of functional programming to text template processors, enabling seamless integration into applications!
|
|
57
72
|
|
|
58
73
|
### Features
|
|
59
74
|
|