@graffiticode/basis 1.5.0 → 1.5.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/package.json +1 -1
- package/src/compiler.js +14 -14
package/package.json
CHANGED
package/src/compiler.js
CHANGED
|
@@ -541,17 +541,21 @@ export class Transformer extends Visitor {
|
|
|
541
541
|
}
|
|
542
542
|
RECORD(node, options, resume) {
|
|
543
543
|
let err = [];
|
|
544
|
-
let val = {};
|
|
545
544
|
let len = 0;
|
|
546
545
|
if (node.elts.length === 0) {
|
|
547
546
|
resume(err, val);
|
|
548
547
|
} else {
|
|
548
|
+
const ndx = [];
|
|
549
549
|
for (let elt of node.elts.reverse()) {
|
|
550
550
|
// For historical reasons, the bindings are reversed in the AST.
|
|
551
551
|
this.visit(elt, options, (e0, v0) => {
|
|
552
552
|
err = err.concat(e0);
|
|
553
|
-
|
|
553
|
+
ndx[elt] = v0;
|
|
554
554
|
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 do to the node being
|
|
557
|
+
// visited asynchronously.
|
|
558
|
+
const val = index.reduce((acc, v0) => ({...acc, [v0.key]: v0.val}), {});
|
|
555
559
|
resume(err, val);
|
|
556
560
|
}
|
|
557
561
|
});
|
|
@@ -613,19 +617,15 @@ export class Transformer extends Visitor {
|
|
|
613
617
|
resume(err, val);
|
|
614
618
|
}
|
|
615
619
|
DATA(node, options, resume) {
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
const err =
|
|
619
|
-
const val =
|
|
620
|
-
resume(err,
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
this.visit(node.elts[0], options, (e0, v0) => {
|
|
624
|
-
const err = e0;
|
|
625
|
-
const val = v0;
|
|
626
|
-
resume(err, val);
|
|
620
|
+
this.visit(node.elts[0], options, (e0, v0) => {
|
|
621
|
+
const data = options.data || {};
|
|
622
|
+
const err = e0;
|
|
623
|
+
const val = v0;
|
|
624
|
+
resume(err, {
|
|
625
|
+
...val,
|
|
626
|
+
...data, // External data overrides internal data.
|
|
627
627
|
});
|
|
628
|
-
}
|
|
628
|
+
});
|
|
629
629
|
}
|
|
630
630
|
PAREN(node, options, resume) {
|
|
631
631
|
this.visit(node.elts[0], options, (e0, v0) => {
|