Skip to content

Conversation

@sciborrudnicki
Copy link
Contributor

@sciborrudnicki sciborrudnicki commented Dec 8, 2025

  • Default functionality is in the core.
  • The base only assigns the adapter.
  • Iterator as method.
  • Collection for arbitrary parameters.

@sciborrudnicki sciborrudnicki merged commit 45bc7c8 into main Dec 8, 2025
4 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR represents version 0.1.0 of the collection library, implementing a significant architectural refactoring where default functionality is moved to the core abstract class, the base class focuses on adapter assignment, and the iterator is changed from a getter to a method.

Key changes:

  • Refactored CollectionCore from abstract methods to concrete implementations that delegate to an adapter
  • Changed Symbol.iterator from a getter property to a method across all relevant classes
  • Updated method signatures to accept rest parameters (e.g., add(...element: E[]), delete(...element: E[]), has(...element: E[]))

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/core/lib/collection.core.ts Moved from abstract method declarations to concrete implementations that delegate to adapter; iterator changed to method
src/core/lib/collection.base.ts Simplified to focus on adapter instantiation and storage; removed duplicate method implementations now in core
src/lib/collection.class.ts Updated template parameter constraints from ...args: any[] to ...elements: E[] for better type safety
src/adapter/lib/set.adapter.ts Changed iterator from getter to method; updated method signatures to accept rest parameters; improved type constraints
src/test/collection.spec.ts Added iterator usage demonstration with for-of loop
package.json Bumped version to 0.1.0 and updated peer dependency to @typedly/collection ^2.0.0
package-lock.json Updated lockfile to reflect new version and dependencies
Comments suppressed due to low confidence (1)

src/core/lib/collection.base.ts:24

  • The JSDoc comment states @protected but the getter is declared as public on line 25. Either change the access modifier to protected or update the documentation to reflect @public.
  /**
   * @description The protected getter and setter for the adapter.
   * @protected
   * @type {A}
   */

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +9
* @template E type in collection.
* @template T of the collection.
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Template parameter descriptions are incomplete. Consider making them more consistent with other files (e.g., @template E The type of elements in collection. and @template T The type of the collection.)

Copilot uses AI. Check for mistakes.
Comment on lines +11 to 17
for (const element of collection) {
console.log(`element: `, element);
}

console.log(`size: `, collection.size); // Output: 5

describe("Collection SetAdapter", () => {
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console.log statements in test files can pollute test output. Consider either removing these statements or moving them into a proper test case if you want to verify the iterator functionality.

Suggested change
for (const element of collection) {
console.log(`element: `, element);
}
console.log(`size: `, collection.size); // Output: 5
describe("Collection SetAdapter", () => {
// Iterator functionality test
describe("Collection SetAdapter", () => {
test("iterator yields expected elements", () => {
const elements = Array.from(collection);
expect(elements.sort()).toEqual([1, 2, 3, 27, 33].sort());
});

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +13
for (const element of collection) {
console.log(`element: `, element);
}
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The iterator functionality added in this PR should have proper test coverage. Consider adding a test case that verifies the iterator returns the expected elements, such as: test('iterator yields all elements', () => { const elements = [...collection]; expect(elements).toContain(1); ... });

Copilot uses AI. Check for mistakes.
return this.adapter[Symbol.iterator]();
}

protected abstract get adapter(): A
Copy link

Copilot AI Dec 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon at the end of the abstract getter declaration. TypeScript requires semicolons for abstract property declarations.

Suggested change
protected abstract get adapter(): A
protected abstract get adapter(): A;

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants