@zag-js/utils 0.3.3 → 0.3.4

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.
@@ -0,0 +1,26 @@
1
+ // src/object.ts
2
+ function compact(obj) {
3
+ if (!isPlainObject(obj) || obj === void 0) {
4
+ return obj;
5
+ }
6
+ const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
7
+ const filtered = {};
8
+ for (const key of keys) {
9
+ const value = obj[key];
10
+ if (value !== void 0) {
11
+ filtered[key] = compact(value);
12
+ }
13
+ }
14
+ return filtered;
15
+ }
16
+ function json(value) {
17
+ return JSON.parse(JSON.stringify(value));
18
+ }
19
+ var isPlainObject = (value) => {
20
+ return value && typeof value === "object" && value.constructor === Object;
21
+ };
22
+
23
+ export {
24
+ compact,
25
+ json
26
+ };
package/dist/index.js CHANGED
@@ -145,15 +145,25 @@ var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
145
145
 
146
146
  // src/object.ts
147
147
  function compact(obj) {
148
- if (obj === void 0)
148
+ if (!isPlainObject(obj) || obj === void 0) {
149
149
  return obj;
150
- return Object.fromEntries(
151
- Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
152
- );
150
+ }
151
+ const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
152
+ const filtered = {};
153
+ for (const key of keys) {
154
+ const value = obj[key];
155
+ if (value !== void 0) {
156
+ filtered[key] = compact(value);
157
+ }
158
+ }
159
+ return filtered;
153
160
  }
154
161
  function json(value) {
155
162
  return JSON.parse(JSON.stringify(value));
156
163
  }
164
+ var isPlainObject = (value) => {
165
+ return value && typeof value === "object" && value.constructor === Object;
166
+ };
157
167
 
158
168
  // src/warning.ts
159
169
  function warn(...a) {
package/dist/index.mjs CHANGED
@@ -22,10 +22,6 @@ import {
22
22
  runIfFn,
23
23
  uuid
24
24
  } from "./chunk-YKQM3BDH.mjs";
25
- import {
26
- compact,
27
- json
28
- } from "./chunk-7DKPTIZF.mjs";
29
25
  import {
30
26
  hasProp,
31
27
  isArray,
@@ -36,6 +32,10 @@ import {
36
32
  isObject,
37
33
  isString
38
34
  } from "./chunk-FZD3QLPB.mjs";
35
+ import {
36
+ compact,
37
+ json
38
+ } from "./chunk-Q55U6R3S.mjs";
39
39
  import {
40
40
  invariant,
41
41
  warn
package/dist/object.js CHANGED
@@ -24,22 +24,26 @@ __export(object_exports, {
24
24
  json: () => json
25
25
  });
26
26
  module.exports = __toCommonJS(object_exports);
27
-
28
- // src/guard.ts
29
- var isArray = (v) => Array.isArray(v);
30
- var isObject = (v) => !(v == null || typeof v !== "object" || isArray(v));
31
-
32
- // src/object.ts
33
27
  function compact(obj) {
34
- if (obj === void 0)
28
+ if (!isPlainObject(obj) || obj === void 0) {
35
29
  return obj;
36
- return Object.fromEntries(
37
- Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
38
- );
30
+ }
31
+ const keys = Reflect.ownKeys(obj).filter((key) => typeof key === "string");
32
+ const filtered = {};
33
+ for (const key of keys) {
34
+ const value = obj[key];
35
+ if (value !== void 0) {
36
+ filtered[key] = compact(value);
37
+ }
38
+ }
39
+ return filtered;
39
40
  }
40
41
  function json(value) {
41
42
  return JSON.parse(JSON.stringify(value));
42
43
  }
44
+ var isPlainObject = (value) => {
45
+ return value && typeof value === "object" && value.constructor === Object;
46
+ };
43
47
  // Annotate the CommonJS export names for ESM import in node:
44
48
  0 && (module.exports = {
45
49
  compact,
package/dist/object.mjs CHANGED
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  compact,
3
3
  json
4
- } from "./chunk-7DKPTIZF.mjs";
5
- import "./chunk-FZD3QLPB.mjs";
4
+ } from "./chunk-Q55U6R3S.mjs";
6
5
  export {
7
6
  compact,
8
7
  json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/utils",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "js",
@@ -1,20 +0,0 @@
1
- import {
2
- isObject
3
- } from "./chunk-FZD3QLPB.mjs";
4
-
5
- // src/object.ts
6
- function compact(obj) {
7
- if (obj === void 0)
8
- return obj;
9
- return Object.fromEntries(
10
- Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
11
- );
12
- }
13
- function json(value) {
14
- return JSON.parse(JSON.stringify(value));
15
- }
16
-
17
- export {
18
- compact,
19
- json
20
- };