@cascateer/core 2.1.26 → 2.1.27

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": "@cascateer/core",
3
- "version": "2.1.26",
3
+ "version": "2.1.27",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/cascateer/core.git"
package/src/api.ts CHANGED
@@ -4,9 +4,7 @@ import {
4
4
  intersectionWith,
5
5
  isEqual,
6
6
  isFunction,
7
- memoize,
8
7
  } from "lodash";
9
- import objectHash from "object-hash";
10
8
  import {
11
9
  combineLatest,
12
10
  filter,
@@ -21,7 +19,12 @@ import {
21
19
  tap,
22
20
  UnaryFunction,
23
21
  } from "rxjs";
24
- import { asObservable, ExtendableDictionary, property } from "./lib";
22
+ import {
23
+ asObservable,
24
+ ExtendableDictionary,
25
+ memoizeHashed,
26
+ property,
27
+ } from "./lib";
25
28
  import { ProxyObservable } from "./observable";
26
29
  import { Action, MaybeArray, MaybeObservable, ProxyEffect } from "./types";
27
30
 
@@ -48,7 +51,7 @@ class Memoizable<Args, Result> {
48
51
  this.tags = isFunction(tags) ? tags : constant([tags ?? []].flat());
49
52
 
50
53
  this.subscribe = (invalidatedTags) => {
51
- const memoizedEffect: ProxyEffect<Args, Result> = memoize(
54
+ const memoizedEffect: ProxyEffect<Args, Result> = memoizeHashed(
52
55
  (args) =>
53
56
  new ProxyObservable((pending) =>
54
57
  this.predicate(args).pipe(
@@ -72,7 +75,6 @@ class Memoizable<Args, Result> {
72
75
  shareReplay({ bufferSize: 1, refCount: false }),
73
76
  ),
74
77
  ),
75
- (args) => objectHash(args ?? null),
76
78
  );
77
79
 
78
80
  return memoizedEffect;
package/src/dom.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { identity, isObject, memoize } from "lodash";
1
+ import { isObject, memoize } from "lodash";
2
2
  import { createFragment } from ".";
3
3
 
4
4
  export class CustomElement extends HTMLElement {
@@ -18,7 +18,7 @@ export const defineCustomElement = memoize((key: string) => {
18
18
  customElements.define(key, constructor);
19
19
 
20
20
  return constructor;
21
- }, identity);
21
+ });
22
22
 
23
23
  export const defineCustomProperties = (
24
24
  definitions: Partial<JSX.CSSCustomPropertyDefinitions>,
package/src/lib/index.ts CHANGED
@@ -11,6 +11,7 @@ export {
11
11
  } from "./Enumerable";
12
12
  export { ExtendableDictionary } from "./ExtendableDictionary";
13
13
  export { keys } from "./keys";
14
+ export { memoizeHashed } from "./memoizeHashed";
14
15
  export { nthArg } from "./nthArg";
15
16
  export { property } from "./property";
16
17
 
@@ -0,0 +1,5 @@
1
+ import { memoize } from "lodash";
2
+ import objectHash from "object-hash";
3
+
4
+ export const memoizeHashed = <T extends (...args: any) => any>(func: T) =>
5
+ memoize(func, (...args: Parameters<T>) => objectHash(args ?? null));
package/src/types.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { Dictionary, mapValues, memoize, tap } from "lodash";
2
- import objectHash from "object-hash";
1
+ import { Dictionary, mapValues, tap } from "lodash";
3
2
  import {
4
3
  combineLatest,
5
4
  distinct,
@@ -10,6 +9,7 @@ import {
10
9
  } from "rxjs";
11
10
  import { Observable } from "rxjs/internal/Observable";
12
11
  import { ObservableInput } from "rxjs/internal/types";
12
+ import { memoizeHashed } from "./lib";
13
13
  import { ProxyObservable } from "./observable";
14
14
  import { concat } from "./operators";
15
15
 
@@ -43,17 +43,15 @@ export class ProxyEffectInterceptor extends ReplaySubject<
43
43
  effects: Effects,
44
44
  ): ProxyEffects<Effects> {
45
45
  return mapValues(effects, (effect) =>
46
- memoize(
47
- (args) =>
48
- tap(
49
- new ProxyObservable(effect(args), (target) =>
50
- combineLatest([target.pending, target.refCount]).pipe(
51
- map((values) => values.every(Boolean)),
52
- ),
46
+ memoizeHashed((args) =>
47
+ tap(
48
+ new ProxyObservable(effect(args), (target) =>
49
+ combineLatest([target.pending, target.refCount]).pipe(
50
+ map((values) => values.every(Boolean)),
53
51
  ),
54
- (source) => this.next(source),
55
52
  ),
56
- (args) => objectHash(args ?? null),
53
+ (source) => this.next(source),
54
+ ),
57
55
  ),
58
56
  );
59
57
  }