Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function encodeImmediate(primitive: number | boolean | null | undefined): number {
switch (typeof primitive) {
case 'number':
return encodeSmi(primitive as number);
case 'boolean':
return primitive ? Immediates.True : Immediates.False;
case 'object':
// assume null
return Immediates.Null;
case 'undefined':
return Immediates.Undef;
default:
throw unreachable();
}
}
prepareArgs(): null {
throw unreachable();
}
lookupPartial(name, referrer) {
throw unreachable();
}
registerComponent(name, ComponentClass) {
lookupPartial(name: string, referrer: TemplateMeta): number {
throw unreachable();
}
function decodeSmi(smi: number): number {
switch (smi & 0b111) {
case PrimitiveType.NUMBER:
return smi >> 3;
case PrimitiveType.NEGATIVE:
return -(smi >> 3);
default:
throw unreachable();
}
}
if (right === undefined) {
if (left.type === 'Newline') {
value = '\n';
} else {
value = left.value;
}
} else if (left.type === 'Newline' && right.type === 'Newline') {
value = '\n\n';
} else if (left.type === 'Newline' && right.type === 'TextNode') {
value = `\n${right.value}`;
} else if (left.type === 'TextNode' && right.type === 'Newline') {
value = `${left.value}\n`;
} else if (left.type === 'TextNode' && right.type === 'TextNode') {
value = `${left.value}${right.value}`;
} else {
throw unreachable();
}
return {
type: 'TextNode',
span,
value,
};
}