@forklaunch/common 0.6.15 → 0.6.16

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/lib/index.d.mts CHANGED
@@ -180,6 +180,15 @@ declare function getTransformationInfo(str: string): {
180
180
  isValid: boolean;
181
181
  };
182
182
 
183
+ /**
184
+ * Deep clones an object while removing all undefined values.
185
+ * Preserves methods, getters/setters, non-enumerable properties, symbols, and prototype chains.
186
+ * @param {unknown} obj - The object to clone.
187
+ * @param {WeakMap} seen - Map to track circular references.
188
+ * @returns {unknown} The cloned object without undefined values.
189
+ */
190
+ declare function deepCloneWithoutUndefined<T>(obj: T, seen?: WeakMap<WeakKey, any>): T;
191
+
183
192
  /**
184
193
  * An empty object literal constant.
185
194
  *
@@ -646,4 +655,4 @@ type UnionToIntersectionChildren<U> = {
646
655
  [K in keyof U]: UnionToIntersection<U[K]>;
647
656
  };
648
657
 
649
- export { type CamelCaseIdentifier, type EmptyObject, type ExclusiveRecord, type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, InMemoryBlob, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type MergeArrayOfMaps, type MergeUnionOnCollision, type MimeType, type Prettify, type PrettyCamelCase, type RecordTimingDto, type RemoveDoubleLeadingSlash, type RemoveTrailingSlash, type ReturnTypeRecord, type SanitizePathSlashes, type StringWithoutSlash, type TypeSafeFunction, type UnionToIntersection, type UnionToIntersectionChildren, type ValidIdentifier, capitalize, emptyObject, extractArgumentNames, getEnvVar, getTransformationInfo, hashString, isAsyncGenerator, isNever, isNodeJsWriteableStream, isRecord, isTrue, isValidIdentifier, noop, openApiCompliantPath, readableStreamToAsyncIterable, removeDoubleLeadingSlash, removeLeadingNumbers, removeLeadingSeparators, removeNonAlphanumeric, removeTrailingSlash, safeParse, safeStringify, sanitizePathSlashes, sortObjectKeys, splitBySeparators, stripUndefinedProperties, toCamelCaseIdentifier, toPrettyCamelCase, toRecord, toValidIdentifier, uncapitalize };
658
+ export { type CamelCaseIdentifier, type EmptyObject, type ExclusiveRecord, type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, InMemoryBlob, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type MergeArrayOfMaps, type MergeUnionOnCollision, type MimeType, type Prettify, type PrettyCamelCase, type RecordTimingDto, type RemoveDoubleLeadingSlash, type RemoveTrailingSlash, type ReturnTypeRecord, type SanitizePathSlashes, type StringWithoutSlash, type TypeSafeFunction, type UnionToIntersection, type UnionToIntersectionChildren, type ValidIdentifier, capitalize, deepCloneWithoutUndefined, emptyObject, extractArgumentNames, getEnvVar, getTransformationInfo, hashString, isAsyncGenerator, isNever, isNodeJsWriteableStream, isRecord, isTrue, isValidIdentifier, noop, openApiCompliantPath, readableStreamToAsyncIterable, removeDoubleLeadingSlash, removeLeadingNumbers, removeLeadingSeparators, removeNonAlphanumeric, removeTrailingSlash, safeParse, safeStringify, sanitizePathSlashes, sortObjectKeys, splitBySeparators, stripUndefinedProperties, toCamelCaseIdentifier, toPrettyCamelCase, toRecord, toValidIdentifier, uncapitalize };
package/lib/index.d.ts CHANGED
@@ -180,6 +180,15 @@ declare function getTransformationInfo(str: string): {
180
180
  isValid: boolean;
181
181
  };
182
182
 
183
+ /**
184
+ * Deep clones an object while removing all undefined values.
185
+ * Preserves methods, getters/setters, non-enumerable properties, symbols, and prototype chains.
186
+ * @param {unknown} obj - The object to clone.
187
+ * @param {WeakMap} seen - Map to track circular references.
188
+ * @returns {unknown} The cloned object without undefined values.
189
+ */
190
+ declare function deepCloneWithoutUndefined<T>(obj: T, seen?: WeakMap<WeakKey, any>): T;
191
+
183
192
  /**
184
193
  * An empty object literal constant.
185
194
  *
@@ -646,4 +655,4 @@ type UnionToIntersectionChildren<U> = {
646
655
  [K in keyof U]: UnionToIntersection<U[K]>;
647
656
  };
648
657
 
649
- export { type CamelCaseIdentifier, type EmptyObject, type ExclusiveRecord, type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, InMemoryBlob, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type MergeArrayOfMaps, type MergeUnionOnCollision, type MimeType, type Prettify, type PrettyCamelCase, type RecordTimingDto, type RemoveDoubleLeadingSlash, type RemoveTrailingSlash, type ReturnTypeRecord, type SanitizePathSlashes, type StringWithoutSlash, type TypeSafeFunction, type UnionToIntersection, type UnionToIntersectionChildren, type ValidIdentifier, capitalize, emptyObject, extractArgumentNames, getEnvVar, getTransformationInfo, hashString, isAsyncGenerator, isNever, isNodeJsWriteableStream, isRecord, isTrue, isValidIdentifier, noop, openApiCompliantPath, readableStreamToAsyncIterable, removeDoubleLeadingSlash, removeLeadingNumbers, removeLeadingSeparators, removeNonAlphanumeric, removeTrailingSlash, safeParse, safeStringify, sanitizePathSlashes, sortObjectKeys, splitBySeparators, stripUndefinedProperties, toCamelCaseIdentifier, toPrettyCamelCase, toRecord, toValidIdentifier, uncapitalize };
658
+ export { type CamelCaseIdentifier, type EmptyObject, type ExclusiveRecord, type Flatten, type FlattenKeys, type FlattenValues, type IdDto, type IdsDto, InMemoryBlob, type InstanceTypeRecord, type MakePropertyOptionalIfChildrenOptional, type MergeArrayOfMaps, type MergeUnionOnCollision, type MimeType, type Prettify, type PrettyCamelCase, type RecordTimingDto, type RemoveDoubleLeadingSlash, type RemoveTrailingSlash, type ReturnTypeRecord, type SanitizePathSlashes, type StringWithoutSlash, type TypeSafeFunction, type UnionToIntersection, type UnionToIntersectionChildren, type ValidIdentifier, capitalize, deepCloneWithoutUndefined, emptyObject, extractArgumentNames, getEnvVar, getTransformationInfo, hashString, isAsyncGenerator, isNever, isNodeJsWriteableStream, isRecord, isTrue, isValidIdentifier, noop, openApiCompliantPath, readableStreamToAsyncIterable, removeDoubleLeadingSlash, removeLeadingNumbers, removeLeadingSeparators, removeNonAlphanumeric, removeTrailingSlash, safeParse, safeStringify, sanitizePathSlashes, sortObjectKeys, splitBySeparators, stripUndefinedProperties, toCamelCaseIdentifier, toPrettyCamelCase, toRecord, toValidIdentifier, uncapitalize };
package/lib/index.js CHANGED
@@ -22,6 +22,7 @@ var index_exports = {};
22
22
  __export(index_exports, {
23
23
  InMemoryBlob: () => InMemoryBlob,
24
24
  capitalize: () => capitalize,
25
+ deepCloneWithoutUndefined: () => deepCloneWithoutUndefined,
25
26
  emptyObject: () => emptyObject,
26
27
  extractArgumentNames: () => extractArgumentNames,
27
28
  getEnvVar: () => getEnvVar,
@@ -145,6 +146,80 @@ function getTransformationInfo(str) {
145
146
  };
146
147
  }
147
148
 
149
+ // src/deepCloneWithoutUndefined.ts
150
+ function deepCloneWithoutUndefined(obj, seen = /* @__PURE__ */ new WeakMap()) {
151
+ if (obj === null || obj === void 0) {
152
+ return obj;
153
+ }
154
+ if (typeof obj !== "object" && typeof obj !== "function") {
155
+ return obj;
156
+ }
157
+ if (seen.has(obj)) {
158
+ return seen.get(obj);
159
+ }
160
+ if (obj instanceof Date) {
161
+ return new Date(obj.getTime());
162
+ }
163
+ if (obj instanceof RegExp) {
164
+ return new RegExp(obj.source, obj.flags);
165
+ }
166
+ if (obj instanceof Map) {
167
+ const clonedMap = /* @__PURE__ */ new Map();
168
+ seen.set(obj, clonedMap);
169
+ obj.forEach((value, key) => {
170
+ if (value !== void 0) {
171
+ clonedMap.set(key, deepCloneWithoutUndefined(value, seen));
172
+ }
173
+ });
174
+ return clonedMap;
175
+ }
176
+ if (obj instanceof Set) {
177
+ const clonedSet = /* @__PURE__ */ new Set();
178
+ seen.set(obj, clonedSet);
179
+ obj.forEach((value) => {
180
+ if (value !== void 0) {
181
+ clonedSet.add(deepCloneWithoutUndefined(value, seen));
182
+ }
183
+ });
184
+ return clonedSet;
185
+ }
186
+ if (Array.isArray(obj)) {
187
+ const clonedArray = [];
188
+ seen.set(obj, clonedArray);
189
+ for (const item of obj) {
190
+ if (item !== void 0) {
191
+ clonedArray.push(deepCloneWithoutUndefined(item, seen));
192
+ }
193
+ }
194
+ return clonedArray;
195
+ }
196
+ if (typeof obj === "function") {
197
+ return obj;
198
+ }
199
+ const proto = Object.getPrototypeOf(obj);
200
+ const cloned = Object.create(proto);
201
+ seen.set(obj, cloned);
202
+ const allKeys = [
203
+ ...Object.getOwnPropertyNames(obj),
204
+ ...Object.getOwnPropertySymbols(obj)
205
+ ];
206
+ for (const key of allKeys) {
207
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
208
+ if (!descriptor) continue;
209
+ if ("value" in descriptor) {
210
+ if (descriptor.value !== void 0) {
211
+ Object.defineProperty(cloned, key, {
212
+ ...descriptor,
213
+ value: deepCloneWithoutUndefined(descriptor.value, seen)
214
+ });
215
+ }
216
+ } else {
217
+ Object.defineProperty(cloned, key, descriptor);
218
+ }
219
+ }
220
+ return cloned;
221
+ }
222
+
148
223
  // src/emptyObject.ts
