Skip to content

Commit 65f7207

Browse files
committed
chore: bump svelte deps
1 parent 352ff73 commit 65f7207

39 files changed

+3485
-53
lines changed

packages/db/src/SortedMap.d.ts

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* A Map implementation that keeps its entries sorted based on a comparator function
3+
* @template TKey - The type of keys in the map
4+
* @template TValue - The type of values in the map
5+
*/
6+
export declare class SortedMap<TKey, TValue> {
7+
private map;
8+
private sortedKeys;
9+
private comparator;
10+
/**
11+
* Creates a new SortedMap instance
12+
*
13+
* @param comparator - Optional function to compare values for sorting
14+
*/
15+
constructor(comparator?: (a: TValue, b: TValue) => number);
16+
/**
17+
* Default comparator function used when none is provided
18+
*
19+
* @param a - First value to compare
20+
* @param b - Second value to compare
21+
* @returns -1 if a < b, 1 if a > b, 0 if equal
22+
*/
23+
private defaultComparator;
24+
/**
25+
* Finds the index where a key-value pair should be inserted to maintain sort order.
26+
* Uses binary search to find the correct position based on the value.
27+
* Hence, it is in O(log n) time.
28+
*
29+
* @param key - The key to find position for
30+
* @param value - The value to compare against
31+
* @returns The index where the key should be inserted
32+
*/
33+
private indexOf;
34+
/**
35+
* Sets a key-value pair in the map and maintains sort order
36+
*
37+
* @param key - The key to set
38+
* @param value - The value to associate with the key
39+
* @returns This SortedMap instance for chaining
40+
*/
41+
set(key: TKey, value: TValue): this;
42+
/**
43+
* Gets a value by its key
44+
*
45+
* @param key - The key to look up
46+
* @returns The value associated with the key, or undefined if not found
47+
*/
48+
get(key: TKey): TValue | undefined;
49+
/**
50+
* Removes a key-value pair from the map
51+
*
52+
* @param key - The key to remove
53+
* @returns True if the key was found and removed, false otherwise
54+
*/
55+
delete(key: TKey): boolean;
56+
/**
57+
* Checks if a key exists in the map
58+
*
59+
* @param key - The key to check
60+
* @returns True if the key exists, false otherwise
61+
*/
62+
has(key: TKey): boolean;
63+
/**
64+
* Removes all key-value pairs from the map
65+
*/
66+
clear(): void;
67+
/**
68+
* Gets the number of key-value pairs in the map
69+
*/
70+
get size(): number;
71+
/**
72+
* Default iterator that returns entries in sorted order
73+
*
74+
* @returns An iterator for the map's entries
75+
*/
76+
[Symbol.iterator](): IterableIterator<[TKey, TValue]>;
77+
/**
78+
* Returns an iterator for the map's entries in sorted order
79+
*
80+
* @returns An iterator for the map's entries
81+
*/
82+
entries(): IterableIterator<[TKey, TValue]>;
83+
/**
84+
* Returns an iterator for the map's keys in sorted order
85+
*
86+
* @returns An iterator for the map's keys
87+
*/
88+
keys(): IterableIterator<TKey>;
89+
/**
90+
* Returns an iterator for the map's values in sorted order
91+
*
92+
* @returns An iterator for the map's values
93+
*/
94+
values(): IterableIterator<TValue>;
95+
/**
96+
* Executes a callback function for each key-value pair in the map in sorted order
97+
*
98+
* @param callbackfn - Function to execute for each entry
99+
*/
100+
forEach(callbackfn: (value: TValue, key: TKey, map: Map<TKey, TValue>) => void): void;
101+
}

packages/db/src/change-events.d.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import type { ChangeMessage, CurrentStateAsChangesOptions, SubscribeChangesOptions } from "./types";
2+
import type { Collection } from "./collection";
3+
import type { SingleRowRefProxy } from "./query/builder/ref-proxy";
4+
import type { BasicExpression } from "./query/ir.js";
5+
/**
6+
* Interface for a collection-like object that provides the necessary methods
7+
* for the change events system to work
8+
*/
9+
export interface CollectionLike<T extends object = Record<string, unknown>, TKey extends string | number = string | number> extends Pick<Collection<T, TKey>, `get` | `has` | `entries` | `indexes`> {
10+
}
11+
/**
12+
* Returns the current state of the collection as an array of changes
13+
* @param collection - The collection to get changes from
14+
* @param options - Options including optional where filter
15+
* @returns An array of changes
16+
* @example
17+
* // Get all items as changes
18+
* const allChanges = currentStateAsChanges(collection)
19+
*
20+
* // Get only items matching a condition
21+
* const activeChanges = currentStateAsChanges(collection, {
22+
* where: (row) => row.status === 'active'
23+
* })
24+
*
25+
* // Get only items using a pre-compiled expression
26+
* const activeChanges = currentStateAsChanges(collection, {
27+
* whereExpression: eq(row.status, 'active')
28+
* })
29+
*/
30+
export declare function currentStateAsChanges<T extends object, TKey extends string | number>(collection: CollectionLike<T, TKey>, options?: CurrentStateAsChangesOptions<T>): Array<ChangeMessage<T>>;
31+
/**
32+
* Creates a filter function from a where callback
33+
* @param whereCallback - The callback function that defines the filter condition
34+
* @returns A function that takes an item and returns true if it matches the filter
35+
*/
36+
export declare function createFilterFunction<T extends object>(whereCallback: (row: SingleRowRefProxy<T>) => any): (item: T) => boolean;
37+
/**
38+
* Creates a filter function from a pre-compiled expression
39+
* @param expression - The pre-compiled expression to evaluate
40+
* @returns A function that takes an item and returns true if it matches the filter
41+
*/
42+
export declare function createFilterFunctionFromExpression<T extends object>(expression: BasicExpression<boolean>): (item: T) => boolean;
43+
/**
44+
* Creates a filtered callback that only calls the original callback with changes that match the where clause
45+
* @param originalCallback - The original callback to filter
46+
* @param options - The subscription options containing the where clause
47+
* @returns A filtered callback function
48+
*/
49+
export declare function createFilteredCallback<T extends object>(originalCallback: (changes: Array<ChangeMessage<T>>) => void, options: SubscribeChangesOptions<T>): (changes: Array<ChangeMessage<T>>) => void;

0 commit comments

Comments
 (0)