mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-01 07:33:12 +08:00
* Expand static Effect support across common APIs * Preserve compiler parity across expanded Effect patterns * Fix compiler regressions exposed by Effect coverage * Bound shared type conversion traversal * Clarify conversion contracts and tidy fixtures * Run every Effect fixture in CI shards * Preserve inferred array assignments in concurrent Effect programs * Record inferred array fixture compiler ordering
24 lines
969 B
JavaScript
24 lines
969 B
JavaScript
function apply(value, operations) {
|
|
for (const operation of operations) value = operation(value);
|
|
return value;
|
|
}
|
|
function make(label) {
|
|
return class Counter {
|
|
static count = 0;
|
|
static label = label;
|
|
static empty;
|
|
static get description() { return this.label + ":" + this.count; }
|
|
static increment() { this.count += 1; return this.description; }
|
|
static pipe() { return apply(this, arguments); }
|
|
static [Symbol.iterator]() { return [label][Symbol.iterator](); }
|
|
};
|
|
}
|
|
const Left = make("left"), Right = make("right");
|
|
console.log(Left.increment(), Left.increment(), Right.increment());
|
|
console.log(Left.description, Right.description, Left.empty);
|
|
console.log(Left[Symbol.iterator]().next().value);
|
|
class Child extends make("child") {}
|
|
console.log(Child.increment(), Child.description);
|
|
console.log("label" in Child, Object.hasOwn(Child, "count"));
|
|
console.log(Child.pipe((Type) => Type.label), Left.pipe((Type) => Type.description));
|