From 404e9aaba3e576e35a3ea362d0434c56f5f4ec80 Mon Sep 17 00:00:00 2001 From: Patrick O'Meara Date: Wed, 22 Jun 2022 20:07:58 +1000 Subject: [PATCH] Push can take variadic arguments * updated docs * use multiple arguments in test to make it clearer --- README.md | 2 +- docs/api/push.md | 2 +- index.d.ts | 4 ++-- test/methods/push_test.js | 4 +--- 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 75f1ed67..917bd23a 100644 --- a/README.md +++ b/README.md @@ -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]); diff --git a/docs/api/push.md b/docs/api/push.md index 50d4ff17..1f384c95 100644 --- a/docs/api/push.md +++ b/docs/api/push.md @@ -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]); diff --git a/index.d.ts b/index.d.ts index 95618a0b..f3780e4d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -303,9 +303,9 @@ declare module 'collect.js' { pull(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. diff --git a/test/methods/push_test.js b/test/methods/push_test.js index 06e05609..a2de9c6d 100644 --- a/test/methods/push_test.js +++ b/test/methods/push_test.js @@ -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]); }); };