Skip to content

Commit 26f2001

Browse files
Replace lodash.omit with destructuring in all files
Co-authored-by: victor-enogwe <23452630+victor-enogwe@users.noreply.github.com>
1 parent 2e53ae4 commit 26f2001

5 files changed

Lines changed: 37 additions & 46 deletions

File tree

packages/backend/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"helmet": "^7.0.0",
1818
"jsonwebtoken": "^9.0.0",
1919
"lodash.mergewith": "^4.6.2",
20-
"lodash.omit": "^4.5.0",
2120
"mongodb": "6.3",
2221
"morgan": "^1.10.0",
2322
"rrule": "^2.7.2",
@@ -38,7 +37,6 @@
3837
"@types/jest": "^29.0.0",
3938
"@types/jsonwebtoken": "^9.0.1",
4039
"@types/lodash.mergewith": "^4.6.9",
41-
"@types/lodash.omit": "^4.5.9",
4240
"@types/module-alias": "^2.0.1",
4341
"@types/morgan": "^1.9.4",
4442
"@types/node": "^22.13.10",

packages/backend/src/event/classes/gcal.event.parser.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import omit from "lodash.omit";
21
import { ClientSession, UpdateFilter, WithId } from "mongodb";
32
import { Logger } from "@core/logger/winston.logger";
43
import { gEventToCompassEvent } from "@core/mappers/map.event";
@@ -267,10 +266,15 @@ export class GcalEventParser {
267266
const seriesChanges = await this.cancelSeries(false, session);
268267
const event = gEventToCompassEvent(this.#event, this.userId);
269268

269+
const {
270+
recurrence, // eslint-disable-line @typescript-eslint/no-unused-vars
271+
gRecurringEventId, // eslint-disable-line @typescript-eslint/no-unused-vars
272+
...eventWithoutProps
273+
} = event;
270274
const baseChanges = await this.upsertCompassEvent({
271275
$unset: { recurrence: 1, gRecurringEventId: 1 },
272276
$set: {
273-
...omit(event, ["recurrence", "gRecurringEventId"]),
277+
...eventWithoutProps,
274278
updatedAt: new Date(),
275279
},
276280
});

packages/backend/src/event/classes/gcal.event.rrule.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { omit } from "lodash";
21
import { Options, RRule, RRuleStrOptions, rrulestr } from "rrule";
32
import { GCAL_MAX_RECURRENCES } from "@core/constants/core.constants";
43
import { gEventToCompassEvent } from "@core/mappers/map.event";
@@ -75,22 +74,22 @@ export class GcalEventRRule extends RRule {
7574
const startDate = dayjs(date).tz(tzid);
7675
const endDate = startDate.add(this.#durationMs, "milliseconds");
7776

78-
return omit(
79-
{
80-
...this.#event,
81-
id: `${this.#event.id}_${startDate.toRRuleDTSTARTString(this.#isAllDay)}`,
82-
recurringEventId: this.#event.id!,
83-
start: {
84-
[this.#dateKey]: startDate?.format(this.#dateFormat),
85-
timeZone: this.#event.start?.timeZone ?? timezone,
86-
},
87-
end: {
88-
[this.#dateKey]: endDate.format(this.#dateFormat),
89-
timeZone: this.#event.end?.timeZone ?? timezone,
90-
},
77+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
78+
const { recurrence, ...eventWithoutRecurrence } = {
79+
...this.#event,
80+
id: `${this.#event.id}_${startDate.toRRuleDTSTARTString(this.#isAllDay)}`,
81+
recurringEventId: this.#event.id!,
82+
start: {
83+
[this.#dateKey]: startDate?.format(this.#dateFormat),
84+
timeZone: this.#event.start?.timeZone ?? timezone,
9185
},
92-
["recurrence"],
93-
);
86+
end: {
87+
[this.#dateKey]: endDate.format(this.#dateFormat),
88+
timeZone: this.#event.end?.timeZone ?? timezone,
89+
},
90+
};
91+
92+
return eventWithoutRecurrence;
9493
});
9594
}
9695

packages/backend/src/event/services/recur/util/recur.util.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import omit from "lodash.omit";
21
import { ObjectId } from "mongodb";
32
import { RRule } from "rrule";
43
import { RRULE } from "@core/constants/core.constants";
@@ -47,16 +46,18 @@ export const stripBaseProps = (
4746
| "user"
4847
| "updatedAt"
4948
> => {
50-
return omit(base, [
51-
"_id",
52-
"gEventId",
53-
"startDate",
54-
"endDate",
55-
"order",
56-
"recurrence",
57-
"user",
58-
"updatedAt",
59-
]);
49+
const {
50+
_id, // eslint-disable-line @typescript-eslint/no-unused-vars
51+
gEventId, // eslint-disable-line @typescript-eslint/no-unused-vars
52+
startDate, // eslint-disable-line @typescript-eslint/no-unused-vars
53+
endDate, // eslint-disable-line @typescript-eslint/no-unused-vars
54+
order, // eslint-disable-line @typescript-eslint/no-unused-vars
55+
recurrence, // eslint-disable-line @typescript-eslint/no-unused-vars
56+
user, // eslint-disable-line @typescript-eslint/no-unused-vars
57+
updatedAt, // eslint-disable-line @typescript-eslint/no-unused-vars
58+
...rest
59+
} = base;
60+
return rest;
6061
};
6162

6263
export const stripReadonlyEventProps = (
@@ -73,9 +74,10 @@ export const stripReadonlyEventProps = (
7374
| "user"
7475
| "updatedAt"
7576
> => {
76-
return omit(stripBaseProps(base as Schema_Event_Recur_Base), [
77-
"gRecurringEventId",
78-
]);
77+
const strippedBase = stripBaseProps(base as Schema_Event_Recur_Base);
78+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
79+
const { gRecurringEventId, ...rest } = strippedBase;
80+
return rest;
7981
};
8082

8183
const _generateInstances = (

yarn.lock

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2701,13 +2701,6 @@
27012701
dependencies:
27022702
"@types/lodash" "*"
27032703

2704-
"@types/lodash.omit@^4.5.9":
2705-
version "4.5.9"
2706-
resolved "https://registry.yarnpkg.com/@types/lodash.omit/-/lodash.omit-4.5.9.tgz#cf4744d034961406d6dc41d9cd109773a9ed8fe3"
2707-
integrity sha512-zuAVFLUPJMOzsw6yawshsYGgq2hWUHtsZgeXHZmSFhaQQFC6EQ021uDKHkSjOpNhSvtNSU9165/o3o/Q51GpTw==
2708-
dependencies:
2709-
"@types/lodash" "*"
2710-
27112704
"@types/lodash.throttle@^4.1.6":
27122705
version "4.1.9"
27132706
resolved "https://registry.yarnpkg.com/@types/lodash.throttle/-/lodash.throttle-4.1.9.tgz#f17a6ae084f7c0117bd7df145b379537bc9615c5"
@@ -8007,11 +8000,6 @@ lodash.mergewith@^4.6.2:
80078000
resolved "https://registry.yarnpkg.com/lodash.mergewith/-/lodash.mergewith-4.6.2.tgz#617121f89ac55f59047c7aec1ccd6654c6590f55"
80088001
integrity sha512-GK3g5RPZWTRSeLSpgP8Xhra+pnjBC56q9FZYe1d5RN3TJ35dbkGy3YqBSMbyCrlbi+CM9Z3Jk5yTL7RCsqboyQ==
80098002

8010-
lodash.omit@^4.5.0:
8011-
version "4.5.0"
8012-
resolved "https://registry.yarnpkg.com/lodash.omit/-/lodash.omit-4.5.0.tgz#6eb19ae5a1ee1dd9df0b969e66ce0b7fa30b5e60"
8013-
integrity sha512-XeqSp49hNGmlkj2EJlfrQFIzQ6lXdNro9sddtQzcJY8QaoC2GO0DT7xaIokHeyM+mIT0mPMlPvkYzg2xCuHdZg==
8014-
80158003
lodash.once@^4.0.0:
80168004
version "4.1.1"
80178005
resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac"

0 commit comments

Comments
 (0)