get-full-year
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

get-full-year 🗓️

npm version License: ISC

An unofficial TypeScript client for getfullyear.com that helps you get the full year. Because sometimes you just need to know what year it is, and you need to know it properly.

🚀 Features

  • Written in TypeScript with full type definitions
  • Zero dependencies
  • Supports both ESM and CommonJS
  • Tiny bundle size
  • Simple, clean API
  • Promise-based for modern JavaScript applications

📦 Installation

Using npm:

npm install get-full-year

Using yarn:

yarn add get-full-year

Using pnpm:

pnpm add get-full-year

🔨 Usage

ESM

import getFullYear from "get-full-year";

// Using async/await
const main = async () => {
  const data = await getFullYear();
  console.log(data);
};

// Using promises
getFullYear().then((data) => {
  console.log(data);
});

CommonJS

const getFullYear = require("get-full-year").default;

getFullYear().then((data) => {
  console.log(data);
});

🔍 API Reference

getFullYear(isEnterprise?: boolean)

Makes a sophisticated request to getfullyear.com's API to fetch the current year data, with optional enterprise mode support.

Parameters:

  • isEnterprise (optional): boolean - Enables enterprise mode, suppressing sponsorship messages

Returns: Promise<YearResponseDTO> - A promise that resolves with the year data.

Throws: YearFetchingError - When the temporal data acquisition fails

Types:

interface YearResponseDTO {
  year: number;
  sponsored_by?: string;
  metadata?: Record<string, unknown>;
}

Example:

// Standard mode
const yearData = await getFullYear();
console.log(yearData.year); // 2024

// Enterprise mode
const enterpriseData = await getFullYear(true);

Error Handling:

try {
  const yearData = await getFullYear();
} catch (error) {
  if (error instanceof YearFetchingError) {
    console.error("Failed to acquire year:", error.message);
  }
}

🏗️ Project Structure

get-full-year/
├── src/           # Source code
├── dist/          # Compiled output
│   ├── esm/      # ES Modules
│   └── commonjs/  # CommonJS modules
├── example/       # Usage examples
└── .tshy/        # TypeScript build configuration

🛠️ Development

  1. Clone the repository
git clone https://github.com/threepointone/get-full-year.git
  1. Install dependencies
npm install
  1. Build the project
npm run prepare

📝 TypeScript Configuration

This project uses tshy for TypeScript builds, supporting both ESM and CommonJS output formats. The TypeScript configuration is split across multiple files:

  • tsconfig.json: Base TypeScript configuration
  • .tshy/build.json: Shared build configuration
  • .tshy/esm.json: ESM-specific configuration
  • .tshy/commonjs.json: CommonJS-specific configuration

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

📄 License

This project is licensed under the ISC License - see the LICENSE file for details.

👤 Author

Sunil Pai

🙏 Acknowledgments

  • Thanks to getfullyear.com for providing this essential service
  • The TypeScript team for making type-safe JavaScript possible
  • The open-source community for continuous inspiration

📊 Stats

GitHub stars npm downloads


Made with ❤️ and probably too much coffee ☕️

/get-full-year/

    Package Sidebar

    Install

    npm i get-full-year

    Weekly Downloads

    0

    Version

    0.0.3

    License

    ISC

    Unpacked Size

    18.3 kB

    Total Files

    13

    Last publish

    Collaborators

    • threepointone