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AC,EAAE,CAAC,EACzC;IACJ,CAAC;IAfD,kCAeC","sourcesContent":["import { CancellablePromise, deepMixin } from '@theintern/common';\n\nimport { Config, ResourceConfig } from './config';\nimport { Events, Executor, PluginDescriptor } from '../executors/Executor';\nimport { getPathSep, join, normalize } from './path';\nimport { InternError } from '../types';\n\nexport interface EvaluatedProperty {\n name: keyof Config;\n addToExisting: boolean;\n}\n\nexport interface TextLoader {\n (path: string): CancellablePromise<string>;\n}\n\nexport type TypeName =\n | 'string'\n | 'boolean'\n | 'number'\n | 'regexp'\n | 'object'\n | 'string[]'\n | 'object[]';\n\nexport type Parser<T = any> = (value: any) => T;\n\n/**\n * Evaluate a config property key\n */\nexport function evalProperty<C>(key: keyof C): EvaluatedProperty {\n const strKey = <string>key;\n const addToExisting = strKey[strKey.length - 1] === '+';\n const name = <keyof Config>(\n (addToExisting ? strKey.slice(0, strKey.length - 1) : key)\n );\n return { name, addToExisting };\n}\n\n/**\n * Get the base path based on a config file path and a user-supplied base path.\n *\n * The path separator will be normalized based on the separator used in\n * configFile or basePath and the optional pathSep arg.\n */\nexport function getBasePath(\n configFile: string,\n basePath: string,\n isAbsolute: (path: string) => boolean,\n pathSep?: string\n) {\n pathSep = pathSep || getPathSep(configFile, basePath);\n\n // initialBasePath is the path containing the config file\n const configPathParts = configFile.replace(/\\\\/g, '/').split('/');\n let initialBasePath: string;\n\n if (configFile[0] === '/' && configPathParts.length === 2) {\n initialBasePath = '/';\n } else {\n initialBasePath = configPathParts.slice(0, -1).join('/');\n }\n\n let finalBasePath: string;\n\n if (basePath) {\n basePath = normalize(basePath);\n\n if (isAbsolute(basePath)) {\n // basePath is absolute, so use it directly\n finalBasePath = basePath;\n } else {\n // basePath is relative, so resolve it against initialBasePath\n finalBasePath = join(initialBasePath, basePath);\n }\n } else {\n // No basePath was provided, so use initialBasePath\n finalBasePath = initialBasePath;\n }\n\n return finalBasePath.split('/').join(pathSep);\n}\n\n/**\n * Return a string describing a config file, including any child configs.\n */\nexport function getConfigDescription(config: any, prefix = '') {\n let description = '';\n\n if (config.description) {\n description += `${prefix}${config.description}\\n\\n`;\n }\n\n if (config.configs) {\n description += `${prefix}Configs:\\n`;\n const width = Object.keys(config.configs).reduce((width, name) => {\n return Math.max(width, name.length);\n }, 0);\n const lines = Object.keys(config.configs).map((name) => {\n const child = config.configs[name];\n while (name.length < width) {\n name += ' ';\n }\n let line = ` ${name}`;\n if (child.description) {\n line += ` (${child.description})`;\n }\n return `${prefix}${line}`;\n });\n\n description += lines.join('\\n');\n }\n\n return description;\n}\n\n/**\n * Load config data from a given path, using a given text loader, and mixing\n * args and/or a childConfig into the final config value if provided.\n */\nexport function loadConfig(\n configPath: string,\n loadText: TextLoader,\n args?: { [key: string]: any },\n childConfig?: string | string[]\n): CancellablePromise<any> {\n return _loadConfig(configPath, loadText, args, childConfig).then((config) => {\n // 'config' and 'extends' are only applicable to the config loader, not\n // the Executors\n delete config.config;\n delete config.extends;\n\n if (!(args && (args.showConfigs || args.help))) {\n // 'configs' is only relevant if we're showing configs\n delete config.configs;\n }\n\n return config;\n });\n}\n\n/**\n * Parse an array of name=value arguments into an object\n */\nexport function parseArgs(rawArgs: string[]) {\n const parsedArgs: { [key: string]: any } = {};\n\n for (const arg of rawArgs) {\n let name = arg;\n let value: string | undefined;\n let args = parsedArgs;\n\n const eq = arg.indexOf('=');\n if (eq !== -1) {\n name = arg.slice(0, eq);\n value = arg.slice(eq + 1);\n }\n\n if (name.indexOf('.') !== -1) {\n const parts = name.split('.');\n const head = parts.slice(0, parts.length - 1);\n name = parts[parts.length - 1];\n\n for (const part of head) {\n if (!args[part]) {\n args[part] = {};\n }\n args = args[part];\n }\n }\n\n if (typeof value === 'undefined') {\n args[name] = true;\n } else {\n if (!(name in args)) {\n args[name] = value;\n } else if (!Array.isArray(args[name])) {\n args[name] = [args[name], value];\n } else {\n args[name].push(value);\n }\n }\n }\n\n return parsedArgs;\n}\n\n/**\n * Parse a JSON string that may contain comments\n */\nexport function parseJson(json: string) {\n return JSON.parse(removeComments(json));\n}\n\n/**\n * Parse a particular type of value from a given value\n *\n * @param name The 'name' of the value being parsed (used for error messages)\n * @param value A value to parse something from\n * @param parser The type of thing to parse, or a parser function\n * @param requiredProperty Only used with 'object' and 'object[]' parsers\n */\nexport function parseValue(\n name: string,\n value: any,\n parser: TypeName | Parser,\n requiredProperty?: string\n) {\n switch (parser) {\n case 'boolean':\n if (typeof value === 'boolean') {\n return value;\n }\n if (value === 'true') {\n return true;\n }\n if (value === 'false') {\n return false;\n }\n throw new Error(`Non-boolean value \"${value}\" for ${name}`);\n\n case 'number':\n const numValue = Number(value);\n if (!isNaN(numValue)) {\n return numValue;\n }\n throw new Error(`Non-numeric value \"${value}\" for ${name}`);\n\n case 'regexp':\n if (typeof value === 'string') {\n return new RegExp(value);\n }\n if (value instanceof RegExp) {\n return value;\n }\n throw new Error(`Non-regexp value \"${value}\" for ${name}`);\n\n case 'object':\n if (typeof value === 'string') {\n try {\n value = value ? JSON.parse(value) : {};\n } catch (error) {\n if (!requiredProperty) {\n throw new Error(`Non-object value \"${value}\" for ${name}`);\n }\n value = { [requiredProperty]: value };\n }\n }\n // A value of type 'object' should be a simple object, not a\n // built-in type like RegExp or Array\n if (Object.prototype.toString.call(value) === '[object Object]') {\n if (requiredProperty && !value[requiredProperty]) {\n throw new Error(\n `Invalid value \"${JSON.stringify(\n value\n )}\" for ${name}: missing '${requiredProperty}' property`\n );\n }\n return value;\n }\n throw new Error(`Non-object value \"${value}\" for ${name}`);\n\n case 'object[]':\n if (!value) {\n value = [];\n }\n if (!Array.isArray(value)) {\n value = [value];\n }\n return value.map((item: any) => {\n return parseValue(name, item, 'object', requiredProperty);\n });\n\n case 'string':\n if (typeof value === 'string') {\n return value;\n }\n throw new Error(`Non-string value \"${value}\" for ${name}`);\n\n case 'string[]':\n if (!value) {\n value = [];\n }\n if (typeof value === 'string') {\n value = [value];\n }\n if (Array.isArray(value) && value.every((v) => typeof v === 'string')) {\n return value;\n }\n throw new Error(`Non-string[] value \"${value}\" for ${name}`);\n\n default:\n if (typeof parser === 'function') {\n return parser(value);\n } else {\n throw new Error('Parser must be a valid type name');\n }\n }\n}\n\n/**\n * Return a string with all lines prefixed with a given prefix.\n */\nexport function prefix(message: string, prefix: string) {\n return message\n .split('\\n')\n .map((line) => prefix + line)\n .join('\\n');\n}\n\n/**\n * Process a Config option, transforming it to a canonical form and storing it\n * on the given config object.\n *\n * If an executor is provided, it will be used to emit deprecation and log\n * events.\n */\nexport function processOption<C extends Config>(\n key: keyof C,\n value: any,\n config: C,\n executor?: Executor\n) {\n const { name, addToExisting } = evalProperty<C>(key);\n const emit = executor\n ? (eventName: keyof Events, data?: any) => {\n executor.emit(eventName, data);\n }\n : (..._args: any[]) => {};\n\n switch (name) {\n case 'loader': {\n setOption(config, name, parseValue(name, value, 'object', 'script'));\n break;\n }\n case 'bail':\n case 'baseline':\n case 'benchmark':\n case 'debug':\n case 'filterErrorStack':\n case 'showConfig': {\n setOption(config, name, parseValue(name, value, 'boolean'));\n break;\n }\n case 'basePath':\n case 'coverageVariable':\n case 'description':\n case 'internPath':\n case 'name':\n case 'sessionId': {\n setOption(config, name, parseValue(name, value, 'string'));\n break;\n }\n case 'defaultTimeout': {\n setOption(config, name, parseValue(name, value, 'number'));\n break;\n }\n case 'grep': {\n setOption(config, name, parseValue(name, value, 'regexp'));\n break;\n }\n case 'reporters': {\n setOption(\n config,\n name,\n parseValue(name, value, 'object[]', 'name'),\n addToExisting\n );\n break;\n }\n case 'plugins':\n case 'requires':\n case 'require':\n case 'scripts': {\n let useLoader = false;\n let _name = name;\n switch (name) {\n case 'scripts':\n emit('deprecated', {\n original: 'scripts',\n replacement: 'plugins',\n });\n _name = 'plugins';\n break;\n case 'require':\n emit('deprecated', {\n original: 'require',\n replacement: 'plugins',\n });\n _name = 'plugins';\n break;\n case 'requires':\n emit('deprecated', {\n original: 'require',\n replacement: 'plugins',\n message: 'Set `useLoader: true`',\n });\n _name = 'plugins';\n useLoader = true;\n break;\n }\n const parsed = parseValue(_name, value, 'object[]', 'script');\n if (useLoader) {\n parsed.forEach((entry: PluginDescriptor) => {\n entry.useLoader = true;\n });\n }\n setOption(config, _name, parsed, addToExisting);\n break;\n }\n case 'suites': {\n setOption(\n config,\n name,\n parseValue(name, value, 'string[]'),\n addToExisting\n );\n break;\n }\n case 'node':\n case 'browser': {\n const envConfig: ResourceConfig = config[name] || {};\n if (!config[name]) {\n config[name] = envConfig;\n }\n const envName = name;\n const _value = parseValue(name, value, 'object');\n if (_value) {\n Object.keys(_value).forEach((valueKey) => {\n const key = <keyof ResourceConfig>valueKey;\n let resource = _value[key];\n let { name, addToExisting } = evalProperty(key);\n switch (name) {\n case 'loader': {\n resource = parseValue(name, resource, 'object', 'script');\n setOption(<Config>envConfig, name, resource, false);\n break;\n }\n case 'reporters': {\n resource = parseValue('reporters', resource, 'object[]', 'name');\n setOption(<Config>envConfig, name, resource, addToExisting);\n break;\n }\n case 'plugins':\n case 'require':\n case 'requires':\n case 'scripts': {\n let useLoader = false;\n switch (name) {\n case 'scripts': {\n emit('deprecated', {\n original: 'scripts',\n replacement: 'plugins',\n });\n name = 'plugins';\n break;\n }\n case 'require': {\n emit('deprecated', {\n original: 'require',\n replacement: 'plugins',\n });\n name = 'plugins';\n break;\n }\n case 'requires': {\n emit('deprecated', {\n original: 'requires',\n replacement: 'plugins',\n message: 'Set `useLoader: true`',\n });\n name = 'plugins';\n useLoader = true;\n break;\n }\n }\n resource = parseValue(name, resource, 'object[]', 'script');\n if (useLoader) {\n resource.forEach((entry: PluginDescriptor) => {\n entry.useLoader = true;\n });\n }\n setOption(\n <Config>envConfig,\n <keyof Config>name,\n resource,\n addToExisting\n );\n break;\n }\n case 'suites': {\n resource = parseValue(name, resource, 'string[]');\n setOption(<Config>envConfig, name, resource, addToExisting);\n break;\n }\n case 'tsconfig': {\n resource = parseValue(name, resource, (tsconfig) => {\n let value;\n\n if (tsconfig === false || tsconfig === 'false') {\n value = false;\n } else if (typeof tsconfig === 'string') {\n value = tsconfig;\n }\n\n if (typeof value === 'undefined') {\n throw new Error('\"tsconfig\" must be a string or `false`');\n }\n\n return value;\n });\n setOption(<Config>envConfig, name, resource);\n break;\n }\n default: {\n throw new Error(`Invalid property ${key} in ${envName} config`);\n }\n }\n });\n }\n break;\n }\n case 'functionalBaseUrl':\n case 'serverUrl': {\n setOption(config, name, parseValue(name, value, 'string'));\n break;\n }\n case 'proxy': {\n if (value == null) {\n setOption(config, name, undefined);\n } else {\n setOption(config, name, parseValue(name, value, 'string'));\n }\n break;\n }\n case 'capabilities':\n case 'instrumenterOptions':\n case 'tunnelOptions': {\n setOption(config, name, parseValue(name, value, 'object'), addToExisting);\n break;\n }\n case 'environments': {\n // Must be a string, object, or array of (string | object)\n let _value = value;\n if (!_value) {\n _value = [];\n } else if (!Array.isArray(_value)) {\n _value = [_value];\n }\n _value = _value.map((val: any) => {\n if (typeof val === 'object') {\n // Use browserName instead of browser\n if (val.browserName == null && typeof val.browser !== 'undefined') {\n val.browserName = val.browser;\n }\n delete val.browser;\n }\n if (typeof val === 'object' && val.version == null) {\n val.version = val.browserVersion;\n }\n return val;\n });\n setOption(\n config,\n name,\n parseValue(name, _value, 'object[]', 'browserName'),\n addToExisting\n );\n break;\n }\n case 'remoteOptions': {\n setOption(config, name, parseValue(name, value, 'object'));\n break;\n }\n case 'excludeInstrumentation': {\n emit('deprecated', {\n original: 'excludeInstrumentation',\n replacement: 'coverage',\n });\n break;\n }\n case 'tunnel': {\n setOption(config, name, parseValue(name, value, 'string'));\n break;\n }\n case 'functionalCoverage':\n case 'serveOnly':\n case 'runInSync': {\n setOption(config, name, parseValue(name, value, 'boolean'));\n break;\n }\n case 'leaveRemoteOpen': {\n let parsed: boolean | 'fail';\n try {\n parsed = parseValue(name, value, 'boolean');\n } catch (error) {\n parsed = parseValue(name, value, 'string');\n if (parsed !== 'fail') {\n throw new Error(`Invalid value '${parsed}' for leaveRemoteOpen`);\n }\n }\n setOption(config, name, parsed);\n break;\n }\n case 'coverage': {\n let parsed: boolean | string[];\n try {\n parsed = parseValue(name, value, 'boolean');\n } catch (error) {\n parsed = parseValue(name, value, 'string[]');\n }\n if (typeof parsed === 'boolean' && parsed !== false) {\n throw new Error(\"Non-false boolean for 'coverage'\");\n }\n setOption(config, name, parsed);\n break;\n }\n case 'functionalSuites': {\n setOption(\n config,\n name,\n parseValue(name, value, 'string[]'),\n addToExisting\n );\n break;\n }\n case 'functionalTimeouts': {\n if (!config.functionalTimeouts) {\n config.functionalTimeouts = {};\n }\n const parsedTimeout = parseValue(name, value, 'object');\n if (parsedTimeout) {\n // If the given value was an object, mix it in to the\n // default functionalTimeouts\n Object.keys(parsedTimeout).forEach((timeoutKey) => {\n const key = <keyof Config['functionalTimeouts']>timeoutKey;\n if (key === 'connectTimeout') {\n emit('deprecated', {\n original: 'functionalTimeouts.connectTimeout',\n replacement: 'connectTimeout',\n });\n setOption(\n config,\n key,\n parseValue(key, parsedTimeout[key], 'number')\n );\n } else {\n config.functionalTimeouts[key] = parseValue(\n `functionalTimeouts.${key}`,\n parsedTimeout[key],\n 'number'\n );\n }\n });\n } else {\n // If the given value was null/undefined, clear out\n // functionalTimeouts\n setOption(config, name, {});\n }\n break;\n }\n case 'connectTimeout':\n case 'heartbeatInterval':\n case 'maxConcurrency':\n case 'serverPort':\n case 'socketPort':\n case 'socketTimeout': {\n setOption(config, name, parseValue(name, value, 'number'));\n break;\n }\n case 'warnOnUncaughtException':\n case 'warnOnUnhandledRejection': {\n let parsed: boolean | RegExp;\n try {\n parsed = parseValue(name, value, 'boolean');\n } catch (error) {\n parsed = parseValue(name, value, 'regexp');\n }\n setOption(config, name, parsed);\n break;\n }\n default: {\n emit('log', `Config has unknown option \"${name}\"`);\n setOption(config, name, value);\n }\n }\n}\n\n/**\n * Remove all instances of of an item from any array and return the removed\n * instances.\n */\nexport function pullFromArray<T>(haystack: T[], needle: T): T[] {\n let removed: T[] = [];\n let i = 0;\n\n while ((i = haystack.indexOf(needle, i)) > -1) {\n removed.push(haystack.splice(i, 1)[0]);\n }\n\n return removed;\n}\n\n/**\n * Remove JS-style line and block comments from a string\n */\nfunction removeComments(text: string) {\n let state: 'string' | 'block-comment' | 'line-comment' | 'default' =\n 'default';\n let i = 0;\n\n // Create an array of chars from the text, the blank out anything in a\n // comment\n const chars = text.split('');\n\n while (i < chars.length) {\n switch (state) {\n case 'block-comment':\n if (chars[i] === '*' && chars[i + 1] === '/') {\n chars[i] = ' ';\n chars[i + 1] = ' ';\n state = 'default';\n i += 2;\n } else if (chars[i] !== '\\n') {\n chars[i] = ' ';\n i += 1;\n } else {\n i += 1;\n }\n break;\n\n case 'line-comment':\n if (chars[i] === '\\n') {\n state = 'default';\n } else {\n chars[i] = ' ';\n }\n i += 1;\n break;\n\n case 'string':\n if (chars[i] === '\"') {\n state = 'default';\n i += 1;\n } else if (chars[i] === '\\\\' && chars[i + 1] === '\\\\') {\n i += 2;\n } else if (chars[i] === '\\\\' && chars[i + 1] === '\"') {\n i += 2;\n } else {\n i += 1;\n }\n break;\n\n default:\n if (chars[i] === '\"') {\n state = 'string';\n i += 1;\n } else if (chars[i] === '/' && chars[i + 1] === '*') {\n chars[i] = ' ';\n chars[i + 1] = ' ';\n state = 'block-comment';\n i += 2;\n } else if (chars[i] === '/' && chars[i + 1] === '/') {\n chars[i] = ' ';\n chars[i + 1] = ' ';\n state = 'line-comment';\n i += 2;\n } else {\n i += 1;\n }\n }\n }\n\n return chars.join('');\n}\n\n/**\n * Set an option value.\n */\nexport function setOption(\n config: Config,\n name: keyof Config,\n value: any,\n addToExisting = false\n) {\n if (addToExisting) {\n const currentValue: any = config[name];\n if (currentValue == null) {\n (config as any)[name] = value;\n } else if (Array.isArray(currentValue)) {\n currentValue.push(...value);\n } else if (typeof config[name] === 'object') {\n (config as any)[name] = deepMixin({}, <object>config[name]!, value);\n } else {\n throw new Error('Only array or object options may be added');\n }\n } else {\n (config as any)[name] = value;\n }\n}\n\n/**\n * Split a config path into a file name and a child config name.\n *\n * This allows for the case where a file name itself may include the config\n * separator (e.g., a scoped npm package).\n */\nexport function splitConfigPath(\n path: string,\n separator = '/'\n): { configFile: string; childConfig?: string } {\n const lastSep = path.lastIndexOf(configPathSeparator);\n if (lastSep === 0) {\n // path is like '@foo' -- specifies a child config\n return { configFile: '', childConfig: path.slice(1) };\n }\n if (lastSep === -1 || path[lastSep - 1] === separator) {\n // path is like 'foo' or 'node_modules/@foo' -- specifies a\n // path\n return { configFile: path };\n }\n\n // path is like 'foo@bar' or 'node_modules/@foo@bar' -- specifies a path and\n // a child config\n return {\n configFile: path.slice(0, lastSep),\n childConfig: path.slice(lastSep + 1),\n };\n}\n\n/**\n * Convert an object to JSON, handling non-primitive properties\n *\n * @param object The object to serialise.\n * @returns A JSON string\n */\nexport function stringify(object: Object, indent?: string) {\n return JSON.stringify(object, getSerializeReplacer(), indent);\n}\n\n// ============================================================================\n// support functions\n\nfunction _loadConfig(\n configPath: string,\n loadText: TextLoader,\n args?: { [key: string]: any },\n childConfig?: string | string[]\n): CancellablePromise<any> {\n return loadText(configPath)\n .then((text) => {\n let preConfig: { [key: string]: any };\n\n try {\n preConfig = parseJson(text);\n } catch (error) {\n throw new Error(`Invalid JSON in ${configPath}`);\n }\n\n // extends paths are assumed to be relative and use '/'\n if (preConfig.extends) {\n const parts = configPath.split('/');\n const { configFile, childConfig } = splitConfigPath(preConfig.extends);\n const extensionPath = parts\n .slice(0, parts.length - 1)\n .concat(configFile)\n .join('/');\n\n return _loadConfig(\n extensionPath,\n loadText,\n undefined,\n childConfig\n ).then((extension) => {\n // Process all keys except 'configs' from the config to the\n // thing it's extending\n Object.keys(preConfig)\n .filter((key) => key !== 'configs')\n .forEach((key) => {\n processOption(<keyof Config>key, preConfig[key], extension);\n });\n\n // If config has a 'configs' property, mix its values into\n // extension.configs (slightly deeper mixin)\n if (preConfig.configs) {\n if (extension.configs == null) {\n extension.configs = {};\n }\n Object.keys(preConfig.configs).forEach((key) => {\n extension.configs[key] = preConfig.configs[key];\n });\n }\n return extension;\n });\n } else {\n const config: any = {};\n Object.keys(preConfig).forEach((key) => {\n processOption(<keyof Config>key, preConfig[key], config);\n });\n return config;\n }\n })\n .then((config) => {\n if (args && (args.showConfigs || args.help)) {\n // If we're showing the configs, don't mix in children\n return config;\n }\n\n if (childConfig) {\n const mixinConfig = (childConfig: string | string[]) => {\n const configs = Array.isArray(childConfig)\n ? childConfig\n : [childConfig];\n configs.forEach((childConfig) => {\n const child = config.configs[childConfig];\n if (!child) {\n throw new Error(`Unknown child config \"${childConfig}\"`);\n }\n if (child.extends) {\n mixinConfig(child.extends);\n }\n\n // Mix the child into the current config. Properties\n // other than the environment resource keys ('node' and\n // 'browser') will replace values on the parent. The\n // environment resource objects will be mixed into the\n // corresponding objects on the parent.\n Object.keys(child)\n .filter((key) => key !== 'node' && key !== 'browser')\n .forEach((key) => {\n processOption(<keyof Config>key, child[key], config);\n });\n\n ['node', 'browser'].forEach((key) => {\n if (child[key]) {\n if (config[key]) {\n // Run the environment config through\n // setOption, then mix it into the main\n // config\n const envConfig: any = {};\n processOption(<keyof Config>key, child[key], envConfig);\n Object.assign(config[key], envConfig[key]);\n } else {\n processOption(<keyof Config>key, child[key], config);\n }\n }\n });\n });\n };\n\n mixinConfig(childConfig);\n }\n return config;\n })\n .then((config) => {\n if (args) {\n // If any non-additive resources are specified in args, they\n // will apply to all environments and will override any\n // environment specific resources.\n const resources: (keyof ResourceConfig)[] = [\n 'plugins',\n 'reporters',\n 'suites',\n ];\n resources\n .filter((resource) => resource in args)\n .forEach((resource) => {\n const environments: (keyof Config)[] = ['node', 'browser'];\n environments\n .filter((environment) => config[environment])\n .forEach((environment) => {\n delete config[environment][resource];\n });\n });\n\n Object.keys(args).forEach((key) => {\n processOption(<keyof Config>key, args[key], config);\n });\n }\n return config;\n });\n}\n\nconst configPathSeparator = '@';\n\n/**\n * Replacer function used in stringify\n */\nfunction getSerializeReplacer() {\n const seen = new WeakSet();\n return function (_key: string, value: any) {\n if (!value) {\n return value;\n }\n\n if (value instanceof RegExp) {\n return value.source;\n }\n\n if (typeof value === 'function') {\n return value.toString();\n }\n\n if (typeof value === 'object') {\n if (seen.has(value)) {\n return;\n }\n seen.add(value);\n }\n\n return value;\n };\n}\n\nexport function errorToJSON(error?: InternError): InternError | undefined {\n if (!error) {\n return undefined;\n }\n const { name, message, stack, lifecycleMethod, showDiff, actual, expected } =\n error;\n\n return {\n name,\n message,\n stack,\n ...(lifecycleMethod ? { lifecycleMethod } : {}),\n showDiff: Boolean(showDiff),\n ...(showDiff ? { actual, expected } : {}),\n };\n}\n"]}
\No newline at end of file