149
224
  var emptyObject = {};
150
225
 
@@ -373,6 +448,7 @@ function toRecord(obj) {
373
448
  0 && (module.exports = {
374
449
  InMemoryBlob,
375
450
  capitalize,
451
+ deepCloneWithoutUndefined,
376
452
  emptyObject,
377
453
  extractArgumentNames,
378
454
  getEnvVar,
package/lib/index.mjs CHANGED
@@ -88,6 +88,80 @@ function getTransformationInfo(str) {
88
88
  };
89
89
  }
90
90
 
91
+ // src/deepCloneWithoutUndefined.ts
92
+ function deepCloneWithoutUndefined(obj, seen = /* @__PURE__ */ new WeakMap()) {
93
+ if (obj === null || obj === void 0) {
94
+ return obj;
95
+ }
96
+ if (typeof obj !== "object" && typeof obj !== "function") {
97
+ return obj;
98
+ }
99
+ if (seen.has(obj)) {
100
+ return seen.get(obj);
101
+ }
102
+ if (obj instanceof Date) {
103
+ return new Date(obj.getTime());
104
+ }
105
+ if (obj instanceof RegExp) {
106
+ return new RegExp(obj.source, obj.flags);
107
+ }
108
+ if (obj instanceof Map) {
109
+ const clonedMap = /* @__PURE__ */ new Map();
110
+ seen.set(obj, clonedMap);
111
+ obj.forEach((value, key) => {
112
+ if (value !== void 0) {
113
+ clonedMap.set(key, deepCloneWithoutUndefined(value, seen));
114
+ }
115
+ });
116
+ return clonedMap;
117
+ }
118
+ if (obj instanceof Set) {
119
+ const clonedSet = /* @__PURE__ */ new Set();
120
+ seen.set(obj, clonedSet);
121
+ obj.forEach((value) => {
122
+ if (value !== void 0) {
123
+ clonedSet.add(deepCloneWithoutUndefined(value, seen));
124
+ }
125
+ });
126
+ return clonedSet;
127
+ }
128
+ if (Array.isArray(obj)) {
129
+ const clonedArray = [];
130
+ seen.set(obj, clonedArray);
131
+ for (const item of obj) {
132
+ if (item !== void 0) {
133
+ clonedArray.push(deepCloneWithoutUndefined(item, seen));
134
+ }
135
+ }
136
+ return clonedArray;
137
+ }
138
+ if (typeof obj === "function") {
139
+ return obj;
140
+ }
141
+ const proto = Object.getPrototypeOf(obj);
142
+ const cloned = Object.create(proto);
143
+ seen.set(obj, cloned);
144
+ const allKeys = [
145
+ ...Object.getOwnPropertyNames(obj),
146
+ ...Object.getOwnPropertySymbols(obj)
147
+ ];
148
+ for (const key of allKeys) {
149
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
150
+ if (!descriptor) continue;
151
+ if ("value" in descriptor) {
152
+ if (descriptor.value !== void 0) {
153
+ Object.defineProperty(cloned, key, {
154
+ ...descriptor,
155
+ value: deepCloneWithoutUndefined(descriptor.value, seen)
156
+ });
157
+ }
158
+ } else {
159
+ Object.defineProperty(cloned, key, descriptor);
160
+ }
161
+ }
162
+ return cloned;
163
+ }
164
+
91
165
  // src/emptyObject.ts
92
166
  var emptyObject = {};
93
167
 
@@ -315,6 +389,7 @@ function toRecord(obj) {
315
389
  export {
316
390
  InMemoryBlob,
317
391
  capitalize,
392
+ deepCloneWithoutUndefined,
318
393
  emptyObject,
319
394
  extractArgumentNames,
320
395
  getEnvVar,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/common",
3
- "version": "0.6.15",
3
+ "version": "0.6.16",
4
4
  "description": "Common package for base types, interfaces, implementations.",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {