-
-
Notifications
You must be signed in to change notification settings - Fork 0
v0.1.0 #3
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
v0.1.0 #3
Changes from all commits
0d3e59c
93687aa
bd4b141
c37de39
c547d93
284f2f0
7f7fc51
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,25 +1,58 @@ | ||||||
| // Interface. | ||||||
| import { CollectionShape } from '@typedly/collection'; | ||||||
| import { CollectionAdapter, CollectionShape } from '@typedly/collection'; | ||||||
| /** | ||||||
| * @description The core abstract class for `Type` collections of elements `Element` type. | ||||||
| * @export | ||||||
| * @abstract | ||||||
| * @class CollectionCore | ||||||
| * @template Element type in collection. | ||||||
| * @template Type of the collection. | ||||||
| * @implements {CollectionShape<Element, Type>} | ||||||
| * @template E type in collection. | ||||||
| * @template T of the collection. | ||||||
| * @template {CollectionAdapter<E, T>} A Adapter type. | ||||||
| * @implements {CollectionShape<E, T>} | ||||||
| */ | ||||||
| export abstract class CollectionCore<Element, Type> implements CollectionShape<Element, Type> { | ||||||
| abstract get [Symbol.toStringTag](): string; | ||||||
| abstract get [Symbol.iterator](): Iterator<Element>; | ||||||
| abstract value: Type; | ||||||
| abstract add(...element: Element[]): this; | ||||||
| abstract clear(): this; | ||||||
| abstract delete(...element: Element[]): boolean; | ||||||
| abstract destroy(): this; | ||||||
| abstract forEach(callbackfn: (element: Element, element2: Element, collection: CollectionShape<Element, Type>) => void, thisArg?: any): void; | ||||||
| abstract has(element: Element): boolean; | ||||||
| abstract lock(): this; | ||||||
| abstract set(value: Type): this; | ||||||
| abstract readonly size: number; | ||||||
| export abstract class CollectionCore< | ||||||
| E, | ||||||
| T, | ||||||
| A extends CollectionAdapter<E, T> | ||||||
| > implements CollectionShape<E, T> { | ||||||
| get [Symbol.toStringTag](): string { | ||||||
| return 'Collection'; | ||||||
| } | ||||||
|
|
||||||
| [Symbol.iterator](): Iterator<E> { | ||||||
| return this.adapter[Symbol.iterator](); | ||||||
| } | ||||||
|
|
||||||
| protected abstract get adapter(): A | ||||||
|
||||||
| protected abstract get adapter(): A | |
| protected abstract get adapter(): A; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,6 +8,10 @@ collection.add(27, 29, 31, 33); | |||||||||||||||||||||||||||
| // Deletes. | ||||||||||||||||||||||||||||
| collection.delete(29, 31); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| for (const element of collection) { | ||||||||||||||||||||||||||||
| console.log(`element: `, element); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
Comment on lines
+11
to
+13
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| console.log(`size: `, collection.size); // Output: 5 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| describe("Collection SetAdapter", () => { | ||||||||||||||||||||||||||||
|
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", () => { | |
| // 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()); | |
| }); |
There was a problem hiding this comment.
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.)