Formatted Messages
formatted-messages
is just a smaller (non intl) copy of the react-intl
API made for Node packages. Reference chalk to see what colours formatted-messages
supports.
API
formatMessage
Formats and colourises a message
.
Arguments
unformattedMessage
: an object with the following propertiesmessage
: a string message to be formatted with tags to be replaceddefaultOptions
: an object with properties to be replaced in the message if options are not passed. These will be overridden by properties inoption
if passed.
options
: an object with variables to be replaced?separator
: an optional property that will define how array type variables will be separated
Example
let message; // message = 'Hello, world!'message = ; // message = 'Hello, Nick!'message = ; // message = 'Hello, Alex!'message = ; // message = 'Hello, Alex!' <= 'Alex' will be coloured cyan :)message = ; // message = 'Hello, Alex!' <= 'Alex' will be coloured red :)message = ; // message = 'Hello, Nick, Alex, Ash!' <= 'Nick, Alex, Ash' will be coloured green :)message = ; // message = 'Hello, Nick and Alex and Ash!' <= 'Nick and Alex and Ash' will be coloured green :)message = ;
printMessage
Prints a message
to the console.
Arguments
message
: a string message to print to the console.
Example
const message = ; // prints message to console;