A tiny ~150-byte polyfill for Promise.prototype.finally
.
Useful for browsers that support Promise but not the .finally()
method.
npm install finally-polyfill
export default (function create(options = {}) { | |
const client = { | |
headers: options.headers || {}, | |
create | |
}; | |
const events = {}; | |
client.emit = (type, e) => { | |
events[type] && | |
events[type].slice().map(fn => { |
type State = { | |
added: boolean; | |
interval: false | ReturnType<typeof setInterval>; | |
inFrame: boolean; | |
callbacks: Array<SetFocusedCallback>; | |
}; | |
type EnrichedHTMLIFrameElement = HTMLIFrameElement & { ___onWindowFocusHandled: boolean }; | |
type SetFocusedCallback = (focused?: boolean) => void; |
/** | |
* @flow | |
*/ | |
opaque type Ruleset = { [string]: string | number }; | |
type CreateInput = { | |
[styleName: string]: CSSProperties | |
}; |
/** | |
* @flow | |
*/ | |
import VisuallyHidden from "@reach/visually-hidden"; | |
import instyle from "instyle"; | |
import * as React from "react"; | |
import { Focus } from "react-events/focus"; | |
import { Drag } from "react-events/drag"; | |
import { Press } from "react-events/press"; |
#!/bin/bash | |
username="COGNITO_USER_NAME" | |
password="PASSWORD" | |
clientid="APP_CLIENT_ID" | |
region="eu-west-1" | |
aws_profile="AWS_CLI_PROFILE" | |
response_json="" | |
json_field='IdToken' |
const AWS = require('aws-sdk'); | |
const ssm = new AWS.SSM(); | |
function getRegionFromServiceRegionResponse(ServiceRegionResponse) { | |
return ServiceRegionResponse.Parameters | |
.map((serviceRegion => serviceRegion.Value)); | |
} | |
function getServiceRegions(serviceName) { | |
let params = { |
const fs = require('fs'); | |
const { ReadableStream, TransformStream, WritableStream} = require('web-streams-polyfill/ponyfill/es2018'); | |
function createReadStream(file, opts) { | |
return new ReadableStream({ | |
start(controller) { | |
const stream = fs.createReadStream(file, opts); | |
stream.on('readable', () => { | |
const data = stream.read(); | |
controller.enqueue(data); |
import { useReducer } from 'react' | |
export function updateName(name: string) { | |
return <const>{ | |
type: 'UPDATE_NAME', | |
name | |
} | |
} | |
export function addPoints(points: number) { |
now published as https://www.swyx.io/writing/svelte-amplify-datastore
Some thoughts on the challenges of the first 2 and possibly solving them with the latter 2.
In a world where API latency is unpredictable, the way to make user interactions seem instant is essentially by lying to the user. Most implementations of optimistic updates work like this: