Skip to content

feat: add defuSchema#104

Open
ferferga wants to merge 5 commits into
unjs:mainfrom
ferferga:main
Open

feat: add defuSchema#104
ferferga wants to merge 5 commits into
unjs:mainfrom
ferferga:main

Conversation

@ferferga
Copy link
Copy Markdown

@ferferga ferferga commented Aug 27, 2023

🔗 Linked issue

Fixes #48

❓ Type of change

  • 📖 Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

  • Minor code improvement by using optional chaining as well when checking for merger function
  • Create defuSchema for removing keys not present in the default object

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@ferferga
Copy link
Copy Markdown
Author

ferferga commented Oct 7, 2023

@pi0 Can I get a review in this please?

Comment thread src/defu.ts
@ferferga ferferga changed the title feat: create defuSchema and optional chaining feat: create defuSchema Oct 25, 2023
@ferferga ferferga mentioned this pull request Oct 25, 2023
8 tasks
@ferferga ferferga requested a review from pi0 October 25, 2023 07:16
@ferferga
Copy link
Copy Markdown
Author

ferferga commented Nov 6, 2023

@pi0 Can I get a re-review of this please? Would be realy useful to have this upstream already 😅

Comment thread src/defu.ts Outdated
@ferferga ferferga requested a review from pi0 November 8, 2023 22:28
Comment thread src/defu.ts Outdated
Copy link
Copy Markdown
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! (i will try to merge and release by this week)

@pi0 pi0 changed the title feat: create defuSchema feat: add `defuSchema Nov 8, 2023
@pi0
Copy link
Copy Markdown
Member

pi0 commented Nov 8, 2023

Once last thing, it is missing in https://github.com/unjs/defu/blob/main/lib/defu.cjs

@pi0 pi0 changed the title feat: add `defuSchema feat: add defuSchema Nov 8, 2023
@ferferga
Copy link
Copy Markdown
Author

ferferga commented Nov 9, 2023

@pi0 Done!

@ferferga
Copy link
Copy Markdown
Author

ferferga commented Jan 6, 2024

@pi0 Hey sorry for pinging again about this... But it would be really useful to have this upstream!

Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: GitHub <noreply@github.com>
Signed-off-by: GitHub <noreply@github.com>
@ferferga
Copy link
Copy Markdown
Author

@pi0 I fixed the conflicts after the merge of #121

Comment thread README.md
Comment on lines +137 to +145
console.log(
defuSchema(
{ a: 1, b: 2, c: 3, d: 4 },
{ a: 2, c: 4, d: 6, e: 8 }
)
);
// => { a: 1, c: 3, d: 4, e: 8 }
``

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defuSchema(
      { a: 1, b: 2, c: 3, d: 4 },
      { a: 2, c: 4, d: 6, e: 8 }
  )
  // => { a: 2, b: 2, c:4, d: 6 }

You can check the issua that is opened, the output should be like this. It is useful to review your code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

request: schema support

3 participants