From 195325001cb62b8bd010fd229b5898f6c9266785 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sun, 31 May 2026 01:17:23 -0500 Subject: [PATCH] fix: correct map-keys/map-values transform callback types in `@stdlib/utils` The transform/callback type signatures for `map-values`, `async/map-keys`, and `async/map-values` contradicted both the implementations and their own TSDoc: - `map-values`: the `Unary` transform was typed `( key: string ) => any`, but the implementation invokes the transform with the object value first; retype as `( value: any ) => any` (consistent with the `Binary` and `Ternary` transforms and the `@param value` documentation). - `async/map-keys`: the transforms are invoked as `( key, value, obj, next )`, but were typed with `value` first and a spurious `index: number`; retype as `( key: string, ... )` with `value: any`. - `async/map-values`: the transforms are invoked as `( value, key, obj, next )`, but the second argument was typed `index: number`; retype as `key: string`. The completion callback yielded `group: string` (copied from `map-keys`); retype as `value: any`, since `map-values` produces arbitrary transformed values. Reorder the affected `@param` tags to match the signatures. Verified against the implementations (`lib/limit.js`) and the `expect-type` declaration tests. --- .../utils/async/map-keys/docs/types/index.d.ts | 6 +++--- .../async/map-values/docs/types/index.d.ts | 18 +++++++++--------- .../utils/map-values/docs/types/index.d.ts | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/utils/async/map-keys/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/async/map-keys/docs/types/index.d.ts index 1b6dde881cda..4c20f259c14e 100644 --- a/lib/node_modules/@stdlib/utils/async/map-keys/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/async/map-keys/docs/types/index.d.ts @@ -100,7 +100,7 @@ type Callback = Nullary | Unary | Binary; * @param key - object key * @param next - a callback to be invoked after processing an object `value` */ -type BinaryTransform = ( value: any, next: Callback ) => void; +type BinaryTransform = ( key: string, next: Callback ) => void; /** * Transform function. @@ -109,7 +109,7 @@ type BinaryTransform = ( value: any, next: Callback ) => void; * @param value - object value corresponding to `key` * @param next - a callback to be invoked after processing an object `value` */ -type TernaryTransform = ( value: any, index: number, next: Callback ) => void; +type TernaryTransform = ( key: string, value: any, next: Callback ) => void; /** * Transform function. @@ -119,7 +119,7 @@ type TernaryTransform = ( value: any, index: number, next: Callback ) => void; * @param obj - the input object * @param next - a callback to be invoked after processing an object `value` */ -type QuaternaryTransform = ( value: any, index: number, obj: any, next: Callback ) => void; +type QuaternaryTransform = ( key: string, value: any, obj: any, next: Callback ) => void; /** * Transform function. diff --git a/lib/node_modules/@stdlib/utils/async/map-values/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/async/map-values/docs/types/index.d.ts index 6dd388b046a9..c25b895aa80c 100644 --- a/lib/node_modules/@stdlib/utils/async/map-values/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/async/map-values/docs/types/index.d.ts @@ -82,22 +82,22 @@ type Unary = ( error: Error | null ) => void; * Callback function. * * @param error - encountered error or null -* @param group - value group +* @param value - transformed value */ -type Binary = ( error: Error | null, group: string ) => void; +type Binary = ( error: Error | null, value: any ) => void; /** * Callback function. * * @param error - encountered error or null -* @param group - value group +* @param value - transformed value */ type Callback = Nullary | Unary | Binary; /** * Transform function. * -* @param key - object key +* @param value - object value corresponding to `key` * @param next - a callback to be invoked after processing an object `value` */ type BinaryTransform = ( value: any, next: Callback ) => void; @@ -105,27 +105,27 @@ type BinaryTransform = ( value: any, next: Callback ) => void; /** * Transform function. * -* @param key - object key * @param value - object value corresponding to `key` +* @param key - object key * @param next - a callback to be invoked after processing an object `value` */ -type TernaryTransform = ( value: any, index: number, next: Callback ) => void; +type TernaryTransform = ( value: any, key: string, next: Callback ) => void; /** * Transform function. * -* @param key - object key * @param value - object value corresponding to `key` +* @param key - object key * @param obj - the input object * @param next - a callback to be invoked after processing an object `value` */ -type QuaternaryTransform = ( value: any, index: number, obj: any, next: Callback ) => void; +type QuaternaryTransform = ( value: any, key: string, obj: any, next: Callback ) => void; /** * Transform function. * -* @param key - object key * @param value - object value corresponding to `key` +* @param key - object key * @param obj - the input object * @param next - a callback to be invoked after processing an object `value` */ diff --git a/lib/node_modules/@stdlib/utils/map-values/docs/types/index.d.ts b/lib/node_modules/@stdlib/utils/map-values/docs/types/index.d.ts index e41a9c5d5641..5d92f1ce17c2 100644 --- a/lib/node_modules/@stdlib/utils/map-values/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/utils/map-values/docs/types/index.d.ts @@ -31,7 +31,7 @@ type Nullary = () => any; * @param value - object value corresponding to `key` * @returns new value */ -type Unary = ( key: string ) => any; +type Unary = ( value: any ) => any; /** * Returns an object value.