goldstein 4.0.0 → 4.0.1
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/ChangeLog +5 -0
- package/README.md +2 -2
- package/package.json +4 -1
- package/packages/goldstein/index.js +9 -6
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -78,7 +78,7 @@ When you need to compile **Goldstein** to **JavaScript** use:
|
|
|
78
78
|
```js
|
|
79
79
|
import {compile} from 'goldstein';
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
compile(`
|
|
82
82
|
fn hello() {
|
|
83
83
|
guard text !== "world" else {
|
|
84
84
|
return ""
|
|
@@ -117,7 +117,7 @@ const source = `
|
|
|
117
117
|
|
|
118
118
|
const {keywordFn} = keywords;
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
compile(source, {
|
|
121
121
|
keywords: [
|
|
122
122
|
keywordFn,
|
|
123
123
|
function id(Parser) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "goldstein",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "JavaScript with no limits",
|
|
@@ -29,6 +29,9 @@
|
|
|
29
29
|
"wisdom": "madrun wisdom"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@putout/plugin-declare": "^2.0.1",
|
|
33
|
+
"@putout/plugin-logical-expressions": "^4.0.0",
|
|
34
|
+
"@putout/plugin-try-catch": "^3.0.0",
|
|
32
35
|
"@putout/printer": "^3.6.0",
|
|
33
36
|
"acorn": "^8.7.1",
|
|
34
37
|
"esbuild": "^0.19.2",
|
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {transform} from 'putout';
|
|
2
2
|
import {print} from '@putout/printer';
|
|
3
3
|
import {parse} from './parser.js';
|
|
4
4
|
import estreeToBabel from 'estree-to-babel';
|
|
5
|
+
import tryCatchPlugin from '@putout/plugin-try-catch';
|
|
6
|
+
import declarePlugin from '@putout/plugin-declare';
|
|
7
|
+
import logicalExpressionsPlugin from '@putout/plugin-logical-expressions';
|
|
5
8
|
|
|
6
9
|
export * from './parser.js';
|
|
7
|
-
export const compile =
|
|
10
|
+
export const compile = (source, options = {}) => {
|
|
8
11
|
const ast = estreeToBabel(parse(source, options));
|
|
9
12
|
|
|
10
|
-
|
|
13
|
+
transform(ast, source, {
|
|
11
14
|
rules: {
|
|
12
15
|
...options.rules,
|
|
13
16
|
},
|
|
14
17
|
plugins: [
|
|
15
|
-
'try-catch',
|
|
16
|
-
'declare',
|
|
17
|
-
'logical-expressions',
|
|
18
|
+
['try-catch', tryCatchPlugin],
|
|
19
|
+
['declare', declarePlugin],
|
|
20
|
+
['logical-expressions', logicalExpressionsPlugin],
|
|
18
21
|
],
|
|
19
22
|
});
|
|
20
23
|
|