Releases: Sv443-Network/UserUtils
Releases · Sv443-Network/UserUtils
v9.0.4
v9.0.3
v9.0.2
v9.0.1
v9.0.0
Major Changes
- 9abfc6b: BREAKING - Reworked translation system:
- Removed
tr()
,tr.setLanguage()
andtr.getLanguage()
- Renamed function
tr.addLanguage()
totr.addTranslations()
- Removed
%n
-based argument insertion by default (re-enable explicitly withtr.addTransform(tr.transforms.percent)
). - Added ability for nested translation objects and object traversal via dot notation.
- Added functions:
tr.for()
- translates a key for the specified language.tr.use()
- creates a translation function for the specified language for much easier usage.tr.hasKey()
- checks if a key exists in the given language.tr.setFallbackLanguage()
- sets the fallback language used when a key is not found in the given language.tr.getFallbackLanguage()
- returns the fallback language.tr.addTransform()
- adds a transform function to the translation system, allowing for custom argument insertion and much more.tr.deleteTransform()
- removes a transform function.
- Added ability to specify transform patterns and functions for arbitrary modification of the translation string.
- Added transform for template literal syntax (e.g.
${keyName}
) withtr.addTransform(tr.transforms.templateLiteral)
. This transform supports positional argument injection, as well as named arguments via an object with the same keys as in the template literal pattern. See the documentation for more information and a code example. - Added transform for the old
%n
syntax withtr.addTransform(tr.transforms.percent)
. This transform behaves the exact same as the translation sytem before 9.0.0 (only supporting positional arguments).
- Added transform for template literal syntax (e.g.
- Added TS type
TrKeys<T>
for extracting the keys of a translation object (both flat and nested). - Fixed bug with resolving translations for flat objects.
- Removed
- d0737dc: BREAKING - Reworked debounce system:
- Renamed
SelectorObserverOptions
'sdefaultDebounceEdge
todefaultDebounceType
- Renamed
SelectorListenerOptions
'sdebounceEdge
todebounceType
- Edge types
rising
andfalling
have been replaced with new edge typesimmediate
andidle
, overhauling their behavior:immediate
(default & recommended) will trigger immediately, then queue all subsequent calls until the timeout has passed.idle
will trigger the last queued call only after there haven't been any subsequent calls for the specified timeout.
- Added
Debouncer
class for more advanced control over debouncing, and with that the following changes:- Ability to attach and manage multiple listeners.
- Inherits from NanoEmitter, allowing event-based debouncing.
- Can be inherited by your own classes for built-in debouncing.
debounce()
function can still be called as usual (after replacing the edge type names with the new ones). Internally, it will instantiate aDebouncer
instance, which is available via thedebouncer
property on the returned function.- Reduced default timeout from 300ms to 200ms.
- Renamed
Minor Changes
- cd241b0: Added
additionalProps
parameter toopenInNewTab()
to add or overwrite anchor element props (only ifGM.openInTab()
is unavailable) - d0737dc: Moved documentation to separate file
docs.md
to speed upREADME.md
load time.
Patch Changes
v8.4.0
Minor Changes
- e10d629: Added function
digitCount()
to calculate the amount of digits in the passed number - 949877a: Added support for nested objects in translations (e.g.
tr("foo.bar.baz")
) - 52d392a: Added
ValueGen
andStringGen
types with accompanyingconsumeGen()
andconsumeStringGen()
functions to allow for super flexible typing and declaration of values - bbce0e1: Added overload to
clamp()
withoutmin
parameter