get-full-year v0.0.3
get-full-year šļø
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
- Clone the repository
git clone https://github.com/threepointone/get-full-year.git
- Install dependencies
npm install
- 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
- Email: threepointone@gmail.com
- GitHub: @threepointone
š 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
Made with ā¤ļø and probably too much coffee āļø