📄 cloneDeeplyExcludesParent¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/rule-tester/src/utils/cloneDeeplyExcludesParent.ts
Functions¶
cloneDeeplyExcludesParent(x: T): T¶
Clones a given value deeply.
Note: This ignores parent property.
Calls:
Array.isArrayx.mapObject.hasOwncloneDeeplyExcludesParent
Code
export function cloneDeeplyExcludesParent<T>(x: T): T {
if (typeof x === 'object' && x != null) {
if (Array.isArray(x)) {
return x.map(cloneDeeplyExcludesParent) as T;
}
const retv = {} as typeof x;
for (const key in x) {
if (key !== 'parent' && Object.hasOwn(x, key)) {
retv[key] = cloneDeeplyExcludesParent(x[key]);
}
}
return retv;
}
return x;
}
Generated by Syntax Scribe