This Node.js library provides functions for greeting and bidding farewell, as well as calculating the elapsed time since a given date.
- Install the library along with its peer dependency Moment.js:
npm install moment
const { sayHello, sayBye, elapsedTimeSince } = require("peer-test");
// Greet someone
const helloMessage = sayHello("John");
console.log(helloMessage); // Output: {"type":"greeting","message":"Hello John","status":200}
// Bid farewell to someone
const byeMessage = sayBye("Jane");
console.log(byeMessage); // Output: {"type":"farewell","message":"Goodbye Jane","status":200}
// Calculate the time elapsed since a date
const elapsed = elapsedTimeSince(2000, 2, 7);
console.log(elapsed); // Output: "22 years ago"
Greets the person with the specified name.
- name: Name of the person to greet.
Bids farewell to the person with the specified name.
- name: Name of the person to bid farewell.
-
Calculates how much time has elapsed since the specified date until the current date.
-
year
: Year of the date. -
month
: Month of the date (1 for January, 2 for February, etc.). -
day
: Day of the month.
-