typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
18 lines (17 loc) • 527 B
JavaScript
import { isAccessor, isMutableAccessor, } from "../slot/slotTypes.js";
export class ConfigurableImpl {
bindings;
constructor(bindings) {
this.bindings = bindings;
}
with(slot, value) {
return new ConfigurableImpl([
...this.bindings,
[isAccessor(slot) || isMutableAccessor(slot) ? slot.slot : slot, value],
]);
}
pipe(transform) {
const newCfg = transform(this);
return new ConfigurableImpl([...this.bindings, ...newCfg.bindings]);
}
}