npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

greeting-generator

v1.0.0

Published

A framework-agnostic greeting generator based on time, date, and weekday with multi-language support

Readme

Greeting Generator

A framework-agnostic TypeScript library to generate dynamic greetings based on time, date, and weekday. Supports multi-language and custom greetings. This is framework-agnostic and can be used with all mainstream frameworks.

Installation

npm install greeting-generator

Usage

Basic Example

import { GreetingGenerator } from 'greeting-generator';
import { extendLanguage } from 'greeting-generator';

// Extend or initialize a language (required for default greetings)
extendLanguage('zh', {
  default: {
    morning: '早上好',
    afternoon: '下午好',
    evening: '晚上好',
    night: '晚安'
  },
  dates: {
    '01-01': '新年快乐',
    '12-25': '圣诞快乐'
  },
  weekdays: {
    0: [{ startHour: 6, endHour: 12, greeting: '周日早晨' }]
  }
});

const greeter = new GreetingGenerator({ locale: 'zh' });

greeter.startAutoUpdate((greeting) => {
  console.log(greeting);
});

// Customize greeting for a specific date
greeter.setCustomGreeting('2025-03-11', '特别的一天!');

// Switch language
greeter.setLocale('en');

Features

  • Dynamic greetings based on time (e.g., "Good morning"), weekday (e.g., "Happy Monday"), and special dates (e.g., "Happy New Year").
  • Multi-language support (default: English and Chinese, extensible by users).
  • Customizable greetings with localStorage persistence.
  • Framework-agnostic (works with any JavaScript environment).
  • Flexible language extension for any date, time slot, or weekday-specific time slots.

Language Extension

You can easily extend the language pack to add new languages or customize greetings for specific dates, time slots, or weekdays. Default greetings (e.g., morning, afternoon) must be initialized using extendLanguage before creating a GreetingGenerator instance.

Adding or Initializing a Language

import { extendLanguage } from 'greeting-generator';

extendLanguage('ja', {
  default: {
    morning: 'おはよう',
    afternoon: 'こんにちは',
    evening: 'こんばんは',
    night: 'おやすみ'
  },
  dates: {
    '01-01': '新年おめでとう',
    '12-25': 'メリークリスマス'
  },
  weekdays: {
    0: [{ startHour: 6, endHour: 12, greeting: '日曜日おめでとう' }],
    1: [{ startHour: 9, endHour: 17, greeting: '月曜日頑張って' }]
  }
});

Customizing Specific Dates

You can define greetings for any date (format: YYYY-MM-DD or MM-DD) with optional time slots:

extendLanguage('zh', {
  dates: {
    '2025-03-11': '特别的一天', // Full-day greeting
    '2025-03-12': [
      { startHour: 8, endHour: 12, greeting: '上午学习' },
      { startHour: 13, endHour: 17, greeting: '下午工作' }
    ]
  }
});

Customizing Weekday Time Slots

Define time-specific greetings for any day of the week (0 = Sunday, 6 = Saturday):

extendLanguage('zh', {
  weekdays: {
    2: [
      { startHour: 9, endHour: 11, greeting: '周二会议' },
      { startHour: 14, endHour: 18, greeting: '周二加班' }
    ]
  }
});

API

GreetingGenerator(options)

  • options.locale: Initial language (default: 'zh'). Must be initialized with extendLanguage beforehand.
  • options.updateInterval: Update interval in milliseconds (default: 60000).

Methods

  • generateGreeting(): string - Generate the current greeting.
  • setCustomGreeting(key: string, value: string): void - Set a custom greeting (e.g., key can be 2025-03-11 or day_1).
  • startAutoUpdate(callback: (greeting: string) => void): void - Start auto-updating the greeting.
  • setLocale(locale: string): boolean - Switch language. The locale must exist in the language pack.
  • stopAutoUpdate(): void - Stop auto-update.

License

MIT