pax_global_header00006660000000000000000000000064132477024440014521gustar00rootroot0000000000000052 comment=cb7853325dc0aafdeeec932590781c1dd4b40ff7 jslicense-spdx-compare.js-a3a0e4c/000077500000000000000000000000001324770244400171755ustar00rootroot00000000000000jslicense-spdx-compare.js-a3a0e4c/.gitignore000066400000000000000000000000151324770244400211610ustar00rootroot00000000000000node_modules jslicense-spdx-compare.js-a3a0e4c/.npmignore000066400000000000000000000000271324770244400211730ustar00rootroot00000000000000.npmignore .travis.yml jslicense-spdx-compare.js-a3a0e4c/.travis.yml000066400000000000000000000001441324770244400213050ustar00rootroot00000000000000--- language: "node_js" node_js: - "0.10" - "0.11" - "0.12" - "node" - "iojs" sudo: false jslicense-spdx-compare.js-a3a0e4c/LICENSE.md000066400000000000000000000020651324770244400206040ustar00rootroot00000000000000The MIT License Copyright (c) 2015 Kyle E. Mitchell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jslicense-spdx-compare.js-a3a0e4c/README.md000066400000000000000000000012311324770244400204510ustar00rootroot00000000000000```javascript var assert = require('assert') var compare = require('spdx-compare') assert(compare.gt('GPL-3.0', 'GPL-2.0')) assert(compare.gt('GPL-3.0-only', 'GPL-2.0-only')) assert(compare.gt('GPL-2.0-or-later', 'GPL-2.0-only')) assert(compare.eq('GPL-3.0-or-later', 'GPL-3.0-only')) assert(compare.lt('MPL-1.0', 'MPL-2.0')) assert(compare.gt('LPPL-1.3a', 'LPPL-1.0')) assert(compare.gt('LPPL-1.3c', 'LPPL-1.3a')) assert(!compare.gt('MIT', 'ISC')) assert(!compare.gt('OSL-1.0', 'OPL-1.0')) assert(compare.gt('AGPL-3.0', 'AGPL-1.0')) assert.throws(function () { compare.gt('(MIT OR ISC)', 'GPL-3.0') }, '"(MIT OR ISC)" is not a simple license identifier') ``` jslicense-spdx-compare.js-a3a0e4c/index.js000066400000000000000000000031751324770244400206500ustar00rootroot00000000000000var arrayFindIndex = require('array-find-index') var parse = require('spdx-expression-parse') var ranges = require('spdx-ranges') var notALicenseIdentifier = ' is not a simple license identifier' var rangeComparison = function (comparison) { return function (first, second) { var firstAST = parse(first) if (!firstAST.hasOwnProperty('license')) { throw new Error('"' + first + '"' + notALicenseIdentifier) } var secondAST = parse(second) if (!secondAST.hasOwnProperty('license')) { throw new Error('"' + second + '"' + notALicenseIdentifier) } return ranges.some(function (range) { var firstLicense = firstAST.license var indexOfFirst = arrayFindIndex(range, function (element) { return ( element === firstLicense || ( Array.isArray(element) && element.indexOf(firstLicense) !== -1 ) ) }) if (indexOfFirst < 0) { return false } var secondLicense = secondAST.license var indexOfSecond = arrayFindIndex(range, function (element) { return ( element === secondLicense || ( Array.isArray(element) && element.indexOf(secondLicense) !== -1 ) ) }) if (indexOfSecond < 0) { return false } return comparison(indexOfFirst, indexOfSecond) }) } } exports.gt = rangeComparison(function (first, second) { return first > second }) exports.lt = rangeComparison(function (first, second) { return first < second }) exports.eq = rangeComparison(function (first, second) { return first === second }) jslicense-spdx-compare.js-a3a0e4c/package.json000066400000000000000000000012361324770244400214650ustar00rootroot00000000000000{ "name": "spdx-compare", "description": "compare SPDX license expressions", "version": "1.0.0", "author": "Kyle E. Mitchell (https://kemitchell.com)", "dependencies": { "array-find-index": "^1.0.2", "spdx-expression-parse": "^3.0.0", "spdx-ranges": "^2.0.0" }, "devDependencies": { "defence-cli": "^2.0.1" }, "keywords": [ "SPDX", "law", "legal", "license", "metadata", "package", "package.json", "standards" ], "license": "MIT", "repository": "kemitchell/spdx-compare.js", "scripts": { "test": "defence -i javascript README.md | sed 's!spdx-compare!./!' | node" } }