@juulsgaard/signal-tools 18.0.5 → 18.0.6
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { signal, computed, untracked } from '@angular/core';
|
|
2
2
|
|
|
3
3
|
class SignalSet {
|
|
4
|
-
constructor(values) {
|
|
4
|
+
constructor(values = []) {
|
|
5
5
|
this._set = signal(new Set(values));
|
|
6
6
|
this.value = this._set.asReadonly();
|
|
7
7
|
this.size = computed(() => this.value().size);
|
|
@@ -139,5 +139,8 @@ class SignalSet {
|
|
|
139
139
|
}
|
|
140
140
|
//</editor-fold>
|
|
141
141
|
}
|
|
142
|
+
function signalSet(values) {
|
|
143
|
+
return new SignalSet(values);
|
|
144
|
+
}
|
|
142
145
|
|
|
143
|
-
export { SignalSet };
|
|
146
|
+
export { SignalSet, signalSet };
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed, signal, untracked } from '@angular/core';
|
|
2
2
|
import { pairwiseSignal } from '../operators.mjs';
|
|
3
3
|
|
|
4
4
|
class SignalStack {
|
|
5
|
-
constructor() {
|
|
6
|
-
this._items = signal([]);
|
|
7
|
-
/** A signal containing the items of the stack from bottom to top */
|
|
8
|
-
this.items = this._items.asReadonly();
|
|
5
|
+
constructor(values = []) {
|
|
9
6
|
/** A signal emitting the number of items in the stack */
|
|
10
7
|
this.length = computed(() => this.items().length);
|
|
11
8
|
/** A signal emitting true if there are no items in the stack */
|
|
12
9
|
this.empty = computed(() => this.length() <= 0);
|
|
10
|
+
this._items = signal(values);
|
|
11
|
+
this.items = this._items.asReadonly();
|
|
13
12
|
this.top = computed(() => this.items().at(-1));
|
|
14
13
|
this.bottom = computed(() => this.items().at(0));
|
|
15
14
|
const delta = pairwiseSignal(this.items, []);
|
|
@@ -86,5 +85,8 @@ class SignalStack {
|
|
|
86
85
|
}
|
|
87
86
|
//</editor-fold>
|
|
88
87
|
}
|
|
88
|
+
function signalStack(values) {
|
|
89
|
+
return new SignalStack(values);
|
|
90
|
+
}
|
|
89
91
|
|
|
90
|
-
export { SignalStack };
|
|
92
|
+
export { SignalStack, signalStack };
|
package/dist/index.d.ts
CHANGED
|
@@ -202,6 +202,12 @@ interface ReadonlySignalMap<TKey, TVal> extends Iterable<[TKey, TVal]> {
|
|
|
202
202
|
/** Create a signal emitting the value under a given key */
|
|
203
203
|
get(key: TKey): Signal<TVal | undefined>;
|
|
204
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* Create a new SignalMap
|
|
207
|
+
* @param values - Optional default values
|
|
208
|
+
* @category Signal Collections
|
|
209
|
+
*/
|
|
210
|
+
declare function signalMap<K, T>(values?: ReadonlyMap<K, T>): SignalMap<K, T>;
|
|
205
211
|
|
|
206
212
|
/**
|
|
207
213
|
* A Set where the state and values are accessible as signals
|
|
@@ -286,6 +292,12 @@ interface ReadonlySignalSet<T> extends Iterable<T> {
|
|
|
286
292
|
/** Create a signal emitting true if a key exists in the collection */
|
|
287
293
|
has(key: T): Signal<boolean>;
|
|
288
294
|
}
|
|
295
|
+
/**
|
|
296
|
+
* Create a new SignalSet
|
|
297
|
+
* @param values - Optional default values
|
|
298
|
+
* @category Signal Collections
|
|
299
|
+
*/
|
|
300
|
+
declare function signalSet<T>(values?: T[]): SignalSet<T>;
|
|
289
301
|
|
|
290
302
|
/**
|
|
291
303
|
* A signal FIFO queue
|
|
@@ -388,6 +400,12 @@ interface SignalQueueDelta<T> {
|
|
|
388
400
|
added: boolean;
|
|
389
401
|
item?: T;
|
|
390
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Create a new SignalQueue
|
|
405
|
+
* @param options - Optional configuration
|
|
406
|
+
* @category Signal Collections
|
|
407
|
+
*/
|
|
408
|
+
declare function signalQueue<T>(options?: SignalQueueOptions): SignalQueue<T>;
|
|
391
409
|
|
|
392
410
|
/**
|
|
393
411
|
* A signal based FILO stack
|
|
@@ -401,7 +419,7 @@ declare class SignalStack<T> {
|
|
|
401
419
|
readonly length: Signal<number>;
|
|
402
420
|
/** A signal emitting true if there are no items in the stack */
|
|
403
421
|
readonly empty: Signal<boolean>;
|
|
404
|
-
constructor();
|
|
422
|
+
constructor(values?: T[]);
|
|
405
423
|
/** Signal returning the element at the top of the stack */
|
|
406
424
|
readonly top: Signal<T | undefined>;
|
|
407
425
|
/** Signal returning the current top element and whether it was just added */
|
|
@@ -471,6 +489,12 @@ interface SignalStackDelta<T> {
|
|
|
471
489
|
item?: T;
|
|
472
490
|
added: boolean;
|
|
473
491
|
}
|
|
492
|
+
/**
|
|
493
|
+
* Create a new SignalStack
|
|
494
|
+
* @param values - Optional default values
|
|
495
|
+
* @category Signal Collections
|
|
496
|
+
*/
|
|
497
|
+
declare function signalStack<T>(values?: T[]): SignalStack<T>;
|
|
474
498
|
|
|
475
499
|
/**
|
|
476
500
|
* A class representing the state of a request
|
|
@@ -793,4 +817,4 @@ declare function requestTracker<T>(request: IValueRequestState<T>): ValueRequest
|
|
|
793
817
|
*/
|
|
794
818
|
declare function requestTracker(request: IRequestState): RequestTracker;
|
|
795
819
|
|
|
796
|
-
export { AsyncRequestState, type CreateLoadingSignalOptions, EmptyRequestState, ErrorRequestState, IRequestState, IValueRequestState, LoadingRequestState, type LoadingSignal, type LoadingSignalOptions, type ReadonlySignalMap, type ReadonlySignalSet, RequestTracker, SignalMap, SignalQueue, type SignalQueueDelta, type SignalQueueOptions, SignalSet, SignalStack, type SignalStackDelta, StaticRequestState, ValueRequestTracker, WritableRequestState, debouncedSignal, debouncedThrottledSignal, loadingSignal, requestState, requestTracker, searchSignal, subjectToSignal, throttledSignal, toLoadingSignal };
|
|
820
|
+
export { AsyncRequestState, type CreateLoadingSignalOptions, EmptyRequestState, ErrorRequestState, IRequestState, IValueRequestState, LoadingRequestState, type LoadingSignal, type LoadingSignalOptions, type ReadonlySignalMap, type ReadonlySignalSet, RequestTracker, SignalMap, SignalQueue, type SignalQueueDelta, type SignalQueueOptions, SignalSet, SignalStack, type SignalStackDelta, StaticRequestState, ValueRequestTracker, WritableRequestState, debouncedSignal, debouncedThrottledSignal, loadingSignal, requestState, requestTracker, searchSignal, signalMap, signalQueue, signalSet, signalStack, subjectToSignal, throttledSignal, toLoadingSignal };
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export { debouncedSignal, debouncedThrottledSignal, searchSignal, throttledSignal } from './async.mjs';
|
|
2
2
|
export { subjectToSignal } from './interop.mjs';
|
|
3
3
|
export { loadingSignal, toLoadingSignal } from './loading-signal.mjs';
|
|
4
|
-
export { SignalMap } from './data-structures/signal-map.mjs';
|
|
5
|
-
export { SignalSet } from './data-structures/signal-set.mjs';
|
|
6
|
-
export { SignalQueue } from './data-structures/signal-queue.mjs';
|
|
7
|
-
export { SignalStack } from './data-structures/signal-stack.mjs';
|
|
4
|
+
export { SignalMap, signalMap } from './data-structures/signal-map.mjs';
|
|
5
|
+
export { SignalSet, signalSet } from './data-structures/signal-set.mjs';
|
|
6
|
+
export { SignalQueue, signalQueue } from './data-structures/signal-queue.mjs';
|
|
7
|
+
export { SignalStack, signalStack } from './data-structures/signal-stack.mjs';
|
|
8
8
|
export { requestState } from './request-state/constructors.mjs';
|
|
9
9
|
export { IRequestState, IValueRequestState } from './request-state/request-state.mjs';
|
|
10
10
|
export { AsyncRequestState } from './request-state/async-request-state.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juulsgaard/signal-tools",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.6",
|
|
4
4
|
"description": "Tools for working with Angular signals",
|
|
5
5
|
"repository": "git@github.com:Juulsgaard/signal-tools.git",
|
|
6
6
|
"homepage": "https://juulsgaard.github.io/signal-tools/",
|
|
@@ -14,17 +14,19 @@
|
|
|
14
14
|
"dist/**"
|
|
15
15
|
],
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@angular/core": "^18.2.
|
|
17
|
+
"@angular/core": "^18.2.0",
|
|
18
18
|
"@juulsgaard/ts-tools": "^1.6.8",
|
|
19
19
|
"@juulsgaard/rxjs-tools": "^1.7.8",
|
|
20
20
|
"rxjs": "^7.8.1",
|
|
21
|
-
"
|
|
22
|
-
|
|
21
|
+
"typescript": "~5.5.4"
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"tslib": "^2.8.1"
|
|
23
25
|
},
|
|
24
26
|
"devDependencies": {
|
|
25
|
-
"@angular/core": "18.2.
|
|
26
|
-
"@juulsgaard/ts-tools": "1.6.
|
|
27
|
-
"@juulsgaard/rxjs-tools": "1.7.
|
|
27
|
+
"@angular/core": "18.2.0",
|
|
28
|
+
"@juulsgaard/ts-tools": "1.6.7",
|
|
29
|
+
"@juulsgaard/rxjs-tools": "1.7.7",
|
|
28
30
|
"@types/jest": "^29.5.14",
|
|
29
31
|
"jest": "^29.7.0",
|
|
30
32
|
"rollup": "^4.26.0",
|
|
@@ -33,8 +35,7 @@
|
|
|
33
35
|
"rxjs": "7.8.1",
|
|
34
36
|
"ts-jest": "^29.2.5",
|
|
35
37
|
"typedoc": "^0.26.11",
|
|
36
|
-
"typescript": "~5.
|
|
37
|
-
"tslib": "2.8.1"
|
|
38
|
+
"typescript": "~5.5.4"
|
|
38
39
|
},
|
|
39
40
|
"scripts": {
|
|
40
41
|
"build": "rollup -c",
|