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

WolferyScripting / WolferyJS / #12

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

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

81.43
/lib/models/BaseModel.ts
1
import type WolferyJS from "../WolferyJS.js";
1✔
2
import { ridOnlyClass } from "../util/Util.js";
1✔
3
import ModelListeners from "../util/ModelListeners.js";
1✔
4
import {
1✔
5
    type AnyObject,
1✔
6
    Properties,
1✔
7
    type ResClient,
1✔
8
    ResModel,
1✔
9
    type ResModelOptions
1✔
10
} from "resclient-ts";
1✔
11
import util, { type InspectOptions } from "node:util";
1✔
12

1✔
13
export default class BaseModel extends ResModel {
1✔
14
    protected client!: WolferyJS;
5✔
15
    listeners!: ModelListeners<this>;
5✔
16
    constructor(client: WolferyJS, api: ResClient, rid: string, options?: ResModelOptions) {
5✔
17
        super(api, rid, options);
5✔
18
        Properties.of(this)
5✔
19
            .readOnly("client", client)
5✔
20
            .readOnly("listeners", new ModelListeners(this));
5✔
21
    }
5✔
22

5✔
23
    protected override async _listen(on: boolean): Promise<void> {
5✔
24
        await super._listen(on);
5✔
25
        if (on) this.listeners.activate();
5✔
26
        else this.listeners.deactivate();
×
27
    }
5✔
28

5✔
29
    override update(props: AnyObject, reset = false): AnyObject | null {
5✔
30
        if (!props) {
5!
31
            return null;
×
32
        }
×
33

5✔
34
        if (this._definition) {
5✔
35
            const missing: Array<string> = [];
5✔
36
            for (const prop in props) {
5✔
37
                if (!(prop in this._definition)) {
5!
38
                    missing.push(prop);
×
39
                }
×
40
            }
5✔
41

5✔
42
            if (missing.length !== 0) {
5!
43
                this.client.emit("missingProperties", this, missing, props);
×
44
            }
×
45
        }
5✔
46

5✔
47
        return super.update(props, reset);
5✔
48
    }
5✔
49
}
5✔
50

1✔
51

1✔
52
export function enableCustomInspectForModels(): void {
1✔
53
    if (util.inspect.custom in BaseModel.prototype) return;
4✔
54
    Object.defineProperty(BaseModel.prototype, util.inspect.custom, {
1✔
55
        value(this: BaseModel, depth: number, inspectOptions: InspectOptions, inspect: typeof util.inspect): string {
1✔
56
            return inspect(ridOnlyClass(this.constructor as typeof BaseModel, this.rid), inspectOptions);
×
57
        }
×
58
    });
1✔
59
}
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