var parse = require('spdx-expression-parse')
var assert = require('assert')
var firstAST = {
left: { license: 'LGPL-2.1' },
conjunction: 'or',
right: {
left: { license: 'BSD-3-Clause' },
conjunction: 'and',
right: { license: 'MIT' } } }
assert.deepEqual(
parse('(LGPL-2.1 OR BSD-3-Clause AND MIT)'),
firstAST)
var secondAST = {
left: { license: 'MIT' },
conjunction: 'and',
right: {
left: {
license: 'LGPL-2.1',
plus: true },
conjunction: 'and',
right: { license: 'BSD-3-Clause' } } }
assert.deepEqual(
parse('(MIT AND (LGPL-2.1+ AND BSD-3-Clause))'),
secondAST)
// 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.
```javascript var parse = require('spdx-expression-parse') var assert = require('assert') var firstAST = { left: { license: 'LGPL-2.1' }, conjunction: 'or', right: { left: { license: 'BSD-3-Clause' }, conjunction: 'and', right: { license: 'MIT' } } } assert.deepEqual( parse('(LGPL-2.1 OR BSD-3-Clause AND MIT)'), firstAST) var secondAST = { left: { license: 'MIT' }, conjunction: 'and', right: { left: { license: 'LGPL-2.1', plus: true }, conjunction: 'and', right: { license: 'BSD-3-Clause' } } } assert.deepEqual( parse('(MIT AND (LGPL-2.1+ AND BSD-3-Clause))'), secondAST) // 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](http://spdx.org) is the work of the [Linux Foundation](http://www.linuxfoundation.org) and its contributors, and is licensed under the terms of [the Creative Commons Attribution License 3.0 Unported (SPDX: "CC-BY-3.0")](http://spdx.org/licenses/CC-BY-3.0). "SPDX" is a United States federally registered trademark of the Linux Foundation.
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/spdx-expression-parse/README.md | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |