code:
/*! <<checkvars>> macro for SugarCube 2.x */
/* converted from macro to normal function for easy usage in pure JS, no logic changes */
/* modified for SC 2.37 */
App.checkVars = function() {
	function toString(value, indent) {
		var baseType = typeof value;
		switch (baseType) {
			case"number":
				return isNaN(value) ? "NaN" : isFinite(value) ? String(value) : "Infinity";
			case"string":
				return Serial.stringify(value);
			case"function":
				return "(function)";
			default:
				if ("object" !== baseType || null == value) {
					return String(value);
				}
				var objType = Object.prototype.toString.call(value);
				if ("[object Date]" === objType) {
					return '(object: Date, value: "' + value.toISOString() + '")';
				}
				if ("[object RegExp]" === objType) {
					return "(object: RegExp, value: " + value.toString() + ")";
				}
				var opener, closer, result = [], indentText = "  ";
				return indent || (indent = ""), ("[object Set]" === objType || value instanceof Set) && (value = Array.from(value)), Array.isArray(value) ? (opener = "[\n", closer = "\n" + indent + "]", value.forEach(function(p, i) {
					result.push(indent + indentText + i + " ⇒ " + toString(value[i], indent + indentText));
				}), Object.keys(value).forEach(function(p) {
					/^\d+$/.test(p) || result.push(indent + indentText + toString(p) + " ⇒ " + toString(value[p], indent + indentText));
				})) : "[object Map]" === objType || value instanceof Map ? (opener = "{\n", closer = "\n" + indent + "}", Array.from(value).map(function(kv) {
					result.push(indent + indentText + toString(kv[0], indent + indentText) + " ⇒ " + toString(kv[1], indent + indentText));
				})) : (opener = "{\n", closer = "\n" + indent + "}", Object.keys(value).forEach(function(p) {
					result.push(indent + indentText + toString(p) + " ⇒ " + toString(value[p], indent + indentText));
				})), opener + result.join(",\n") + closer;
		}
	}

	function isNumeric(n) {
		return !isNaN(parseFloat(n)) && isFinite(n);
	}

	var dialog, sv = State.variables, names = Object.keys(sv);
	if (dialog = Dialog.create("Story $variables", "checkvars"), 0 === names.length) {
		dialog.append("
Story $variables (State.variables):

No $variables currently set…
");
	} else {
		dialog.append("
Story $variables (State.variables):

Name	Value

" + (/applewebkit|chrome/.test(Browser.userAgent) ? "" : '

'));
		var tbody = dialog.body().querySelector("tbody");
		names.sort(function(a, b) {
			return isNumeric(a) && isNumeric(b) ? Number(a) - Number(b) : a.localeCompare(b);
		});
		for (var i = 0; i < names.length; i++) {
			var tr = document.createElement("tr"), tdName = document.createElement("td"),
				tdValue = document.createElement("td");
			tdName.textContent = "$" + names[i], tdValue.textContent = toString(sv[names[i]]), tr.appendChild(tdName), tr.appendChild(tdValue), tbody.appendChild(tr);
		}
	}
	Dialog.open();
};

repo_name: Nithhogg/fc

license: mit