diff --git a/examples/scripts/countdown.js b/examples/scripts/countdown.js index b6963f0e9..3d99d1ee2 100644 --- a/examples/scripts/countdown.js +++ b/examples/scripts/countdown.js @@ -80,7 +80,7 @@ WoT.produce({ const listToDelete = []; for (const id of countdowns.keys()) { const as = countdowns.get(id); - if ((as === null || as === void 0 ? void 0 : as.output) !== undefined) { + if (as?.output !== undefined) { const prev = as.output; as.output--; console.log("\t" + id + ", from " + prev + " to " + as.output); @@ -111,7 +111,6 @@ WoT.produce({ }); // set action handlers (using async-await) thing.setActionHandler("startCountdown", async (params, options) => { - var _a; let initValue = 100; if (params != null) { const value = await params.value(); @@ -126,7 +125,7 @@ WoT.produce({ }; const ii = resp; console.log("init countdown value = " + JSON.stringify(resp)); - countdowns.set((_a = resp.href) !== null && _a !== void 0 ? _a : "", resp); + countdowns.set(resp.href ?? "", resp); return ii; }); thing.setActionHandler("stopCountdown", async (params, options) => { diff --git a/examples/scripts/counter-client.js b/examples/scripts/counter-client.js index 24c317bc4..6b28dd5c9 100644 --- a/examples/scripts/counter-client.js +++ b/examples/scripts/counter-client.js @@ -14,8 +14,7 @@ ********************************************************************************/ function getFormIndexForDecrementWithCoAP(thing) { - var _a; - const forms = (_a = thing.getThingDescription().actions) === null || _a === void 0 ? void 0 : _a.decrement.forms; + const forms = thing.getThingDescription().actions?.decrement.forms; if (forms !== undefined) { for (let i = 0; i < forms.length; i++) { if (/^coaps?:\/\/.*/.test(forms[i].href)) { diff --git a/examples/scripts/smart-coffee-machine-client.js b/examples/scripts/smart-coffee-machine-client.js index b8133e139..9dd42c843 100644 --- a/examples/scripts/smart-coffee-machine-client.js +++ b/examples/scripts/smart-coffee-machine-client.js @@ -47,7 +47,7 @@ WoT.requestThingDescription("http://127.0.0.1:8080/smart-coffee-machine").then(a const makeCoffee = await thing.invokeAction("makeDrink", undefined, { uriVariables: { drinkId: "latte", size: "l", quantity: 3 }, }); - const makeCoffeep = await (makeCoffee === null || makeCoffee === void 0 ? void 0 : makeCoffee.value()); + const makeCoffeep = await makeCoffee?.value(); if (makeCoffeep.result != null) { log("Enjoy your drink!", makeCoffeep); } else { @@ -64,9 +64,7 @@ WoT.requestThingDescription("http://127.0.0.1:8080/smart-coffee-machine").then(a time: "10:00", mode: "everyday", }); - const scheduledTaskp = await (scheduledTask === null || scheduledTask === void 0 - ? void 0 - : scheduledTask.value()); + const scheduledTaskp = await scheduledTask?.value(); log(scheduledTaskp.message, scheduledTaskp); // See how it has been added to the schedules property const schedules = await (await thing.readProperty("schedules")).value(); diff --git a/examples/scripts/smart-coffee-machine.js b/examples/scripts/smart-coffee-machine.js index 9f039eede..6c89b9e15 100644 --- a/examples/scripts/smart-coffee-machine.js +++ b/examples/scripts/smart-coffee-machine.js @@ -359,10 +359,8 @@ Assumes one medium americano if not specified, but time and mode are mandatory f // Check if the amount of available resources is sufficient to make a drink for (const resource in newResources) { if (newResources[resource] <= 0) { - return new Promise((resolve, reject) => { - thing.emitEvent("outOfResource", `Low level of ${resource}: ${newResources[resource]}%`); - return { result: false, message: `${resource} level is not sufficient` }; - }); + thing.emitEvent("outOfResource", `Low level of ${resource}: ${newResources[resource]}%`); + return { result: false, message: `${resource} level is not sufficient` }; } } // Now store the new level of allAvailableResources @@ -384,9 +382,7 @@ Assumes one medium americano if not specified, but time and mode are mandatory f schedules.push(paramsp); return { result: true, message: `Your schedule has been set!` }; } - return new Promise((resolve, reject) => { - resolve({ result: false, message: `Please provide all the required parameters: time and mode.` }); - }); + return { result: false, message: `Please provide all the required parameters: time and mode.` }; }); // Finally expose the thing thing.expose().then(() => { diff --git a/examples/security/oauth/consumer.js b/examples/security/oauth/consumer.js index c72f27a4d..08e508fa3 100644 --- a/examples/security/oauth/consumer.js +++ b/examples/security/oauth/consumer.js @@ -16,7 +16,7 @@ WoT.requestThingDescription("https://localhost:8080/oauth").then((td) => { WoT.consume(td).then(async (thing) => { try { const resp = await thing.invokeAction("sayOk"); - const result = await (resp === null || resp === void 0 ? void 0 : resp.value()); + const result = await resp?.value(); console.log("oAuth token was", result); } catch (error) { console.log("It seems that I couldn't access the resource"); diff --git a/examples/templates/exposed-thing/tsconfig.json b/examples/templates/exposed-thing/tsconfig.json index f2cc4b7f3..be9b8bca8 100644 --- a/examples/templates/exposed-thing/tsconfig.json +++ b/examples/templates/exposed-thing/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { - "target": "ES2016", - "lib": ["ES2016", "dom"], + "target": "ES2021", + "lib": ["ES2021", "dom"], "module": "commonjs", "outDir": "dist", "alwaysStrict": true, diff --git a/packages/examples/tsconfig.json b/packages/examples/tsconfig.json index 63049fbba..e3ba0664c 100644 --- a/packages/examples/tsconfig.json +++ b/packages/examples/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "outDir": "dist", "rootDir": "src", - "target": "ES2018", + "target": "ES2021", "sourceMap": false, "removeComments": false }, diff --git a/tsconfig.json b/tsconfig.json index bdf11fa4e..938d2a93e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "target": "es6", + "target": "ES2021", "lib": ["dom"], "skipLibCheck": false, "module": "commonjs",