This example demonstrates how to convert to number to a string (and string to a number). The function will return "succeeded" and both if-statements will use the inferred type in their comparison. Open in playground
export const main = asl.deploy.asStateMachine(async () => {
const num = asl.convert.stringToNumber("42");
if (num === 42) {
const str = asl.convert.numberToString(num);
if (str === "42") {
return "succeeded";
}
}
throw new Error("failed");
});
This example demonstrates how to convert to boolean to a string (and string to a boolean). The function will return "succeeded" and both if-statements will use the inferred type in their comparison. Open in playground
export const main = asl.deploy.asStateMachine(async () => {
const bool = asl.convert.stringToBoolean("true");
if (bool === true) {
const str = asl.convert.booleanToString(bool);
if (str === "true") {
return "succeeded";
}
}
throw new Error("failed");
});