DEV Community

Cover image for Greet your visitor
Mayank
Mayank

Posted on β€’ Edited on

4 1 1 1 2

Greet your visitor

Greet your Visitors with Good Morning, Good Afternoon or Good Evening Message using JavaScript

Install using npm

npm install greet-visitor
Enter fullscreen mode Exit fullscreen mode

https://www.npmjs.com/package/greet-visitor

Sample Output - with emoji

Time Range Output
>= 3 - <= 12 🌞 Good morning
>= 12 - <= 17 🌞 Good afternoon
>= 17 - <= 20 πŸŒ“ Good evening
>= 20 - <= 24 πŸŒ’ Good night
>= 23 - <= 3 🌚 Oh! working late night

Configurable Default Options

{
    "emoji": true,
    "morning": "Good Morning",
    "noon": "Good Afternoon",
    "evening": "Good Evening",
    "night": "Good Night",
    "midnight": "Oh! working late night",
}
Enter fullscreen mode Exit fullscreen mode

Sample Code

var greet = require("greet-visitor");

greet();
// Based on system default time it will show different messages. as mentioned above
Enter fullscreen mode Exit fullscreen mode

Sample Code with Option Change

var greet = require("greet-visitor");

greet({emoji: false, noon: "Good noon !"});

// Output- at noon
"Good noon !"

// Output- in morning
"Good Morning"
Enter fullscreen mode Exit fullscreen mode

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

Top comments (4)

Collapse
 
corners2wall profile image
Corners 2 Wall β€’

Good job dude
Image description

Collapse
 
mayank30 profile image
Mayank β€’

Thanks alot..

Collapse
 
mayank30 profile image
Mayank β€’

Guys i have upgrade the package. added mid night support

Collapse
 
mayank30 profile image
Mayank β€’

for discussion on Product hunt - producthunt.com/discussions/greet-...

nextjs tutorial video

Youtube Tutorial Series πŸ“Ί

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series πŸ‘€

Watch the Youtube series