tova 0.10.1 → 0.10.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tova",
3
- "version": "0.10.1",
3
+ "version": "0.10.3",
4
4
  "description": "Tova — a modern programming language that transpiles to JavaScript, unifying frontend and backend",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -875,7 +875,9 @@ export class BaseCodegen {
875
875
  this.pushScope();
876
876
  for (const v of vars) this.declareVar(v);
877
877
  if (vars.length === 2) {
878
- p.push(`${this.i()}${labelPrefix}for${awaitKeyword} (const [${vars[0]}, ${vars[1]}] of ${tempVar}) {\n`);
878
+ // for i, v in collection => auto-enumerate: use .entries() for index-value pairs
879
+ const entriesExpr = `(Array.isArray(${tempVar}) ? ${tempVar}.entries() : Object.entries(${tempVar}))`;
880
+ p.push(`${this.i()}${labelPrefix}for${awaitKeyword} (const [${vars[0]}, ${vars[1]}] of ${entriesExpr}) {\n`);
879
881
  } else {
880
882
  p.push(`${this.i()}${labelPrefix}for${awaitKeyword} (const ${vars[0]} of ${tempVar}) {\n`);
881
883
  }
@@ -904,7 +906,9 @@ export class BaseCodegen {
904
906
  for (const v of vars) this.declareVar(v);
905
907
  const p = [];
906
908
  if (vars.length === 2) {
907
- p.push(`${this.i()}${labelPrefix}for${awaitKeyword} (const [${vars[0]}, ${vars[1]}] of ${iterExpr}) {\n`);
909
+ // for i, v in collection => auto-enumerate: use .entries() for index-value pairs
910
+ const entriesExpr = `(Array.isArray(${iterExpr}) ? ${iterExpr}.entries() : Object.entries(${iterExpr}))`;
911
+ p.push(`${this.i()}${labelPrefix}for${awaitKeyword} (const [${vars[0]}, ${vars[1]}] of ${entriesExpr}) {\n`);
908
912
  } else {
909
913
  p.push(`${this.i()}${labelPrefix}for${awaitKeyword} (const ${vars[0]} of ${iterExpr}) {\n`);
910
914
  }
package/src/version.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // Auto-generated by scripts/embed-runtime.js — do not edit
2
- export const VERSION = "0.10.1";
2
+ export const VERSION = "0.10.3";