use of "RulesDefinitions" will need to be restircted to only the base grammar, to deal with typescript's limitations
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 { exec } from 'child_process'; | |
| import { readFile, writeFile } from 'node:fs/promises'; | |
| import path from 'node:path'; | |
| import { promisify } from 'util'; | |
| import * as YAML from 'yaml'; | |
| const execAsync = promisify(exec); | |
| // update package.json imports.types path to point to the source file | |
| /** |
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
| // manually loading a module with only public apis | |
| type ModuleBody = ( | |
| exports: object, | |
| require: NodeRequire, | |
| module: Module, | |
| filename: string, | |
| dirname: string, | |
| ) => void; |
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
| interface EventEmitterOn { | |
| on(event: string, listener: (...args: any) => void): any; | |
| } | |
| type EventNames<T extends EventEmitterOn> = T extends { | |
| on(event: infer N1, listener: any): any; | |
| on(event: infer N2, listener: any): any; | |
| on(event: infer N3, listener: any): any; | |
| on(event: infer N4, listener: any): any; | |
| on(event: infer N5, listener: any): any; | |
| on(event: infer N6, listener: any): any; |
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
| { | |
| "$ref": "#/definitions/Settings", | |
| "$schema": "http://json-schema.org/draft-07/schema#", | |
| "definitions": { | |
| "AccessibilitySettings": { | |
| "additionalProperties": false, | |
| "properties": { | |
| "disableLoadingPhrases": { | |
| "type": "boolean" | |
| } |
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 type { Primitive } from 'type-fest'; | |
| interface TypeguardTuple<T> extends Omit<readonly [T, ...T[]], never> { | |
| includes(searchElement: unknown): searchElement is T; | |
| includes(searchElement: T, fromIndex?: number): boolean; | |
| } | |
| const typeguardTuple = <T extends Primitive>(tuple: readonly [T, ...T[]]) => | |
| tuple as Omit<readonly [T, ...T[]], never> as TypeguardTuple<T>; |
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 { ObjectId } from 'bson'; | |
| export class ObjectIdSet { | |
| map = new Map<number, Set<number>>(); | |
| constructor(values: Iterable<ObjectId>) { | |
| for (const value of values) { | |
| this.add(value); | |
| } | |
| } | |
| add(value: ObjectId): this { |
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
| const port = process.argv[2]; | |
| const host = process.argv[3]; | |
| const delay = 1000; | |
| const socket = new net.Socket(); | |
| socket.on('close', () => { | |
| setTimeout(() => { | |
| socket.connect(port, host); | |
| }, delay); | |
| }); |
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
| function analyseObjectId(/** @type {import('bson').ObjectId} */ oid) { | |
| const randomidBuffer = Buffer.from( | |
| oid.buffer.buffer, | |
| oid.buffer.byteOffset + 4, | |
| 5, | |
| ); | |
| const counterBuffer = Buffer.alloc(4); | |
| oid.buffer.copy(counterBuffer, 1, 9); | |
| return { | |
| timestamp: oid.buffer.readInt32BE(0), |
NewerOlder
