MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / safeJoin

Function safeJoin

packages/core/src/utils/string.ts:69–90  ·  view source on GitHub ↗
(input: unknown[], delimiter?: string)

Source from the content-addressed store, hash-verified

67 * @returns Joined values
68 */
69export function safeJoin(input: unknown[], delimiter?: string): string {
70 if (!Array.isArray(input)) {
71 return '';
72 }
73
74 const output = [];
75 // eslint-disable-next-line typescript/prefer-for-of
76 for (let i = 0; i < input.length; i++) {
77 const value = input[i];
78 if (isPrimitive(value)) {
79 output.push(String(value));
80 } else if (value instanceof Error) {
81 // While stringifyValue does not special-case errors, because we later handle them specifically based on the [object XXX] fallback,
82 // in this method we want to render them more nicely
83 output.push(value.message ? `${value.name}: ${value.message}` : value.name);
84 } else {
85 output.push(stringifyValue(undefined, value));
86 }
87 }
88
89 return output.join(delimiter);
90}
91
92/**
93 * Checks if the given value matches a regex or string

Callers 5

string.test.tsFile · 0.90
formatConsoleArgsFunction · 0.90
consoleHandlerFunction · 0.90

Calls 3

isPrimitiveFunction · 0.90
stringifyValueFunction · 0.90
pushMethod · 0.80

Tested by

no test coverage detected