From 6fe636ff1ec0c9ca7bee5626ac9716efb70a9c2e Mon Sep 17 00:00:00 2001 From: panzerstadt Date: Mon, 8 May 2023 20:11:04 +0900 Subject: [PATCH 1/2] improve .partition type --- src/array.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/array.ts b/src/array.ts index 9aa8a6e..86f8c86 100644 --- a/src/array.ts +++ b/src/array.ts @@ -366,7 +366,7 @@ export function shuffle(value: T[]) { /** * Returns a tuple separating the items that pass the given truth test. */ -export function partition(value: T[], callback: Function) { +export function partition(value: T[], callback: (item:T) => boolean) { const tuple = [[], []] as [T[], T[]] value.forEach((item, index) => { From 51ce79250248dc693bc5858fc8a7734b08183961 Mon Sep 17 00:00:00 2001 From: panzerstadt Date: Mon, 8 May 2023 20:14:41 +0900 Subject: [PATCH 2/2] ah types for fp and chains too --- src/array.ts | 2 +- src/objects/Arrayable.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/array.ts b/src/array.ts index 86f8c86..f79b219 100644 --- a/src/array.ts +++ b/src/array.ts @@ -366,7 +366,7 @@ export function shuffle(value: T[]) { /** * Returns a tuple separating the items that pass the given truth test. */ -export function partition(value: T[], callback: (item:T) => boolean) { +export function partition(value: T[], callback: (item: T, index?: number) => boolean) { const tuple = [[], []] as [T[], T[]] value.forEach((item, index) => { diff --git a/src/objects/Arrayable.ts b/src/objects/Arrayable.ts index 79ef863..1cbc9d9 100644 --- a/src/objects/Arrayable.ts +++ b/src/objects/Arrayable.ts @@ -312,7 +312,7 @@ class Arrayable extends Array { /** * Returns a tuple separating the items that pass the given truth test. */ - partition(callback: Function) { + partition(callback: (item: T) => boolean) { const partitioned = this.constructor.from(Arr.partition(this, callback)) return partitioned.map(item => this.constructor.from(item)) }