Skip to content

Commit c10cdfc

Browse files
committed
refactor(core/interaction-output): use make all private properties use #
1 parent 1148fab commit c10cdfc

1 file changed

Lines changed: 16 additions & 16 deletions

File tree

packages/core/src/interaction-output.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,17 @@ const { debug } = createLoggers("core", "interaction-output");
3232
const ajv = new Ajv({ strict: false });
3333

3434
export class InteractionOutput implements WoT.InteractionOutput {
35-
private content: Content;
35+
#content: Content;
3636
#value: unknown;
37-
private buffer?: ArrayBuffer;
38-
private _stream?: ReadableStream;
37+
#buffer?: ArrayBuffer;
38+
#stream?: ReadableStream;
3939
dataUsed: boolean;
4040
form?: WoT.Form;
4141
schema?: WoT.DataSchema;
4242

4343
public get data(): ReadableStream {
44-
if (this._stream) {
45-
return this._stream;
44+
if (this.#stream) {
45+
return this.#stream;
4646
}
4747

4848
if (this.dataUsed) {
@@ -51,28 +51,28 @@ export class InteractionOutput implements WoT.InteractionOutput {
5151
// Once the stream is created data might be pulled unpredictably
5252
// therefore we assume that it is going to be used to be safe.
5353
this.dataUsed = true;
54-
return (this._stream = ProtocolHelpers.toWoTStream(this.content.body) as ReadableStream);
54+
return (this.#stream = ProtocolHelpers.toWoTStream(this.#content.body) as ReadableStream);
5555
}
5656

5757
constructor(content: Content, form?: WoT.Form, schema?: WoT.DataSchema) {
58-
this.content = content;
58+
this.#content = content;
5959
this.form = form;
6060
this.schema = schema;
6161
this.dataUsed = false;
6262
}
6363

6464
async arrayBuffer(): Promise<ArrayBuffer> {
65-
if (this.buffer) {
66-
return this.buffer;
65+
if (this.#buffer) {
66+
return this.#buffer;
6767
}
6868

6969
if (this.dataUsed) {
7070
throw new Error("Can't read the stream once it has been already used");
7171
}
7272

73-
const data = await this.content.toBuffer();
73+
const data = await this.#content.toBuffer();
7474
this.dataUsed = true;
75-
this.buffer = data;
75+
this.#buffer = data;
7676

7777
return data;
7878
}
@@ -96,17 +96,17 @@ export class InteractionOutput implements WoT.InteractionOutput {
9696
}
9797

9898
// is content type valid?
99-
if (!ContentSerdes.get().isSupported(this.content.type)) {
100-
const message = `Content type ${this.content.type} not supported`;
99+
if (!ContentSerdes.get().isSupported(this.#content.type)) {
100+
const message = `Content type ${this.#content.type} not supported`;
101101
throw new NotSupportedError(message);
102102
}
103103

104104
// read fully the stream
105-
const bytes = await this.content.toBuffer();
105+
const bytes = await this.#content.toBuffer();
106106
this.dataUsed = true;
107-
this.buffer = bytes;
107+
this.#buffer = bytes;
108108

109-
const json = ContentSerdes.get().contentToValue({ type: this.content.type, body: bytes }, this.schema);
109+
const json = ContentSerdes.get().contentToValue({ type: this.#content.type, body: bytes }, this.schema);
110110

111111
// validate the schema
112112
const validate = ajv.compile<T>(this.schema);

0 commit comments

Comments
 (0)