JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 31160529
  • Score
    100M100P100Q258568F
  • License (MIT AND CC-BY-3.0)

parse SPDX license expressions

Package Exports

  • spdx-expression-parse

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (spdx-expression-parse) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

var parse = require('spdx-expression-parse')
var assert = require('assert')

assert.deepEqual(
  parse('(LGPL-2.1 OR BSD-3-Clause AND MIT)'),
  {
    left: {license: 'LGPL-2.1'},
    conjunction: 'or',
    right: {
      left: {license: 'BSD-3-Clause'},
      conjunction: 'and',
      right: {license: 'MIT'}
    }
  }
)

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'}
    }
  }
)

// We handle all the bare SPDX license and exception ids as well.
require('spdx-license-ids').forEach(function (id) {
  assert.deepEqual(parse(id), {license: id})
  require('spdx-exceptions').forEach(function (e) {
    assert.deepEqual(
      parse(id + ' WITH ' + e),
      {license: id, exception: e}
    )
  })
})

The Software Package Data Exchange (SPDX) specification is the work of the Linux Foundation and its contributors, and is licensed under the terms of the Creative Commons Attribution License 3.0 Unported (SPDX: "CC-BY-3.0"). "SPDX" is a United States federally registered trademark of the Linux Foundation.