API Reference

StructuredDeepCloneclass

Clones values with the platform structured clone behavior.

Overview

Used to deep clone values safely, including proxy-aware cloning and async-value normalization.

When to use

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.

Quick facts
Kind
class
Implements
IDeepClone
Members
1
Package
@rs-x/core

Import

import { StructuredDeepClone } from '@rs-x/core';

Example

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);

Constructor injection example

import { Inject, RsXCoreInjectionTokens, type IDeepClone } from '@rs-x/core';

class CloneConsumer {
  constructor(
    @Inject(RsXCoreInjectionTokens.IStructuredDeepClone)
    private readonly structuredDeepCloneByDi: IDeepClone,
  ) {}
}

Members

1 member in this class.

clone
methodpublic
public clone(source: unknown): unknown

Parameters

Name
Type
Required
source
unknown
required

Returns

unknown