repo
stringlengths
7
64
file_url
stringlengths
81
338
file_path
stringlengths
5
257
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:25:31
2026-01-05 01:50:38
truncated
bool
2 classes
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/config/dotenv.ts
config/dotenv.ts
import path from "path"; import dotenv from "dotenv"; import { assertDefined } from "@aca/shared/assert"; function getDotEnvPath() { if (!__dirname) { // It is possible that __dirname is not set (in next.js it is by design to disable access to file system) return null; } if (process.env.NODE_ENV === "...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/deepMap.spec.ts
shared/deepMap.spec.ts
import { createDeepMap } from "./deepMap"; describe("deepMap", () => { it("does not re-run when not needed", () => { const map = createDeepMap<number>(); const fn = jest.fn(() => 42); map.getOrCreate([1, 2, 3], fn); map.getOrCreate([1, 2, 3], fn); expect(fn).toBeCalledTimes(1); map.getOrC...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hash.ts
shared/hash.ts
import { v5 as hashIntoUUID } from "uuid"; const UUID_NAMESPACE = "0db0c44a-90e6-416c-8341-d1cdb04775e9"; export function getHash(input: string) { return hashIntoUUID(input, UUID_NAMESPACE); }
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/focus.ts
shared/focus.ts
export function getFocusedElement(): HTMLElement | null { if (typeof document === "undefined") return null; if (document.activeElement && document.activeElement !== document.body) { return document.activeElement as HTMLElement; } return null; }
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/urlPattern.ts
shared/urlPattern.ts
import { Split } from "type-fest"; import UrlPattern from "url-pattern"; /** * Utility types that convert string /foo/:bar/:baz into {bar: string, baz: string} */ type PathSegments<Path extends string, Delimiter extends string> = Split<Path, Delimiter>; type PathSegment<Path extends string, Delimiter extends string...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/deepMap.ts
shared/deepMap.ts
import { EqualValueReuser, createReuseValueGroup } from "./createEqualReuser"; const targetSymbol = { symbol: Symbol("target") }; const equalReuserSymbol = { symbol: Symbol("equalReuserSymbol") }; const undefinedSymbol = { symbol: Symbol("undefined") }; interface Options { /** * Allows getting the same value for...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/domEvents.ts
shared/domEvents.ts
import { RefObject, useEffect } from "react"; import { getDocument, getWindow, useDocument } from "./context/window"; import { useBoolean } from "./hooks/useBoolean"; export function createWindowEvent<K extends keyof WindowEventMap>( type: K, handler: (event: WindowEventMap[K]) => void, options?: AddEventListen...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/isPlainObjectEqual.ts
shared/isPlainObjectEqual.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable prefer-const */ const getKeys = Object.keys; const hasOwnProperty = Object.prototype.hasOwnProperty; const isArray = Array.isArray; /** * Simplified version of isEqual that compares plain objects. * * plain object - any json-like object eg. c...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/groupByFilter.tsx
shared/groupByFilter.tsx
export function groupByFilter<T>(inputList: T[], filter: (item: T, index: number) => boolean) { const acceptedItems: T[] = []; const rejectedItems: T[] = []; inputList.forEach((item, index) => { const isPassing = filter(item, index); if (isPassing) { acceptedItems.push(item); } else { r...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/email.ts
shared/email.ts
import { APIClient, RegionEU, SendEmailRequest } from "customerio-node"; import { assertDefined } from "./assert"; const customerioApiKey = assertDefined( process.env.CUSTOMERIO_APP_API_KEY, "Cannot use mailer if there is no CUSTOMERIO_APP_API_KEY env variable." ); const customerioClient = new APIClient(customer...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/map.ts
shared/map.ts
type AnyMap = Map<unknown, unknown>; type MapKey<M extends AnyMap> = M extends Map<infer K, unknown> ? K : never; type MapValue<M extends AnyMap> = M extends Map<unknown, infer V> ? V : never; export function mapGetOrCreate<M extends Map<unknown, unknown>>( map: M, key: MapKey<M>, getter: () => MapValue<M> ): M...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/slugify.test.ts
shared/slugify.test.ts
import { slugify } from "@aca/shared/slugify"; describe("slugify", () => { const testCases = [ ["hello world", "hello-world"], ["Hello World", "hello-world"], ["hello world", "hello-world"], ["hello 🌍", "hello"], ["🌍", "globe-showing-europe-africa"], ["⎃", "U9091"], ["⎋", "U9099"], ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/backendAnalytics.ts
shared/backendAnalytics.ts
import Sentry from "@sentry/node"; import Analytics from "analytics-node"; import { User } from "@aca/db"; import { AnalyticsEventsMap, AnalyticsUserProfile } from "./types/analytics"; function getAnalyticsProfileFromDbUser(user: User): Partial<AnalyticsUserProfile> { return { id: user.id, email: user.emai...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/files.ts
shared/files.ts
/** * Will open browser file picker and return promise of picked files or null if cancelled. * * Note: Must be called during trusted event (eg. inside sync handler of onClick etc.) */ export async function pickUserFiles(): Promise<File[] | null> { return new Promise<File[] | null>((resolve) => { const input =...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/id.ts
shared/id.ts
import { useConst } from "./hooks/useConst"; const DEFAULT_ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; function getRandomCharFromAlphabet(alphabet: string): string { return alphabet.charAt(Math.floor(Math.random() * alphabet.length)); } export function generateId(idDesiredLength = ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/performance.ts
shared/performance.ts
import { getNumbersAverage } from "@aca/shared/numbers"; import { startRequestAnimationFrameLoop } from "@aca/shared/raf"; function getNow() { if (typeof performance === undefined) { return Date.now(); } // Performance 'now' is float precision time. return performance.now(); } export type EndFpsMeasuremen...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/jwt.ts
shared/jwt.ts
import jwt, { JwtPayload, Secret, SignOptions, VerifyOptions } from "jsonwebtoken"; import { isServer } from "@aca/shared/isServer"; const JWT_OPTIONS: SignOptions & VerifyOptions = { algorithm: "HS256" }; export const signJWT = (token: Parameters<typeof jwt.sign>[0], secret: Secret = process.env.AUTH_JWT_TOKEN_SECR...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/google.ts
shared/google.ts
const wrapScope = (scopeName: string) => `https://www.googleapis.com/auth/${scopeName}`; const BASE_SCOPES = ["userinfo.profile", "userinfo.email"]; export const GOOGLE_AUTH_SCOPES = BASE_SCOPES.map(wrapScope).join(" "); export const GMAIL_SCOPES = ["readonly", "modify"].map((s) => `gmail.${s}`); export const GOOGLE...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/isServer.ts
shared/isServer.ts
export const isServer = typeof window == "undefined";
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/interactionUtils.ts
shared/interactionUtils.ts
export function makeElementVisible(element?: HTMLElement | null) { element?.scrollIntoView({ behavior: "auto", block: "nearest", inline: "nearest" }); }
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/raf.ts
shared/raf.ts
export function startRequestAnimationFrameLoop(loop: () => void) { let stopCurrent: () => void; function next() { stopCurrent = createRequestAnimationFrame(() => { loop(); next(); }); } next(); return function stop() { if (stopCurrent) { stopCurrent(); } }; } export fun...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/requests.ts
shared/requests.ts
export const REQUEST_READ = "request-read"; export const REQUEST_RESPONSE = "request-response"; export const REQUEST_ACTION = "request-action"; export const REQUEST_DECISION = "request-decision"; export const REQUEST_TYPES = [REQUEST_READ, REQUEST_RESPONSE, REQUEST_ACTION, REQUEST_DECISION] as const; export type R...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/time.ts
shared/time.ts
/** * Indicates at what time app started. It can be used in various scenarios: * - measuring how long did it take to load the app * - detecting 'new' topics (we compare last activity date with app startup time.) * * This date is const for entire lifecycle of the app until browser window is refreshed */ export con...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/slugify.ts
shared/slugify.ts
import _slugify from "@sindresorhus/slugify"; async function slugifyWithEmojis(text: string): Promise<string> { const emojis = (await import("@aca/shared/emoji/slugs.json")).default; const customReplacements = Object.entries(emojis); const slug = _slugify(text, { customReplacements }); if (slug.length != 0) re...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/createEqualReuser.ts
shared/createEqualReuser.ts
import { isPlainObjectEqual } from "./isPlainObjectEqual"; import { isPrimitive } from "./primitive"; /** * Useful if we want to re-use ref to equal value. * * eg. * * const reuse = createEqualValueReuser() * const a = reuse({foo: 2}); * const b = reuse({foo: 2}); * * a === b // true * * const a = {foo: 2} ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/none.ts
shared/none.ts
/** * Used to indicate the absence of a value, in cases where `null` and `undefined` are possible values themselves, * and thus unsuitable */ export const None = Symbol("None");
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/effect.ts
shared/effect.ts
import { Cleanup, MaybeCleanup } from "./types"; export interface Effect<A extends unknown[]> { clean: Cleanup; run(...args: A): Cleanup; } export function createEffect<A extends unknown[]>(callback: (...args: A) => MaybeCleanup): Effect<A> { let currentCleanup: MaybeCleanup; function clean() { if (curre...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/array.ts
shared/array.ts
import { isEqual, sortBy } from "lodash"; import { None } from "@aca/shared/none"; export function removeElementFromArray<T>(arr: T[], element: T) { const index = arr.indexOf(element); if (index > -1) { arr.splice(index, 1); return true; } return false; } export function removeElementsFromArrayByFil...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/assert.ts
shared/assert.ts
import { IS_DEV } from "./dev"; import { Nullish, isNotNullish } from "./nullish"; export class AssertError extends Error { constructor(message: string) { super(`Assert error - ${message}`); this.name = "AssertError"; } } export type MessageOrError = string | Error; function getErrorFromMessageOrError(me...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/localStorage.ts
shared/localStorage.ts
import { throttle } from "lodash"; import { useState } from "react"; import { createChannel } from "./channel"; import { mapGetOrCreate } from "./map"; import { ValueUpdater, updateValue } from "./updateValue"; type ValueWrapper<T> = { value: T }; interface LocalStorageValueManager<T> { get: () => T; set: (value...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/jsonWithDates.ts
shared/jsonWithDates.ts
import { isDate } from "lodash"; import { removePrefix } from "./text/substring"; const JSON_DATE_PREFIX = `$$date:`; function stringifyJSONDate(date: Date) { return `${JSON_DATE_PREFIX}${date.toISOString()}`; } function maybeParseJSONDate(maybeJSONDate: string) { if (!maybeJSONDate.startsWith(JSON_DATE_PREFIX)...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/dev.ts
shared/dev.ts
import { noop } from "lodash"; export const IS_DEV = process.env.STAGE !== "staging" && process.env.STAGE !== "production"; export const IS_CI = Boolean(process.env.CI) && process.env.CI !== "false"; export const TESTING_PREFIX = "__TESTING__"; const groupsTotal = new Map<string, number>(); export function measureT...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/uuid.ts
shared/uuid.ts
import { v4 as uuid, validate } from "uuid"; export function getUUID() { return uuid(); } export function isUUID(input: string) { return validate(input); }
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/channel.ts
shared/channel.ts
import { useEffect, useState } from "react"; import { useConst } from "@aca/shared/hooks/useConst"; type Cancel = () => void; export interface Channel<T> { getLastValue(): T | null; publish(value: T): void; subscribe(subscriber: Subscriber<T>): Cancel; useLastValue(): T | null; useSubscribe(subscriber: Sub...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/log.ts
shared/log.ts
interface LoggerConfig { isEnabled?: boolean; } type LoggerConfigInput = LoggerConfig | boolean; function resolveLoggerConfigInput(input: LoggerConfigInput): LoggerConfig { if (typeof input === "boolean") { return { isEnabled: input }; } return input; } export function createLogger(key: string, configIn...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/point.ts
shared/point.ts
export interface Point { x: number; y: number; }
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/imports.ts
shared/imports.ts
import { typedKeys } from "./object"; export type AnyStarImport = Record<string, unknown>; /** * Converts 'foo' in * import * as foo from './foo' * * into list of everything that is exported */ export function convertStarImportsToList<M>(importsMap: M) { return typedKeys(importsMap).map((key) => importsMap[key...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/nullish.ts
shared/nullish.ts
export type Nullish = null | undefined; export function isNotNullish<T>(input: T | Nullish): input is T { return !isNullish(input); } export function isNullish(input: unknown): input is Nullish { return input === null || input === undefined; } export type Falsy = false | 0 | "" | null | undefined; export functi...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/colors.ts
shared/colors.ts
import Color from "color"; export function setColorOpacity(color: string, opacity: number): string { const colorInstance = new Color(color); return colorInstance .hsl() .fade(1 - opacity) .hsl() .toString(); } export function isColorDark(color: string): boolean { const colorInstance = new Color(...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/numbers.ts
shared/numbers.ts
export function formatNumberWithMaxValue(inputNumber: number, max: number, alwaysShowMoreIndicator = false) { if (inputNumber < max) { if (alwaysShowMoreIndicator) { return `${inputNumber}+`; } return `${inputNumber}`; } return `${max}+`; } export function getNumbersAverage(input: number[]) {...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/logger.ts
shared/logger.ts
import "@aca/config/dotenv"; import * as Sentry from "@sentry/node"; import pino from "pino"; import { addBackendLogAttachment } from "@aca/backend/src/debug/postAttachment"; import { assertDefined } from "@aca/shared/assert"; import { IS_DEV } from "@aca/shared/dev"; import { isLogAttachment } from "./debug/logAtta...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/primitive.ts
shared/primitive.ts
import { Primitive } from "type-fest"; export function isPrimitive(input: unknown): input is Primitive { if (typeof input === "object" || typeof input === "function") { return input === null; } return true; } export function isNotPrimitive(input: unknown): input is object { if (typeof input === "object" ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/document.ts
shared/document.ts
import { wait } from "./time"; const documentReadyPromise = new Promise<void>((resolve) => { if (typeof document === "undefined") return; if (document.readyState !== "loading") { resolve(); return; } document.addEventListener( "DOMContentLoaded", () => { resolve(); }, { once: tr...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/thunk.ts
shared/thunk.ts
/** * Thunk is a value or lazy getter of that value. It is useful if we don't want to have to eagerly provide some value, * but instead calculate it when demanded. */ export type Thunk<T> = T | (() => T); export function resolveThunk<T>(thunk: Thunk<T>): T { if (typeof thunk === "function") { return (thunk as...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/sharedState.tsx
shared/sharedState.tsx
import { autorun, computed, makeAutoObservable, runInAction } from "mobx"; import { PropsWithChildren, createContext, useContext, useEffect } from "react"; import { useConst } from "@aca/shared/hooks/useConst"; import { MessageOrError, assert } from "./assert"; import { useMethod } from "./hooks/useMethod"; export f...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/cleanup.ts
shared/cleanup.ts
import { Cleanup, MaybeCleanup } from "./types"; export type CleanupOrder = "from-first" | "from-last"; export type CleanupObject = ReturnType<typeof createCleanupObject>; /** * Useful for cases when we have to clean multiple things in effects. * * ```ts * useEffect(() => { * const cleanup = createCleanupObje...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/promises.ts
shared/promises.ts
export type MaybePromise<T> = Promise<T> | T; export async function resolveMaybePromise<T>(maybePromise: MaybePromise<T>): Promise<T> { return await maybePromise; } export function makePromiseVoidable(input: Promise<unknown>): Promise<void> { return new Promise<void>((resolve, reject) => { input.then(() => re...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/object.ts
shared/object.ts
import { isPlainObject, mergeWith, pick } from "lodash"; import { DeepPartial } from "utility-types"; import { isPlainObjectEqual } from "@aca/shared/isPlainObjectEqual"; import { generateId } from "./id"; export type AnyObject = Record<keyof unknown, unknown>; export function objectMap<O extends AnyObject, NV>( ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/types.ts
shared/types.ts
/* eslint-disable @typescript-eslint/no-explicit-any */ export type Maybe<T> = T | null | undefined; // Checks if type is composed of multiple values eg 'foo' | 'bar' export type IsUnion<T, U extends T = T> = (T extends any ? (U extends T ? false : true) : never) extends false ? false : true; export type EmptyObj...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/promiseGroup.ts
shared/promiseGroup.ts
export function createPromisesGroup() { const runningPromisesSet = new Set<Promise<unknown>>(); async function run<R>(callback: () => Promise<R>): Promise<R> { const callbackPromise = callback(); try { runningPromisesSet.add(callbackPromise); return await callbackPromise; } finally { ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/index.ts
shared/index.ts
// This is needed to allow resolving `@aca/shared' export default null;
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/attlassian.ts
shared/attlassian.ts
export const SUPPORTED_FIELDS = [ "assignee", "summary", "attachment", "description", "duedate", "timeoriginalestimate", "priority", "labels", "reporter", ]; export const jiraIssueFieldAlias: Record<typeof SUPPORTED_FIELDS[number], string> = { assignee: "Assignee", summary: "Title", description...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/namedLazy.ts
shared/namedLazy.ts
import { memoize } from "lodash"; import { ComponentType, LazyExoticComponent, lazy } from "react"; import { PickByValue } from "utility-types"; import { onDocumentReady } from "@aca/shared/document"; // eslint-disable-next-line @typescript-eslint/no-explicit-any type AnyComponent = ComponentType<any>; type WithPrel...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/events.ts
shared/events.ts
interface AnyEvent { stopPropagation: () => void; preventDefault: () => void; } export function handleWithStopPropagation<E extends AnyEvent>(handler?: (event?: E) => void) { return function handle(event?: E) { event?.stopPropagation?.(); handler?.(event); }; } export function handleWithPreventDefaul...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/updateValue.tsx
shared/updateValue.tsx
import produce from "immer"; import { isPrimitive } from "utility-types"; export type FunctionUpdater<T> = (draft: T) => void; export type ValueUpdater<T> = FunctionUpdater<T> | Partial<T>; export function updateValue<T>(currentValue: T, updater: ValueUpdater<T>): T { if (typeof updater === "function") { retur...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/debounce.ts
shared/debounce.ts
/** * Similar to regular debounce, expect calling debounced function returns cancel function. * * This cancel function allows cancelling this one specific call if it is still pending. * * Example: * * const call = cancellableDebounce(() => console.info("foo"), 500); * * const cancelA = call(); * const cancelB...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/groupBy.ts
shared/groupBy.ts
import { mapGetOrCreate } from "@aca/shared/map"; interface Group<I, G> { groupItem: G; items: I[]; } export function groupBy<I, G>( items: I[], groupItemGetter: (item: I) => G, groupKeyGetter: (groupItem: G) => string ): Group<I, G>[] { const groupsMap = new Map<string, Group<I, G>>(); for (const item...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/component.ts
shared/component.ts
import { observer } from "mobx-react"; import { ForwardRefRenderFunction, FunctionComponent, forwardRef } from "react"; import styled from "styled-components"; import { namedForwardRef } from "./react/namedForwardRef"; export function styledObserver<Props>(Component: FunctionComponent<Props>) { return styled(observ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/validation/inputValidation.tsx
shared/validation/inputValidation.tsx
import isEmail from "validator/lib/isEmail"; export type ValidationResult = string | true; export type InputValidatorFunction = (input: string) => ValidationResult; export function emailInputValidator(email: string): ValidationResult { if (!email.trim().length) { return `Email is required`; } if (!isEmail(...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/styledComponents/types.d.ts
shared/styledComponents/types.d.ts
declare module "styled-components" {}
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/typeUtils/typeGuard.ts
shared/typeUtils/typeGuard.ts
/** * This simple function allows creating objects of some type that extends some 'root type'. * * Might sound confusing, but the goal is rather simple: * * Let's say we have: * * const dict = { * foo: 1, * bar: 2 * } * * it works nice and typescript is guarding us: * dict.foo // number * dict.baz // ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/slack/clone-manifest-cli.ts
shared/slack/clone-manifest-cli.ts
import * as fs from "fs"; import path from "path"; import clipboard from "clipboardy"; import { merge } from "lodash"; import prompts from "prompts"; import manifest from "./manifest.json"; const DEFAULT_DOMAIN = "https://app.acape.la"; function cloneManifestIntoClipboard({ name, domain }: { name: string; domain: s...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/slack/index.ts
shared/slack/index.ts
import _ from "lodash"; import manifest from "./manifest.json"; export const USER_SCOPES = manifest.oauth_config.scopes.user; export const isSubsetOf = (a: unknown[], b: unknown[]) => _.intersection(a, b).length === a.length; export const SLACK_INSTALL_ERROR_KEY = "slack_install_error"; export const SLACK_WORKSPACE...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/mobx/persistedStore.ts
shared/mobx/persistedStore.ts
import { isEqual } from "lodash"; import { AnnotationsMap, CreateObservableOptions, autorun, makeAutoObservable } from "mobx"; import { IS_DEV } from "../dev"; // Took from mobx // eslint-disable-next-line @typescript-eslint/no-explicit-any type NoInfer<T> = [T][T extends any ? 0 : never]; /** * It has the same sig...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/mobx/utils.ts
shared/mobx/utils.ts
import { uniqBy } from "lodash"; import { CreateObservableOptions, IObservableValue, action, autorun, computed, observable, reaction, runInAction, toJS, untracked, } from "mobx"; import { getUUID } from "@aca/shared/uuid"; import { Effect, createEffect } from "../effect"; import { MaybeCleanup } f...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/mobx/time.ts
shared/mobx/time.ts
import { mapValues, memoize } from "lodash"; import { createAtom } from "mobx"; import { createLogger } from "@aca/shared/log"; import { createTimeout, timeDuration } from "@aca/shared/time"; /** * Ticks that will make react components re-render periodically in given interval. */ export const createMobxTick = memo...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/mobx/promiseCache.ts
shared/mobx/promiseCache.ts
import { observable, runInAction } from "mobx"; import { createFunctionWithProps } from "../functions"; import { createSharedPromise } from "../promises"; export function createObservablePromiseCache<T>(getter: () => Promise<T>, defaultValue: T) { const currentValue = observable.box(defaultValue, { deep: false }); ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/mobx/debouncedAutorun.ts
shared/mobx/debouncedAutorun.ts
import { DebounceSettings, debounce } from "lodash"; import { Reaction } from "mobx"; import { MaybeCleanup } from "../types"; export function debouncedAutorunEffect( callback: () => MaybeCleanup, time: number, debounceSettings?: DebounceSettings ) { const reaction = new Reaction("debouncedAutorun", () => { ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/emoji/list.tsx
shared/emoji/list.tsx
import { Index } from "flexsearch"; import { memoize } from "lodash"; import { typedKeys } from "@aca/shared/object"; import emojiByCategory from "./categories.json"; import emojiSearchTags from "./search.json"; import emojiSlugByNative from "./slugs.json"; export const emojiByCategories = emojiByCategory; export f...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/usePromiseState.ts
shared/hooks/usePromiseState.ts
import { useEffect, useState } from "react"; export function usePromiseState<T>(promise: Promise<T>) { const [isLoading, setIsLoading] = useState(true); const [data, setData] = useState<T | null>(null); useEffect(() => { setIsLoading(true); promise.then((result) => { setData(result); setIsLo...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useMountSafeState.ts
shared/hooks/useMountSafeState.ts
import { SetStateAction, useCallback, useState } from "react"; import { useIsMountedRef } from "./useIsMountedRef"; /** * Works exactly like useState, but will ignore updates if component is not mounted anymore. * * Useful where setState is part of any sort of async callbacks, where we want to avoid react warnings...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useGrowingArray.ts
shared/hooks/useGrowingArray.ts
import { useRef } from "react"; import { unsafeAssert } from "@aca/shared/assert"; /** * Will result array from provided one, except if input is different - it will only add new items, * never removing existing ones */ export function useGrowingArray<T>(incomingArray: T[], keyGetter?: (item: T) => string) { cons...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useClickOutside.ts
shared/hooks/useClickOutside.ts
import { maxBy, sortBy } from "lodash"; import { RefObject, useEffect } from "react"; import styled from "styled-components"; import { createShortcutListener } from "@aca/ui/keyboard/shortcutBase"; import { unshiftElement } from "../array"; import { createDocumentEvent } from "../domEvents"; import { useMethod } from...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useBoolean.ts
shared/hooks/useBoolean.ts
import { useCallback, useState } from "react"; export function useBoolean(initial: boolean) { const [value, setValue] = useState(initial); const set = useCallback(() => setValue(true), []); const unset = useCallback(() => setValue(false), []); const toggle = useCallback(() => setValue((old) => !old), []); ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useDebouncedState.ts
shared/hooks/useDebouncedState.ts
import { debounce, throttle } from "lodash"; import { useConst } from "./useConst"; import { useMountSafeState } from "./useMountSafeState"; export function useDebouncedState<S>(initial: S | (() => S), time: number) { const [value, setValue] = useMountSafeState(initial); const setThrottled = useConst(() => debou...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useEqualRef.ts
shared/hooks/useEqualRef.ts
import { isEqual } from "lodash"; import { useRef } from "react"; /** * It will return reference to previous value if new value is equal old one. * * Example. * const a = { foo: 1 } * const b = { foo: 1 } * * Note: a and b are equal, but are different object refs. * * Now * const output = useEqualRef(a); * ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useListWithNavigation.ts
shared/hooks/useListWithNavigation.ts
import { useStateList } from "react-use"; import { useShortcut } from "@aca/ui/keyboard/useShortcut"; interface UseListWithNavigationConfig { enableKeyboard: boolean; } /** * Creates a hook that manages any list and allows having one of list items active. * * It also supports having keyboard navigation with up/...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useRefValue.ts
shared/hooks/useRefValue.ts
import { RefObject, useEffect, useRef } from "react"; import { useUpdate } from "react-use"; export function useRefValue<T>(ref: RefObject<T>) { const previousRefValue = useRef(ref.current); const forceUpdate = useUpdate(); useEffect(() => { const currentValue = ref.current; const previousValue = previo...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useEqualEffect.ts
shared/hooks/useEqualEffect.ts
import { DependencyList, EffectCallback, useEffect } from "react"; import { useDependencyChangeEffect } from "./useChangeEffect"; import { useEqualRef } from "./useEqualRef"; /** * It is the same as useEffect, except it will compare deps by equality, not by reference. */ export function useEqualEffect(effect: Effec...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useNewItemInArrayEffect.ts
shared/hooks/useNewItemInArrayEffect.ts
import { useRef } from "react"; import { useDependencyChangeEffect } from "./useChangeEffect"; import { useMethod } from "./useMethod"; type Cleanup = () => void; export function useNewItemInArrayEffect<T>( items: T[], keyGetter: (item: T) => string, callback: (newItem: T) => Cleanup | void ) { const callbac...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useAsyncEffect.ts
shared/hooks/useAsyncEffect.ts
import { DependencyList, EffectCallback, useEffect, useRef } from "react"; import { createResolvablePromise } from "@aca/shared/promises"; type GetIsCancelled = () => boolean; type Cleanup = () => void; interface AsyncEffectInput { getIsCancelled: GetIsCancelled; waitForPreviousEffectToResolve(): Promise<void>;...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useMutableSearchParam.ts
shared/hooks/useMutableSearchParam.ts
import { decode, encode } from "js-base64"; import { useCallback, useMemo } from "react"; import { useSearchParam } from "react-use"; function setUrlParam(key: string, value: string) { const url = new URL(window.location.href); url.searchParams.set(key, value); window.history.replaceState({}, "", url.toString())...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useComparingEffect.ts
shared/hooks/useComparingEffect.ts
import { useEffect, useRef } from "react"; type EffectCleanup = () => void; type CompareEffect<T> = (valueNow: T, valueBefore: T) => void | EffectCleanup; export function useComparingEffect<D>(effect: CompareEffect<D>, dependency: D) { const previousValueRef = useRef<D>(dependency); const isFirstRunRef = useRef(...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useWait.ts
shared/hooks/useWait.ts
import { useEffect, useState } from "react"; import { createTimeout } from "@aca/shared/time"; export function useWait(time: number, isEnabled = true) { const [isCompleted, setIsCompleted] = useState(false); useEffect(() => { if (!isEnabled) { setIsCompleted(false); return; } if (isCompl...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useConst.ts
shared/hooks/useConst.ts
import { useState } from "react"; export function useConst<T>(factory: () => T): T { const [value] = useState(factory); return value; }
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useLastValue.ts
shared/hooks/useLastValue.ts
import { useEffect, useRef } from "react"; export function useLastValue<T>(currentValue: T) { const valueRef = useRef<T | null>(null); useEffect(() => { valueRef.current = currentValue; }); return valueRef.current; }
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useUserFocusedOnElement.ts
shared/hooks/useUserFocusedOnElement.ts
import { RefObject, useEffect } from "react"; import { createDocumentEvent, createElementEvent } from "@aca/shared/domEvents"; import { createLazyChangeCallback } from "../callbacks/lazyChangeCallback"; import { createCleanupObject } from "../cleanup"; import { cancellableDebounce } from "../debounce"; /** * Will w...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useMethod.ts
shared/hooks/useMethod.ts
import { useCallback, useRef } from "react"; import { useIsomorphicLayoutEffect } from "react-use"; type Callback<Args extends unknown[], Result> = (...args: Args) => Result; /** * Create callback that keeps the same reference during entire lifecycle of the component while having access to fresh * variables values ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useHashChangeEffect.ts
shared/hooks/useHashChangeEffect.ts
import { useState } from "react"; import { useWindowEvent } from "@aca/shared/domEvents"; export function useHashChangeEffect(callback: (hash: string | null) => void) { useWindowEvent("hashchange", () => { const hashStringOnly = location.hash.replace(/^#/, ""); if (!hashStringOnly.length) { callback(...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/usePausableTimeout.ts
shared/hooks/usePausableTimeout.ts
import { useEffect, useRef } from "react"; import { createTimeout } from "@aca/shared/time"; import { useMethod } from "./useMethod"; export function usePausableTimeout(time: number, isPlaying: boolean, callback: () => void) { const timeRemainingRef = useRef(time); const callbackRef = useMethod(callback); use...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useElementHasOverflow.ts
shared/hooks/useElementHasOverflow.ts
import { RefObject, useState } from "react"; import { useResizeCallback } from "./useResizeCallback"; function getElementHasOverflow(element: HTMLElement) { return element.scrollWidth > element.clientWidth || element.scrollHeight > element.clientWidth; } export function useElementHasOverflow(ref: RefObject<HTMLEle...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useResizeCallback.ts
shared/hooks/useResizeCallback.ts
import { RefObject } from "react"; import { useIsomorphicLayoutEffect } from "react-use"; import { useMethod } from "./useMethod"; function getSizeChange(previous: DOMRectReadOnly, current: DOMRectReadOnly) { const widthChange = Math.abs(previous.width - current.width); const heightChange = Math.abs(previous.heig...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useIsElementOrChildHovered.ts
shared/hooks/useIsElementOrChildHovered.ts
import { RefObject, useEffect } from "react"; import { createElementEvent } from "@aca/shared/domEvents"; import { useBoolean } from "./useBoolean"; export function useIsElementOrChildHovered(ref: RefObject<HTMLElement>) { const [isHovered, { set: setHovered, unset: unsetHovered }] = useBoolean(false); useEffec...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useElementAttribute.ts
shared/hooks/useElementAttribute.ts
import { RefObject, useEffect, useState } from "react"; /** * Will return current value of provided attribute and watch attribute value changes. */ export function useDOMAttributeValue(ref: RefObject<HTMLElement>, attributeName: string) { const [value, setValue] = useState(() => getElementAttribute(ref.current, at...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useChangeEffect.ts
shared/hooks/useChangeEffect.ts
import { DependencyList, EffectCallback, useEffect, useLayoutEffect, useRef } from "react"; /** * Works the same way as normal useEffect, except it ignores the first call of the effect. * * It means it can be used to track changes of dependencies after initial render. */ export function useDependencyChangeEffect(c...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useDoubleClick.ts
shared/hooks/useDoubleClick.ts
import { RefObject, useEffect } from "react"; import { createElementEvent } from "@aca/shared/domEvents"; import { useMethod } from "./useMethod"; interface Options { isEnabled?: boolean; secondClickWaitTime?: number; } const DEFAULT_SECOND_CLICK_TIMEOUT = 500; /** * Allows attaching double click event to an ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useBoundingBox.ts
shared/hooks/useBoundingBox.ts
import { RefObject } from "react"; import { useIsomorphicLayoutEffect } from "react-use"; import { useEqualState } from "./useEqualState"; import { useResizeCallback } from "./useResizeCallback"; type PlainDomRect = Omit<DOMRect, "toJSON">; function getDefaultSize(ref: RefObject<HTMLElement>): PlainDomRect { if (r...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useDebouncedValue.ts
shared/hooks/useDebouncedValue.ts
import { debounce } from "lodash"; import { useCallback, useEffect, useState } from "react"; import { createTimeout } from "@aca/shared/time"; interface DebouncedBooleanOptions { onDelay?: number; offDelay?: number; } export function useDebouncedBoolean( value: boolean, // Time can be passed as milliseconds ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useIsMountedRef.ts
shared/hooks/useIsMountedRef.ts
import { useRef } from "react"; import { useUnmount } from "react-use"; export function useIsMountedRef() { const isMountedRef = useRef(true); useUnmount(() => { isMountedRef.current = false; }); return isMountedRef; }
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false
acapela/monorepo
https://github.com/acapela/monorepo/blob/27047fac40321891abe42d04d40a14ca329f87ee/shared/hooks/useSharedRef.ts
shared/hooks/useSharedRef.ts
import { MutableRefObject, useMemo } from "react"; type InputRef<T> = ((instance: T | null) => void) | MutableRefObject<T | null> | null; function createRefWithCallback<T>(initial: T, callback: (value: T) => void) { let value = initial; const ref: MutableRefObject<T> = { get current() { return value; ...
typescript
MIT
27047fac40321891abe42d04d40a14ca329f87ee
2026-01-05T05:01:22.776906Z
false