Skip to content

Commit

Permalink
refactor(lodash): Tweak utils class
Browse files Browse the repository at this point in the history
  • Loading branch information
bubonicfred committed Jun 26, 2024
1 parent eeaf010 commit 7b4efb1
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 16 deletions.
2 changes: 1 addition & 1 deletion client/helpers/confirmationDialog.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _ } from "./utils";
import { Util as _ } from "./utils";
import { Blaze } from "meteor/blaze";
import { Template } from "meteor/templating";
import { i18n } from "meteor/universe:i18n";
Expand Down
2 changes: 1 addition & 1 deletion client/templates/topic/topicEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { configureSelect2Responsibles } from "/imports/client/ResponsibleSearch"
import { MeetingSeries } from "/imports/meetingseries";
import { Minutes } from "/imports/minutes";
import { Topic } from "/imports/topic";
import { _ } from "../../../imports/helpers/utils";
import { Util as _ } from "../../../imports/helpers/utils";
import { $ } from "meteor/jquery";
import { Meteor } from "meteor/meteor";
import { Session } from "meteor/session";
Expand Down
2 changes: 1 addition & 1 deletion imports/attachment.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { _ } from "./helpers/utils";
import { Util _ } from "./helpers/utils";

import { AttachmentsCollection } from "./collections/attachments_private";
import { Minutes } from "./minutes";
Expand Down
13 changes: 5 additions & 8 deletions imports/helpers/utils.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
class _ {
assignIn = (target, ...sources) => {
export class Util {
assignIn(target, ...sources) {
const length = sources.length;
if (length < 1 || target == null) return target;
for (let i = 0; i < length; i++) {
const source = sources[i];
for (const source of sources) {
for (const key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
this.target[key] = source[key];
}
}
}
return target;
};
}
}

export { _ };
6 changes: 3 additions & 3 deletions imports/infoitem.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* and a list of associated tags.
*/
import { User } from "/imports/user";
import { _ } from "lodash";
import { Meteor } from "meteor/meteor";
import { Random } from "meteor/random";

Expand Down Expand Up @@ -49,12 +48,13 @@ export class InfoItem {
if (!Object.prototype.hasOwnProperty.call(source, "createdInMinute")) {
throw new Meteor.Error("Property createdInMinute of topicDoc required");
}
_.defaults(source, {
const defaultValues = {
itemType: "infoItem",
isNew: true,
isSticky: false,
labels: [],
});
};
this._infoItemDoc = Object.assign({}, defaultValues, source);
this._infoItemDoc = source;
}

Expand Down
2 changes: 1 addition & 1 deletion imports/meetingseries.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "./collections/meetingseries_private";
import { formatDateISO8601 } from "/imports/helpers/date";
import { subElementsHelper } from "/imports/helpers/subElements";
import { MinutesFinder } from "/imports/services/minutesFinder";
import { _ } from "./helpers/utils";
import { Util as _ } from "./helpers/utils";
import { Meteor } from "meteor/meteor";
import { Random } from "meteor/random";
import moment from "moment/moment";
Expand Down
2 changes: 1 addition & 1 deletion imports/minutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "./collections/workflow_private";
import { emailAddressRegExpMatch } from "/imports/helpers/email";
import { subElementsHelper } from "/imports/helpers/subElements";
import { User } from "/imports/user";
import { _ } from "./helpers/utils";
import { Util as _ } from "./helpers/utils";
import { Meteor } from "meteor/meteor";
import { Random } from "meteor/random";
import { i18n } from "meteor/universe:i18n";
Expand Down

0 comments on commit 7b4efb1

Please sign in to comment.