Skip to content

Commit

Permalink
refactor: introduce anonymous InteractionOutput options parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpeintner committed May 9, 2024
1 parent 4708fe7 commit 8a05b90
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/core/src/consumed-thing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ export default class ConsumedThing extends TD.Thing implements IConsumedThing {
);
}
}
return new InteractionOutput(content, form, outputDataSchema, ignoreValidation);
return new InteractionOutput(content, form, outputDataSchema, { ignoreValidation: ignoreValidation ?? false });
}

async _readProperties(propertyNames: string[]): Promise<WoT.PropertyReadMap> {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/interaction-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ export class InteractionOutput implements WoT.InteractionOutput {
return (this.#stream = ProtocolHelpers.toWoTStream(this.#content.body) as ReadableStream);
}

constructor(content: Content, form?: WoT.Form, schema?: WoT.DataSchema, ignoreValidation?: boolean) {
constructor(content: Content, form?: WoT.Form, schema?: WoT.DataSchema, options = { ignoreValidation: false }) {
this.#content = content;
this.form = form;
this.schema = schema;
this.ignoreValidation = ignoreValidation ?? false;
this.ignoreValidation = options.ignoreValidation ?? false;
this.dataUsed = false;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/test/InteractionOutputTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class InteractionOutputTests {
const stream = Readable.from(Buffer.from("not boolean", "utf-8"));
const content = new Content("application/json", stream);

const out = new InteractionOutput(content, {}, { type: "boolean" }, true);
const out = new InteractionOutput(content, {}, { type: "boolean" }, { ignoreValidation: true });
const result = await out.value();
expect(result).to.eql("not boolean");
}
Expand Down

0 comments on commit 8a05b90

Please sign in to comment.