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

Add Collection.clone() #1238

Merged
merged 4 commits into from
Mar 1, 2017
Merged

Add Collection.clone() #1238

merged 4 commits into from
Mar 1, 2017

Conversation

bdistin
Copy link
Contributor

@bdistin bdistin commented Feb 27, 2017

This was discussed the other day. I didn't need it for my earlier pr, so I made it a separate pr.

@devsnek
Copy link
Member

devsnek commented Feb 28, 2017

why not return new Collection(Array.from(this))

@bdistin
Copy link
Contributor Author

bdistin commented Feb 28, 2017

You can also return new this.constructor(this); ... But to be consistent with existing code, (concat) it is written this way.

It was a conscious decision to keep it consistent.

@devsnek
Copy link
Member

devsnek commented Feb 28, 2017

concat has to do that since it iterates in one collection from multiple. new this.constructor(this) would actually be much more efficient, and that is what we want.

@Gawdl3y Gawdl3y merged commit 25bb602 into discordjs:master Mar 1, 2017
devsnek pushed a commit to devsnek/discord.js that referenced this pull request May 14, 2017
* Add Collection.clone()

* More efficient cloning, and concat update

* Update Collection.js

* Update Collection.js
devsnek pushed a commit to devsnek/discord.js that referenced this pull request May 14, 2017
* Add Collection.clone()

* More efficient cloning, and concat update

* Update Collection.js

* Update Collection.js
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.

5 participants