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 * as crypto from "crypto"; | |
| import * as fs from "fs"; | |
| /** | |
| * Generates the cryptographic hash (fingerprint) of a local file. | |
| * | |
| * @param filePath The path to the file. | |
| * @param algorithm The hashing algorithm to use (e.g., 'sha256', 'md5'). | |
| * | |
| * @returns A promise that resolves to the hexadecimal hash string. |
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 { createContext, memo, useContext } from "react"; | |
| export const withContextSelectors = < | |
| TProps extends object, | |
| TContextValue, | |
| TSelectors extends Record<string, (data: TContextValue) => unknown>, | |
| >( | |
| Component: React.ComponentType< | |
| TProps & { [K in keyof TSelectors]: ReturnType<TSelectors[K]> } | |
| >, |
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 canUseDOM: boolean = !!( | |
| typeof window !== 'undefined' && | |
| typeof window.document !== 'undefined' && | |
| typeof window.document.createElement !== 'undefined' | |
| ); |
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
| /** | |
| * Memoizes a function by caching only the most recent call result. | |
| * Compares arguments with the previous call using shallow equality. | |
| * | |
| * @template TArgs The function arguments type | |
| * @template TReturn The function return type | |
| * @param fn The function to memoize | |
| * @returns Memoized function that caches only the last result | |
| * | |
| * @example |
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
| // eslint-disable-next-line eslint-comments/disable-enable-pair | |
| /* eslint-disable @typescript-eslint/no-explicit-any */ | |
| import type { QueryKey } from "@tanstack/react-query"; | |
| type UnknownObject = Record<PropertyKey, unknown>; | |
| type QueryKeySegment = | |
| | string | |
| | number | |
| | 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
| export type WithRetryOptions = { | |
| /** | |
| * The maximum number of retry attempts. | |
| * Defaults to 5. | |
| * | |
| * @default 5 | |
| */ | |
| maxRetries?: number; | |
| /** |
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
| /** | |
| * A Mutex (Mutual Exclusion) class to ensure a task runs exclusively. | |
| * It prevents race conditions in asynchronous code by ensuring only one task | |
| * can access a shared resource at a time. | |
| */ | |
| export class Mutex { | |
| private _isLocked: boolean = false; | |
| private _taskQueue: Array<() => 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
| /** | |
| * Waits for a specific value to be present in local storage. | |
| * | |
| * @param key The key to look for in local storage. | |
| * @param [options] The options to configure the waiting behavior. | |
| * @returns A promise that resolves when the condition is met, or rejects if the timeout is reached. | |
| */ | |
| export const waitForStorage = ( | |
| key: string, | |
| options?: { |
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 { flushSync } from "react-dom"; | |
| /** | |
| * Flush custom event dispatch. | |
| * | |
| * React batches *all* event handlers since version 18, this introduces certain considerations when using custom event types. | |
| * | |
| * Internally, React prioritises events in the following order: | |
| * - discrete | |
| * - continuous |
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 { describe, it, expect, beforeEach } from "vitest"; | |
| import { DoubleEndedList, Positions } from "./DoubleEndedList.ts"; | |
| describe("DoubleEndedList", () => { | |
| let list: DoubleEndedList<number>; | |
| beforeEach(() => { | |
| list = new DoubleEndedList<number>(); | |
| }); |
NewerOlder