GitShow/ljharb/call-bound
ljharb

call-bound

Robust call-bound JavaScript intrinsics, using `call-bind` and `get-intrinsic`.

by ljharb
Star on GitHubForknpm

JavaScript

4 stars2 forks1 contributorQuiet · 1y agoSince 2024MIT

Meet the team

See all 1 on GitHub →
ljharb
ljharb20 contributions

Languages

View on GitHub →
JavaScript100%

Commit activity

Last 12 weeks · 0 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Quiet · 2 discussions · Last activity 1y ago
See all on GitHub →
jdmiranda
Performance optimization opportunities for bound function callsOpenIssue

Summary Thank you for maintaining this critical infrastructure package! As is a low-level utility with high call frequency across the npm ecosystem (35M+ downloads/week), I wanted to share some performance optimization opportunities that could benefit the broader JavaScript community. Proposed Optimizations 1. Intrinsic Result Caching Current behavior: Each call to invokes and potentially , even for frequently-requested intrinsics. Optimization: Implement a lightweight cache for bound intrinsics: Impact: Estimated 60-80% performance improvement for repeated calls to the same intrinsic (common in hot paths). 2. Lazy String.prototype.indexOf Initialization Current behavior: is created at module load time via . Optimization: While this is already well-optimized, consider extracting this pattern to avoid the array allocation: Impact: Marginal (~5-10%), but eliminates one array allocation at module initialization. 3. Fast-Path for Common Intrinsics Current behavior: All intrinsic lookups go through the full machinery and string operations. Optimization: Add a fast-path for the most commonly requested intrinsics: Impact: 70-90% improvement for the most frequently used intrinsics. 4. Avoid Repeated String Search Current behavior: is called on every invocation. Optimization: Since intrinsic names are typically string literals, the result is deterministic: Impact: 15-25% improvement by eliminating redundant string searches. 5. Combined Optimization: Unified Cache Strategy For maximum performance, combine approaches 1, 3, and 4: Impact: Combined 3-5x performance improvement in typical usage patterns. Performance Testing Methodology I'd be happy to help create benchmarks using to measure: Cold start (first call to each intrinsic) Warm path (repeated calls to same intrinsic) Mixed workload (calls to different intrinsics) Memory overhead of caching Considerations Trade-offs: Memory: Caching adds memory overhead (typically < 1KB for common use cases) Correctness: Cache must be properly keyed by both and Edge cases: Dynamic intrinsic modification (rare but possible) Testing: All existing tests should pass Add cache invalidation tests if needed Benchmark suite to validate improvements Offer to Contribute I'd be happy to: Create a PR implementing any/all of these optimizations Develop comprehensive benchmarks Add additional test coverage Work with you on the best approach for this package's philosophy Given that is foundational infrastructure used by thousands of packages, even small improvements can have significant ecosystem-wide impact. Thank you for considering these suggestions!

jdmiranda · 10mo ago

Recent fixes

View closed PRs →
tj-commits
Something I noticedClosedIssue

is its own package, but there is also . Would it make more sense to just export inside of this so you're not installing two callBound inplementations?

tj-commits · 6mo ago
odovbysh
No matching version found for call-bound@1.0.3ClosedIssue

After the release of the new version, the restriction ceased to be available !Annotation 2024-12-16 111414

odovbysh · 1y ago
Structured data for AI agents

Repository: ljharb/call-bound. Description: Robust call-bound JavaScript intrinsics, using `call-bind` and `get-intrinsic`. Stars: 4, Forks: 2. Primary language: JavaScript. Languages: JavaScript (100%). License: MIT. Open PRs: 0, open issues: 2. Last activity: 1y ago. Community health: 85%. Top contributors: ljharb.

·@ofershap

Replace github.com with gitshow.dev