Formatting

Percentage Escape Formatting

Tampered Console supports percentage escape formatting. Similar to printf string formatting.

The following escapes are supported:

  • %s: String will be used to convert all values except BigInt, Object and -0.

  • %d: Number will be used to convert all values except BigInt and Symbol.

  • %i: parseInt(value, 10) is used for all values except BigInt and Symbol.

  • %f: parseFloat(value) is used for all values expect Symbol.

  • %j: JSON. Replaced with the string '[Circular]' if the argument contains circular references.

  • %o: Object. A string representation of an object with generic JavaScript object formatting. Similar to util.inspect() with options { showHidden: true, showProxy: true }. This will show the full object including non-enumerable properties and proxies.

  • %O: Object. A string representation of an object with generic JavaScript object formatting. Similar to util.inspect() without options. This will show the full object not including non-enumerable properties and proxies.

  • %c: CSS. This specifier is ignored and will skip any CSS passed in.

  • %%: single percent sign ('%'). This does not consume an argument.

If a specifier does not have a corresponding argument, the escape is never replaced:

util.format('%s:%s', 'foo');
// Returns: 'foo:%s'

If there are more arguments passed than the number of specifiers, the extra arguments are concatenated to the returned string, separated by spaces:

util.format('%s:%s', 'foo', 'bar', 'baz');
// Returns: 'foo:bar baz'

If only one argument is passed, it is returned as it is without any formatting:

util.format('%% %s');
// Returns: '%% %s'

Last updated