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

deepDuplicateArray #28

Open
CMEONE opened this issue Oct 31, 2021 · 5 comments · May be fixed by #34
Open

deepDuplicateArray #28

CMEONE opened this issue Oct 31, 2021 · 5 comments · May be fixed by #34
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@CMEONE
Copy link
Member

CMEONE commented Oct 31, 2021

We should have a method that duplicates an array and all subarrays, like this:

helpful.deepDuplicateArray([1, 2, [3, 4], 5]) => [1, 2, [3, 4], 5]

We encourage using the existing duplicateArray method and recursion to create the deepDuplicateArray method.

@CMEONE CMEONE added enhancement New feature or request good first issue Good for newcomers labels Oct 31, 2021
@TheSoniix
Copy link

Hi, I'm pretty new to github and would like to try my hand at this issue. During my computer science studies I worked a lot with JavaScript / Typescript and I think I can fix this issue. I would be happy if I would be assigned to that.

Best regards
Soniix

@CMEONE
Copy link
Member Author

CMEONE commented Nov 11, 2021

@TheSoniix Sounds great, we look forward to seeing your PR!

@TheSoniix
Copy link

How should I deal with objects in an array? Can i ignore that case, because we want a solution for subarrays? We have not implemented a function of duplicating objects yet. The duplicateArray function would only saves the references of the objects.

@CMEONE
Copy link
Member Author

CMEONE commented Nov 12, 2021

Good point! #29 proposes duplication and deep duplication for an object. If you would like to work on that as well, please let me know so that I can assign you to that PR. I think both methods will need to use each other (for example, arrays within an object would use the deepDuplicateArray method and then objects within an array would need the deepDuplicateObject method) to ensure full duplication. However, custom class objects should not be duplicated and should just be transferred over as normal in both cases. You can detect if an object is not made by a custom class by checking if the constructor is an object constructor (({}).constructor == myObject.constructor).

@TheSoniix
Copy link

Of course! I will try it

@CMEONE CMEONE linked a pull request Dec 17, 2021 that will close this issue
15 tasks
TheSoniix added a commit to TheSoniix/helpful.js that referenced this issue Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants