A tiny set of utility types for working with unions.
npm i gist:5d48bb3b92fa02cd9eb34ee87d3c7050| /** | |
| * Extracts and transforms members of a union type `T` based on a filter type | |
| * `F`. It's similar to `Extract<T, U>` but rather than omitting members of `T` | |
| * that aren't wholly assignable to `U`, (e.g., omitting `{ a: string }` when | |
| * `U` is `{ a: 'foo' }`), it narrows values of `T` that the filter type `F` is | |
| * assignable to (e.g., `{ a: string }` is narrowed to `{ a: 'foo' }`). | |
| * | |
| * For each member in `T` (distributing over unions), if it includes all | |
| * required keys (as determined by {@linkcode RequiredValueKey<F>}), the type is | |
| * transformed by applying the filter: |
| /** | |
| * Get a union of value types for `T` by unwrapping it recursively. | |
| * | |
| * @example | |
| * ```ts | |
| * type Scalar = string; | |
| * type ScalarValue = DeepValue<Scalar>; | |
| * // => string | |
| * | |
| * type NestedArray = [string, [number, [boolean]]]; |
| Hey, I'm ryangoree-3289505 and I have contributed to the Privacy Pools Ceremony. | |
| The following are my contribution signatures: | |
| Circuit # 1 (withdraw) | |
| Contributor # 499 | |
| Contribution Hash: 2a9dc7df 157d1efd e26552c4 3b1f5ee8 | |
| b16eaf2c f9eef243 44e49d7f 0f76aeeb | |
| 10f8272f b1e8363a 3a739711 574bf433 | |
| e0242565 275625c4 e7dbeb83 331dc5c1 |
| import { createWriteStream, writeFileSync } from 'node:fs'; | |
| import { createServer, request } from 'node:http'; | |
| // Settings // | |
| const TARGET_HOST = '127.0.0.1'; | |
| const TARGET_PORT = 8545; | |
| const PROXY_PORT = 8546; | |
| // Server // |
| type BuildTuple< | |
| L extends number, | |
| T extends any[] = [], | |
| F = unknown, | |
| > = `${L}` extends `-${number}` | |
| ? never | |
| : T["length"] extends L | |
| ? T | |
| : BuildTuple<L, [...T, F], F>; |
| /** | |
| * Get the length of a string. | |
| * | |
| * @example | |
| * ```ts | |
| * type L = Length<"hello">; // 5 | |
| * ``` | |
| */ | |
| type Length< | |
| T extends string, |
| /** | |
| * Get a superset of `T` that allows for arbitrary properties. | |
| * | |
| * @example | |
| * | |
| * ```ts | |
| * interface Order { | |
| * account: `0x${string}`; | |
| * amount: bigint; | |
| * } |
| import { PutObjectCommand, S3Client } from "@aws-sdk/client-s3"; | |
| const currentPath = []; | |
| const csvRows = ["test_name,duration,passed,error,skipped,skip_message,logs"]; | |
| let pendingRow; | |
| let diagnostics = []; | |
| /** | |
| * A test reporter that formats results as CSV and uploads to S3. | |
| * @see https://nodejs.org/api/test.html#custom-reporters |
| /** | |
| * Creates a new type that only includes properties from `T` that match the | |
| * structure defined in `M`. Useful for creating a subset of an object type | |
| * based on a mask/template type. Handles special cases for built-in objects | |
| * (Functions, Maps, Sets, Arrays) by preserving their structure rather than | |
| * attempting to deeply map their properties. | |
| * | |
| * | |
| * @example | |
| * ```ts |