const result = await withCleanup(async (defer) => {
const fileHandle = await getFileHandle();
defer(() => fileHandle.close());
// Carry on
This file contains 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 { | |
CachedInputFileSystem, | |
FileSystem, | |
ResolveContext, | |
ResolverFactory, | |
} from 'enhanced-resolve'; | |
import { build, ImportKind, Loader } from 'esbuild'; | |
import * as Fs from 'fs'; | |
import Module from 'module'; | |
import * as Path from 'path'; |
This file contains 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
export interface AsyncLuggageFactory<TLuggage, TTraveler extends {}> { | |
(obj: TTraveler): PromiseLike<TLuggage>; | |
} | |
export interface AsyncLuggage<TLuggage, TTraveler extends {}> { | |
get(obj: TTraveler): Promise<TLuggage>; | |
} | |
const swallow = () => undefined; |
This file contains 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 * as React from 'react'; | |
import { tw } from 'twind'; | |
import type { Context } from 'twind'; | |
import { css } from 'twind/css'; | |
import { TwindContext } from './internal'; | |
export type StyledIntrinsicFactories = { | |
[TIntrinsic in keyof React.ReactHTML]: StyledHTML<TIntrinsic>; | |
}; |
This file contains 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
//@ts-check | |
'use strict'; | |
const ChildProcess = require('child_process'); | |
const Events = require('events'); | |
const Path = require('path'); | |
const { watch } = require('chokidar'); | |
const { startService } = require('esbuild'); | |
const Pino = require('pino'); |
I've found it helpful when hacking on Velcro to be able to trace the different operations performed by the sytem. Attached is an example log output when bundling up an index.js
file having a dependency on react-ui
.
If you eliminate the network (thank you polly.js), the whole thing takes 591
ms. 🎉
This file contains 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
type PromiseReject = { | |
eventName: '@@promiseReject'; | |
err: unknown; | |
}; | |
type PromiseResolve<T> = { | |
eventName: '@@promiseResolve'; | |
value: T; | |
}; |
This file contains 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
{ | |
"PendingSocket": { | |
"kind": "Intermediate", | |
"onEnter": [ | |
{} | |
], | |
"onEvent": { | |
"Error": [ | |
{ | |
"targetStates": [ |
Check out Velcro for more information.
// Load the runtime
var V={},velcro=(()=>{V.V='Velcro' in window?Promise.resolve(Velcro):new Promise(resolve=>{V.S=document.createElement('script');V.S.src='https://unpkg.com/@velcro/runtime@0.1';V.S.onload=()=>resolve(Velcro);document.head.appendChild(V.S);});V.R=V.V.then(v=>v.createRuntime());return s=>V.R.then(r=>r.import(s))})();
// Render a simple React element to document.body
var React = await velcro('react'), ReactDOM = await velcro('react-dom'); ReactDOM.render(React.createElement('h1', null, 'Hello Velcro'), document.body);
This file contains 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
'use strict'; | |
const Assert = require('assert'); | |
Assert.ok(module.webtask.secrets['jwt-scope'], 'The jwt-scope secret is required for the jwt-authz'); | |
module.exports = () => { | |
const requiredScopes = module.webtask.secrets['jwt-scope'].split(/\s+/); | |
return function middleware(req, res, next) { |
NewerOlder