Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
state.id = id;
if (type === 'item')
app.run('get-item', id, state);
else
app.run('get-list', type, state[type]);
},
'render': state => state,
'more': state => {
const list = state[state.type];
list.max = Math.min(list.max + page_size, list.items.length)
app.run('get-list', state.type, list);
},
}
app.start('my-app', {}, view, update);
document.body.addEventListener('click', e => {
const t = e.target as HTMLElement;
if (t.matches('.toggle')) {
t.classList.toggle('closed');
t.nextElementSibling && t.nextElementSibling.classList.toggle('collapsed');
}
});
function pluralize(number, label) {
if (!number) number = 0;
return (number === 1) ? number + label : number + label + 's'
}
function timeAgo(time) {
const between = Date.now() / 1000 - Number(time)