Member Junction
    Preparing search index...

    Function CopyScalarsAndArrays

    • This utility function will copy all scalar and array properties from an object to a new object and return the new object. This function will NOT copy non-plain object instances (unless they implement toJSON() or resolveCircularReferences is true).

      The function respects the standard JavaScript toJSON() protocol: if a value exposes a toJSON() method (as Date, BaseInfo subclasses, and user-defined classes can), the method is invoked and its return value is processed in place of the original. This mirrors how JSON.stringify() handles serialization.

      Arrays are recursively processed — each item is copied/toJSON'd individually — so nested objects with toJSON() are unwrapped to their serializable form.

      Type Parameters

      • T extends object

      Parameters

      • input: T

        The object to copy

      • resolveCircularReferences: boolean = false

        If true, handles circular references and complex objects for safe JSON serialization. When enabled, circular references are replaced with '[Circular Reference]', complex objects without toJSON() are replaced with their type names, Error objects are specially handled to extract name/message/stack, and Dates are converted to ISO strings. Default: false

      • maxDepth: number = 10

        Maximum recursion depth when resolveCircularReferences is true (default: 10)

      Returns Partial<T>

      A new object with scalars and arrays copied