@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.
- package/docs/classes/sharedQuery.SharedQuery.html +6 -6
- package/docs/classes/sharedState.SharedState.html +2 -2
- package/docs/classes/utils_storage.InMemoryStorageAdapter.html +2 -2
- package/docs/classes/utils_storage.IndexedDbAdapter.html +2 -2
- package/docs/classes/utils_storage.LocalStorageAdapter.html +2 -2
- package/docs/functions/sharedQuery.sharedQuery.html +1 -1
- package/docs/functions/sharedQuery.useSharedQuery.html +1 -1
- package/docs/functions/sharedState.sharedState.html +1 -1
- package/docs/functions/sharedState.useSharedState.html +1 -1
- package/docs/functions/sharedState.useSharedStateSetter.html +1 -1
- package/docs/functions/sharedState.useSharedStateValue.html +1 -1
- package/docs/functions/utils_storage.getStorageAdapter.html +1 -1
- package/docs/functions/utils_stringify.stringifyDeterministicForKeys.html +1 -1
- package/docs/types/sharedQuery.FetchFn.html +1 -1
- package/docs/types/sharedQuery.PersistTo.html +1 -1
- package/docs/types/sharedQuery.QueryStateValue.html +2 -2
- package/docs/types/sharedQuery.SharedQueryOptions.html +1 -1
- package/docs/types/sharedQuery.SharedQueryState.html +1 -1
- package/docs/types/sharedQuery.UseQueryResult.html +1 -1
- package/docs/types/sharedState.SharedStateOptions.html +1 -1
- package/docs/types/utils_storage.StorageAdapter.html +2 -2
- package/docs/types/utils_storage.StorageOptions.html +2 -2
- package/docs/variables/fetcher.fetcher.html +1 -1
- package/docs/variables/fetcher.fetcherWithRetries.html +1 -1
- package/docs/variables/sharedQuery.SharedQueryDefaults.html +1 -1
- package/docs/variables/sharedState.SharedStateDefaults.html +1 -1
- package/package.json +1 -1
- package/sharedQuery.js +1 -1
- package/sharedQuery.mjs +1 -1
- package/src/utils/stringify.test.ts +8 -0
- package/src/utils/stringify.ts +1 -1
- package/utils/stringify.js +1 -1
- package/utils/stringify.mjs +1 -1
- package/utils/stringify.test.js +6 -1
- 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/
|
|
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
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
|
});
|
package/src/utils/stringify.ts
CHANGED
|
@@ -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
|
|
package/utils/stringify.js
CHANGED
|
@@ -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)) {
|
package/utils/stringify.mjs
CHANGED
|
@@ -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)) {
|
package/utils/stringify.test.js
CHANGED
|
@@ -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
|
});
|
package/utils/stringify.test.mjs
CHANGED
|
@@ -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
|
});
|