INNER CODE UNIT · TypeScript
esc
aws-devtools-labs/aws-blocks · native/swift/Demo/typescript-demo/src/index.ts:9
function esc(str: string): string {
return str.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
}
let currentUser: { username: string } | null = null;
let currentSort: 'priority' | 'title' | 'createdAt' | undefined = undefined;
// Refresh todo list
async function refreshTodos() {
const todoList = document.getElementById('todo-list');
const errorDiv = document.getElementById('todo-error');
if (!todoList) return;
if (errorDiv) errorDiv.innerHTML = '';
if (!currentUser) {
todoList.innerHTML = '<p>Please sign in to view todos</p>';
return;