goldstein 4.8.0 → 4.9.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/ChangeLog +5 -0
- package/README.md +13 -9
- package/package.json +1 -1
- package/packages/convert/add-array/index.js +4 -0
- package/packages/convert/index.js +2 -0
package/ChangeLog
CHANGED
package/README.md
CHANGED
|
@@ -165,7 +165,7 @@ parse(`
|
|
|
165
165
|
|
|
166
166
|
You can parse to **ESTree**:
|
|
167
167
|
|
|
168
|
-
```
|
|
168
|
+
```js
|
|
169
169
|
const options = {
|
|
170
170
|
type: 'estree',
|
|
171
171
|
};
|
|
@@ -184,8 +184,11 @@ parse(`
|
|
|
184
184
|
|
|
185
185
|
You can make any modifications to **Goldstein AST** and then `print` back to **Goldstein**:
|
|
186
186
|
|
|
187
|
-
```
|
|
188
|
-
import {
|
|
187
|
+
```js
|
|
188
|
+
import {
|
|
189
|
+
parse,
|
|
190
|
+
print,
|
|
191
|
+
} from 'goldstein';
|
|
189
192
|
|
|
190
193
|
const ast = parse(`const t = try f('hello')`);
|
|
191
194
|
const source = print(ast);
|
|
@@ -195,13 +198,13 @@ const source = print(ast);
|
|
|
195
198
|
|
|
196
199
|
You can even convert **JavaScript** to **Goldstein** with:
|
|
197
200
|
|
|
198
|
-
```
|
|
201
|
+
```js
|
|
199
202
|
import {convert} from 'goldstein';
|
|
200
203
|
|
|
201
|
-
const ast = convert(`const t = tryCatch(f, 'hello')
|
|
204
|
+
const ast = convert(`const t = tryCatch(f, 'hello')`);
|
|
202
205
|
|
|
203
206
|
// returns
|
|
204
|
-
`const t = try f('hello')
|
|
207
|
+
`const t = try f('hello')`;
|
|
205
208
|
```
|
|
206
209
|
|
|
207
210
|
## Keywords
|
|
@@ -227,11 +230,12 @@ function hello() {
|
|
|
227
230
|
}
|
|
228
231
|
```
|
|
229
232
|
|
|
230
|
-
|
|
231
233
|
### `append array`
|
|
232
234
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
+
Append new elements to an array just like in Swift:
|
|
236
|
+
|
|
237
|
+
```js
|
|
238
|
+
let a = [1];
|
|
235
239
|
|
|
236
240
|
a += [2, 3];
|
|
237
241
|
```
|
package/package.json
CHANGED
|
@@ -3,6 +3,7 @@ import {transform} from 'putout';
|
|
|
3
3
|
import {print} from '../printer/index.js';
|
|
4
4
|
import * as removeImportTry from './remove-import-try/index.js';
|
|
5
5
|
import * as applyTry from './apply-try/index.js';
|
|
6
|
+
import * as addArray from './add-array/index.js';
|
|
6
7
|
import {
|
|
7
8
|
fixEmpty,
|
|
8
9
|
parse,
|
|
@@ -13,6 +14,7 @@ export const convert = (source) => {
|
|
|
13
14
|
|
|
14
15
|
transform(ast, source, {
|
|
15
16
|
plugins: [
|
|
17
|
+
['add-array', addArray],
|
|
16
18
|
['apply-try', applyTry],
|
|
17
19
|
['remove-import-try', removeImportTry],
|
|
18
20
|
],
|