Skip to content

[Feature] Add a new getDeferred that gets passed the function and optional parameters #420 - #423

Merged
nev21 merged 1 commit into
mainfrom
nev21/PrepareRelease
May 4, 2025
Merged

nev21 merged 1 commit into
mainfrom
nev21/PrepareRelease

Conversation

@nev21

@nev21 nev21 commented May 4, 2025

Copy link
Copy Markdown
Contributor

No description provided.

@nev21 nev21 added this to the 0.12.3 milestone May 4, 2025
Copilot AI review requested due to automatic review settings May 4, 2025 06:28
@nev21
nev21 requested a review from a team as a code owner May 4, 2025 06:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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

Comment thread lib/test/src/common/funcs/funcs.test.ts Resolved
Comment thread lib/src/helpers/cache.ts Resolved
@codecov

codecov Bot commented May 4, 2025 •

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.85%. Comparing base (198262d) to head (f11ec5d).
Report is 3 commits behind head on main.

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              
Files with missing lines Coverage Δ
lib/src/funcs/funcs.ts 100.00% <ø> (ø)
lib/src/helpers/cache.ts 100.00% <100.00%> (ø)
lib/src/helpers/lazy.ts 100.00% <100.00%> (ø)
lib/src/helpers/safe.ts 100.00% <100.00%> (ø)
lib/src/helpers/safe_get.ts 100.00% <100.00%> (ø)
lib/src/helpers/safe_lazy.ts 100.00% <100.00%> (ø)
🚀 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.

@nev21
nev21 force-pushed the nev21/PrepareRelease branch from a1dd94a to dd74336 Compare May 4, 2025 06:40
@nev21
nev21 requested a review from Copilot May 4, 2025 06:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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";

Comment thread lib/src/helpers/safe_lazy.ts Resolved
@nev21
nev21 force-pushed the nev21/PrepareRelease branch from dd74336 to 43276b6 Compare May 4, 2025 07:00
@nev21
nev21 requested a review from Copilot May 4, 2025 07:01

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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

Comment thread lib/src/helpers/cache.ts Resolved
Comment thread README.md Resolved
@nev21
nev21 force-pushed the nev21/PrepareRelease branch from 43276b6 to f11ec5d Compare May 4, 2025 18:51
@nev21 nev21 changed the title [Feature] Add a new getDeferredValue that gets passed the function and optional parameters #420 [Feature] Add a new getDeferred~Value~ that gets passed the function and optional parameters #420 May 4, 2025
@nev21 nev21 changed the title [Feature] Add a new getDeferred~Value~ that gets passed the function and optional parameters #420 [Feature] Add a new getDeferred~~Value~~ that gets passed the function and optional parameters #420 May 4, 2025
@nev21 nev21 changed the title [Feature] Add a new getDeferred~~Value~~ that gets passed the function and optional parameters #420 [Feature] Add a new getDeferred that gets passed the function and optional parameters #420 May 4, 2025
@nev21
nev21 requested a review from Copilot May 4, 2025 18:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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

Comment thread lib/src/helpers/safe_lazy.ts Resolved
@nev21
nev21 merged commit d4a1f3d into main May 4, 2025
@nev21
nev21 deleted the nev21/PrepareRelease branch May 4, 2025 22:30
@nev21 nev21 added the enhancement New feature or request label May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants