A minimal API for namedays.
# npm
npm install namedays
# yarn
yarn add namedays
# pnpm
pnpm add namedays
The interface that all namedays adhere to is called Nameday and looks like this:
interface Nameday {
id: string
countryCode: CountryCode
name: string
date: {
month: number
day: number
}
}
CountryCode
is the union type of country codes currently supported fully or
partly.
Nameday
is available for usage if needed:
import { Nameday } from "namedays"
namedays.all
is a function that returns all namedays.
- Optional
settings
: An object where country code can be set.
All namedays.
import { namedays } from "namedays"
// all namedays, regardless of which country
namedays.all()
namedays.today
is a function that returns namedays of the current day.
- Optional
settings
: An object where country code can be set.
The namedays of today.
import { namedays } from "namedays"
// all namedays of current day, regardless of country
namedays.today()
// all Swedish namedays of current day
namedays.today({
countryCode: "SE",
})
namedays.when
is a function that returns the nameday of a specific name.
name
: The name or names you want the nameday for.- Optional
settings
: An object where country code can be set.
The nameday of the passed name.
import { namedays } from "namedays"
// all Filip's namedays, regardless of country
namedays.when("Filip")
// Filip's Swedish nameday
namedays.when("Filip", {
countryCode: "SE",
})
// all Filip's and Ida's namedays, regardless of country
namedays.when(["Filip", "Ida"])
namedays.who
is a function that returns the nameday of a specific ID.
id
: The ID of the nameday you want.
The nameday of a specific ID. If ID doesn't exist, undefined
is returned.
import { namedays } from "namedays"
// nameday with id SE-5-2-1, `undefined` if there are no nameday with that id
namedays.who("SE-5-2-1")
namedays.on
is a function that returns the namedays of a specific day.
on
: The month and/or day you want the namedays for.- Optional
settings
: An object where country code can be set.
The namedays of a specific day.
import { namedays } from "namedays"
// all namedays in May, regardless of country
namedays.on({
month: 5,
})
// all namedays the 2nd every month, regardless of country
namedays.on({
day: 2,
})
// all namedays May 2nd, regardless of country
namedays.on({
month: 5,
day: 2,
})
// all Swedish namedays May 2nd
namedays.on(
{
month: 5,
day: 2,
},
{
countryCode: "SE",
},
)
MIT