Skip to content

gaslamp


Function: getValuePreviewOf()

getValuePreviewOf(value, maxLength?): string

Get a human-readable preview of any value for logging and error messages.

Unlike JSON.stringify, handles Map and Set explicitly — useful in GAS where Logger.log(map) shows only "{}". Output is truncated to maxLength characters (default 60).

Parameters

value

unknown

Value to preview

maxLength?

number = 60

Maximum character length before truncation (default 60)

Returns

string

Human-readable string preview

Example

TypeScript
getValuePreviewOf("hello");              // '"hello"'
getValuePreviewOf([1, 2, 3]);            // '[1,2,3]'
getValuePreviewOf(new Map([["a", 1]]));  // 'map: {"a" => 1}'
getValuePreviewOf(new Set([1, 2]));      // 'set: {1, 2}'
getValuePreviewOf(null);                 // 'null'

Since

0.37.0