gitwtfhub

wtf is custom-function?

patrickjs/custom-function — explained in plain English

Analysis updated 2026-07-17 · repo last pushed 2024-11-05

1Audience · developerComplexity · 3/5StaleSetup · easy

TL;DR

A small library that lets you create custom functions with class-like features (methods, private fields, super calls) without unsafely extending Function.

Mindmap

mindmap
  root((custom-function))
    Inputs
      Plain function
      Any constructor
    Outputs
      Callable class-like object
      Extended constructors
    Use Cases
      Build callable validators
      Extend HTMLDivElement
    Tech Stack
      JavaScript
    Audience
      Developer

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Why would anyone build with this?

REASON 1

Build a callable validator function that also exposes methods like .withMessage() or .optional().

REASON 2

Give a function private fields, getters, setters, and super calls like a regular class.

REASON 3

Use the factory export to safely extend other hard-to-extend constructors, like HTMLDivElement.

REASON 4

Build a DSL where functions need to behave like objects with internal state.

What's in the stack?

JavaScript

How it stacks up

patrickjs/custom-function0xkinno/neuralvault0xmayurrr/ai-contractauditor
Stars111
LanguageTypeScriptTypeScript
Last pushed2024-11-05
MaintenanceStale
Setup difficultyeasyhardeasy
Complexity3/54/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you spin it up?

Difficulty · easy Time to first run · 30min

Aimed at framework/library authors rather than typical app developers.

License is not stated in the available content.

Yoink these prompts

Prompt 1
Show me how to use this custom-function library to make a callable validator with a .withMessage() method.
Prompt 2
Explain how this library avoids calling the real Function constructor while still giving functions class features.
Prompt 3
Help me use the factory export from this repo to extend HTMLDivElement safely.
Prompt 4
Compare this library's approach to using Object.defineProperties for adding methods to a function.

Frequently asked questions

wtf is custom-function?

A small library that lets you create custom functions with class-like features (methods, private fields, super calls) without unsafely extending Function.

Is custom-function actively maintained?

Stale — no commits in 1-2 years (last push 2024-11-05).

What license does custom-function use?

License is not stated in the available content.

How hard is custom-function to set up?

Setup difficulty is rated easy, with roughly 30min to a first successful run.

Who is custom-function for?

Mainly developer.

View the repo → Decode another repo

This repo across BitVibe Labs

Don't trust strangers blindly. Verify against the repo.