This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"folders": [ | |
{ | |
// Path to Sway repo directory | |
"path": "./sway" | |
} | |
], | |
"extensions": { | |
"recommendations": [ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow | |
type Completion<TType: 'normal' | 'throw', TValue> = '/* internal */'; | |
type NormalCompletion<TValue> = Completion<'normal', TValue>; | |
type ThrowCompletion<TValue> = Completion<'throw', TValue>; | |
function fetchNode() { | |
if (a) throw new NotAllowedError(); | |
if (b) throw new NotFoundError(); | |
if (c) return new ProfileNode(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* @flow */ | |
export default async function doWithRetries<TFnResolveValue>( | |
retryCount: number, | |
fn: () => Promise<TFnResolveValue>, | |
): Promise<TFnResolveValue> { | |
let retriesLeft = retryCount; | |
let lastError; | |
do { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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 |