// Node.js program to demonstrate the
// util.formatWithOptions() method
// Import the util module
const util = require('util');
// Passing multiple values and
// -0 on string specifier
console.log("1 => ", util.formatWithOptions(
{ colors: true },
'%%: %s', 'alfa', 'beta', -0));
// Passing multiple values
console.log("2 => ", util.formatWithOptions(
{ colors: true },
'%%', 'alfa', 'beta', 'gamma'));
// Passing bigInt to string specifier
console.log("3 => ", util.formatWithOptions(
{ colors: true }, '%s',
'alfa', 94321321321223372036854775807));
// Creating and passing Object along
// with null prototype and a variable
console.log("4 => ", util.formatWithOptions(
{
showHidden: false, depth: 0,
colors: true
}, '%s', 'alfa', Object.create(null,
{ [Symbol.toStringTag]: { value: 'beta' } })));
// Passing string to Number specifier
console.log("5 => ", util.formatWithOptions(
{ colors: true }, '%d', 'alfa',
94303685));
// Passing Symbol and Number to parseInt specifier
console.log("6 => ", util.formatWithOptions(
{ showHidden: false, colors: true },
'%i', '2020 year 2021, ', 'He was 40, ',
'10.33, ', '10, ', 10));
// Passing string and Numbers to
// parseFloat specifier
console.log("7 => ", util.formatWithOptions(
{ colors: true }, '%f',
'94321321321.564000 year 6546',
'alfa', 78987965465464));
// Passing JSON string and Number
// to JSON specifier
console.log("8 => ", util.formatWithOptions(
{ depth: 0, colors: true }, '%j',
'{ "name":"Chotu Mishra", "age":23, "city":"Kanpur" }',
'alfa', 78987965465464));
// Passing class, string, and Number
// to object specifier
console.log("9 => ", util.formatWithOptions(
{ colors: true }, '%o',
class Bar { }, 'alfa', 78987965465464));
// Passing class, string, and Number
// to Object specifier
console.log("10 => ", util.formatWithOptions(
{ depth: 0, colors: true }, '%o:%d',
class Foo { get [Symbol.toStringTag]()
{ return 'alfa'; } }, 'alfa',
78987965465464));