-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(type): add
CallbackPayload
and ForEachCallback
types.
- Loading branch information
1 parent
e09a84f
commit 98a2722
Showing
2 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Experimental shape for a generic type variable `Payload`. | ||
*/ | ||
export type CallbackPayload<Payload = object> = { | ||
/** | ||
* An optional action of a `string` type that describes the cause of performed callback. | ||
*/ | ||
action?: string; | ||
|
||
/** | ||
* An optional name of the function or method of a `string` type that performed callback. | ||
*/ | ||
name?: string; | ||
|
||
/** | ||
* An optional name of the parameter of a `string` type to which performed callback relates. | ||
*/ | ||
param?: string; | ||
|
||
} & Payload; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/** | ||
* Represents a callback function of `forEach()` method which is executed once for each element. | ||
* @param result The result of the check of a `boolean` type. | ||
* @param value The value that has been checked of a generic type variable `Value`. | ||
* @param index An optional `number` of checked `array` element. | ||
* @param array An optional `array` of `any` type that each element is checked. | ||
* @param payload An optional `object` of a generic type variable `Payload` to provide more data. | ||
* @returns The return value is void. | ||
*/ | ||
export type ForEachCallback<Value = any, Payload = object> = ( | ||
result: boolean, | ||
value: Value, | ||
index?: number, | ||
array?: any[], | ||
payload?: Payload | ||
) => void; |