API Reference

DeepCloneValueExceptclass

Transforms special values into clone-safe values during deep clone.

Overview

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

When to use

This is the default implementation behind the IDeepCloneExcept contract. LodashDeepClone calls except(...) while traversing values and uses the returned value when special clone handling is needed. For Promise and Observable nodes, this strategy reads IResolvedValueCache and substitutes the latest resolved value, or the PENDING sentinel when no resolved value is available yet.

Quick facts
Kind
class
Members
2
Package
@rs-x/core

Import

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

Example

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

// Default behavior used by LodashDeepClone:
// Promise/Observable -> resolved cache value (or PENDING)
const cloneExcept = InjectionContainer.get<IDeepCloneExcept>(
  RsXCoreInjectionTokens.DefaultDeepCloneExcept,
);

// Example: manually inspect what except() returns for an async source.
const cache = InjectionContainer.get<IResolvedValueCache>(
  RsXCoreInjectionTokens.IResolvedValueCache,
);
const promise = Promise.resolve(42);
cache.set(promise, 42);
const replaced = cloneExcept.except(promise); // 42

Constructor injection example

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

class CloneConsumer {
  constructor(
    @Inject(RsXCoreInjectionTokens.DefaultDeepCloneExcept)
    private readonly cloneExceptByDi: IDeepCloneExcept,
  ) {}
}

Members

2 members in this class.

constructor
constructorpublic
constructor(
  @Inject(RsXCoreInjectionTokens.IResolvedValueCache) private readonly _resolvedValueCache: IResolvedValueCache
)

Parameters

Name
Type
Required
_resolvedValueCache
IResolvedValueCache
required
except
methodpublic
except(source: unknown): unknown

Parameters

Name
Type
Required
source
unknown
required

Returns

unknown