Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dayongkr
Copy link
Collaborator

No description provided.

@Copilot Copilot AI review requested due to automatic review settings October 24, 2025 02:27
@dayongkr dayongkr requested a review from raon0211 as a code owner October 24, 2025 02:27
@vercel
Copy link

vercel bot commented Oct 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
es-toolkit Ready Ready Preview Comment Oct 24, 2025 4:13am

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the throttle function to properly preserve the this context when the throttled function is called as an object method. Previously, the this context was lost during invocation, which could cause issues when throttling methods that depend on their object context.

Key Changes

  • Added explicit this: any parameter to the throttled function to capture the calling context
  • Changed invocation from direct call to apply() to forward the captured context to the debounced function

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/function/throttle.ts Updated throttled function to preserve this context by adding explicit this parameter and using apply() for invocation
src/function/throttle.spec.ts Added test case verifying that this context is correctly preserved when throttle is used as an object method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.88%. Comparing base (88b843e) to head (bf17963).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1497   +/-   ##
=======================================
  Coverage   99.88%   99.88%           
=======================================
  Files         468      468           
  Lines        4453     4453           
  Branches     1311     1311           
=======================================
  Hits         4448     4448           
  Misses          5        5           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dayongkr dayongkr merged commit 750a9e3 into main Oct 24, 2025
9 of 10 checks passed
@dayongkr dayongkr changed the title feat(throttle): preserve this context when called as method fix(throttle): preserve this context when called as method Oct 24, 2025
@dayongkr dayongkr linked an issue Oct 24, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The function after throttle does not respect this like debounce

2 participants