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

WolferyScripting / WolferyJS / #9

28 Aug 2025 04:31AM UTC coverage: 55.386% (+0.02%) from 55.371%
#9

push

DonovanDMC
Add tenants & teleporters

68 of 139 branches covered (48.92%)

Branch coverage included in aggregate %.

51 of 90 new or added lines in 9 files covered. (56.67%)

4148 of 7473 relevant lines covered (55.51%)

1.46 hits per line

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

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

1✔
6
export default class  BaseCollection<V = unknown> extends ResCollection<V> {
1✔
7
    protected client!: WolferyJS;
6✔
8
    constructor(client: WolferyJS, api: ResClient, rid: string, options?: {
6✔
9
        idCallback?(item: V): string;
6✔
10
    }) {
6✔
11
        super(api, rid, options);
6✔
12
        Object.defineProperty(this, "client", {
6✔
13
            enumerable: false,
6✔
14
            value:      client
6✔
15
        });
6✔
16
    }
6✔
17

6✔
18
    get isPaginated(): boolean {
6✔
NEW
19
        return this.paginationOffset !== null && this.paginationLimit !== null;
×
NEW
20
    }
×
21

6✔
22
    get paginationLimit(): number | null {
6✔
NEW
23
        const match = this.rid.match(/limit=(\d+)/);
×
NEW
24
        return match ? Number(match[1]) : null;
×
NEW
25
    }
×
26

6✔
27
    get paginationOffset(): number | null {
6✔
NEW
28
        const match = this.rid.match(/offset=(\d+)/);
×
NEW
29
        return match ? Number(match[1]) : null;
×
NEW
30
    }
×
31

6✔
32
    async getNextPage(): Promise<this | null> {
6✔
NEW
33
        if (!this.isPaginated) return null;
×
NEW
34
        const offset = this.paginationOffset!;
×
NEW
35
        const limit = this.paginationLimit!;
×
NEW
36
        const nextOffset = offset + limit;
×
NEW
37
        const nextRid = this.rid.replace(/offset=\d+/, `offset=${nextOffset}`);
×
NEW
38
        return this.api.get<this>(nextRid);
×
NEW
39
    }
×
40

6✔
41
    [util.inspect.custom](depth: number, inspectOptions: InspectOptions, inspect: typeof util.inspect): string {
6✔
42
        const base = inspect(ridOnlyClassAndList(this.constructor as typeof BaseCollection<V>, this.rid, this.list), inspectOptions).split("\n");
×
43
        const listStart = base.findIndex(l => l.includes("list: ["));
×
44
        const listEnd = base.findIndex(l => l.includes("]"), listStart);
×
45
        let list = base.splice(listStart, listEnd - listStart + 1).join("\n");
×
46
        if (list.at(-1) === ",") {
×
47
            list = list.slice(0, -1);
×
48
            base[base.length - 2] = `${base.at(-2)},`;
×
49
        }
×
50
        base.splice(-1, 0, list.replace("list: ", ""));
×
51
        return base.join("\n");
×
52
    }
×
53
}
6✔
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