Skip to content

Commit

Permalink
Implemented: replace lodash defaultsDeep with defu #118
Browse files Browse the repository at this point in the history
  • Loading branch information
rizen committed Apr 23, 2024
1 parent a47e34b commit f59f14e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
12 changes: 6 additions & 6 deletions composables/useVingKind.mjs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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();
}

Expand Down Expand Up @@ -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,
});
Expand All @@ -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) {
Expand Down Expand Up @@ -433,7 +433,7 @@ class VingKind {
*/

resetNew() {
this.new = _.defaultsDeep({}, this.#behavior.newDefaults || {});
this.new = defu({}, this.#behavior.newDefaults || {});
}

/**
Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions composables/useVingRecord.mjs
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 3 additions & 1 deletion docs/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit f59f14e

Please sign in to comment.