</>PackageGraphPackageGraph

generate-function

npmv2.3.1

Module that helps you write generated functions in Node

Not recommended for new projects

No — generate-function should not be adopted for new projects. Last published 2931 days ago.

  • AAdoption: grade A, Excellent.

    12M downloads per week and 1 known dependents.

  • FMaintenance: grade F, Failing.

    Last published 2931 days ago.

  • AWeight: grade A, Excellent.

    Pulls in 1 transitive package, about 8.8 KB installed (at least — some of the tree is still being crawled).

  • BSupply chain: grade B, Good.

    This package has a single maintainer (bus factor of 1).

  • ALicense: grade A, Excellent.

    MIT — permissive, with no copyleft found in the dependency tree.

Grades are computed deterministically from registry metadata collected by PackageGraph — downloads, dependents, publish dates, the resolved dependency tree, maintainer count, and declared licenses. No third-party scores are used.

Install cost

What you actually take on by adding generate-function to a project.

1
Direct dependencies

Runtime packages this one declares itself.

1
Total installed

Distinct packages in the full runtime tree, deduplicated the way a package manager would.

8.8 KB
Install size

Unpacked size of this package plus its entire runtime tree.

1
Tree depth

Longest resolved dependency chain below this package.

Part of this dependency tree has not been crawled yet, so these figures are a lower bound rather than a final total.

Compatibility

Node.js
No constraint declared
Module format
CommonJS only
TypeScript
No bundled types
Install scripts
None

Quick start

A usage example from the generate-function README.

const genfun = require('generate-function')
const { d } = genfun.formats

function addNumber (val) {
  const gen = genfun()

  gen(`
    function add (n) {')
      return n + ${d(val)}) // supports format strings to insert values
    }
  `)

  return gen.toFunction() // will compile the function
}
Example truncated — see the full README.

generate-function vs the alternatives

Packages solving a similar problem in the npm ecosystem, compared on the signals that drive an adoption decision.

PackageWeekly downloadsDependentsLicenseLast release
generate-functionthis page12M1MIT8 years ago
reusify91M1MIT1 day ago
@react-native/codegen02MIT1 day ago
callsites136.7M1MIT1 day ago
once109.6M1ISC1 day ago
call-bind80.7M5MIT1 day ago

Dependencies

Declared by generate-function v2.3.1. Runtime dependencies are installed with the package; dev dependencies are not.

Runtime (1)

is-property ^1.0.2

Dev (1)

tape ^4.9.1

Used by

Popular packages that depend on generate-function.

Relationship graph

Dependencies (left) and dependents (right) of generate-function.

mysql2generate-function
generate-function dependencies dependents

Frequently installed together

Release history

No releases in the last two years, typically about 0 days apart.

Recent versions of generate-function
VersionPublishedSizeLicense
2.3.1latest8 years ago8.8 KBMIT
2.3.08 years ago7.4 KBMIT
2.2.18 years ago7.1 KBMIT
2.2.08 years ago7.0 KBMIT
2.0.012 years agoMIT
1.1.012 years agoMIT
1.0.312 years agoMIT
1.0.212 years agoMIT
1.0.112 years agoMIT
1.0.012 years agoMIT
0.0.012 years agoMIT

Overview

generate-function is an npm package that module that helps you write generated functions in Node. It is extremely widely used, with about 12M downloads per week and 1 known dependents in the graph. The latest version is 2.3.1, released under the MIT license.

Who should use it

Teams working in the npm ecosystem who need module that helps you write generated functions in Node and value a battle-tested, widely-adopted solution.

When not to use it

Consider an alternative if you need to have first-class TypeScript types out of the box, or if a more actively-maintained option better fits your npm stack.

Pros

  • Large, well-established user base (12M weekly downloads).
  • Clear open-source license (MIT).
  • Lean dependency tree (2 direct dependencies).

Cons

  • No bundled TypeScript types (may require a separate @types package).

Auto-generated from collected registry metadata. No external claims are inferred.

Maintainers

Keywords

Frequently asked questions

Should I use generate-function?

No — generate-function should not be adopted for new projects. Last published 2931 days ago.

How do I install generate-function?

Run `npm install generate-function` to add generate-function to your npm project.

How many dependencies does generate-function have?

generate-function declares 2 direct dependencies and pulls in 1 packages in total once its runtime tree is resolved totalling about 8.8 KB on disk.

What license is generate-function released under?

generate-function is distributed under the MIT license.

How popular is generate-function?

generate-function has approximately 11,999,809 downloads per week and 1 known dependent packages.

Is generate-function still maintained?

The most recent release of generate-function (v2.3.1) was published 8 years ago.

Does generate-function run install scripts?

No. generate-function does not define preinstall, install, or postinstall scripts, so installing it does not execute publisher-supplied code.