0.0.3 • Published 7 months ago

get-full-year v0.0.3

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

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 ā˜•ļø

0.0.3

7 months ago

0.0.2

7 months ago

0.0.1

7 months ago