@choksheak/react-utils 0.2.1 → 0.2.2

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.
Files changed (35) hide show
  1. package/docs/classes/sharedQuery.SharedQuery.html +6 -6
  2. package/docs/classes/sharedState.SharedState.html +2 -2
  3. package/docs/classes/utils_storage.InMemoryStorageAdapter.html +2 -2
  4. package/docs/classes/utils_storage.IndexedDbAdapter.html +2 -2
  5. package/docs/classes/utils_storage.LocalStorageAdapter.html +2 -2
  6. package/docs/functions/sharedQuery.sharedQuery.html +1 -1
  7. package/docs/functions/sharedQuery.useSharedQuery.html +1 -1
  8. package/docs/functions/sharedState.sharedState.html +1 -1
  9. package/docs/functions/sharedState.useSharedState.html +1 -1
  10. package/docs/functions/sharedState.useSharedStateSetter.html +1 -1
  11. package/docs/functions/sharedState.useSharedStateValue.html +1 -1
  12. package/docs/functions/utils_storage.getStorageAdapter.html +1 -1
  13. package/docs/functions/utils_stringify.stringifyDeterministicForKeys.html +1 -1
  14. package/docs/types/sharedQuery.FetchFn.html +1 -1
  15. package/docs/types/sharedQuery.PersistTo.html +1 -1
  16. package/docs/types/sharedQuery.QueryStateValue.html +2 -2
  17. package/docs/types/sharedQuery.SharedQueryOptions.html +1 -1
  18. package/docs/types/sharedQuery.SharedQueryState.html +1 -1
  19. package/docs/types/sharedQuery.UseQueryResult.html +1 -1
  20. package/docs/types/sharedState.SharedStateOptions.html +1 -1
  21. package/docs/types/utils_storage.StorageAdapter.html +2 -2
  22. package/docs/types/utils_storage.StorageOptions.html +2 -2
  23. package/docs/variables/fetcher.fetcher.html +1 -1
  24. package/docs/variables/fetcher.fetcherWithRetries.html +1 -1
  25. package/docs/variables/sharedQuery.SharedQueryDefaults.html +1 -1
  26. package/docs/variables/sharedState.SharedStateDefaults.html +1 -1
  27. package/package.json +1 -1
  28. package/sharedQuery.js +1 -1
  29. package/sharedQuery.mjs +1 -1
  30. package/src/utils/stringify.test.ts +8 -0
  31. package/src/utils/stringify.ts +1 -1
  32. package/utils/stringify.js +1 -1
  33. package/utils/stringify.mjs +1 -1
  34. package/utils/stringify.test.js +6 -1
  35. package/utils/stringify.test.mjs +6 -1
@@ -3,4 +3,4 @@
3
3
  the top level scope when the shared state is defined.</p>
4
4
  </div></li><li class="tsd-parameter"><h5 id="storeexpiryms"><span class="tsd-kind-property">storeExpiryMs</span><span class="tsd-signature-symbol">: </span><span class="tsd-signature-type">number</span></h5><div class="tsd-comment tsd-typography"><p>Default duration for storage expiration in milliseconds. Initial value
5
5
  is 30 days, but can be changed to anything.</p>
6
- </div></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/621912281cefd2f03e7a6fe32d00c2bb663fe954/src/sharedState.ts#L28">sharedState.ts:28</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Chok’s React Utilities</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
6
+ </div></li></ul></div><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/choksheak/react-utils/blob/ad41baddd972618a95ea449a56501b128648cf9a/src/sharedState.ts#L28">sharedState.ts:28</a></li></ul></aside></div><div class="col-sidebar"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><svg width="20" height="20" viewBox="0 0 24 24" fill="none" aria-hidden="true"><use href="../assets/icons.svg#icon-chevronDown"></use></svg><h3>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-protected" name="protected"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Protected</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-external" name="external"/><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>External</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu"><nav class="tsd-navigation"><a href="../modules.html">Chok’s React Utilities</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"><li>Loading...</li></ul></nav></div></div></div><footer><p class="tsd-generator">Generated using <a href="https://typedoc.org/" target="_blank">TypeDoc</a></p></footer><div class="overlay"></div></body></html>
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@choksheak/react-utils",
3
3
  "license": "The Unlicense",
