node/deps/npm/node_modules/libnpmfund
Ruy Adorno f51a0e4b85
deps: upgrade npm to 7.1.1
PR-URL: https://github.com/nodejs/node/pull/36459
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2020-12-11 17:59:18 -05:00
..
CHANGELOG.md deps: upgrade npm to 7.0.8 2020-11-03 23:19:41 -05:00
index.js deps: update npm to 7.0.0-rc.3 2020-10-07 09:59:49 -04:00
LICENSE deps: update npm to 7.0.0-rc.3 2020-10-07 09:59:49 -04:00
package.json deps: upgrade npm to 7.1.1 2020-12-11 17:59:18 -05:00
README.md deps: update npm to 7.0.0-rc.3 2020-10-07 09:59:49 -04:00

libnpmfund

npm version license GitHub Actions Coverage Status

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.
  • path: Location to current working directory
> 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