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

Push can take variadic arguments #303

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1977,7 +1977,7 @@ collection.all();

#### `push()`

The push method appends an item to the end of the collection:
The push method appends items to the end of the collection:

```js
const collection = collect([1, 2, 3, 4]);
Expand Down
2 changes: 1 addition & 1 deletion docs/api/push.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# `push()`

The push method appends an item to the end of the collection:
The push method appends items to the end of the collection:

```js
const collection = collect([1, 2, 3, 4]);
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,9 @@ declare module 'collect.js' {
pull<K>(key: keyof Item | K): Item | null;

/**
* The push method appends an item to the end of the collection.
* The push method appends items to the end of the collection.
*/
push(item: Item): this;
push(...item: Item[]): this;

/**
* The put method sets the given key and value in the collection.
Expand Down
4 changes: 1 addition & 3 deletions test/methods/push_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ module.exports = (it, expect, collect) => {
const collection = collect([1, 2, 3, 4]);
expect(collection.all()).to.eql([1, 2, 3, 4]);

const values = [1, 2, 3, 4, 5];

collection.push(...values);
collection.push(1, 2, 3, 4, 5);
expect(collection.all()).to.eql([1, 2, 3, 4, 1, 2, 3, 4, 5]);
});
};