Conversation
With the idea to write and maintain less code, documentation, and tests for the utils it already provides.
And drop the custom utils/isEmpty
And drop the custom utils/partition
And drop the custom utils/isObject
And use radashi/isEmpty instead, which also checks "object with no enumerable keys"
And drop the custom utils/noop
No longer used since eeeb61a.
And drop the custom utils/uniq
Since it has not been used for a while and is no longer necessary.
No longer used since 62bfdf3
- Return 0 when sanitized input contains non-numeric characters - Improve documentation for clarity and completeness - Add comprehensive unit tests covering edge cases Note: This util has a specialized behavior and might better belong in the storage/DASD namespace rather than as a general-purpose utility.
Replaced the RegExp-based masking (which involved pattern matching) with a simpler implementation using native string methods wich helps reducing complexity and improving performance. Added comprehensive unit tests covering edge cases including negative, zero, and NaN values for the visible parameter to ensure robustness.
Moved useCancellablePromise from utils to its own file under the hooks/ directory for better code organization. No tests added, as this hook is likely to be removed once storage ZFCP components are updated, similar to how it was removed from other parts of Agama after adopting TanStack Query (see commits 688397a, 5043e96, or 78b50f2 for reference).
Moved useLocalStorage from utils to its own file under the hooks/ directory for better code organization. No tests were added, as the hook is currently used by only one component, and its future in the codebase is uncertain. The component may be refactored and stop relying on this hook for data persistence.
Moved useDebounce from utils to its own file under the hooks/ directory for better code organization. No tests were added, as the hook is currently used by only one component and it could be replaced by the "debounce" Radashi util function.
Replaces the custom useDebounce React hook with Radashi debounce function. This simplifies the code by removing the need for a hook while preserving the same behavior. The radashi implementation is also well-tested and offers additional configuration options and methods, which might be useful in the future.
The Layout component is currently the only consumer of the custom breakpoints, so it makes little sense to keep them in a shared utils file where they unnecessarily pollute the global namespace. As part of the move, the breakpoints and related logic have been properly documented for maintainability.
The `toValidationError` function is no longer in use. It was originally introduced in the storage area implementation (#540, commit 1fc1f6f) but its usage was gradually phased out across later changes (e.g., #1112), until it became fully unused in commit 9cfc9c7 (part of #1972). Removing it to reduce dead code and simplify the utils namespace.
This comment was marked as outdated.
This comment was marked as outdated.
The hook has not been used since commit 726c632.
This makes the Connection type work as expected by supporting boolean values for connection options. This is related to the fact that the removed `isEmpty` utility incorrectly supported boolean values as well.
Merged
imobachgs
added a commit
that referenced
this pull request
Jun 30, 2025
Prepare to release Agama 16: * #1868 * #2347 * #2356 * #2373 * #2393 * #2402 * #2404 * #2406 * #2408 * #2409 * #2410 * #2411 * #2412 * #2413 * #2414 * #2415 * #2416 * #2417 * #2418 * #2419 * #2420 * #2421 * #2422 * #2423 * #2424 * #2425 * #2426 * #2427 * #2428 * #2431 * #2433 * #2434 * #2436 * #2437 * #2438 * #2439 * #2440 * #2441 * #2442 * #2443 * #2445 * #2446 * #2450 * #2451 * #2452 * #2453 * #2454 * #2455 * #2456 * #2457 * #2458 * #2460 * #2461 * #2462 * #2463 * #2464 * #2465 * #2466 * #2467 * #2468 * #2469 * #2470 * #2471 * #2472 * #2473 * #2474 * #2475 * #2476 * #2478 * #2479 * #2480 * #2482 * #2483 * #2484 * #2485 * #2487 * #2488 * #2489 * #2490 * #2491 * #2493 * #2494 * #2495 * #2496 * #2497 * #2498 * #2499 * #2502 * #2505 * #2507 * #2509 * #2511 * #2512 * #2513 * #2515 * #2516 * #2517 * #2518 * #2520 * #2523 * #2524 * #2525
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Over time, we’ve created a number of utility functions, such as
isEmpty, that are already well-implemented in mature, widely-used libraries like Lodash, Ramda, or Radashi. These libraries are not only well-tested and maintained, but they also provide battle-hardened solutions to common problems, allowing us to avoid reinventing the wheel.Some time ago, adopting Radashi was proposed and discussed in #1601, but the idea was eventually postponed.
This week, while updating and expanding our utils/isEmpty function, I noticed it was evolving into something more complex, more along the lines of
isVariableConsideredEmpty, which, apart from being debatable in behavior, also strays from its original simplicity. Writing tests for this change made it even more apparent that our time and energy might be better spent focusing on Agama-specific business logic, rather than on maintaining our own versions of common utility functions.Solution
This PR introduces Radashi as a dependency and removes our custom utility functions that are already covered by it.
Radashi offers modern, type-safe, and well-tested utility functions that align with our needs, and adopting it allows us to:
This change builds on the earlier discussion in #1601 and serves as a practical step forward in simplifying our codebase while improving long-term maintainability.
Summary of changes
As part of this PR, utils without a Radashi counterpart have been either documented, tested, and refactored (if needed), or deleted if they were no longer in use. Find below a brief summary of changes, but refer to commits to know more.
isEmptyRadashi.isEmpty. Additionally, some previous usages ofisEmptywere further refined by being replaced withRadashi.isNullishpartitionRadashi.forkisObjectRadashi.isObjectisObjectEmptyRadashi.isEmptynoopRadashi.noopidentityuniqRadashi.uniqueclassNamesslugifytoValidationErrorhexmasklocalConnectiontimezoneTimeagamaWidthBreakpoints,getBreakpointcomponents/layout/Layout.tsx, the only component using themuseLocalStoragehooks/useCancellablePromisehooks/useDebounceRadashi.debounceuseNodeSiblingsTesting
Notes for reviewers
Do not merge until #2402 is merged and later rebased. It was there where
utils/isEmptywas first extended and then fixed and tested.Related resources
https://github.com/you-dont-need/You-Dont-Need-Lodash-Underscore