kitzo 2.3.22 → 2.3.24

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/fns.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export declare function copy(doc: string): Promise<void>;
1
+ export declare function copy(doc: unknown): Promise<void>;
2
2
 
3
3
  export { }
@@ -1,22 +1,26 @@
1
- function o(e) {
1
+ function a(e) {
2
2
  const t = document.createElement("textarea");
3
3
  t.value = e, document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
4
4
  }
5
- async function n(e) {
5
+ async function o(e) {
6
6
  if (!navigator.clipboard?.writeText) {
7
- o(e);
7
+ a(e);
8
8
  return;
9
9
  }
10
10
  try {
11
11
  await navigator.clipboard.writeText(e);
12
12
  } catch (t) {
13
- o(e), console.error(t);
13
+ a(e), console.error(t);
14
14
  }
15
15
  }
16
16
  async function r(e) {
17
- if (e == null) throw new Error("[kitzo/copy] expected a value to copy, got null or undefined.");
18
- const t = typeof e == "string" || typeof e == "number" ? String(e) : JSON.stringify(e);
19
- await n(t);
17
+ let t;
18
+ try {
19
+ t = typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? String(e) : JSON.stringify(e);
20
+ } catch {
21
+ t = "[Cannot copy circular object]";
22
+ }
23
+ await o(t);
20
24
  }
21
25
  export {
22
26
  r as default
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitzo",
3
- "version": "2.3.22",
3
+ "version": "2.3.24",
4
4
  "description": "A lightweight React micro-utility.",
5
5
  "type": "module",
6
6
  "files": [