spdx-expression-parse
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
spdx-exceptions | 2.5.0 | 3.39 kB | CC-BY-3.0 | prod | 1 1 |
spdx-license-ids | 3.0.17 | 12.33 kB | CC0-1.0 | prod | 1 |
The "spdx-expression-parse" is a JavaScript package that parses SPDX license expression strings, such as the ones seen in package.json license strings, into structured ECMAScript objects. The npm command-line interface depends on it, as do many license-audit tools. This makes it crucial for managing and auditing license data, especially for users of open-source software.
To use spdx-expression-parse, first include it in your project with require('spdx-expression-parse'). Then, employ the parse method to convert a license string into an ECMAScript object. Here's a basic usage example:
var parse = require('spdx-expression-parse')
var assert = require('assert')
assert.deepEqual(
parse('BSD-2-Clause'),
{license: 'BSD-2-Clause'}
)
You can also parse complex license terms, like so:
assert.deepEqual(
parse('(MIT AND (LGPL-2.1+ AND BSD-3-Clause))'),
{
left: {license: 'MIT'},
conjunction: 'and',
right: {
left: {license: 'LGPL-2.1', plus: true},
conjunction: 'and',
right: {license: 'BSD-3-Clause'}
}
}
)
Please, note that invalid SPDX license expressions will throw errors.
For comprehensive documentation on the spdx-expression-parse package, direct your attention to its GitHub page: spdx-expression-parse GitHub. It will elaborate on more advanced parts of the package and give user-friendly guides for you to work with.