@signaldb/sync 2.0.0-beta.7 → 2.0.0-beta.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{sync/src/SyncManager.d.ts → SyncManager.d.ts} +3 -4
  2. package/dist/{sync/src/applyChanges.d.ts → applyChanges.d.ts} +2 -2
  3. package/dist/{sync/src/computeChanges.d.ts → computeChanges.d.ts} +1 -1
  4. package/dist/{sync/src/getSnapshot.d.ts → getSnapshot.d.ts} +2 -2
  5. package/dist/{sync/src/sync.d.ts → sync.d.ts} +2 -2
  6. package/dist/{sync/src/types.d.ts → types.d.ts} +1 -1
  7. package/package.json +2 -2
  8. package/dist/core/src/AsyncDataAdapter.d.ts +0 -64
  9. package/dist/core/src/AutoFetchDataAdapter.d.ts +0 -112
  10. package/dist/core/src/Collection/Cursor.d.ts +0 -113
  11. package/dist/core/src/Collection/Observer.d.ts +0 -64
  12. package/dist/core/src/Collection/index.d.ts +0 -294
  13. package/dist/core/src/Collection/types.d.ts +0 -28
  14. package/dist/core/src/DataAdapter.d.ts +0 -35
  15. package/dist/core/src/DefaultDataAdapter.d.ts +0 -35
  16. package/dist/core/src/WorkerDataAdapter.d.ts +0 -25
  17. package/dist/core/src/WorkerDataAdapterHost.d.ts +0 -62
  18. package/dist/core/src/createIndex.d.ts +0 -7
  19. package/dist/core/src/createIndexProvider.d.ts +0 -8
  20. package/dist/core/src/createReactivityAdapter.d.ts +0 -8
  21. package/dist/core/src/createStorageAdapter.d.ts +0 -9
  22. package/dist/core/src/getIndexInfo.d.ts +0 -39
  23. package/dist/core/src/index.d.ts +0 -22
  24. package/dist/core/src/types/Dependency.d.ts +0 -4
  25. package/dist/core/src/types/IndexProvider.d.ts +0 -26
  26. package/dist/core/src/types/Modifier.d.ts +0 -46
  27. package/dist/core/src/types/ReactivityAdapter.d.ts +0 -6
  28. package/dist/core/src/types/Selector.d.ts +0 -46
  29. package/dist/core/src/types/Signal.d.ts +0 -4
  30. package/dist/core/src/types/StorageAdapter.d.ts +0 -20
  31. package/dist/core/src/utils/EventEmitter.d.ts +0 -71
  32. package/dist/core/src/utils/batchOnNextTick.d.ts +0 -16
  33. package/dist/core/src/utils/compact.d.ts +0 -9
  34. package/dist/core/src/utils/createSignal.d.ts +0 -14
  35. package/dist/core/src/utils/deepClone.d.ts +0 -17
  36. package/dist/core/src/utils/get.d.ts +0 -9
  37. package/dist/core/src/utils/getMatchingKeys.d.ts +0 -19
  38. package/dist/core/src/utils/intersection.d.ts +0 -9
  39. package/dist/core/src/utils/isEqual.d.ts +0 -14
  40. package/dist/core/src/utils/isFieldExpression.d.ts +0 -11
  41. package/dist/core/src/utils/match.d.ts +0 -12
  42. package/dist/core/src/utils/modify.d.ts +0 -14
  43. package/dist/core/src/utils/project.d.ts +0 -15
  44. package/dist/core/src/utils/queryId.d.ts +0 -9
  45. package/dist/core/src/utils/randomId.d.ts +0 -7
  46. package/dist/core/src/utils/reactiveOrAsync.d.ts +0 -59
  47. package/dist/core/src/utils/serializeValue.d.ts +0 -12
  48. package/dist/core/src/utils/set.d.ts +0 -13
  49. package/dist/core/src/utils/sortItems.d.ts +0 -12
  50. package/dist/core/src/utils/uniqueBy.d.ts +0 -10
  51. /package/dist/{sync/src/index.d.ts → index.d.ts} +0 -0
  52. /package/dist/{sync/src/utils → utils}/PromiseQueue.d.ts +0 -0
  53. /package/dist/{sync/src/utils → utils}/debounce.d.ts +0 -0
