typegpu
Version:
A thin layer between JS and WebGPU/WGSL that improves development experience and allows for faster iteration.
15 lines (14 loc) • 519 B
JavaScript
export function stripTemplate(arg, ...values) {
return isTemplateStringsArray(arg) ? templateLiteralIdentity(arg, ...values) : arg;
}
function isTemplateStringsArray(value) {
return (Array.isArray(value) &&
'raw' in value &&
Array.isArray(value.raw) &&
value.raw.every((item) => typeof item === 'string'));
}
function templateLiteralIdentity(strings, ...values) {
return strings
.slice(1)
.reduce((acc, elem, index) => `${acc}${values[index]}${elem}`, strings[0]);
}