hello-message-pkg
v1.0.0
Published
A simple Node.js package that prints hello messages
Maintainers
Readme
hello-message-pkg
A simple Node.js package that provides functions to print and generate hello messages.
Installation
npm install hello-message-pkgUsage
CommonJS (Node.js)
const { sayHello, getHelloMessage, sayHelloColorful } = require('hello-message-pkg');
// Print "Hello, World!" to console
sayHello();
// Print "Hello, Alice!" to console
sayHello('Alice');
// Get hello message as string without printing
const message = getHelloMessage('Bob');
console.log(message); // "Hello, Bob!"
// Print colorful hello message (if terminal supports colors)
sayHelloColorful('Charlie');ES Modules
import { sayHello, getHelloMessage, sayHelloColorful } from 'hello-message-pkg';
sayHello('World');API
sayHello(name?: string): string
Prints a hello message to the console and returns the message string.
- name (optional): Name to include in the greeting. Defaults to "World".
- Returns: The hello message string.
getHelloMessage(name?: string): string
Returns a hello message string without printing it to the console.
- name (optional): Name to include in the greeting. Defaults to "World".
- Returns: The hello message string.
sayHelloColorful(name?: string): string
Prints a colorful hello message to the console (if terminal supports ANSI colors) and returns the plain message string.
- name (optional): Name to include in the greeting. Defaults to "World".
- Returns: The plain hello message string (without color codes).
Testing
npm testLicense
MIT
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
