stevendesu / jsindex

1 stars 0 forks source link

Array methods #2

Closed stevendesu closed 5 years ago

stevendesu commented 5 years ago

There are some array methods that still aren't implemented:

Let's get these knocked out when we can.

Because this isn't a breaking API change (these function have an expected behavior) this will just bump the version number to 0.1.1 or similar.

stevendesu commented 5 years ago

I've decided to not bother implementing concat right now (mostly because I'm lazy, but also because I really want pop functionality right now and I don't feel like waiting until I write unit tests for concat)

For now the default concat behavior will be okay:

const collection1 = [...].index();
const collection2 = [...].index();
const combined = collection1.concat(collection2).index();

Since concat is not an in-place operation (it doesn't modify the array you call it on) the only benefit to implementing it myself would be the removal of the final call to index() -- but honestly that may be desirable since it means you can save CPU cycles if you don't need an index on the concatenated array.