/**

  • Creates a dehydrated object with the given parameters.
  • @param {string} type - The type of the data.
  • @param {boolean} inspectable - Indicates whether the data can be inspected.
  • @param {Object} data - The data to be dehydrated.
  • @param {Array<Array<string | number>>} cleaned - The cleaned array to store paths of dehydrated objects.
  • @param {Array<string | number>} path - The path of the current dehydrated object.
  • @returns {Dehydrated} - The dehydrated object. */ function createDehydrated(type, inspectable, data, cleaned, path) { // Add the current path to the cleaned array cleaned.push(path);

// Create the dehydrated object const dehydrated = { inspectable, type, preview_long: formatDataForPreview(data, true), preview_short: formatDataForPreview(data, false), name: !data.constructor || data.constructor.name === 'Object' ? '' : data.constructor.name, };

// Set the size property based on the type of data if (type === 'array' || type === 'typed_array') { dehydrated.size = data.length; } else if (type === 'object') { dehydrated.size = Object.keys(data).length; }

// Set the readonly property for iterator or typed_array types if (type === 'iterator' || type === 'typed_array') { dehydrated.readonly = true; }

return dehydrated;

function createDehydrated type string inspectable boolean data Object cleaned ArrayArraystring number path Arraystring number Dehydrated cleanedpushpath; const dehydrated Dehydrated = in

原文地址: http://www.cveoy.top/t/topic/iFfG 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录