Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

libnpmfund

npm2.7mISC7.0.9

Programmatic API for npm fund

npm, npmcli, libnpm, cli, git, fund, gitfund

readme

libnpmfund

npm version license CI - libnpmfund

libnpmfund is a Node.js library for retrieving funding information for packages installed using arborist.

Table of Contents

Example

const { read } = require('libnpmfund')

const fundingInfo = await read()
console.log(
  JSON.stringify(fundingInfo, null, 2)
)
// => {
  length: 2,
  name: 'foo',
  version: '1.0.0',
  funding: { url: 'https://example.com' },
  dependencies: {
    bar: {
      version: '1.0.0',
      funding: { url: 'http://collective.example.com' }
    }
  }
}

Install

$ npm install libnpmfund

Contributing

The npm team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The Contributor Guide outlines the process for community interaction and contribution. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.

All participants and maintainers in this project are expected to follow the npm Code of Conduct, and just generally be excellent to each other.

Please refer to the Changelog for project history details, too.

Happy hacking!

API

> fund.read([opts]) -> Promise<Object>

Reads funding info from a npm install and returns a promise for a tree object that only contains packages in which funding info is defined.

Options:

  • countOnly: Uses the tree-traversal logic from npm fund but skips over any obj definition and just returns an obj containing { length } - useful for things such as printing a 6 packages are looking for funding msg.
  • workspaces: Array<String> List of workspaces names to filter for, the result will only include a subset of the resulting tree that includes only the nodes that are children of the listed workspaces names.
  • path, registry and more Arborist options.
> fund.readTree(tree, [opts]) -> Promise<Object>

Reads funding info from a given install tree and returns a tree object that only contains packages in which funding info is defined.

  • tree: An arborist tree to be used, e.g:
const Arborist = require('@npmcli/arborist')
const { readTree } = require('libnpmfund')

const arb = new Arborist({ path: process.cwd() })
const tree = await arb.loadActual()

return readTree(tree, { countOnly: false })

Options:

  • countOnly: Uses the tree-traversal logic from npm fund but skips over any obj definition and just returns an obj containing { length } - useful for things such as printing a 6 packages are looking for funding msg.
> fund.normalizeFunding(funding) -> Object

From a funding <object|string|array>, retrieves normalized funding objects containing a url property.

e.g:

normalizeFunding('http://example.com')
// => {
  url: 'http://example.com'
}
> fund.isValidFunding(funding) -> Boolean

Returns <true> if funding is a valid funding object, e.g:

isValidFunding({ foo: 'not a valid funding obj' })
// => false

isValidFunding('http://example.com')
// => true

LICENSE

ISC

changelog

Changelog

11.6.2 (2025-10-08)

Bug Fixes

11.6.1 (2025-09-23)

Bug Fixes

11.6.0 (2025-09-03)

Features

  • bdcc10d #8359 add support for optional env var replacements in .npmrc (#8359) (@aczekajski, @owlstronaut)

    Bug Fixes

  • dd4cee9 #8539 powershell: improve argument parsing (#8539) (@alexsch01)
  • 5f18557 #8532 powershell: fix issue with modified InvocationName (#8532) (@alexsch01)
  • 9e5abf1 #8529 add redaction to log format egress (#8529) (@wraithgar)
  • 75ce64a #8524 revert handle signal exits gracefully (#8524) (@owlstronaut)
  • 5d82d0b #8469 ps1 scripts in powershell 5.1 (#8469) (@splatteredbits)

Dependencies

11.5.2 (2025-07-30)

Bug Fixes

  • 7d900c4 #8467 oidc visibility check for provenance (#8467) (@reggi, @wraithgar)

    Documentation

  • d4e56b2 #8459 update snapshot generation command (#8459) (@MikeMcC399)

11.5.1 (2025-07-24)

Bug Fixes

  • 476bf17 #8457 provenance should only default for oidc (@reggi)

11.5.0 (2025-07-24)

Features

11.4.2 (2025-06-11)

Bug Fixes

11.4.1 (2025-05-21)

Documentation

  • 3ed764a #8308 Clarify script working directory behavior (fixes #8305) (#8308) (@tarekwfa0110, @owlstronaut)

    Chores

  • 2f30251 #8314 remove references to skimdb.npmjs.com (#8314) (@shmam)
  • 9cb9d50 #8298 add contributor to changelog entry (#8298) (@wraithgar)

Dependencies

11.4.0 (2025-05-15)

Features

11.3.0 (2025-04-08)

Features

11.2.0 (2025-03-05)

Features

11.1.0 (2025-01-29)

Features

  • 7f6c997 #8009 add dry-run to deprecate/undeprecate commands (@wraithgar)
  • 1764a37 #8009 add npm undeprecate command (@wraithgar)

    Bug Fixes

  • 31455b2 #8054 publish: honor force for no dist tag and registry version check (#8054) (@reggi)
  • dc31c1b #8038 remove max-len linting bypasses (@wraithgar)
  • 8a911ff #8038 publish: disregard deprecated versions when calculating highest version (@wraithgar)
  • 7f72944 #8038 publish: accept publishConfig.tag to override highest semver check (@wraithgar)
  • ab9ddc0 #7992 sbom: deduplicate sbom dependencies (#7992) (@bdehamer)
  • f7da341 #7980 search: properly display multiple search terms (#7980) (@wraithgar)

    Documentation

  • 3644e79 #8055 update readme for Node.js versions, remove badges (#8055) (@wraithgar)
  • f1af61f #8041 fix typos in "package-json" (#8041) (@maxkoryukov)
  • e90c6fe #8051 depth flag default value (#8051) (@milaninfy)
  • 866b5ee #8030 safer documentation urls, repos, packages (#8030) (@reggi)

    Dependencies

  • 7ddfbad #8053 @npmcli/package-json@6.1.1
  • 9473a86 #8053 `spdx-license-ids@3.0.21`
  • a65e5ce #8053 @sigstore/protobuf-specs@0.3.3
  • 215ebe4 #8053 `chalk@5.4.1`

    Chores

  • 61f00e3 #8069 splits out smoke-tests from publish-dryrun tests (#8069) (@reggi)
  • 6d0f46e #8058 stop publish smoke from check git clean (#8058) (@reggi)
  • 9281ebf #8057 fix smoke tests prerelease needs separate string args (#8057) (@reggi)
  • aa202e9 #8056 smoke tests using a preid (#8056) (@reggi)
  • 18e0449 #8053 dev dependency updates (@wraithgar)
  • 859a71c #8052 update node versions for release integration tests (#8052) (@wraithgar)
  • 7e7961d #8038 bump @npmcli/eslint-config to 5.1.0 (@wraithgar)
  • workspace: @npmcli/config@10.0.1

11.0.0 (2024-12-16)

Documentation

11.0.0-pre.1 (2024-12-06)

⚠️ BREAKING CHANGES

11.0.0-pre.0 (2024-11-26)

⚠️ BREAKING CHANGES