@tstdl/base 0.85.10 → 0.85.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tstdl/base",
3
- "version": "0.85.10",
3
+ "version": "0.85.12",
4
4
  "author": "Patrick Hein",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -33,12 +33,16 @@ var import_rxjs = require("rxjs");
33
33
  var import_container = require("../container/index.js");
34
34
  var import_api = require("../signals/api.js");
35
35
  var import_switch_map = require("../signals/switch-map.js");
36
+ var import_type_guards = require("../utils/type-guards.js");
36
37
  var import_localization_service = require("./localization.service.js");
37
38
  const missingLocalizationKeyText = "[MISSING LOCALIZATION KEY]";
38
39
  function resolveDynamicText(text, localizationService) {
39
40
  const resolvedLocalizationService = localizationService ?? import_container.container.resolve(import_localization_service.LocalizationService);
40
- const localizableText = (0, import_api.isSignal)(text) ? text : (0, import_rxjs.isObservable)(text) ? (0, import_api.toSignal)(text, { initialValue: missingLocalizationKeyText }) : (0, import_api.computed)(() => text);
41
- return (0, import_switch_map.switchMap)(() => resolvedLocalizationService.localize(localizableText()));
41
+ const localizableTextSignal = (0, import_api.isSignal)(text) ? text : (0, import_rxjs.isObservable)(text) ? (0, import_api.toSignal)(text, { initialValue: missingLocalizationKeyText }) : (0, import_api.computed)(() => text);
42
+ return (0, import_switch_map.switchMap)(() => {
43
+ const localizableText = localizableTextSignal();
44
+ return (0, import_type_guards.isString)(localizableText) ? (0, import_api.computed)(() => localizableText) : resolvedLocalizationService.localize(localizableText);
45
+ });
42
46
  }
43
47
  function resolveDynamicText$(text, localizationService) {
44
48
  return (0, import_api.toObservable)(resolveDynamicText(text, localizationService));
package/utils/equals.d.ts CHANGED
@@ -12,6 +12,7 @@ export type ArrayEqualsOptions<A, B> = {
12
12
  sort?: Comparator<A | B>;
13
13
  comparator?: ArrayEqualsComparator<A, B>;
14
14
  };
15
+ export declare function strictEquals(a: any, b: any): boolean;
15
16
  export declare function arrayEquals<A, B>(a: readonly A[], b: readonly B[], options?: ArrayEqualsOptions<A, B>): boolean;
16
17
  export type EqualsOptions = {
17
18
  deep?: boolean;
package/utils/equals.js CHANGED
@@ -21,7 +21,8 @@ __export(equals_exports, {
21
21
  Equals: () => Equals,
22
22
  arrayEquals: () => arrayEquals,
23
23
  binaryEquals: () => binaryEquals,
24
- equals: () => equals
24
+ equals: () => equals,
25
+ strictEquals: () => strictEquals
25
26
  });
26
27
  module.exports = __toCommonJS(equals_exports);
27
28
  var import_array = require("./array/array.js");
@@ -33,6 +34,9 @@ const equalsSymbol = Symbol("equals");
33
34
  const Equals = {
34
35
  symbol: equalsSymbol
35
36
  };
37
+ function strictEquals(a, b) {
38
+ return a === b;
39
+ }
36
40
  function arrayEquals(a, b, options) {
37
41
  const _sort = options?.sort ?? false;
38
42
  const comparator = options?.comparator ?? equals;
@@ -39,6 +39,7 @@ function isPropertyName(value) {
39
39
  const propertyNameProxy = Symbol("PropertyNameProxy");
40
40
  function getPropertyNameProxy(options = {}) {
41
41
  const { deep = true, flat = false, prefix } = options;
42
+ const cache = /* @__PURE__ */ new Map();
42
43
  const proxy = new Proxy({ [propertyNameProxy]: prefix }, {
43
44
  get: (_target, property) => {
44
45
  if (property == propertyName) {
@@ -55,10 +56,13 @@ function getPropertyNameProxy(options = {}) {
55
56
  if (ignore) {
56
57
  return proxy;
57
58
  }
58
- if (deep) {
59
- return getPropertyNameProxy({ deep, flat, prefix: (0, import_type_guards.isUndefined)(prefix) ? property : `${prefix}.${property}` });
59
+ const cached = cache.get(property);
60
+ if ((0, import_type_guards.isDefined)(cached)) {
61
+ return cached;
60
62
  }
61
- return getPropertyNameProxy({ deep, flat, prefix: property });
63
+ const newProxy = getPropertyNameProxy({ deep, flat, prefix: deep ? (0, import_type_guards.isUndefined)(prefix) ? property : `${prefix}.${property}` : property });
64
+ cache.set(property, newProxy);
65
+ return newProxy;
62
66
  }
63
67
  });
64
68
  return proxy;