@mmstack/primitives 21.0.12 → 21.0.14
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.
package/package.json
CHANGED
|
@@ -1,4 +1,40 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ValueEqualityFn, Injector, Signal, CreateSignalOptions, DestroyRef, WritableSignal, EffectRef, EffectCleanupRegisterFn, CreateEffectOptions, ElementRef } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
type CreateChunkedOptions<T> = {
|
|
4
|
+
/**
|
|
5
|
+
* The number of items to process in each chunk.
|
|
6
|
+
* @default 50
|
|
7
|
+
*/
|
|
8
|
+
chunkSize?: number;
|
|
9
|
+
/**
|
|
10
|
+
* The delay between processing each chunk. Can be a number (milliseconds) or 'frame' to use `requestAnimationFrame`.
|
|
11
|
+
* @default 'frame'
|
|
12
|
+
*/
|
|
13
|
+
delay?: number | 'frame' | 'microtask';
|
|
14
|
+
/**
|
|
15
|
+
* A custom equality function to determine if the processed chunk has changed. This can help prevent unnecessary updates if the chunk content is the same as the previous one.
|
|
16
|
+
*/
|
|
17
|
+
equal?: ValueEqualityFn<T[]>;
|
|
18
|
+
/**
|
|
19
|
+
* An optional `Injector` to use for the internal effect. This allows the effect to have access to dependency injection if needed.
|
|
20
|
+
*/
|
|
21
|
+
injector?: Injector;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Creates a new `Signal` that processes an array of items in time-sliced chunks. This is useful for handling large lists without blocking the main thread.
|
|
25
|
+
*
|
|
26
|
+
* The returned signal will initially contain the first `chunkSize` items from the source array. It will then schedule updates to include additional chunks of items based on the specified `duration`.
|
|
27
|
+
*
|
|
28
|
+
* @template T The type of items in the array.
|
|
29
|
+
* @param source A `Signal` or a function that returns an array of items to be processed in chunks.
|
|
30
|
+
* @param options Configuration options for chunk size, delay duration, equality function, and injector.
|
|
31
|
+
* @returns A `Signal` that emits the current chunk of items being processed.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const largeList = signal(Array.from({ length: 1000 }, (_, i) => i));
|
|
35
|
+
* const chunkedList = chunked(largeList, { chunkSize: 100, duration: 100 });
|
|
36
|
+
*/
|
|
37
|
+
declare function chunked<T>(source: Signal<T[]> | (() => T[]), options?: CreateChunkedOptions<T>): Signal<T[]>;
|
|
2
38
|
|
|
3
39
|
/**
|
|
4
40
|
* Options for creating a debounced writable signal.
|
|
@@ -1312,6 +1348,10 @@ type MutableSignalStore<T> = MutableSignal<T> & {
|
|
|
1312
1348
|
} & (NonNullable<T> extends BaseType ? unknown : Readonly<{
|
|
1313
1349
|
[K in keyof Required<T>]: MutableSignalStore<NonNullable<T>[K]>;
|
|
1314
1350
|
}>);
|
|
1351
|
+
/**
|
|
1352
|
+
* Validates whether a value is a Signal Store.
|
|
1353
|
+
*/
|
|
1354
|
+
declare function isStore<T>(value: unknown): value is SignalStore<T>;
|
|
1315
1355
|
declare function toStore<T extends AnyRecord>(source: MutableSignal<T>, injector?: Injector): MutableSignalStore<T>;
|
|
1316
1356
|
declare function toStore<T extends AnyRecord>(source: WritableSignal<T>, injector?: Injector): WritableSignalStore<T>;
|
|
1317
1357
|
declare function toStore<T extends AnyRecord>(source: Signal<T>, injector?: Injector): SignalStore<T>;
|
|
@@ -1602,6 +1642,11 @@ declare function throttle<T>(source: WritableSignal<T>, opt?: CreateThrottledOpt
|
|
|
1602
1642
|
* writableSignal.set(5); // sets value of originalValue.a to 5 & triggers all signals
|
|
1603
1643
|
*/
|
|
1604
1644
|
declare function toWritable<T>(source: Signal<T>, set: (value: T) => void, update?: (updater: (value: T) => T) => void, opt?: CreateSignalOptions<T> & {
|
|
1645
|
+
/**
|
|
1646
|
+
* If `true` (the default), the returned signal will be a computed signal that depends on the source signal.
|
|
1647
|
+
* If `false`, the returned signal will be a direct wrapper around the source signal without creating a new computed signal.
|
|
1648
|
+
* @default true
|
|
1649
|
+
*/
|
|
1605
1650
|
pure?: boolean;
|
|
1606
1651
|
}): WritableSignal<T>;
|
|
1607
1652
|
|
|
@@ -1755,5 +1800,5 @@ type CreateHistoryOptions<T> = Omit<CreateSignalOptions<T[]>, 'equal'> & {
|
|
|
1755
1800
|
*/
|
|
1756
1801
|
declare function withHistory<T>(source: WritableSignal<T>, opt?: CreateHistoryOptions<T>): SignalWithHistory<T>;
|
|
1757
1802
|
|
|
1758
|
-
export { combineWith, debounce, debounced, derived, distinct, elementSize, elementVisibility, filter, indexArray, isDerivation, isMutable, keyArray, map, mapArray, mapObject, mediaQuery, mousePosition, mutable, mutableStore, nestedEffect, networkStatus, pageVisibility, pipeable, piped, prefersDarkMode, prefersReducedMotion, scrollPosition, select, sensor, sensors, store, stored, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, until, windowSize, withHistory };
|
|
1759
|
-
export type { CreateDebouncedOptions, CreateHistoryOptions, CreateStoredOptions, CreateThrottledOptions, DebouncedSignal, DerivedSignal, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, MousePositionOptions, MousePositionSignal, MutableSignal, MutableSignalStore, NetworkStatusSignal, PipeableSignal, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SignalStore, SignalWithHistory, StoredSignal, ThrottledSignal, UntilOptions, WindowSize, WindowSizeOptions, WindowSizeSignal, WritableSignalStore };
|
|
1803
|
+
export { chunked, combineWith, debounce, debounced, derived, distinct, elementSize, elementVisibility, filter, indexArray, isDerivation, isMutable, isStore, keyArray, map, mapArray, mapObject, mediaQuery, mousePosition, mutable, mutableStore, nestedEffect, networkStatus, pageVisibility, pipeable, piped, prefersDarkMode, prefersReducedMotion, scrollPosition, select, sensor, sensors, store, stored, tabSync, tap, throttle, throttled, toFakeDerivation, toFakeSignalDerivation, toStore, toWritable, until, windowSize, withHistory };
|
|
1804
|
+
export type { CreateChunkedOptions, CreateDebouncedOptions, CreateHistoryOptions, CreateStoredOptions, CreateThrottledOptions, DebouncedSignal, DerivedSignal, ElementSize, ElementSizeOptions, ElementSizeSignal, ElementVisibilityOptions, ElementVisibilitySignal, MousePositionOptions, MousePositionSignal, MutableSignal, MutableSignalStore, NetworkStatusSignal, PipeableSignal, ScrollPosition, ScrollPositionOptions, ScrollPositionSignal, SignalStore, SignalWithHistory, StoredSignal, ThrottledSignal, UntilOptions, WindowSize, WindowSizeOptions, WindowSizeSignal, WritableSignalStore };
|