mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-23 06:10:02 +08:00
* Expand static three.js workflows and host integration * Preserve JavaScript class state in static three.js workflows * Preserve inferred JavaScript behavior across static workflows * Preserve inferred callables and native compatibility boundaries * Retain annotated JavaScript factory exports and bootstrap-safe call spreads * Preserve Buffer and child callback identities in static packages * Clarify JavaScript symbol spread support
29 lines
904 B
JavaScript
29 lines
904 B
JavaScript
class Curve {
|
|
point(t, target) { return target; }
|
|
sample(t) { return this.point(t); }
|
|
}
|
|
class Line extends Curve {
|
|
point(t, target = { x: 0 }) { target.x = t * 2; return target; }
|
|
}
|
|
class Offset extends Line {
|
|
point(t = 3, target = { x: 1 }) { target.x += t; return target; }
|
|
}
|
|
for (const curve of [new Line(), new Offset()]) {
|
|
console.log(curve.sample(0.5).x, curve.point().x);
|
|
const target = { x: 4 };
|
|
console.log(curve.point(2, target) === target, target.x);
|
|
}
|
|
class Loader {
|
|
parse() {}
|
|
read(value) { return this.parse(value); }
|
|
}
|
|
class TextLoader extends Loader {
|
|
parse(value = 'default') { return { text: value }; }
|
|
}
|
|
class CountLoader extends Loader {
|
|
parse(value = 5) { return value + 1; }
|
|
}
|
|
console.log(new Loader().read('x'));
|
|
console.log(new TextLoader().read('abc').text, new TextLoader().parse().text);
|
|
console.log(new CountLoader().read(8), new CountLoader().parse());
|