• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

satanTime / ngrx-entity-relationship / 475a6fe6-862e-42f9-b95e-23a40dfab79b

26 Jan 2024 01:24AM UTC coverage: 100.0%. Remained the same
475a6fe6-862e-42f9-b95e-23a40dfab79b

Pull #2048

circleci

web-flow
chore(deps): update dependency husky to v9
Pull Request #2048: chore(deps): update dependency husky to v9

443 of 443 branches covered (100.0%)

Branch coverage included in aggregate %.

680 of 680 relevant lines covered (100.0%)

33.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/libs/ngrx-entity-relationship/rxjs/src/operators/relationships.ts
1
import {HANDLER_ROOT_ENTITIES, HANDLER_ROOT_ENTITY, ID_TYPES, toFactorySelector} from 'ngrx-entity-relationship';
2
import {iif, Observable, of} from 'rxjs';
3
import {map, switchMap} from 'rxjs/operators';
4

5
export interface STORE_INSTANCE<T> {
6
    select<K>(mapFn: (state: T) => K): Observable<K>;
7
}
8

9
export function relationships<STORE, ENTITY>(
10
    store: STORE_INSTANCE<STORE>,
11
    selector: HANDLER_ROOT_ENTITIES<STORE, ENTITY, ENTITY, ID_TYPES>,
12
): (next: Observable<Array<ENTITY>>) => Observable<Array<ENTITY>>;
13

14
export function relationships<STORE, ENTITY, TRANSFORMED>(
15
    store: STORE_INSTANCE<STORE>,
16
    selector: HANDLER_ROOT_ENTITIES<STORE, ENTITY, TRANSFORMED, ID_TYPES>,
17
): (next: Observable<Array<ENTITY>>) => Observable<Array<TRANSFORMED>>;
18

19
export function relationships<STORE, ENTITY>(
20
    store: STORE_INSTANCE<STORE>,
21
    selector: HANDLER_ROOT_ENTITY<STORE, ENTITY, ENTITY, ID_TYPES>,
22
): (next: Observable<ENTITY>) => Observable<ENTITY>;
23

24
export function relationships<STORE, ENTITY, TRANSFORMED>(
25
    store: STORE_INSTANCE<STORE>,
26
    selector: HANDLER_ROOT_ENTITY<STORE, ENTITY, TRANSFORMED, ID_TYPES>,
27
): (next: Observable<ENTITY>) => Observable<TRANSFORMED>;
28

29
export function relationships<STORE, SET, TRANSFORMED, TYPES>(
30
    store: STORE_INSTANCE<STORE>,
31
    selector: HANDLER_ROOT_ENTITY<STORE, SET, SET | TRANSFORMED, TYPES>,
32
): (next: Observable<SET>) => Observable<undefined | SET | TRANSFORMED> {
33
    const factory = toFactorySelector(selector);
3✔
34

35
    return next =>
3✔
36
        next.pipe(
3✔
37
            switchMap(input => {
38
                const result = of(input);
3✔
39
                return iif(
3✔
40
                    () => input === undefined,
3✔
41
                    result,
42
                    result.pipe(
43
                        map(set => {
44
                            if (Array.isArray(set)) {
2✔
45
                                const processed: Array<ID_TYPES> = [];
1✔
46
                                for (const entity of set) {
1✔
47
                                    processed.push(selector.idSelector(entity));
2✔
48
                                }
49
                                return processed as any as TYPES;
1✔
50
                            }
51
                            return selector.idSelector(set) as any as TYPES;
1✔
52
                        }),
53
                        switchMap(id => store.select(factory(id))),
2✔
54
                    ),
55
                );
56
            }),
57
        );
58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc