@onebeyond/spdx-license-satisfies

1.0.1 • Public • Published

spdx-license-satisfies

npm version npm downloads ci workflow publish workflow socket.dev all-contributors

This project is a fork from jslicense/spdx-satisfies.js. Please, note that the interface is slightly different.

satisfies(first, second)

Checks if first satisfies second. Both arguments must be a string with a simple license or a SPDX expressions. Disjunctive OR operator, conjunctive AND operator and exception WITH operator are allowed.

const { satisfies } = require('spdx-license-satisfies');

satisfies('MIT AND (Apache-2.0 OR GPL-1.0)', 'MIT AND Apache-2.0') // true
satisfies('MIT AND Apache-2.0', 'Apache-2.0') // false

satisfiesAny(first, second)

Checks if first satisfies any license in second.

  • first must be a string with a license or a SPDX expression. Disjunctive OR operator, conjunctive AND operator and exception WITH operator are allowed.
  • second must be an array of licenses. Disjunctive OR operator and conjunctive ANDoperator are not allowed.
const { satisfiesAny } = require('spdx-license-satisfies');

satisfiesAny('(MIT AND GPL-1.0) OR Apache-2.0', ['Apache-2.0']) // true
satisfiesAny('MIT OR GPL-1.0', ['Apache-2.0']) // false

satisfiesAll(first, second)

Checks if first satisfies all the licenses in second.

  • first must be a string with a license or a SPDX expression. Disjunctive OR operator, conjunctive AND operator and exception WITH operator are allowed.
  • second must be an array of licenses. Disjunctive OR operator and conjunctive ANDoperator are not allowed.
const { satisfiesAll } = require('spdx-license-satisfies');

satisfiesAll('MIT AND GPL-1.0 OR Apache-2.0', ['Apache-2.0']) // true
satisfiesAll('MIT OR GPL-1.0', ['MIT','GPL-1.0']) // false

Examples

See a list with more examples.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

David Miguel Yusta
David Miguel Yusta

💻 📖 ⚠️
Fernando de la Torre
Fernando de la Torre

👀
Íñigo Marquínez Prado
Íñigo Marquínez Prado

👀

This project follows the all-contributors specification. Contributions of any kind welcome!

Package Sidebar

Install

npm i @onebeyond/spdx-license-satisfies

Weekly Downloads

33

Version

1.0.1

License

MIT

Unpacked Size

30.5 kB

Total Files

20

Last publish

Collaborators

  • loveirobertob
  • guidesmiths_bot
  • ulisesgascon
  • inigo.marquinez