Skip to content
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

[Snippets] add chunkArray function to array manipulation snippets #190

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

LuziferSenpai
Copy link

@LuziferSenpai LuziferSenpai commented Jan 5, 2025

Description

  • Added snippet to split a array into smaller chunks

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

@LuziferSenpai LuziferSenpai changed the title add chunkArray function to array manipulation snippets [Snippets] add chunkArray function to array manipulation snippets Jan 5, 2025
Copy link
Collaborator

@Mathys-Gasnier Mathys-Gasnier left a comment

Choose a reason for hiding this comment

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

Looks great

if (!Array.isArray(array)) {
throw new TypeError('Expected an array as the first argument.');
}
if (typeof chunkSize !== 'number' || chunkSize <= 0) {
Copy link
Collaborator

@saminjay saminjay Jan 8, 2025

Choose a reason for hiding this comment

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

You need to specifically check for NaN, its type is number

Copy link
Author

Choose a reason for hiding this comment

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

Okay I updated it to also check for NaN.

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.

3 participants