Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "object/clone"

Index

Type aliases

PolyfillRequired

PolyfillRequired<T, TNames>: object

Type parameters

  • T

  • TNames: string

Type declaration

TInstanceCloner

TInstanceCloner: function

Custom Cloner Function

Type declaration

TNonOptionalCloneOptions

TNonOptionalCloneOptions: PolyfillRequired<ICloneOptions, keyof ICloneOptions>

Cloning options with all properties required

see

ICloneOptions

Functions

clone

  • clone<T>(objectToClone: T, __namedParameters?: object): T
  • A function to recursively clone objects, arrays etc. with cloning options

    References Functions & Symbols by default


    Example:

    import { clone } from "@thalesrc/js-utils/object";
    
    const object = {a: 1, b: {c: true, d: ["x", "y"]}};
    
    // Clone all
    const clonedObject = clone(object);
    // {a: 1, b: {c: true, d: ["x", "y"]}}
    // object.b.d === clonedObject.b.d // false
    
    // Clone all but reference "d"
    const clonedObject = clone(object, {propsToRefer: ["d"]});
    // {a: 1, b: {c: true, d: ["x", "y"]}}
    // object.b.d === clonedObject.b.d // true

    Static usage example:

    import "@thalesrc/js-utils/object/static/clone";
    
    const object = {a: 1, b: 2};
    const clonedObject = Object.clone(object); // {a: 1, b: 2}

    see

    ICloneOptions for more information.

    Type parameters

    • T

    Parameters

    • objectToClone: T

      Object to clone

    • Default value __namedParameters: object = <ICloneOptions>{}

    Returns T

Generated using TypeDoc