@graffiticode/basis 1.5.3 → 1.5.4
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 +1 -1
- package/src/compiler.js +16 -11
package/package.json
CHANGED
package/src/compiler.js
CHANGED
|
@@ -471,15 +471,21 @@ export class Transformer extends Visitor {
|
|
|
471
471
|
}
|
|
472
472
|
LIST(node, options, resume) {
|
|
473
473
|
let err = [];
|
|
474
|
-
let val = [];
|
|
475
474
|
if (node.elts.length === 0) {
|
|
476
|
-
resume(err,
|
|
475
|
+
resume(err, []);
|
|
477
476
|
} else {
|
|
477
|
+
let len = 0;
|
|
478
|
+
const ndx = [];
|
|
478
479
|
for (let elt of node.elts) {
|
|
479
480
|
this.visit(elt, options, (e0, v0) => {
|
|
480
481
|
err = err.concat(e0);
|
|
481
|
-
|
|
482
|
-
if (
|
|
482
|
+
ndx[elt] = v0;
|
|
483
|
+
if (++len === node.elts.length) {
|
|
484
|
+
// This is a little trickery to restore the original order of the
|
|
485
|
+
// elements, given that they may have been reordered due to the
|
|
486
|
+
// nodes being visited asynchronously. The node ids are reversed,
|
|
487
|
+
// so we need to add prepend the current v0 to the list.
|
|
488
|
+
const val = ndx.reduce((acc, v0) => [v0, ...acc], []);
|
|
483
489
|
resume(err, val);
|
|
484
490
|
}
|
|
485
491
|
});
|
|
@@ -541,20 +547,19 @@ export class Transformer extends Visitor {
|
|
|
541
547
|
}
|
|
542
548
|
RECORD(node, options, resume) {
|
|
543
549
|
let err = [];
|
|
544
|
-
let len = 0;
|
|
545
550
|
if (node.elts.length === 0) {
|
|
546
|
-
resume(err,
|
|
551
|
+
resume(err, {});
|
|
547
552
|
} else {
|
|
553
|
+
let len = 0;
|
|
548
554
|
const ndx = [];
|
|
549
|
-
for (let elt of node.elts
|
|
550
|
-
// For historical reasons, the bindings are reversed in the AST.
|
|
555
|
+
for (let elt of node.elts) {
|
|
551
556
|
this.visit(elt, options, (e0, v0) => {
|
|
552
557
|
err = err.concat(e0);
|
|
553
558
|
ndx[elt] = v0;
|
|
554
559
|
if (++len === node.elts.length) {
|
|
555
|
-
// This is a little trickery to restore the original order of the
|
|
556
|
-
// given that they may have been reordered
|
|
557
|
-
// visited asynchronously.
|
|
560
|
+
// This is a little trickery to restore the original order of the
|
|
561
|
+
// fields, given that they may have been reordered due to the nodes
|
|
562
|
+
// being visited asynchronously.
|
|
558
563
|
const val = ndx.reduce((acc, v0) => ({...acc, [v0.key]: v0.val}), {});
|
|
559
564
|
resume(err, val);
|
|
560
565
|
}
|