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
// @ts-check | |
///<reference types="mocha" /> | |
const assert = require('node:assert/strict'); | |
// Since the source file is TypeScript, we have to require the module itself and | |
// rely on `npm run build` having been called before running tests. ☹️ | |
const { WellKnownError } = require('./well_known_error'); |
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 | |
const CURLY_OPEN = '{'.charCodeAt(0); | |
const CURLY_CLOSE = '}'.charCodeAt(0); | |
const SQUARE_OPEN = '['.charCodeAt(0); | |
const SQUARE_CLOSE = ']'.charCodeAt(0); | |
const DOUBLE_QUOTE = '"'.charCodeAt(0); | |
const CHARACTER_COLON = ':'.charCodeAt(0); | |
const CHARACTER_COMMA = ','.charCodeAt(0); | |
const CHARACTER_BACKSLASH = '\\'.charCodeAt(0); |
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": [ |
NewerOlder