Utilize ?. operator and set TypeScript target

This commit is contained in:
Zaid Abdulla committed 2021-09-16 13:27:37 -07:00
1 parent ca83704958
commit c3c7ab72b2
19 files changed
+55 -77

No files matched your search

+4 -4
View File
@@ -190,8 +190,8 @@ export async function updateDeviceTags(
const collection = db.collection("devices");
const object = {};
if (add && add.length) object["$addToSet"] = { _tags: { $each: add } };
if (pull && pull.length) object["$pullAll"] = { _tags: pull };
if (add?.length) object["$addToSet"] = { _tags: { $each: add } };
if (pull?.length) object["$pullAll"] = { _tags: pull };
await collection.updateOne({ _id: deviceId }, object);
}
@@ -242,7 +242,7 @@ export function putProvision(
lineOffset: -1,
});
} catch (err) {
if (err.stack && err.stack.startsWith(`${id}:`)) {
if (err.stack?.startsWith(`${id}:`)) {
return Promise.reject(
new Error(`${err.name} at ${err.stack.split("\n", 1)[0]}`)
);
@@ -267,7 +267,7 @@ export function putVirtualParameter(
lineOffset: -1,
});
} catch (err) {
if (err.stack && err.stack.startsWith(`${id}:`)) {
if (err.stack?.startsWith(`${id}:`)) {
return Promise.reject(
new Error(`${err.name} at ${err.stack.split("\n", 1)[0]}`)
);