@atscript/core 0.2.16 → 0.2.17
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/dist/index.cjs +26 -0
- package/dist/index.mjs +26 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4054,6 +4054,7 @@ function definition(pipes) {
|
|
|
4054
4054
|
return true;
|
|
4055
4055
|
}
|
|
4056
4056
|
const resolvedPipes = pipes.map((p) => typeof p === "function" ? p() : p);
|
|
4057
|
+
skipLeadingOperator(fork, opts);
|
|
4057
4058
|
const node = runPipesOnce(resolvedPipes, fork);
|
|
4058
4059
|
if (node) {
|
|
4059
4060
|
fork.accepted();
|
|
@@ -4078,9 +4079,11 @@ function definition(pipes) {
|
|
|
4078
4079
|
fork.unexpected(false, "Unexpected end of group");
|
|
4079
4080
|
break;
|
|
4080
4081
|
}
|
|
4082
|
+
const isComma = fork.$.text === ",";
|
|
4081
4083
|
fork.accepted();
|
|
4082
4084
|
fork.move();
|
|
4083
4085
|
fork.skip(opts.skip);
|
|
4086
|
+
if (isComma) skipLeadingOperator(fork, opts);
|
|
4084
4087
|
} else {
|
|
4085
4088
|
if (fork.$) fork.unexpected();
|
|
4086
4089
|
break;
|
|
@@ -4133,6 +4136,29 @@ function definition(pipes) {
|
|
|
4133
4136
|
}
|
|
4134
4137
|
};
|
|
4135
4138
|
}
|
|
4139
|
+
const LEADING_OPERATORS = ["|", "&"];
|
|
4140
|
+
/**
|
|
4141
|
+
* Step over one `|` or `&` written before the first member of a union or
|
|
4142
|
+
* intersection (a formatting style: one member per line, each starting with the
|
|
4143
|
+
* operator). It carries no meaning. An operator that no member follows (the end
|
|
4144
|
+
* of the block, or more punctuation) is left in place, so it is reported as
|
|
4145
|
+
* unexpected and the rest of the block parses as before.
|
|
4146
|
+
*/ function skipLeadingOperator(ni, opts) {
|
|
4147
|
+
const text = LEADING_OPERATORS.filter((op) => opts.sep.includes(op));
|
|
4148
|
+
if (text.length === 0) return;
|
|
4149
|
+
const ahead = ni.fork().skip(opts.skip);
|
|
4150
|
+
if (!ahead.satisfies({
|
|
4151
|
+
node: "punctuation",
|
|
4152
|
+
text
|
|
4153
|
+
})) return;
|
|
4154
|
+
const member = ahead.next(opts.skip).$;
|
|
4155
|
+
if (member && member.type !== "punctuation") {
|
|
4156
|
+
ni.unfork(ahead);
|
|
4157
|
+
ni.accepted();
|
|
4158
|
+
ni.move();
|
|
4159
|
+
ni.skip(opts.skip);
|
|
4160
|
+
}
|
|
4161
|
+
}
|
|
4136
4162
|
function unwrap(attr) {
|
|
4137
4163
|
const opts = { pipes: [] };
|
|
4138
4164
|
return {
|
package/dist/index.mjs
CHANGED
|
@@ -4023,6 +4023,7 @@ function definition(pipes) {
|
|
|
4023
4023
|
return true;
|
|
4024
4024
|
}
|
|
4025
4025
|
const resolvedPipes = pipes.map((p) => typeof p === "function" ? p() : p);
|
|
4026
|
+
skipLeadingOperator(fork, opts);
|
|
4026
4027
|
const node = runPipesOnce(resolvedPipes, fork);
|
|
4027
4028
|
if (node) {
|
|
4028
4029
|
fork.accepted();
|
|
@@ -4047,9 +4048,11 @@ function definition(pipes) {
|
|
|
4047
4048
|
fork.unexpected(false, "Unexpected end of group");
|
|
4048
4049
|
break;
|
|
4049
4050
|
}
|
|
4051
|
+
const isComma = fork.$.text === ",";
|
|
4050
4052
|
fork.accepted();
|
|
4051
4053
|
fork.move();
|
|
4052
4054
|
fork.skip(opts.skip);
|
|
4055
|
+
if (isComma) skipLeadingOperator(fork, opts);
|
|
4053
4056
|
} else {
|
|
4054
4057
|
if (fork.$) fork.unexpected();
|
|
4055
4058
|
break;
|
|
@@ -4102,6 +4105,29 @@ function definition(pipes) {
|
|
|
4102
4105
|
}
|
|
4103
4106
|
};
|
|
4104
4107
|
}
|
|
4108
|
+
const LEADING_OPERATORS = ["|", "&"];
|
|
4109
|
+
/**
|
|
4110
|
+
* Step over one `|` or `&` written before the first member of a union or
|
|
4111
|
+
* intersection (a formatting style: one member per line, each starting with the
|
|
4112
|
+
* operator). It carries no meaning. An operator that no member follows (the end
|
|
4113
|
+
* of the block, or more punctuation) is left in place, so it is reported as
|
|
4114
|
+
* unexpected and the rest of the block parses as before.
|
|
4115
|
+
*/ function skipLeadingOperator(ni, opts) {
|
|
4116
|
+
const text = LEADING_OPERATORS.filter((op) => opts.sep.includes(op));
|
|
4117
|
+
if (text.length === 0) return;
|
|
4118
|
+
const ahead = ni.fork().skip(opts.skip);
|
|
4119
|
+
if (!ahead.satisfies({
|
|
4120
|
+
node: "punctuation",
|
|
4121
|
+
text
|
|
4122
|
+
})) return;
|
|
4123
|
+
const member = ahead.next(opts.skip).$;
|
|
4124
|
+
if (member && member.type !== "punctuation") {
|
|
4125
|
+
ni.unfork(ahead);
|
|
4126
|
+
ni.accepted();
|
|
4127
|
+
ni.move();
|
|
4128
|
+
ni.skip(opts.skip);
|
|
4129
|
+
}
|
|
4130
|
+
}
|
|
4105
4131
|
function unwrap(attr) {
|
|
4106
4132
|
const opts = { pipes: [] };
|
|
4107
4133
|
return {
|