Overview
Used to deep clone values safely, including proxy-aware cloning and async-value normalization.
API Reference
Clones values with the platform structured clone behavior.
This implementation delegates to the platform structured clone behavior and is useful when you want a direct structuredClone-style copy without Lodash traversal. Use RsXCoreInjectionTokens.IStructuredDeepClone when you explicitly want this implementation. Use RsXCoreInjectionTokens.IDeepClone when you want the currently configured default clone service.
import { StructuredDeepClone } from '@rs-x/core';import {
InjectionContainer,
RsXCoreInjectionTokens,
type IDeepClone,
} from '@rs-x/core';
// Resolve via container.
const structuredDeepClone = InjectionContainer.get<IDeepClone>(
RsXCoreInjectionTokens.IStructuredDeepClone,
);
const cloned = structuredDeepClone.clone({ a: 1, nested: { b: 2 } });
console.log(cloned);import { Inject, RsXCoreInjectionTokens, type IDeepClone } from '@rs-x/core';
class CloneConsumer {
constructor(
@Inject(RsXCoreInjectionTokens.IStructuredDeepClone)
private readonly structuredDeepCloneByDi: IDeepClone,
) {}
}1 member in this class.
public clone(source: unknown): unknownParameters
Returns
unknown