Skip to content

add snippet to compare two javascript arrays for equality #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jan 17, 2025

Conversation

KCSquid
Copy link
Contributor

@KCSquid KCSquid commented Jan 6, 2025

Description

Added a new JavaScript snippet that compares two arrays, checking for equality.

Type of Change

  • ✨ New snippet
  • πŸ›  Improvement to an existing snippet
  • 🐞 Bug fix
  • πŸ“– Documentation update
  • πŸ”§ Other (please describe):

Checklist

  • I have tested my code and verified it works as expected.
  • My code follows the style and contribution guidelines of this project.
  • Comments are added where necessary for clarity.
  • Documentation has been updated (if applicable).
  • There are no new warnings or errors from my changes.

Related Issues

Closes #

Additional Context

Screenshots (Optional)

Click to view screenshots

image

Copy link
Collaborator

@majvax majvax left a comment

Choose a reason for hiding this comment

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

Hey, thanks for your contribution! πŸ™Œ

I have a few changes I'm thinking about:

  • Adding validation (e.g. Array.isArray)
  • Adding support for deep equality,
    compareArrays([[1,2]], [[1,2]]); return false
    compareArrays([{a:1}], [{a:1}]); return false
    It will make your snippets more versatile.

@KCSquid KCSquid requested a review from majvax January 7, 2025 17:57
… possible, switch to strict equality, use every instead of loop for one liner, add object tag
@KCSquid
Copy link
Contributor Author

KCSquid commented Jan 8, 2025

Sorry, made it 2.5x shorter while still comparing objects, etc. Is this better?

@KCSquid KCSquid requested a review from Mathys-Gasnier January 8, 2025 15:35
Copy link
Collaborator

@majvax majvax left a comment

Choose a reason for hiding this comment

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

For me it's good but I will ask two last little thing:

  • what's your opinion on the change
  • merging main branch onto your branch to get rid of public/consolidated/*, we recently update our system to make PR easier and those files are no longer needed.

@KCSquid KCSquid reopened this Jan 9, 2025
@KCSquid
Copy link
Contributor Author

KCSquid commented Jan 9, 2025

Okay, messed it up a little bit but it's fixed now.
Which change are you referencing? For the changes to the file (in terms of size), I definately agree it was way to big and this is better in general. Tell me if you need me to change anything else!

@KCSquid KCSquid requested a review from majvax January 9, 2025 21:30
@@ -0,0 +1,32 @@
---
title: Compare Arrays
description: Compares two arrays to check if they are equal.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would like the description to tell that it compares deeply two arrays since we added that

Copy link
Collaborator

@psychlone77 psychlone77 left a comment

Choose a reason for hiding this comment

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

Tested and looks good πŸ‘

@majvax majvax merged commit 40c29cb into quicksnip-dev:main Jan 17, 2025
2 checks passed
@KCSquid KCSquid deleted the compare-arrays branch January 17, 2025 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants