Repository navigation
[Feature] Add a new getDeferred that gets passed the function and optional parameters #420 - #423
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds new deferred caching functions – getDeferred, getWritableDeferred, safeGetDeferred, and safeGetWritableDeferred – along with extensive tests and updated exports to support passing arguments to lazy callbacks. Key changes include updating test suites in timer, safe_lazy, lazy, and cache modules, revising documentation and index exports, and minor refinements in helper functions.
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/test/src/common/timer/timeout.test.ts | Added clearer test organization for timeout overrides. |
| lib/test/src/common/helpers/safe_lazy.test.ts | Extended tests for new safe deferred functions. |
| lib/test/src/common/helpers/lazy.test.ts | Updated tests to cover lazy evaluation with arguments and bypass cache. |
| lib/test/src/common/helpers/deferredFn.test.ts | New tests for deferred cached values using safe functions. |
| lib/test/src/common/helpers/cache.writable.test.ts | Added tests covering writable deferred caching functionality. |
| lib/test/src/common/funcs/funcs.test.ts | Modified call to fnCall reflecting updated parameter usage. |
| lib/test/bundle-size-check.js | Adjusted bundle size limits. |
| lib/src/index.ts | Updated exports to include deferred caching functions. |
| lib/src/helpers/* | Updated implementations and documentation for lazy, cache, and safe helpers. |
| docs/README.md and README.md | Revised documentation to reflect new API and wording changes. |
Files not reviewed (1)
- .size-limit.json: Language not supported
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #423 +/- ##
==========================================
+ Coverage 98.84% 98.85% +0.01%
==========================================
Files 108 108
Lines 2934 2978 +44
Branches 614 619 +5
==========================================
+ Hits 2900 2944 +44
Misses 34 34
🚀 New features to boost your workflow:
|
a1dd94a to
dd74336
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces deferred caching functions that support passing callback arguments, while also updating the existing lazy and cache APIs along with their tests and documentation. Key changes include:
- Adding and exporting new functions getDeferred, getWritableDeferred, safeGetDeferred, and safeGetWritableDeferred.
- Updating related test suites to cover the added argument support and deferred execution.
- Adjusting function signatures and documentation in several helper modules for consistent API usage.
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/test/src/common/timer/timeout.test.ts | Reformatted test descriptions for clarity. |
| lib/test/src/common/helpers/safe_lazy.test.ts | Added tests for safe deferred functions with argument support. |
| lib/test/src/common/helpers/lazy.test.ts | Updated lazy caching tests to exercise argument passing. |
| lib/test/src/common/helpers/deferredFn.test.ts | Introduced tests covering deferred cache functionality. |
| lib/test/src/common/helpers/cache.writable.test.ts | Added comprehensive tests for writable deferred caching. |
| lib/test/src/common/funcs/funcs.test.ts | Adjusted fnCall usage to reflect improved type parameter handling. |
| lib/test/bundle-size-check.js | Updated the bundle size limits for various builds. |
| lib/src/index.ts | Updated exports to include the new deferred caching functions. |
| lib/src/helpers/safe_lazy.ts | Updated safe lazy functions to support argument arrays and added safeGetDeferred/safeGetWritableDeferred. |
| lib/src/helpers/safe_get.ts | Enhanced safeGet by adding an optional argument array parameter. |
| lib/src/helpers/safe.ts | Revised safe function signature with improved type parameters. |
| lib/src/helpers/lazy.ts | Updated getLazy and getWritableLazy to use argArray with helper fnApply. |
| lib/src/helpers/cache.ts | Implemented getDeferred and getWritableDeferred with argument support. |
| lib/src/funcs/funcs.ts | Refined fnCall signature to use Parameters for better type safety. |
| docs/README.md & README.md | Documentation updates to reflect new exports and API changes. |
Files not reviewed (1)
- .size-limit.json: Language not supported
Comments suppressed due to low confidence (1)
lib/src/index.ts:31
- [nitpick] The PR title references adding 'getDeferredValue', yet the new functions are named 'getDeferred' and 'getWritableDeferred'. Consider aligning the naming in the code and documentation with the PR title for consistency.
export { ICachedValue, createCachedValue, createDeferredCachedValue, getDeferred, getWritableDeferred } from "./helpers/cache";
dd74336 to
43276b6
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces new deferred caching APIs and extends the safe/lazy helper functions to support passing optional argument arrays to the underlying callbacks. Additionally, the tests and documentation have been updated to reflect these new enhancements and slight API changes.
- Updates timeout and lazy tests to better isolate various override and argument handling scenarios.
- Adds new functions getDeferred and getWritableDeferred along with their safe variants, and updates exports accordingly.
- Revises documentation and minor function signatures for consistency and clarity.
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/test/src/common/timer/timeout.test.ts | Refactored test blocks for timeout overrides and improved test clarity. |
| lib/test/src/common/helpers/safe_lazy.test.ts | Added tests for new safeGetDeferred/safeGetWritableDeferred functions. |
| lib/test/src/common/helpers/lazy.test.ts | Updated lazy cache tests to include argument support and bypass scenarios. |
| lib/test/src/common/helpers/deferredFn.test.ts | Introduced additional tests for deferred cache functionality. |
| lib/test/src/common/helpers/cache.writable.test.ts | Added tests for writable deferred cache behaviors. |
| lib/test/src/common/funcs/funcs.test.ts | Adjusted function call tests to match signature changes. |
| lib/test/bundle-size-check.js | Updated expected bundle sizes per new build configuration. |
| lib/src/index.ts | Updated exports to include deferred caching APIs. |
| lib/src/helpers/safe_lazy.ts | Extended safe lazy functions to accept optional argument arrays. |
| lib/src/helpers/safe_get.ts | Enhanced safeGet to support passing arguments to the callback. |
| lib/src/helpers/safe.ts | Revised typings for the safe function for better clarity. |
| lib/src/helpers/lazy.ts | Modified lazy functions to accept and apply an argument array. |
| lib/src/helpers/cache.ts | Introduced getDeferred and getWritableDeferred and re-aliased createDeferredCachedValue. |
| lib/src/funcs/funcs.ts | Updated fnCall signature to use explicit parameter types. |
| docs/README.md | Updated documentation on polyfill support and phrasing improvements. |
| README.md | Revised ECMAScript support and polyfill descriptions for clarity. |
Files not reviewed (1)
- .size-limit.json: Language not supported
43276b6 to
f11ec5d
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the lazy and deferred caching helpers by adding support for passing an optional argument array to the callback functions and updates tests and type signatures accordingly. Key changes include:
- Addition of an optional argArray parameter across safeGetLazy, safeGetWritableLazy, safeGetDeferred, safeGetWritableDeferred, getLazy, and getWritableLazy.
- Updated type definitions for functions such as fnCall and safe to use improved parameter types.
- Minor documentation and test adjustments across multiple files and updated bundle size limits.
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/test/src/common/timer/timeout.test.ts | Reformatted test blocks with clearer separation of test suites. |
| lib/test/src/common/helpers/safe_lazy.test.ts | Added tests for deferred caching functions with argument support. |
| lib/test/src/common/helpers/lazy.test.ts | Modified tests to incorporate argument passing into lazy functions. |
| lib/test/src/common/helpers/deferredFn.test.ts | Introduced tests to validate safe JSON parsing with arguments. |
| lib/test/src/common/helpers/cache.writable.test.ts | Added tests for writable deferred caching with argument support. |
| lib/test/src/common/funcs/funcs.test.ts | Adjusted fnCall usage to remove redundant arguments. |
| lib/test/bundle-size-check.js | Updated size limits for various bundle formats. |
| lib/src/index.ts | Re-exported new deferred caching functions. |
| lib/src/helpers/safe_lazy.ts | Extended safeGet* functions to accept an argArray parameter. |
| lib/src/helpers/safe_get.ts | Updated safeGet to support passing arguments. |
| lib/src/helpers/safe.ts | Revised safe type signature with explicit result type. |
| lib/src/helpers/lazy.ts | Modified getLazy/getWritableLazy to use fnApply with optional args. |
| lib/src/helpers/cache.ts | Added getDeferred and getWritableDeferred with argument support. |
| lib/src/funcs/funcs.ts | Revised fnCall to use precise argument types. |
| docs/README.md & README.md | Minor textual updates and clarification of ECMAScript support. |
Files not reviewed (1)
- .size-limit.json: Language not supported
No description provided.