solid-ctrl-flow 1.0.37 → 1.0.38

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/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import { Accessor } from 'solid-js';
2
2
  import { Context } from 'solid-js';
3
3
  import { EffectFunction } from 'solid-js';
4
4
  import { JSX } from 'solid-js';
5
+ import { MemoOptions } from 'solid-js';
5
6
  import { Ref } from 'solid-js';
6
7
  import { Resource } from 'solid-js';
7
8
  import { Setter } from 'solid-js';
@@ -132,6 +133,9 @@ export declare function createReactiveResource<R>(f: EffectFunction<R | undefine
132
133
  /** Built-in {@link ReactiveContext} which allows you to display different things in debug mode */
133
134
  export declare const debug: ReactiveContext<boolean>;
134
135
 
136
+ /** Handy type alias */
137
+ declare type Equals = MemoOptions<unknown>["equals"];
138
+
135
139
  /** Informations about a {@link Source} component */
136
140
  declare type Info = {
137
141
  /** Order of the current source if there are many */
@@ -140,12 +144,16 @@ declare type Info = {
140
144
  };
141
145
 
142
146
  /**
143
- * Memoizes some of the properties of {@link obj}
144
- * If {@link keys} is not provided, memoizes everything that get returned by {@link Object.keys} when provided with {@link obj}
147
+ * Memoizes some of the properties of {@link obj}.
148
+ * If {@link keys} is not provided, memoizes everything that get returned by {@link Object.keys} when provided with {@link obj}.
149
+ * The {@link equals} parameter defaults to `false` to allow the specific reactive value to have control over when its dependant effects are triggered
145
150
  * @param obj Object to partially memoize
146
151
  * @param keys The keys of the properties to memoize
152
+ * @param equals The comparator function to use on the newly created memos
147
153
  */
148
- export declare function memoProps<T, K extends readonly (keyof T)[] = (keyof T)[]>(obj: T, keys?: K): Pick<T, K[number]>;
154
+ export declare function memoProps<T>(obj: T, keys?: undefined, equals?: Equals): T;
155
+
156
+ export declare function memoProps<T, K extends readonly (keyof T)[]>(obj: T, keys: K, equals?: Equals): Pick<T, K[number]>;
149
157
 
150
158
  /**
151
159
  * Like a {@link For}, but instead of putting an element after another it nests them.
@@ -229,11 +237,12 @@ export declare function runWithContext<T, V extends T, R>(ctx: Context<T>, value
229
237
  export declare function runWithContext<T, R>(ctx: Context<T>, value: T | undefined, f: (x: T) => R): R;
230
238
 
231
239
  /**
232
- * Executes {@link splitProps} and memoizes the first of the two returned objects
240
+ * Executes {@link splitProps} and memoizes the first of the two returned objects using {@link memoProps}
233
241
  * @param obj Object to split and partially memoize
234
242
  * @param keys The keys of the properties to memoize and to include in the first of the two objects
243
+ * @param equals The comparator function to use on the newly created memos
235
244
  */
236
- export declare function splitAndMemoProps<T extends object, K extends readonly (keyof T)[]>(obj: T, keys: K): [Pick<T, Extract<K, readonly (keyof T)[]>[number]>, Omit<T, K[number]>];
245
+ export declare function splitAndMemoProps<T extends Record<any, any>, K extends readonly (keyof T)[]>(obj: T, keys: K, equals?: Equals): [Pick<T, Extract<K, readonly (keyof T)[]>[number]>, Omit<T, K[number]>];
237
246
 
238
247
  /**
239
248
  * Creates a full-fledged solid {@link Setter} from a normal one
package/dist/index.mjs CHANGED
@@ -191,18 +191,20 @@ function refCall(ref, value) {
191
191
  ref(value);
192
192
  return value;
193
193
  }
194
- function memoProps(obj, keys = Object.keys(obj)) {
194
+ function memoProps(obj, keys = Object.keys(obj), equals = false) {
195
195
  const out = {};
196
196
  for (const elm of keys)
197
197
  Object.defineProperty(out, elm, {
198
198
  enumerable: true,
199
- get: createMemo(() => obj[elm])
199
+ get: createMemo(() => obj[elm], void 0, {
200
+ equals
201
+ })
200
202
  });
201
203
  return out;
202
204
  }
203
- function splitAndMemoProps(obj, keys) {
205
+ function splitAndMemoProps(obj, keys, equals) {
204
206
  const out = splitProps(obj, keys);
205
- out[0] = memoProps(out[0], keys);
207
+ out[0] = memoProps(out[0], keys, equals);
206
208
  return out;
207
209
  }
208
210
  function runWithContext(ctx2, value, f) {
package/dist/index.umd.js CHANGED
@@ -193,18 +193,20 @@
193
193
  ref(value);
194
194
  return value;
195
195
  }
196
- function memoProps(obj, keys = Object.keys(obj)) {
196
+ function memoProps(obj, keys = Object.keys(obj), equals = false) {
197
197
  const out = {};
198
198
  for (const elm of keys)
199
199
  Object.defineProperty(out, elm, {
200
200
  enumerable: true,
201
- get: solidJs.createMemo(() => obj[elm])
201
+ get: solidJs.createMemo(() => obj[elm], void 0, {
202
+ equals
203
+ })
202
204
  });
203
205
  return out;
204
206
  }
205
- function splitAndMemoProps(obj, keys) {
207
+ function splitAndMemoProps(obj, keys, equals) {
206
208
  const out = solidJs.splitProps(obj, keys);
207
- out[0] = memoProps(out[0], keys);
209
+ out[0] = memoProps(out[0], keys, equals);
208
210
  return out;
209
211
  }
210
212
  function runWithContext(ctx2, value, f) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "solid-ctrl-flow",
3
- "version": "1.0.37",
3
+ "version": "1.0.38",
4
4
  "description": "Control flow components for solid-js",
5
5
  "author": "AFatNiBBa",
6
6
  "license": "ISC",