MCPcopy
hub / github.com/facebook/react / truncateForDisplay

Function truncateForDisplay

packages/react-devtools-shared/src/utils.js:916–925  ·  view source on GitHub ↗
(
  string: string,
  length: number = MAX_PREVIEW_STRING_LENGTH,
)

Source from the content-addressed store, hash-verified

914const MAX_PREVIEW_STRING_LENGTH = 50;
915
916function truncateForDisplay(
917 string: string,
918 length: number = MAX_PREVIEW_STRING_LENGTH,
919) {
920 if (string.length > length) {
921 return string.slice(0, length) + '…';
922 } else {
923 return string;
924 }
925}
926
927// Attempts to mimic Chrome's inline preview for values.
928// For example, the following value...

Callers 1

formatDataForPreviewFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected