@zag-js/utils 0.0.0-dev-20221031083441 → 0.0.0-dev-20221105065843

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
@@ -33,9 +33,11 @@ declare const isString: (v: any) => v is string;
33
33
  declare const isFunction: (v: any) => v is Function;
34
34
  declare const hasProp: <T extends string>(obj: any, prop: T) => obj is Record<T, any>;
35
35
 
36
+ declare function compact<T extends Record<string, unknown>>(obj: T): T;
37
+
36
38
  declare function warn(m: string): void;
37
39
  declare function warn(c: boolean, m: string): void;
38
40
  declare function invariant(m: string): void;
39
41
  declare function invariant(c: boolean, m: string): void;
40
42
 
41
- export { IndexOptions, add, callAll, cast, chunk, clear, first, fromLength, has, hasProp, invariant, isArray, isBoolean, isDev, isEmpty, isFunction, isNumber, isObject, isString, last, next, nextIndex, noop, prev, prevIndex, remove, removeAt, runIfFn, toArray, uuid, warn };
43
+ export { IndexOptions, add, callAll, cast, chunk, clear, compact, first, fromLength, has, hasProp, invariant, isArray, isBoolean, isDev, isEmpty, isFunction, isNumber, isObject, isString, last, next, nextIndex, noop, prev, prevIndex, remove, removeAt, runIfFn, toArray, uuid, warn };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(src_exports, {
25
25
  cast: () => cast,
26
26
  chunk: () => chunk,
27
27
  clear: () => clear,
28
+ compact: () => compact,
28
29
  first: () => first,
29
30
  fromLength: () => fromLength,
30
31
  has: () => has,
@@ -142,6 +143,13 @@ var isString = (v) => typeof v === "string";
142
143
  var isFunction = (v) => typeof v === "function";
143
144
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
144
145
 
146
+ // src/object.ts
147
+ function compact(obj) {
148
+ return Object.fromEntries(
149
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
150
+ );
151
+ }
152
+
145
153
  // src/warning.ts
146
154
  function warn(...a) {
147
155
  const m = a.length === 1 ? a[0] : a[1];
@@ -164,6 +172,7 @@ function invariant(...a) {
164
172
  cast,
165
173
  chunk,
166
174
  clear,
175
+ compact,
167
176
  first,
168
177
  fromLength,
169
178
  has,
package/dist/index.mjs CHANGED
@@ -87,6 +87,13 @@ var isString = (v) => typeof v === "string";
87
87
  var isFunction = (v) => typeof v === "function";
88
88
  var hasProp = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);
89
89
 
90
+ // src/object.ts
91
+ function compact(obj) {
92
+ return Object.fromEntries(
93
+ Object.entries(obj).filter(([, value]) => value !== void 0).map(([key, value]) => [key, isObject(value) ? compact(value) : value])
94
+ );
95
+ }
96
+
90
97
  // src/warning.ts
91
98
  function warn(...a) {
92
99
  const m = a.length === 1 ? a[0] : a[1];
@@ -108,6 +115,7 @@ export {
108
115
  cast,
109
116
  chunk,
110
117
  clear,
118
+ compact,
111
119
  first,
112
120
  fromLength,
113
121
  has,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zag-js/utils",
3
- "version": "0.0.0-dev-20221031083441",
3
+ "version": "0.0.0-dev-20221105065843",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",