Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
368 changes: 182 additions & 186 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions src/aggregate-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,23 @@ export class AggregateCollection {
* Add a new Integer at the end of this AggregateCollection
* @param item - The item to add
*/
push(item: number) {
push(item: number): void {
this.#items.push(item)
this.#sum += item
}

size() {
size(): number {
return this.#items.length
}

aggregate() {
aggregate(): {
min: number
max: number
mean: number
mode: number
range: number
sum: number
} {
let len = this.#items.length

if (len === 0) {
Expand Down Expand Up @@ -88,7 +95,7 @@ export class AggregateCollection {
}
}

toArray() {
toArray(): number[] {
return this.#items
}
}
4 changes: 2 additions & 2 deletions src/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class Collection<UseLocations extends boolean = false> {
this.#useLocations = useLocations
}

p(item: string | number, node_location: Location) {
p(item: string | number, node_location: Location): void {
let index = this.#total

if (this.#useLocations) {
Expand All @@ -56,7 +56,7 @@ export class Collection<UseLocations extends boolean = false> {
this.#total++
}

size() {
size(): number {
return this.#total
}

Expand Down
6 changes: 4 additions & 2 deletions src/context-collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class ContextCollection<UseLocations extends boolean = false> {
* @param context Context to push Item to
* @param node_location
*/
push(item: string, context: string, node_location: Location) {
push(item: string, context: string, node_location: Location): void {
this.#list.p(item, node_location)

if (!this.#contexts.has(context)) {
Expand All @@ -27,7 +27,9 @@ export class ContextCollection<UseLocations extends boolean = false> {
this.#contexts.get(context)!.p(item, node_location)
}

count() {
count(): CollectionCount<UseLocations> & {
itemsPerContext: { [k: string]: CollectionCount<UseLocations> }
} {
let itemsPerContext: Map<string, CollectionCount<UseLocations>> = new Map()

for (let [context, value] of this.#contexts.entries()) {
Expand Down
Loading
Loading