Skip to content

Commit

Permalink
chore: improve several types
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Nov 24, 2024
1 parent def59b8 commit f709158
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions .vscode/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Spatie
stacksjs
stringifying
typecheck
undefineds
undot
unplugin
unref
Expand Down
12 changes: 6 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,13 +265,13 @@ export interface CollectionOperations<T> extends Collection<T> {
takeWhile: (value: T | ((item: T) => boolean)) => CollectionOperations<T>
times: <U>(count: number, callback: (index: number) => U) => CollectionOperations<U>
undot: () => CollectionOperations<Record<string, any>>
unlessEmpty: (callback: (collection: CollectionOperations<T>) => CollectionOperations<T>) => CollectionOperations<T>
unlessNotEmpty: (callback: (collection: CollectionOperations<T>) => CollectionOperations<T>) => CollectionOperations<T>
unwrap: <U>(value: U | CollectionOperations<U>) => U[]
whenEmpty: (callback: (collection: CollectionOperations<T>) => CollectionOperations<T>) => CollectionOperations<T>
whenNotEmpty: (callback: (collection: CollectionOperations<T>) => CollectionOperations<T>) => CollectionOperations<T>
unlessEmpty: <U = T>(callback: (collection: CollectionOperations<T>) => CollectionOperations<U>) => CollectionOperations<T | U>
unlessNotEmpty: <U = T>(callback: (collection: CollectionOperations<T>) => CollectionOperations<U>) => CollectionOperations<T | U>
unwrap: <U>(value: U | U[] | CollectionOperations<U>) => U extends any[] ? U : U[]
whenEmpty: <U = T>(callback: (collection: CollectionOperations<T>) => CollectionOperations<U>) => CollectionOperations<T | U>
whenNotEmpty: <U = T>(callback: (collection: CollectionOperations<T>) => CollectionOperations<U>) => CollectionOperations<T | U>
wrap: <U>(value: U | U[]) => CollectionOperations<U>
zip: <U>(array: U[]) => CollectionOperations<[T, U]>
zip: <U>(array: U[]) => CollectionOperations<[T, U | undefined]>

// Transformations
map: <U>(callback: (item: T, index: number) => U) => CollectionOperations<U>
Expand Down
1 change: 1 addition & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,7 @@ describe('Collection Core Operations', () => {

it('should handle empty collection', () => {
const collection = collect([])
// @ts-expect-error Testing with invalid types
expect(collection.skipUntil(1).toArray()).toEqual([])
})
})
Expand Down

0 comments on commit f709158

Please sign in to comment.