Alican Çubukçuoğlu AlicanC
- Istanbul, Turkey
- Sign in to view email
- https://twitter.com/alicanc
View gitClean.sh
# Helpers | |
ask() { | |
# http://djm.me/ask | |
local prompt default REPLY | |
while true; do | |
if [ "${2:-}" = "Y" ]; then | |
prompt="Y/n" | |
default=Y | |
elif [ "${2:-}" = "N" ]; then |
View doWithRetries.js
/* @flow */ | |
export default async function doWithRetries<TFnResolveValue>( | |
retryCount: number, | |
fn: () => Promise<TFnResolveValue>, | |
): Promise<TFnResolveValue> { | |
let retriesLeft = retryCount; | |
let lastError; | |
do { |
View asyncComponentDidMount.js
import _ from 'lodash'; | |
export default function asyncComponentDidMount(rejector = 'Component was unmounted.') { | |
return (component) => { | |
const cancelMap = new WeakMap(); | |
const isCancelled = async (promise) => { | |
let cancelled = cancelMap.get(this); | |
if (cancelled) return cancelled; |
View ordered-limited-promise-queue.js
/* | |
Queue | |
- Push task runners (async functions) to its "list" | |
- Run it | |
- Subscribe to its observable and wait for results | |
Runs "threadCount" amount of tasks in the "list" | |
When any of those tasks are completed, runs another task | |
If task #2 finishes before #1, it waits for #1 to finish and published before it publishes #2 so results are delivered in order |