From f59f14e37cda4fd4b51803f7b6b1661632a505e6 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Tue, 23 Apr 2024 14:20:05 -0500 Subject: [PATCH] Implemented: replace lodash defaultsDeep with defu #118 --- composables/useVingKind.mjs | 12 ++++++------ composables/useVingRecord.mjs | 6 +++--- docs/change-log.md | 4 +++- package-lock.json | 1 + package.json | 1 + 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/composables/useVingKind.mjs b/composables/useVingKind.mjs index dc80099d..03e05885 100644 --- a/composables/useVingKind.mjs +++ b/composables/useVingKind.mjs @@ -1,4 +1,4 @@ -import _ from 'lodash'; +import { defu } from "defu"; import { debounce } from 'perfect-debounce'; import { ouch } from '#ving/utils/ouch.mjs'; class VingKind { @@ -85,7 +85,7 @@ class VingKind { constructor(behavior = {}) { this.#behavior = behavior; - this.query = _.defaultsDeep(this.query, this.#behavior.query); + this.query = defu(this.query, this.#behavior.query); this.resetNew(); } @@ -166,7 +166,7 @@ class VingKind { */ async call(method, url, query = {}, options = {}) { const response = await useRest(url, { - query: _.defaultsDeep({}, this.query, query), + query: defu({}, this.query, query), method, suppressErrorNotifications: this.#behavior.suppressErrorNotifications, }); @@ -193,7 +193,7 @@ class VingKind { */ create(props = {}, options = {}) { const self = this; - const newProps = _.defaultsDeep({}, props, self.new); + const newProps = defu({}, props, self.new); const newRecord = self.mint({ props: newProps }); const addIt = function () { if (options?.unshift || self.#behavior?.unshift) { @@ -433,7 +433,7 @@ class VingKind { */ resetNew() { - this.new = _.defaultsDeep({}, this.#behavior.newDefaults || {}); + this.new = defu({}, this.#behavior.newDefaults || {}); } /** @@ -449,7 +449,7 @@ class VingKind { page: options?.page || this.paging.page || 1, itemsPerPage: this.paging.itemsPerPage || 10, }; - const query = _.defaultsDeep({}, pagination, options?.query, this.query); + const query = defu({}, pagination, options?.query, this.query); const response = await useRest(this.getListApi(), { query: query, diff --git a/composables/useVingRecord.mjs b/composables/useVingRecord.mjs index ef499d66..69aa4736 100644 --- a/composables/useVingRecord.mjs +++ b/composables/useVingRecord.mjs @@ -1,5 +1,5 @@ import { defineStore } from 'pinia'; -import _ from 'lodash'; +import { defu } from "defu"; import { v4 } from 'uuid'; import { ouch } from '#ving/utils/ouch.mjs'; @@ -38,7 +38,7 @@ export default (behavior) => { async call(method, url, query = {}, options = {}) { const response = await useRest(url, { - query: _.defaultsDeep({}, this.query, query), + query: defu({}, this.query, query), method, body: options.body, suppressErrorNotifications: behavior.suppressErrorNotifications, @@ -69,7 +69,7 @@ export default (behavior) => { */ async create(props, options) { - const newProps = _.defaultsDeep({}, props, this.props); + const newProps = defu({}, props, this.props); const response = await useRest(this.getCreateApi(), { query: this.query, method: 'post', diff --git a/docs/change-log.md b/docs/change-log.md index fc1d89cb..c4117a3a 100644 --- a/docs/change-log.md +++ b/docs/change-log.md @@ -8,7 +8,9 @@ outline: deep * Updated CopyToClipboard in generator to use size xs. * Added a little better documentation for Pulumi. * Fix: bio on User is required. -* Implemented: replace axios with ofetch for CLI and jobs #117 +* Implemented: replace axios with ofetch for CLI and jobs #117. +* Implemented: replace lodash defaultsDeep with defu #118 +* NOTE: You will have to run npm i to get new modules. ## 2024-04-22 * Added MarkdownInput form control component for editing markdown text. diff --git a/package-lock.json b/package-lock.json index 7de313f6..ca8b3a28 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,7 @@ "bullmq": "^5.3.0", "citty": "^0.1.5", "date-fns": "^2.30.0", + "defu": "^6.1.4", "drizzle-orm": "^0.29.3", "dropzone": "^6.0.0-beta.2", "email-templates": "^11.1.1", diff --git a/package.json b/package.json index 72c1a075..d7fb7d00 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "bullmq": "^5.3.0", "citty": "^0.1.5", "date-fns": "^2.30.0", + "defu": "^6.1.4", "drizzle-orm": "^0.29.3", "dropzone": "^6.0.0-beta.2", "email-templates": "^11.1.1",