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

farm-plugin-overload

v0.2.1

Published

Compile-time function overloading for FarmFE — @overload decorator groups functions into dispatchers with i18n error messages

Downloads

500

Readme

farm-plugin-overload

Compile-time function overloading for FarmFE — implement runtime overloading via @overload decorator with i18n error messages.

Install

npm install farm-plugin-overload

Concept

JavaScript/TypeScript supports overloading in declarations but not in implementations. This plugin bridges that gap: mark multiple functions with @overload('name') and the compiler generates a single dispatcher that selects the right implementation based on argument count and types.

Usage

import overload from 'farm-plugin-overload'

export default {
  plugins: [overload()],
}

Example

@overload('greet')
function greet_0(): string { return 'Hello!' }

@overload('greet')
function greet_1(name: string): string { return `Hello, ${name}` }

@overload('greet')
function greet_2(name: string, age: number): string { return `Hello, ${name}, age ${age}` }

// Call the unified name — dispatcher selects the right implementation
greet()              // → 'Hello!'
greet('Alice')       // → 'Hello, Alice'
greet('Alice', 30)   // → 'Hello, Alice, age 30'
greet(true)          // → Error: No overload for "greet" matches (boolean)

Compiles to:

function greet_0() { return 'Hello!' }
function greet_1(name) { return `Hello, ${name}` }
function greet_2(name, age) { return `Hello, ${name}, age ${age}` }

function greet(...args) {
  if (args.length === 0) return greet_0(...args)
  if (args.length === 1 && typeof args[0] === "string") return greet_1(...args)
  if (args.length === 2 && typeof args[0] === "string" && typeof args[1] === "number") return greet_2(...args)
  throw new Error(`No overload for function "greet" matches the provided arguments (${args.map(a => typeof a).join(", ")}).`)
}

.d.ts Generation

The plugin generates TypeScript declaration files with proper overload signatures, so IDEs show correct type hints:

declare function greet(): string;
declare function greet(name: string): string;
declare function greet(name: string, age: number): string;

i18n Error Messages

Runtime errors support multiple locales:

| Locale | Code | Example | |--------|------|---------| | English | en | No overload for function "greet" matches the provided arguments (boolean). | | 中文 | zh | 函数 "greet" 没有匹配参数 (boolean) 的重载。 | | Latina | la | Nulla supersonicatio pro functione "greet" congrit argumentis (boolean). |

overload({ locale: 'zh' })  // Chinese error messages

Options

  • locale — Error message locale. Default: 'en'. Supported: 'en', 'zh', 'la'
  • extensions — File extensions to process. Default: ['.ts', '.tsx', '.js', '.jsx']

License

MIT