Skip to content

Commit

Permalink
Fix collections
Browse files Browse the repository at this point in the history
  • Loading branch information
Efnilite authored Feb 7, 2023
1 parent 415baf4 commit c4e89fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/types/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit c4e89fb

Please sign in to comment.