GitShow/ljharb/call-bind-apply-helpers
ljharb

call-bind-apply-helpers

Helper functions around Function call/apply/bind, for use in `call-bind`

by ljharb
Star on GitHubForknpm

JavaScript

5 stars4 forks1 contributorQuiet · 1y agoSince 2024MIT

Meet the team

See all 1 on GitHub →
ljharb
ljharb12 contributions

Recent PRs & issues

Quiet · 3 discussions · Last activity 1y ago
See all on GitHub →
jdmiranda
Performance optimization opportunities for function bindingOpenIssue

Overview As a low-level infrastructure package used extensively throughout the JavaScript ecosystem (via and ), performance optimizations in can have significant downstream impact. This issue proposes several optimization opportunities that could improve performance in hot-path scenarios where these helpers are called frequently. Proposed Optimizations 1. Argument Array Pooling for Current Implementation: Optimization: The object is passed directly to , which may cause repeated conversions and allocations. We could pool argument arrays for common arity cases. Proposed Implementation: Performance Impact: ~15-25% improvement for 0-2 argument calls (most common case) 2. Type Check Fast-Paths in Current Implementation: Optimization: The type check can be optimized with early returns and separated checks for better branch prediction. Proposed Implementation: Performance Impact: ~5-10% improvement in validation overhead 3. Inline Function Check for Reflect.apply Detection Current Implementation: Optimization: This triple check happens at module load, which is fine, but we can add a fast-path verification that Reflect.apply is actually a function to avoid runtime errors. Proposed Implementation: Performance Impact: Minimal overhead, but prevents potential runtime errors and ensures cached value is always callable 4. Optimized actualApply with Arity-Based Dispatch Current Implementation: Optimization: Instead of always using the same bound apply, we could provide arity-specific fast paths. Proposed Implementation: Performance Impact: ~20-30% improvement for 0-2 argument calls 5. Lazy Initialization of WeakMap Cache Optimization: If WeakMap caching is added (as seen in some forks), lazy initialization can reduce memory footprint for applications that never use the caching feature. Proposed Implementation: Performance Impact:** Reduces initial memory overhead; no performance impact once initialized Benchmarking Offer I'd be happy to: Create detailed benchmarks comparing current vs optimized implementations Test across different Node.js versions and JavaScript engines Provide benchmark suite that can be run in CI Submit PRs for approved optimizations Context This is a critical low-level package used by thousands of projects. Even small percentage improvements can have meaningful real-world impact given the frequency these helpers are called in polyfill infrastructure. Would you be interested in exploring any of these optimizations? I'm happy to provide more detailed implementations, benchmarks, or clarifications on any of these proposals. Thank you for maintaining this essential infrastructure package!

jdmiranda · 9mo ago
pixitraining
Cannot find module call-bind-apply-helpersOpenIssue

!Image

pixitraining · 1y ago

Recent fixes

View closed PRs →
arcaderob
Consistently getting `$actualApply is not a function` when running Cypress tests ClosedIssue

My project recently upgraded from React 18.2.0 to 18.3.1 and your package is now a part of my project as a dependency. If I use I get When I try to run my Cypress tests, I am getting the error , but I cannot figure out why this is the case.

arcaderob · 1y ago
Structured data for AI agents

Repository: ljharb/call-bind-apply-helpers. Description: Helper functions around Function call/apply/bind, for use in `call-bind` Stars: 5, Forks: 4. Primary language: JavaScript. License: MIT. Open PRs: 0, open issues: 3. Last activity: 1y ago. Top contributors: ljharb.

·@ofershap

Replace github.com with gitshow.dev