Skip to content

Instantly share code, notes, and snippets.

View niksumeiko's full-sized avatar

Nik Sumeiko niksumeiko

View GitHub Profile
@andrewcourtice
andrewcourtice / task.ts
Last active April 21, 2024 09:08
Async cancellation using promise extension and abort controller
/*
This a basic implementation of task cancellation using a Promise extension
combined with an AbortController. There are 3 major benefits to this implementation:
1. Because it's just an extension of a Promise the Task is fully
compatible with the async/await syntax.
2. By using the abort controller as a native cancellation token
fetch requests and certain DOM operations can be cancelled inside the task.
3. By passing the controller from parent tasks to new child tasks an entire
async chain can be cancelled using a single AbortController.
@keriati
keriati / git-list-todos.sh
Created September 30, 2022 11:09
List todos in codebase and git blame
git grep -ino "// TODO" | cut -d":" -f1-2 | sed 's/:/ /g' | sed 's/\(.*\) \(.*\)/\2,\2 \1/g' | xargs -r -L 1 git blame -c -L > todo-lol.txt