Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move to es2021 #1340

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/scripts/countdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand All @@ -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) => {
Expand Down
3 changes: 1 addition & 2 deletions examples/scripts/counter-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
6 changes: 2 additions & 4 deletions examples/scripts/smart-coffee-machine-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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();
Expand Down
10 changes: 3 additions & 7 deletions examples/scripts/smart-coffee-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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(() => {
Expand Down
2 changes: 1 addition & 1 deletion examples/security/oauth/consumer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 2 additions & 2 deletions examples/templates/exposed-thing/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "ES2016",
"lib": ["ES2016", "dom"],
"target": "ES2021",
"lib": ["ES2021", "dom"],
"module": "commonjs",
"outDir": "dist",
"alwaysStrict": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"target": "ES2018",
"target": "ES2021",
"sourceMap": false,
"removeComments": false
},
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"compilerOptions": {
"target": "es6",
"target": "ES2021",
"lib": ["dom"],
"skipLibCheck": false,
"module": "commonjs",
Expand Down
Loading