From c4e89fb424bae5e0e4a164c998b7ac8e18c87b7a Mon Sep 17 00:00:00 2001 From: Efy <35348263+Efnilite@users.noreply.github.com> Date: Tue, 7 Feb 2023 09:27:08 +0100 Subject: [PATCH] Fix collections --- src/types/collection.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/types/collection.js b/src/types/collection.js index d4eafb8..39e2c8d 100644 --- a/src/types/collection.js +++ b/src/types/collection.js @@ -57,17 +57,17 @@ export class Collection { } map(fn) { - return this.items.map(fn); + return new Collection(this.items.map(fn)); } // Reduce the collection to a single value by applying a function to each item in the collection reduce(fn, initialValue) { - return this.items.reduce(fn, initialValue); + return new Collection(this.items.reduce(fn, initialValue)); } // Filter the collection to a new Collection with only the items that pass a test function filter(fn) { - return this.items.filter(fn); + return new Collection(this.items.filter(fn)); } toString() {