4
- "version": "0.2.1",
4
+ "version": "0.2.2",
5
5
  "description": "Miscellaneous React+TypeScript utilities with support for full tree-shaking.",
6
6
  "private": false,
7
7
  "main": "index.js",
package/sharedQuery.js CHANGED
@@ -268,7 +268,7 @@ function stringifyDeterministicForKeys(params) {
268
268
  if (typeof value === "function") {
269
269
  throw new Error(`Functions should not be passed into query parameters`);
270
270
  }
271
- if (!value || typeof value !== "object") {
271
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
272
272
  return value;
273
273
  }
274
274
  if (cache.has(value)) {
package/sharedQuery.mjs CHANGED
@@ -241,7 +241,7 @@ function stringifyDeterministicForKeys(params) {
241
241
  if (typeof value === "function") {
242
242
  throw new Error(`Functions should not be passed into query parameters`);
243
243
  }
244
- if (!value || typeof value !== "object") {
244
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
245
245
  return value;
246
246
  }
247
247
  if (cache.has(value)) {
@@ -35,4 +35,12 @@ describe("stringifyDeterministicForKeys", () => {
35
35
  `Functions should not be passed into query parameters`,
36
36
  );
37
37
  });
38
+
39
+ test("array", () => {
40
+ const a = [1, "a", { b: 2 }, [true]];
41
+
42
+ const actual = stringifyDeterministicForKeys(a);
43
+
44
+ expect(actual).toBe(`[1,"a",{"b":2},[true]]`);
45
+ });
38
46
  });
@@ -15,7 +15,7 @@ export function stringifyDeterministicForKeys(params: unknown): string {
15
15
  throw new Error(`Functions should not be passed into query parameters`);
16
16
  }
17
17
 
18
- if (!value || typeof value !== "object") {
18
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
19
19
  return value;
20
20
  }
21
21
 
@@ -29,7 +29,7 @@ function stringifyDeterministicForKeys(params) {
29
29
  if (typeof value === "function") {
30
30
  throw new Error(`Functions should not be passed into query parameters`);
31
31
  }
32
- if (!value || typeof value !== "object") {
32
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
33
33
  return value;
34
34
  }
35
35
  if (cache.has(value)) {
@@ -5,7 +5,7 @@ function stringifyDeterministicForKeys(params) {
5
5
  if (typeof value === "function") {
6
6
  throw new Error(`Functions should not be passed into query parameters`);
7
7
  }
8
- if (!value || typeof value !== "object") {
8
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
9
9
  return value;
10
10
  }
11
11
  if (cache.has(value)) {
@@ -7,7 +7,7 @@ function stringifyDeterministicForKeys(params) {
7
7
  if (typeof value === "function") {
8
8
  throw new Error(`Functions should not be passed into query parameters`);
9
9
  }
10
- if (!value || typeof value !== "object") {
10
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
11
11
  return value;
12
12
  }
13
13
  if (cache.has(value)) {
@@ -61,4 +61,9 @@ describe("stringifyDeterministicForKeys", () => {
61
61
  `Functions should not be passed into query parameters`
62
62
  );
63
63
  });
64
+ test("array", () => {
65
+ const a = [1, "a", { b: 2 }, [true]];
66
+ const actual = stringifyDeterministicForKeys(a);
67
+ expect(actual).toBe(`[1,"a",{"b":2},[true]]`);
68
+ });
64
69
  });
@@ -13,7 +13,7 @@ function stringifyDeterministicForKeys(params) {
13
13
  if (typeof value === "function") {
14
14
  throw new Error(`Functions should not be passed into query parameters`);
15
15
  }
16
- if (!value || typeof value !== "object") {
16
+ if (!value || typeof value !== "object" || Array.isArray(value)) {
17
17
  return value;
18
18
  }
19
19
  if (cache.has(value)) {
@@ -75,6 +75,11 @@ var require_stringify_test = __commonJS({
75
75
  `Functions should not be passed into query parameters`
76
76
  );
77
77
  });
78
+ test("array", () => {
79
+ const a = [1, "a", { b: 2 }, [true]];
80
+ const actual = stringifyDeterministicForKeys(a);
81
+ expect(actual).toBe(`[1,"a",{"b":2},[true]]`);
82
+ });
78
83
  });
79
84
  }
80
85
  });