JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 132
  • Score
    100M100P100Q86723F
  • License ISC

Get an array of the latest list of SPDX license IDs from spdx.org

Package Exports

  • get-spdx-license-ids

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 (get-spdx-license-ids) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

get-spdx-license-ids

npm version Build Status Coverage Status

A Node.js module to get an array of the latest SPDX license identifiers from spdx.org

const getSpdxLicenseIds = require('get-spdx-license-ids');

(async () => {
  const ids = await getSpdxLicenseIds();
  //=> ['0BSD', 'AAL', 'Abstyles', 'Adobe-2006', 'Adobe-Glyph', 'ADSL', 'AFL-1.1', 'AFL-1.2', ...]
})();

Installation

Use npm.

npm install get-spdx-license-ids

API

const getSpdxLicenseIds = require('get-spdx-license-ids');

getSpdxLicenseIds([options])

options: Object (request options without json option that defaults to true)
Return: Promise<Array<string>>

It retrieves an array of non-deprecated SPDX license identifiers from https://spdx.org/licenses/licenses.json.

(async () => {
  const ids = await getSpdxLicenseIds();
  ids.includes('MIT'); //=> true
  ids.includes('ISC'); //=> true

  ids.includes('GPL-1.0'); //=> false
})

getSpdxLicenseIds.deprecated([options])

Retrieves deprecated IDs only.

(async () => {
  const deprecatedIds = await getSpdxLicenseIds.deprecated();
  deprecatedIds.includes('MIT'); //=> false
  deprecatedIds.includes('ISC'); //=> false

  deprecatedIds.includes('GPL-1.0'); //=> true
})();

getSpdxLicenseIds.all([options])

Retrieves both deprecated and non-deprecated IDs in a single array.

(async () => {
  const allIds = await getSpdxLicenseIds.all();
  allIds.includes('MIT'); //=> true
  allIds.includes('ISC'); //=> true
  allIds.includes('GPL-1.0'); //=> false
})();

getSpdxLicenseIds.both([options])

Retrieves both deprecated and non-deprecated IDs in two separate arrays.

(async () => {
  const pair = await getSpdxLicenseIds.both();
  pair.length; //=> 2

  const [valid, deprecated] = pair;

  valid.includes('MIT'); //=> true
  valid.includes('ISC'); //=> true

  valid.includes('GPL-1.0'); //=> false

  deprecated.includes('MIT'); //=> false
  deprecated.includes('ISC'); //=> false

  deprecated.includes('GPL-1.0'); //=> true
})();

License

ISC License © 2018 Shinnosuke Watanabe