• This function is used to create a deep clone of plain values. It can handle arrays, plain objects, and primitives. For non-plain objects, it either transfers them as is or throws an error, based on the transferUnclonables flag.

    Type Parameters

    • T

    Parameters

    • value: T

      The value to be cloned.

    • Optional transferUnclonables: boolean

      A flag indicating whether to transfer unclonable values as is. If false, the function will throw an error when encountering an unclonable value.

    Returns T

    The cloned value.

    Throws

    Throws an error if the function encounters a non-plain object and transferUnclonables is false.