-
Notifications
You must be signed in to change notification settings - Fork 6
add comments for debounce, delay, difference #275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ All utility modules are properly registered in |
Benchmark Results
View Full Benchmark Data{
"files": [
{
"filepath": "/home/runner/work/hidash/hidash/src/difference.bench.ts",
"groups": [
{
"fullName": "src/difference.bench.ts > difference performance",
"benchmarks": [
{
"id": "173394915_0_0",
"name": "hidash",
"rank": 1,
"rme": 0.8516265325051949,
"samples": [],
"totalTime": 500.6241629999993,
"min": 3.2616140000000087,
"max": 4.819305999999983,
"hz": 287.6409303479828,
"period": 3.476556687499995,
"mean": 3.476556687499995,
"variance": 0.032858470711223685,
"sd": 0.18126905613265515,
"sem": 0.015105754677721262,
"df": 143,
"critical": 1.96,
"moe": 0.029607279168333674,
"p75": 3.497673999999961,
"p99": 4.630835000000047,
"p995": 4.819305999999983,
"p999": 4.819305999999983,
"sampleCount": 144,
"median": 3.4673324999999693
},
{
"id": "173394915_0_1",
"name": "lodash",
"rank": 2,
"rme": 0.5941335307761362,
"samples": [],
"totalTime": 500.2116189999999,
"min": 10.723551999999927,
"max": 12.150990999999976,
"hz": 91.96107857702523,
"period": 10.874165630434781,
"mean": 10.874165630434781,
"variance": 0.04728982907698834,
"sd": 0.21746224747525336,
"sem": 0.032063059157591695,
"df": 45,
"critical": 2.015,
"moe": 0.06460706420254726,
"p75": 10.92500700000005,
"p99": 12.150990999999976,
"p995": 12.150990999999976,
"p999": 12.150990999999976,
"sampleCount": 46,
"median": 10.82320750000008
}
]
}
]
}
]
} Last updated by GitHub Actions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
* @returns {{debounce: Function, cancel: Function, flush: Function}} An object containing the debounced function, a cancel function, and a flush function. | ||
*/ | ||
export function debounce<Args extends unknown[]>( | ||
func: (...args: Args) => unknown, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not related to the changes in this PR, but I have a question regarding the debounce implementation, especially about the return type of func
.
Currently, the func
argument is typed to return unknown
. Is this considered type-safe in TypeScript?
For example, if I pass an async function that returns a Promise<boolean>
to debounce, the resulting debounced function’s return type becomes unknown
, which requires type assertions or runtime checks when using the return value.
Would it be possible or preferable to type the debounced function so that it preserves the original return type of func, instead of returning unknown
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yujeong-jeon thanks for your comment.
I think it would be better to improve this using generics instead of unknown. I'll handle this in a separate issue.
thanks.
No description provided.