function MakeClonable(value) {
    if (Utils.IsCloneable(value)) {
      return value;
    }

    if (Buffer.isBuffer(value)) {
      return Utils.BufferToArrayBuffer(value);
    }

    switch ({}.toString.call(value).slice(8, -1)) {
      // Class
      case "Response":
      case "Function":
        return undefined;

      case "Boolean":
      case "Number":
      case "String":
      case "Date":
      case "RegExp":
      case "Blob":
      case "FileList":
      case "ImageData":
      case "ImageBitmap":
      case "ArrayBuffer":
        return value;

      case "Array":
        return value.map(function (element) {
          return Utils.MakeClonable(element);
        });

      case "Set":
        return new Set(Array.from(value.keys()).map(function (entry) {
          return Utils.MakeClonable(entry);
        }));

      case "Map":
        var cloneableMap = new Map();
        Array.from(value.keys()).forEach(function (key) {
          var cloneable = Utils.MakeClonable(value.get(key));

          if (cloneable) {
            cloneableMap.set(key, cloneable);
          }
        });
        return cloneableMap;

      case "Error":
        return value.message;

      case "Object":
        var cloneableObject = {};
        Object.keys(value).map(function (key) {
          var cloneable = Utils.MakeClonable(value[key]);

          if (cloneable) {
            cloneableObject[key] = cloneable;
          }
        });
        return cloneableObject;

      default:
        return JSON.parse(JSON.stringify(value));
    }
  }
/**
   * Make the given value cloneable if it is not already.
   *
   * Note: this will remove or transform any attributes of the object that are not cloneable (e.g. functions)
   *
   * Transformations:
   * - Buffer: Converted to ArrayBuffer
   * - Error: Converted to string (error.message)
   *
   * @param {*} value - Value to check
   * @returns {*} - Cloneable value
   */
Make the given value cloneable if it is not already.
Note: this will remove or transform any attributes of the object that are not cloneable

- Buffer: Converted to ArrayBuffer
- Error: Converted to string (error.message)

@param {*} value - Value to check
@returns {*} - Cloneable value
Make the given value cloneable if it is not already . Note : this will remove or transform any attributes of the object that are not cloneable - Buffer : Converted to ArrayBuffer - Error : Converted to string ( error . message ) @param { * } value - Value to check @returns { * } - Cloneable value
function MakeClonable(value) {
    if (Utils.IsCloneable(value)) {
      return value;
    }
    if (Buffer.isBuffer(value)) {
      return Utils.BufferToArrayBuffer(value);
    }
    switch ({}.toString.call(value).slice(8, -1)) {
      case "Response":
      case "Function":
        return undefined;
      case "Boolean":
      case "Number":
      case "String":
      case "Date":
      case "RegExp":
      case "Blob":
      case "FileList":
      case "ImageData":
      case "ImageBitmap":
      case "ArrayBuffer":
        return value;
      case "Array":
        return value.map(function (element) {
          return Utils.MakeClonable(element);
        });
      case "Set":
        return new Set(Array.from(value.keys()).map(function (entry) {
          return Utils.MakeClonable(entry);
        }));
      case "Map":
        var cloneableMap = new Map();
        Array.from(value.keys()).forEach(function (key) {
          var cloneable = Utils.MakeClonable(value.get(key));
          if (cloneable) {
            cloneableMap.set(key, cloneable);
          }
        });
        return cloneableMap;
      case "Error":
        return value.message;
      case "Object":
        var cloneableObject = {};
        Object.keys(value).map(function (key) {
          var cloneable = Utils.MakeClonable(value[key]);
          if (cloneable) {
            cloneableObject[key] = cloneable;
          }
        });
        return cloneableObject;
      default:
        return JSON.parse(JSON.stringify(value));
    }
  }
function MakeClonable ( value ) { if ( Utils . IsCloneable ( value ) ) { return value ; } if ( Buffer . isBuffer ( value ) ) { return Utils . BufferToArrayBuffer ( value ) ; } switch ( { } . toString . call ( value ) . slice ( 8 , - 1 ) ) { case "Response" : case "Function" : return undefined ; case "Boolean" : case "Number" : case "String" : case "Date" : case "RegExp" : case "Blob" : case "FileList" : case "ImageData" : case "ImageBitmap" : case "ArrayBuffer" : return value ; case "Array" : return value . map ( function ( element ) { return Utils . MakeClonable ( element ) ; } ) ; case "Set" : return new Set ( Array . from ( value . keys ( ) ) . map ( function ( entry ) { return Utils . MakeClonable ( entry ) ; } ) ) ; case "Map" : var cloneableMap = new Map ( ) ; Array . from ( value . keys ( ) ) . forEach ( function ( key ) { var cloneable = Utils . MakeClonable ( value . get ( key ) ) ; if ( cloneable ) { cloneableMap . set ( key , cloneable ) ; } } ) ; return cloneableMap ; case "Error" : return value . message ; case "Object" : var cloneableObject = { } ; Object . keys ( value ) . map ( function ( key ) { var cloneable = Utils . MakeClonable ( value [ key ] ) ; if ( cloneable ) { cloneableObject [ key ] = cloneable ; } } ) ; return cloneableObject ; default : return JSON . parse ( JSON . stringify ( value ) ) ; } }
Make the given value cloneable if it is not already.
Make the given value cloneable if it is not already .
// Class