Overview
Used to deep clone values safely, including proxy-aware cloning and async-value normalization.
API Reference
Transforms special values into clone-safe values during deep clone.
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.
import { DeepCloneValueExcept } from '@rs-x/core';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); // 42import {
Inject,
RsXCoreInjectionTokens,
type IDeepCloneExcept,
} from '@rs-x/core';
class CloneConsumer {
constructor(
@Inject(RsXCoreInjectionTokens.DefaultDeepCloneExcept)
private readonly cloneExceptByDi: IDeepCloneExcept,
) {}
}2 members in this class.
constructor(
@Inject(RsXCoreInjectionTokens.IResolvedValueCache) private readonly _resolvedValueCache: IResolvedValueCache
)Parameters
except(source: unknown): unknownParameters
Returns
unknown