@@ -1,46 +0,0 @@
1
- import type { DotNotation, GetType } from './Selector';
2
- type Dictionary<T> = Record<string, T>;
3
- type PartialMapTo<T, M> = Partial<Record<DotNotation<T>, M>> & Dictionary<M>;
4
- type OnlyElementsOfArrays<T> = T extends any[] ? Partial<T[0]> : never;
5
- type ElementsOf<T> = {
6
- [P in DotNotation<T>]?: OnlyElementsOfArrays<GetType<T, P>>;
7
- };
8
- type PushModifier<T> = {
9
- [P in DotNotation<T>]?: OnlyElementsOfArrays<GetType<T, P>> | {
10
- $each?: GetType<T, P> | undefined;
11
- $position?: number | undefined;
12
- $slice?: number | undefined;
13
- $sort?: 1 | -1 | Dictionary<number> | undefined;
14
- };
15
- };
16
- type ArraysOrEach<T> = {
17
- [P in DotNotation<T>]?: OnlyElementsOfArrays<GetType<T, P>> | {
18
- $each: GetType<T, P>;
19
- };
20
- };
21
- type CurrentDateModifier = {
22
- $type: 'timestamp' | 'date';
23
- } | true;
24
- type Modifier<T extends Dictionary<any> = Dictionary<any>> = {
25
- $currentDate?: (Partial<Record<DotNotation<T>, CurrentDateModifier>> & Dictionary<CurrentDateModifier>) | undefined;
26
- $inc?: (PartialMapTo<T, number> & Dictionary<number>) | undefined;
27
- $min?: (PartialMapTo<T, Date | number> & Dictionary<Date | number>) | undefined;
28
- $max?: (PartialMapTo<T, Date | number> & Dictionary<Date | number>) | undefined;
29
- $mul?: (PartialMapTo<T, number> & Dictionary<number>) | undefined;
30
- $rename?: (PartialMapTo<T, string> & Dictionary<string>) | undefined;
31
- $set?: ({
32
- [P in DotNotation<T>]?: GetType<T, P>;
33
- } & Dictionary<any>) | undefined;
34
- $setOnInsert?: ({
35
- [P in DotNotation<T>]?: GetType<T, P>;
36
- } & Dictionary<any>) | undefined;
37
- $unset?: (PartialMapTo<T, string | boolean | 1 | 0> & Dictionary<any>) | undefined;
38
- $addToSet?: (ArraysOrEach<T> & Dictionary<any>) | undefined;
39
- $push?: (PushModifier<T> & Dictionary<any>) | undefined;
40
- $pull?: (ElementsOf<T> & Dictionary<any>) | undefined;
41
- $pullAll?: ({
42
- [P in DotNotation<T>]?: GetType<T, P>;
43
- } & Dictionary<any>) | undefined;
44
- $pop?: (PartialMapTo<T, 1 | -1> & Dictionary<1 | -1>) | undefined;
45
- };
46
- export default Modifier;
@@ -1,6 +0,0 @@
1
- import type Dependency from './Dependency';
2
- export default interface ReactivityAdapter<T extends Dependency = Dependency> {
3
- create(): T;
4
- onDispose?(callback: () => void, Dependency: T): void;
5
- isInScope?(): boolean;
6
- }
@@ -1,46 +0,0 @@
1
- export interface FieldExpression<T> {
2
- $eq?: T;
3
- $gt?: T;
4
- $gte?: T;
5
- $lt?: T;
6
- $lte?: T;
7
- $in?: T[] | undefined;
8
- $nin?: T[];
9
- $ne?: T;
10
- $exists?: boolean;
11
- $not?: FieldExpression<T>;
12
- $expr?: FieldExpression<T>;
13
- $jsonSchema?: any;
14
- $mod?: number[];
15
- $regex?: RegExp | string;
16
- $options?: string;
17
- $where?: string | ((this: T) => boolean);
18
- $all?: T[];
19
- $elemMatch?: T extends object ? Query<T> : FieldExpression<T>;
20
- $size?: number;
21
- $bitsAllClear?: any;
22
- $bitsAllSet?: any;
23
- $bitsAnyClear?: any;
24
- $bitsAnySet?: any;
25
- }
26
- export type DotNotation<T> = {
27
- [K in keyof T & string]: T[K] extends Array<infer U> ? `${K}` | `${K}.$` | `${K}.${DotNotation<U>}` : T[K] extends object ? `${K}` | `${K}.${DotNotation<T[K]>}` : `${K}`;
28
- }[keyof T & string];
29
- export type GetType<T, P extends string> = P extends `${infer H}.${infer R}` ? H extends keyof T ? T[H] extends Array<infer U> ? GetType<U, R> : GetType<T[H], R> : H extends '$' ? T extends Array<infer U> ? GetType<U, R> : never : never : P extends keyof T ? T[P] : never;
30
- type FlatQuery<T> = {
31
- [P in DotNotation<T>]?: FlatQueryValue<T, P>;
32
- };
33
- type FieldValue<U> = U extends string ? string | RegExp | FieldExpression<string> : U | FieldExpression<U>;
34
- type FlatQueryValue<T, P extends string> = GetType<T, P> extends never ? never : GetType<T, P> extends Array<infer U> ? FieldValue<U> | FieldValue<U[]> : FieldValue<GetType<T, P>>;
35
- type Query<T> = FlatQuery<T> & {
36
- $or?: Query<T>[];
37
- $and?: Query<T>[];
38
- $nor?: Query<T>[];
39
- };
40
- export type FlatSelector<T extends Record<string, any>> = FlatQuery<T> & {
41
- $or?: never;
42
- $and?: never;
43
- $nor?: never;
44
- };
45
- type Selector<T extends Record<string, any>> = Query<T>;
46
- export default Selector;
@@ -1,4 +0,0 @@
1
- export default interface Signal<T> {
2
- get(): T;
3
- set(value: T): void;
4
- }
@@ -1,20 +0,0 @@
1
- export interface Changeset<T> {
2
- added: T[];
3
- modified: T[];
4
- removed: T[];
5
- }
6
- export default interface StorageAdapter<T extends {
7
- id: I;
8
- } & Record<string, any>, I> {
9
- setup(): Promise<void>;
10
- teardown(): Promise<void>;
11
- readAll(): Promise<T[]>;
12
- readIds(positions: I[]): Promise<T[]>;
13
- createIndex(field: string): Promise<void>;
14
- dropIndex(field: string): Promise<void>;
15
- readIndex(field: string): Promise<Map<any, Set<I>>>;
16
- insert(items: T[]): Promise<void>;
17
- replace(items: T[]): Promise<void>;
18
- remove(items: T[]): Promise<void>;
19
- removeAll(): Promise<void>;
20
- }
@@ -1,71 +0,0 @@
1
- /**
2
- * A strongly‑typed EventEmitter.
3
- */
4
- export default class EventEmitter<Events extends Record<string | symbol, any>> {
5
- private _maxListeners;
6
- /**
7
- * We store a set of the listeners for each event.
8
- */
9
- private _listenerStore;
10
- setMaxListeners(max: number): this;
11
- /**
12
- * Subscribe to an event with a listener function.
13
- * @param eventName The event name (key of E).
14
- * @param listener A function that receives the emitted arguments.
15
- * @returns The emitter instance (for chaining).
16
- */
17
- on<K extends keyof Events>(eventName: K, listener: Events[K]): this;
18
- /**
19
- * Subscribe to an event with a listener function.
20
- * @param eventName The event name (key of E).
21
- * @param listener A function that receives the emitted arguments.
22
- * @returns The emitter instance (for chaining).
23
- */
24
- addListener<K extends keyof Events>(eventName: K, listener: Events[K]): this;
25
- /**
26
- * Subscribe to an event, handling it only once. Automatically removes
27
- * the listener after it fires the first time.
28
- * @param eventName The event name (key of E).
29
- * @param listener A function that receives the emitted arguments.
30
- * @returns The emitter instance (for chaining).
31
- */
32
- once<K extends keyof Events>(eventName: K, listener: Events[K]): this;
33
- /**
34
- * Unsubscribe a previously subscribed listener.
35
- * @param eventName The event name (key of E).
36
- * @param listener The original function passed to `on` or `once`.
37
- * @returns The emitter instance (for chaining).
38
- */
39
- off<K extends keyof Events>(eventName: K, listener: Events[K]): this;
40
- /**
41
- * Unsubscribe a previously subscribed listener.
42
- * @param eventName The event name (key of E).
43
- * @param listener The original function passed to `on` or `once`.
44
- * @returns The emitter instance (for chaining).
45
- */
46
- removeListener<K extends keyof Events>(eventName: K, listener: Events[K]): this;
47
- /**
48
- * Emit (dispatch) an event with a variable number of arguments.
49
- * @param eventName The event name (key of E).
50
- * @param args The arguments to pass to subscribed listeners.
51
- */
52
- emit<K extends keyof Events>(eventName: K, ...args: Parameters<Events[K]>): void;
53
- /**
54
- * Returns the array of listener functions currently registered for a given event.
55
- * @param eventName The event name (key of E).
56
- * @returns An array of listener functions.
57
- */
58
- listeners<K extends keyof Events>(eventName: K): Array<(...args: Parameters<Events[K]>) => void>;
59
- /**
60
- * Returns the number of listeners for a given event.
61
- * @param eventName The event name (key of E).
62
- * @returns The number of listeners.
63
- */
64
- listenerCount<K extends keyof Events>(eventName: K): number;
65
- /**
66
- * Removes all listeners for a given event, or all events if none is specified.
67
- * @param eventName Optional. If omitted, clears all events’ listeners.
68
- * @returns The emitter instance (for chaining).
69
- */
70
- removeAllListeners<K extends keyof Events>(eventName?: K): this;
71
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Groups multiple calls by key and flushes them on the next tick (macrotask).
3
- * @param onFlush - Function that will be called with the key and all queued items when flushing.
4
- * @returns An object with `enqueue` and `flush` methods.
5
- * @example
6
- * const batcher = batchOnNextTick<string>(async (key, items) => {
7
- * // items is an array of { args, resolve, reject }
8
- * // do something once with all args...
9
- * })
10
- *
11
- * batcher.enqueue("my-key", [arg1, arg2])
12
- */
13
- export default function batchOnNextTick<TKey>(onFlush: (key: TKey, items: any[][]) => Promise<any[]>): {
14
- enqueue: (key: TKey, args: any[]) => Promise<any>;
15
- flush: (key: TKey) => Promise<void>;
16
- };
@@ -1,9 +0,0 @@
1
- type Truthy<T> = T extends false | '' | 0 | null | undefined ? never : T;
2
- /**
3
- * Filters out falsy values (`false`, `''`, `0`, `null`, `undefined`) from an array.
4
- * @template T - The type of the elements in the array.
5
- * @param array - The array to filter.
6
- * @returns A new array containing only the truthy values from the input array.
7
- */
8
- export default function compact<T>(array: T[]): Truthy<T>[];
9
- export {};
@@ -1,14 +0,0 @@
1
- import type ReactivityAdapter from '../types/ReactivityAdapter';
2
- import type Signal from '../types/Signal';
3
- /**
4
- * Creates a reactive signal for managing state and triggering dependencies.
5
- * The signal holds a value and provides methods to get and set the value,
6
- * with optional equality checks and dependency tracking.
7
- * @template T - The type of the value held by the signal.
8
- * @param reactivityAdapter - An optional reactivity adapter for managing dependencies.
9
- * @param initialValue - The initial value of the signal.
10
- * @param isEqual - A custom equality function to determine if the new value is different
11
- * from the current value (default is `Object.is`).
12
- * @returns A signal object with `get` and `set` methods to manage the value.
13
- */
14
- export default function createSignal<T>(reactivityAdapter: ReactivityAdapter | undefined, initialValue: T, isEqual?: (a: T, b: T) => boolean): Signal<T>;
@@ -1,17 +0,0 @@
1
- /**
2
- * Performs a deep clone of a value, supporting various types including arrays, objects,
3
- * Maps, Sets, Dates, and RegExps. Functions are not supported and will throw an error.
4
- * @template T - The type of the value to clone.
5
- * @param value - The value to deep clone.
6
- * @returns A deep copy of the provided value.
7
- * @throws {Error} An error if the value is a function, as cloning functions is not supported.
8
- */
9
- export declare function clone<T>(value: T): T;
10
- /**
11
- * Creates a deep clone of an object. Uses the `structuredClone` function if available,
12
- * otherwise falls back to a manual deep clone implementation.
13
- * @template T - The type of the object to clone.
14
- * @param object - The object to deep clone.
15
- * @returns A deep copy of the provided object.
16
- */
17
- export default function deepClone<T>(object: T): T;
@@ -1,9 +0,0 @@
1
- /**
2
- * Retrieves the value at a specified path within an object.
3
- * Supports dot and bracket notation for navigating nested properties.
4
- * @template T - The type of the object to retrieve the value from.
5
- * @param value - The object to navigate.
6
- * @param path - The path (dot or bracket notation) to the desired value.
7
- * @returns The value at the specified path, or `undefined` if the path does not exist.
8
- */
9
- export default function get<T extends Record<string, any>>(value: T, path: string): any;
@@ -1,19 +0,0 @@
1
- import type { BaseItem } from '../Collection/types';
2
- import type { FlatSelector } from '../types/Selector';
3
- type KeyResult = {
4
- include: (string | null)[] | null;
5
- exclude: (string | null)[] | null;
6
- };
7
- /**
8
- * Extracts the matching and excluded keys for a given field in a selector.
9
- * Supports serialized values and `$in`/`$nin` field expressions for optimization.
10
- * Returns `null` for include/exclude if the field cannot be optimized.
11
- * @template T - The type of the items in the selector.
12
- * @template I - The type of the unique identifier for the items.
13
- * @param field - The name of the field to extract matching keys for.
14
- * @param selector - The selector object containing query criteria.
15
- * @returns An object containing arrays of serialized included and excluded keys,
16
- * or `null` if the field cannot be optimized.
17
- */
18
- export default function getMatchingKeys<T extends BaseItem<I> = BaseItem, I = any>(field: string, selector: FlatSelector<T>): KeyResult;
19
- export {};
@@ -1,9 +0,0 @@
1
- /**
2
- * Computes the intersection of multiple arrays, returning an array of unique elements
3
- * that are present in all the input arrays.
4
- * @template T - The type of elements in the arrays.
5
- * @param arrays - A variable number of arrays to compute the intersection of.
6
- * @returns An array containing the unique elements found in all the input arrays.
7
- * - If no arrays are provided, returns an empty array.
8
- */
9
- export default function intersection<T>(...arrays: T[][]): T[];
@@ -1,14 +0,0 @@
1
- /**
2
- * Compares two values for deep equality.
3
- * @param a - The first value to compare.
4
- * @param b - The second value to compare.
5
- * @returns - Returns `true` if the two values are deeply equal, otherwise `false`.
6
- * @example
7
- * isEqual({ a: 1 }, { a: 1 }); // true
8
- * isEqual([1, 2], [1, 2]); // true
9
- * isEqual(new Date(0), new Date(0)); // true
10
- * isEqual(/abc/, /abc/); // true
11
- * isEqual({ a: 1 }, { a: 2 }); // false
12
- * isEqual(null, null); // true
13
- */
14
- export default function isEqual<T, K>(a: T, b: K): boolean;
@@ -1,11 +0,0 @@
1
- import type { FieldExpression } from '../types/Selector';
2
- /**
3
- * Determines whether a given object is a valid field expression.
4
- * A field expression is an object containing query operators supported by MongoDB-style queries.
5
- * @template T - The type of the field expression.
6
- * @param expression - The object to test.
7
- * @returns A boolean indicating whether the object is a valid field expression.
8
- * - `true` if the object contains only recognized query operators.
9
- * - `false` otherwise.
10
- */
11
- export default function isFieldExpression<T>(expression: any): expression is FieldExpression<T>;
@@ -1,12 +0,0 @@
1
- import type Selector from '../types/Selector';
2
- type BaseItem = Record<string, any>;
3
- /**
4
- * Tests whether a given item matches a specified selector.
5
- * Uses the `mingo` library to evaluate the query.
6
- * @template T - The type of the item being tested.
7
- * @param item - The item to test against the selector.
8
- * @param selector - The query selector used to match the item.
9
- * @returns A boolean indicating whether the item matches the selector.
10
- */
11
- export default function match<T extends BaseItem = BaseItem>(item: T, selector: Selector<T>): boolean;
12
- export {};
@@ -1,14 +0,0 @@
1
- import type Modifier from '../types/Modifier';
2
- /**
3
- * Applies a modifier to an object and returns a new modified object.
4
- * @template T - The type of the object to be modified.
5
- * @param item - The object to be modified.
6
- * @param modifier - The modifier to apply. This can be any transformation logic.
7
- * @returns - Returns a new object with the modifications applied.
8
- * @example
9
- * const item = { a: 1, b: 2 }
10
- * const modifier = { $set: { b: 3, c: 4 } }
11
- * const result = modify(item, modifier)
12
- * // result: { a: 1, b: 3, c: 4 }
13
- */
14
- export default function modify<T extends Record<string, any>>(item: T, modifier: Modifier): T;
@@ -1,15 +0,0 @@
1
- /**
2
- * Projects the fields of an object based on a specified fields configuration.
3
- * Supports inclusion (`1`) and exclusion (`0`) of specific fields. Creates a new object
4
- * with the desired fields included or excluded, based on the configuration.
5
- * @template T - The type of the object being projected.
6
- * @param item - The original object to project fields from.
7
- * @param fields - An object defining the fields to include (`1`) or exclude (`0`).
8
- * - Keys are the field names, and values are either `1` (include) or `0` (exclude).
9
- * @returns A new object with the specified fields included or excluded.
10
- * - If all fields are set to `0`, the excluded fields are removed from the result.
11
- * - If fields are set to `1`, only the included fields are retained.
12
- */
13
- export default function project<T extends Record<string, any>>(item: T, fields: {
14
- [P in keyof T]?: 0 | 1;
15
- } & Record<string, 0 | 1>): T;
@@ -1,9 +0,0 @@
1
- import type { QueryOptions } from '../DataAdapter';
2
- import type Selector from '../types/Selector';
3
- /**
4
- * Generates a unique identifier for a query based on its selector and options.
5
- * @param selector - The selector object.
6
- * @param options - The query options object (optional).
7
- * @returns A unique identifier string for the query.
8
- */
9
- export default function queryId(selector: Selector<any>, options?: QueryOptions<any>): string;
@@ -1,7 +0,0 @@
1
- /**
2
- * creates a random id
3
- * @returns a random string of 16 characters
4
- * @example
5
- * randomId() // '1234567890abcdef'
6
- */
7
- export default function randomId(): string;
@@ -1,59 +0,0 @@
1
- export type MaybePromise<T> = T | Promise<T>;
2
- /**
3
- * Options that control execution mode (and potential future mode-specific behavior).
4
- * Keep this minimal; you can extend it later (e.g. signal, timeoutMs, debugLabel).
5
- */
6
- export type ModeOptions = {
7
- async?: boolean;
8
- };
9
- /**
10
- * A generator helper that makes TypeScript infer the “synchronous value type” for maybe-async expressions.
11
- *
12
- * Usage:
13
- * const doc = yield* unwrap(Collection.findOne(...))
14
- * const list = yield* unwrap(Collection.find(...).fetch())
15
- *
16
- * Runtime note:
17
- * This does not “unwrap” Promises by itself. It yields the value/Promise to the runner and returns the
18
- * value that the runner feeds back via `.next(...)`.
19
- * @param value The value (or Promise of a value) to yield to the runner.
20
- * @returns A generator that yields `value` and resolves to the runner-supplied unwrapped `T`.
21
- */
22
- export declare function unwrap<T>(value: MaybePromise<T>): Generator<MaybePromise<T>, T, T>;
23
- /**
24
- * Generator shape used by the factory.
25
- *
26
- * `TThis` is the type of `this` inside the generator.
27
- * `Args` are the method parameters (excluding the mode flag).
28
- * `TReturn` is the final return value of the workflow.
29
- * `TNext` is the type that is yielded/awaited and fed back via `.next(...)`.
30
- *
31
- * Note:
32
- * - For best inference at yield sites, prefer `yield* unwrap(expr)` for maybe-async expressions.
33
- */
34
- export type ReactiveOrAsyncGen<TThis, Arguments extends any[], TReturn, TNext> = (this: TThis, a: boolean, ...args: Arguments) => Generator<MaybePromise<TNext>, TReturn, TNext>;
35
- /**
36
- * The method type produced from the generator signature.
37
- * Adds overloads so that `{ async: true }` yields a `Promise<...>` return type.
38
- */
39
- export type ReactiveOrAsyncMethod<TThis, P extends any[], R, N> = {
40
- (this: TThis, ...args: P): R;
41
- (this: TThis, ...args: [...P, ModeOptions?]): MaybePromise<R>;
42
- (this: TThis, ...args: [...P, {
43
- async: true;
44
- }]): Promise<R>;
45
- } & {
46
- /** Exposes the underlying generator for composition via `yield* method.generator.call(this, a, ...)` */
47
- generator: (this: TThis, a: boolean, ...args: P) => Generator<MaybePromise<N>, R, N>;
48
- };
49
- /**
50
- * Factory that turns a generator workflow into a callable method that can run in sync (reactive) or async mode.
51
- *
52
- * Call style:
53
- * fn(a, b) -> sync/reactive return
54
- * await fn(a, b, { async: true }) -> async return
55
- * @param gen Generator workflow. Receives `(a)` which indicates async mode and should `yield`/`yield* unwrap(...)`
56
- * any values that may be Promises.
57
- * @returns A callable method with overloads plus a `.generator` property for composition.
58
- */
59
- export default function reactiveOrAsync<TThis, P extends any[], R, N>(gen: (this: TThis, a: boolean, ...args: P) => Generator<MaybePromise<N>, R, N>): ReactiveOrAsyncMethod<TThis, P, R, N>;
@@ -1,12 +0,0 @@
1
- /**
2
- * Serializes a value into a string representation.
3
- * Handles various types, including strings, numbers, booleans, dates, and objects.
4
- * Falls back to JSON stringification for unsupported types.
5
- * @param value - The value to serialize.
6
- * - Strings are returned as-is.
7
- * - Numbers and booleans are converted to their string representation.
8
- * - Dates are converted to ISO string format.
9
- * - Other values are stringified using `JSON.stringify`.
10
- * @returns A string representation of the value.
11
- */
12
- export default function serializeValue(value: any): string | null;
@@ -1,13 +0,0 @@
1
- /**
2
- * Sets a value at a specified path within an object. Creates nested structures
3
- * (arrays or objects) as needed to set the value at the correct location. Supports
4
- * deleting the key if the value is `undefined` and the `deleteIfUndefined` flag is set to `true`.
5
- * @template T - The type of the object to modify.
6
- * @template K - The type of the value to set.
7
- * @param object - The object to modify. The object is mutated directly.
8
- * @param path - The path (dot or bracket notation) where the value should be set.
9
- * @param value - The value to set at the specified path.
10
- * @param deleteIfUndefined - A boolean indicating whether to delete the key if the value is `undefined` (default: `false`).
11
- * @returns The modified object.
12
- */
13
- export default function set<T extends object, K>(object: T, path: string, value: K, deleteIfUndefined?: boolean): T;
@@ -1,12 +0,0 @@
1
- /**
2
- * Sorts an array of items based on multiple fields and their specified sort order.
3
- * Uses the `fast-sort` library for efficient sorting.
4
- * @template T - The type of the items in the array.
5
- * @param items - The array of items to be sorted.
6
- * @param sortFields - An object defining the sort order for each field.
7
- * - Keys are the field names, and values are either `1` (ascending) or `-1` (descending).
8
- * @returns A new array of items sorted based on the specified fields and their order.
9
- */
10
- export default function sortItems<T extends Record<string, any>>(items: T[], sortFields: {
11
- [P in keyof T]?: -1 | 1;
12
- } & Record<string, -1 | 1>): T[];
@@ -1,10 +0,0 @@
1
- /**
2
- * Filters an array to ensure unique values based on a specified key or transformation function.
3
- * @template T - The type of the elements in the array.
4
- * @param array - The array to filter for unique values.
5
- * @param fn - A key or transformation function to determine uniqueness.
6
- * - If a key is provided, it will use the corresponding property of each element for uniqueness.
7
- * - If a function is provided, it will use the return value of the function applied to each element for uniqueness.
8
- * @returns A new array containing only unique elements based on the specified key or transformation.
9
- */
10
- export default function uniqueBy<T>(array: T[], fn: keyof T | ((item: T) => any)): T[];
File without changes
File without changes