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

WolferyScripting / WolferyJS / #13

28 Aug 2025 08:28PM UTC coverage: 59.188% (+3.8%) from 55.392%
#13

push

DonovanDMC
0.0.4

88 of 170 branches covered (51.76%)

Branch coverage included in aggregate %.

4608 of 7764 relevant lines covered (59.35%)

1.51 hits per line

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

65.57
/lib/collections/BaseCollection.ts
1
import type WolferyJS from "../WolferyJS.js";
1✔
2
import { ridOnlyClassAndList } from "../util/Util.js";
1✔
3
import CollectionListeners from "../util/CollectionListeners.js";
1✔
4
import { Properties, type ResClient, ResCollection } from "resclient-ts";
1✔
5
import util, { type InspectOptions } from "node:util";
1✔
6

1✔
7
export default class  BaseCollection<V = unknown> extends ResCollection<V> {
1✔
8
    protected client!: WolferyJS;
3✔
9
    listeners!: CollectionListeners<this>;
3✔
10
    constructor(client: WolferyJS, api: ResClient, rid: string, options?: {
3✔
11
        idCallback?(item: V): string;
3✔
12
    }) {
3✔
13
        super(api, rid, options);
3✔
14
        Properties.of(this)
3✔
15
            .readOnly("client", client)
3✔
16
            .readOnly("listeners", new CollectionListeners(this));
3✔
17
    }
3✔
18

3✔
19
    protected override async _listen(on: boolean): Promise<void> {
3✔
20
        await super._listen(on);
×
21
        if (on) this.listeners.activate();
×
22
        else this.listeners.deactivate();
×
23
    }
×
24

3✔
25
    get isPaginated(): boolean {
3✔
26
        return this.paginationOffset !== null && this.paginationLimit !== null;
×
27
    }
×
28

3✔
29
    get paginationLimit(): number | null {
3✔
30
        const match = this.rid.match(/limit=(\d+)/);
×
31
        return match ? Number(match[1]) : null;
×
32
    }
×
33

3✔
34
    get paginationOffset(): number | null {
3✔
35
        const match = this.rid.match(/offset=(\d+)/);
×
36
        return match ? Number(match[1]) : null;
×
37
    }
×
38

3✔
39
    async getNextPage(): Promise<this | null> {
3✔
40
        if (!this.isPaginated) return null;
×
41
        const offset = this.paginationOffset!;
×
42
        const limit = this.paginationLimit!;
×
43
        const nextOffset = offset + limit;
×
44
        const nextRid = this.rid.replace(/offset=\d+/, `offset=${nextOffset}`);
×
45
        return this.api.get<this>(nextRid);
×
46
    }
×
47
}
3✔
48

1✔
49
export function enableCustomInspectForCollections(): void {
1✔
50
    if (util.inspect.custom in BaseCollection.prototype) return;
4✔
51
    Object.defineProperty(BaseCollection.prototype, util.inspect.custom, {
1✔
52
        value(this: BaseCollection, depth: number, inspectOptions: InspectOptions, inspect: typeof util.inspect): string {
1✔
53
            return inspect(ridOnlyClassAndList(this.constructor as typeof BaseCollection, this.rid, this.list), inspectOptions);
×
54
        }
×
55
    });
1✔
56
}
1✔
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

© 2026 Coveralls, Inc