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 CHANGED
@@ -1,3 +1,8 @@
1
+ 2023.10.19, v4.9.0
2
+
3
+ feature:
4
+ - 2346464 goldstein: convert: add-array
5
+
1
6
  2023.10.19, v4.8.0
2
7
 
3
8
  feature:
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 {parse, print} from 'goldstein';
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
- ```swift
234
- const a = [1];
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goldstein",
3
- "version": "4.8.0",
3
+ "version": "4.9.0",
4
4
  "type": "module",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "JavaScript with no limits",
@@ -0,0 +1,4 @@
1
+ export const report = () => `Use 'add-array'`;
2
+ export const replace = () => ({
3
+ '__a.push(...__array)': '__a += __array',
4
+ });
@@ -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
  ],