@helpers4/license 3.1.2 → 3.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/llms.txt +1 -1
- package/meta/api.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@ A set of helpers for working with URLs.
|
|
|
28
28
|
- [function](../function)
|
|
29
29
|
- [guard](../guard)
|
|
30
30
|
- [id](../id)
|
|
31
|
+
- [json](../json)
|
|
31
32
|
- [map](../map)
|
|
32
33
|
- [markdown](../markdown)
|
|
33
34
|
- [node](../node)
|
|
@@ -56,6 +57,7 @@ A set of helpers for working with URLs.
|
|
|
56
57
|
| function | [@helpers4/function](https://www.npmjs.com/package/@helpers4/function) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/function) | Function utilities and type guards |
|
|
57
58
|
| guard | [@helpers4/guard](https://www.npmjs.com/package/@helpers4/guard) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/guard) | Runtime type guard utilities |
|
|
58
59
|
| id | [@helpers4/id](https://www.npmjs.com/package/@helpers4/id) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/id) | Unique identifier generation utilities |
|
|
60
|
+
| json | [@helpers4/json](https://www.npmjs.com/package/@helpers4/json) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/json) | JSON parsing and serialization, with its common variants |
|
|
59
61
|
| license | [@helpers4/license](https://www.npmjs.com/package/@helpers4/license) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/license) | License string classification and comparison |
|
|
60
62
|
| map | [@helpers4/map](https://www.npmjs.com/package/@helpers4/map) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/map) | Native Map manipulation utilities |
|
|
61
63
|
| markdown | [@helpers4/markdown](https://www.npmjs.com/package/@helpers4/markdown) | [Source](https://github.com/helpers4/helpers4/tree/main/helpers/markdown) | Markdown formatting and escaping utilities |
|
package/lib/index.js
CHANGED
|
@@ -133,7 +133,7 @@ function matchAlias(normalized) {
|
|
|
133
133
|
for (const [family, aliases] of Object.entries(FAMILY_ALIASES)) if (aliases.includes(normalized)) return family;
|
|
134
134
|
}
|
|
135
135
|
function splitTokens(raw) {
|
|
136
|
-
return raw.split(/\s+(?:and|or)\s+/i).map((token) => token.split(/\s+with\s+/i)[0].trim()).filter((token) => token.length > 0);
|
|
136
|
+
return raw.trim().split(/\s+(?:and|or)\s+/i).map((token) => token.split(/\s+with\s+/i)[0].trim()).filter((token) => token.length > 0);
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* Groups a raw, possibly compound license string into its coarse family set — e.g.
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../helpers/license/_unknownFamily.ts","../../../helpers/license/families.ts","../../../helpers/license/agree.ts","../../../helpers/license/isKnown.ts"],"sourcesContent":["/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Sentinel family for a license token that carries no comparable content — `custom`, a bare\n * vendor name inside `custom:<...>`/`LicenseRef-<...>`, or an explicit \"we don't know\". Two\n * unknown tokens are never treated as either agreeing or conflicting with each other, since\n * neither is a real claim to compare against the other.\n *\n * Not exported from the package — `families()`, `agree()` and `isKnown()` already fully\n * encapsulate this concept; a consumer never needs the sentinel's actual value.\n * @ignore\n */\nexport const UNKNOWN_FAMILY = 'unknown';\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\n\n// Longest/most specific alias keys first within a family so a substring match never lets a\n// shorter, less specific alias shadow a longer one that also matches the same input.\nconst FAMILY_ALIASES: Record<string, readonly string[]> = {\n mit: ['mit-0', 'mit'],\n gpl: [\n 'gpl-3.0-or-later', 'gpl-3.0-only', 'gpl-2.0-or-later', 'gpl-2.0-only',\n 'gpl-1.0-or-later', 'gpl-3.0+', 'gpl-2.0+', 'gpl-3.0', 'gpl-2.0',\n 'gplv3', 'gplv2', 'gpl3+', 'gpl3', 'gpl2', 'gpl-3', 'gpl-2', 'gpl',\n ],\n lgpl: [\n 'lgpl-3.0-or-later', 'lgpl-3.0-only', 'lgpl-2.1-or-later', 'lgpl-2.1-only',\n 'lgpl-2.0-or-later', 'lgpl-2.0-only', 'lgpl-3.0+', 'lgpl-2.1+', 'lgpl-3.0', 'lgpl-2.1',\n 'lgplv3', 'lgplv2.1', 'lgpl3', 'lgpl2.1', 'lgpl2', 'lgpl',\n ],\n agpl: ['agpl-3.0-or-later', 'agpl-3.0-only', 'agpl-3.0', 'agplv3', 'agpl3', 'agpl'],\n bsd: [\n 'bsd-3-clause', 'bsd-2-clause', '0bsd', 'bsd3', 'bsd 3-clause',\n 'bsd 2-clause', 'bsd-3', 'bsd',\n ],\n apache: ['apache-2.0', 'apache license 2.0', 'apache license, version 2.0', 'apache2', 'apache 2.0', 'apache'],\n mpl: ['mpl-2.0', 'mpl2', 'mpl'],\n artistic: ['artistic-2.0', 'artistic2.0', 'perlartistic', 'artistic'],\n isc: ['isc'],\n unlicense: ['unlicense'],\n zlib: ['zlib'],\n wtfpl: ['wtfpl'],\n php: ['php'],\n epl: ['epl'],\n cc: ['cc0-1.0', 'cc0', 'cc-by-sa-4.0', 'cc-by-nc-sa-4.0', 'cc-by-sa', 'ccpl'],\n 'public-domain': ['public domain'],\n boost: ['bsl-1.0', 'boost'],\n eupl: ['eupl-1.2', 'eupl'],\n postgresql: ['postgresql'],\n psf: ['psf-2.0', 'psf'],\n gfdl: ['gfdl-1.3', 'gfdl'],\n sspl: ['sspl-1.0', 'sspl'],\n busl: ['busl-1.1', 'busl'],\n};\n\n// Non-informative tokens — a real license claim was made, but it carries no comparable content\n// (\"custom\", a bare vendor name inside `custom:<...>`/`LicenseRef-<...>`, or an explicit \"we\n// don't know\"). Checked first, before the alias table, so e.g. \"custom:MIT\" reads as\n// UNKNOWN_FAMILY rather than incorrectly matching MIT's alias substring — a `custom:<...>`\n// convention names the *vendor's own license text*, not necessarily the SPDX license the name\n// resembles.\nconst UNKNOWN_PATTERNS = [/^custom\\b/, /^licenseref-/, /unknown/, /^none$/, /^various$/, /^unknow$/];\n\nfunction matchAlias(normalized: string): string | undefined {\n for (const [family, aliases] of Object.entries(FAMILY_ALIASES)) {\n if (aliases.includes(normalized)) return family;\n }\n return undefined;\n}\n\n// Splits an SPDX-ish compound expression (\"GPL-3.0+ AND LGPL-3.0+\", or a lowercase \"GPL-2.0+ and\n// GFDL-1.3\") into its individual license tokens. `WITH` exceptions (\"Apache-2.0 WITH\n// LLVM-exception\") are dropped entirely — the exception clause never itself resembles a distinct\n// license family, so it would otherwise either land in UNKNOWN_FAMILY for no reason or dilute the\n// comparison with a token that isn't really a separate license claim.\nfunction splitTokens(raw: string): string[] {\n return raw\n .split(/\\s+(?:and|or)\\s+/i)\n .map((token) => token.split(/\\s+with\\s+/i)[0].trim())\n .filter((token) => token.length > 0);\n}\n\n/**\n * Groups a raw, possibly compound license string into its coarse family set — e.g.\n * `\"GPL-3.0-or-later AND LGPL-3.0-or-later\"` yields `{\"gpl\", \"lgpl\"}`. Two sources reporting the\n * same real license under different notation (`\"GPL3\"` vs `\"GPL-3.0-or-later\"`, `\"GPL\"` vs\n * `\"GPL2\"`) yield the same family, so they read as agreeing rather than conflicting.\n *\n * Proprietary/custom/unknown tokens all collapse to a single shared unknown-family sentinel\n * rather than each becoming their own one-off family, so a batch of otherwise-identical\n * `\"custom:<vendor>\"` strings don't look like dozens of distinct disagreeing licenses. Use\n * {@link isKnown} to check whether any real (non-sentinel) family was found.\n * @param raw - A raw license string, single (`\"MIT\"`) or compound (`\"GPL-3.0+ AND LGPL-3.0+\"`)\n * @returns The set of families found; empty only when `raw` has no tokens at all (e.g. an empty string)\n * @example\n * families('GPL3')\n * // => Set(1) { 'gpl' }\n * @example\n * families('GPL-3.0-or-later AND LGPL-3.0-or-later')\n * // => Set(2) { 'gpl', 'lgpl' }\n * @example\n * families('custom:Acme End User License')\n * // => Set(1) { 'unknown' }\n * @since 3.1.2\n */\nexport function families(raw: string): Set<string> {\n const result = new Set<string>();\n for (const token of splitTokens(raw)) {\n const normalized = token.toLowerCase();\n if (UNKNOWN_PATTERNS.some((pattern) => pattern.test(normalized))) {\n result.add(UNKNOWN_FAMILY);\n continue;\n }\n result.add(matchAlias(normalized) ?? UNKNOWN_FAMILY);\n }\n return result;\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\nimport { families } from './families';\n\n/**\n * Whether two raw license strings agree closely enough to count as \"no real conflict\" — true\n * when their family sets share at least one real (known) family, or when either side is entirely\n * unknown (e.g. `\"custom\"`/`\"unknown\"`) — a vague claim is never itself evidence of disagreement.\n * Only two *different*, both-known family sets (e.g. `bsd` vs `apache`) count as a real conflict.\n * @param a - The first raw license string\n * @param b - The second raw license string\n * @returns `true` when the two strings can be treated as the same license (or too vague to tell), `false` on a real family conflict\n * @example\n * agree('GPL3', 'GPL-3.0-or-later')\n * // => true\n * @example\n * agree('BSD-2-Clause', 'Apache-2.0')\n * // => false\n * @example\n * agree('custom', 'MIT')\n * // => true (a vague claim is never itself a conflict)\n * @since 3.1.2\n */\nexport function agree(a: string, b: string): boolean {\n const knownA = new Set([...families(a)].filter((f) => f !== UNKNOWN_FAMILY));\n const knownB = new Set([...families(b)].filter((f) => f !== UNKNOWN_FAMILY));\n\n if (knownA.size === 0 || knownB.size === 0) return true;\n for (const family of knownA) if (knownB.has(family)) return true;\n return false;\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\nimport { families } from './families';\n\n/**\n * Whether a raw license string resolves to at least one recognized family — `false` for an\n * empty string, a purely non-informative claim (`\"custom\"`, `\"unknown\"`, `\"LicenseRef-EULA\"`,\n * ...), or a compound expression where every token is non-informative.\n * @param raw - The raw license string to check\n * @returns `true` if at least one token in `raw` resolves to a real family\n * @example\n * isKnown('GPL-3.0-or-later')\n * // => true\n * @example\n * isKnown('custom:Acme End User License')\n * // => false\n * @since 3.1.2\n */\nexport function isKnown(raw: string): boolean {\n for (const family of families(raw)) {\n if (family !== UNKNOWN_FAMILY) return true;\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,iBAAiB;;;;;;;;ACN9B,IAAM,iBAAoD;CACxD,KAAK,CAAC,SAAS,KAAK;CACpB,KAAK;EACH;EAAoB;EAAgB;EAAoB;EACxD;EAAoB;EAAY;EAAY;EAAW;EACvD;EAAS;EAAS;EAAS;EAAQ;EAAQ;EAAS;EAAS;CAC/D;CACA,MAAM;EACJ;EAAqB;EAAiB;EAAqB;EAC3D;EAAqB;EAAiB;EAAa;EAAa;EAAY;EAC5E;EAAU;EAAY;EAAS;EAAW;EAAS;CACrD;CACA,MAAM;EAAC;EAAqB;EAAiB;EAAY;EAAU;EAAS;CAAM;CAClF,KAAK;EACH;EAAgB;EAAgB;EAAQ;EAAQ;EAChD;EAAgB;EAAS;CAC3B;CACA,QAAQ;EAAC;EAAc;EAAsB;EAA+B;EAAW;EAAc;CAAQ;CAC7G,KAAK;EAAC;EAAW;EAAQ;CAAK;CAC9B,UAAU;EAAC;EAAgB;EAAe;EAAgB;CAAU;CACpE,KAAK,CAAC,KAAK;CACX,WAAW,CAAC,WAAW;CACvB,MAAM,CAAC,MAAM;CACb,OAAO,CAAC,OAAO;CACf,KAAK,CAAC,KAAK;CACX,KAAK,CAAC,KAAK;CACX,IAAI;EAAC;EAAW;EAAO;EAAgB;EAAmB;EAAY;CAAM;CAC5E,iBAAiB,CAAC,eAAe;CACjC,OAAO,CAAC,WAAW,OAAO;CAC1B,MAAM,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AAQ,IAAI,OAAO,IAAI,MAAM,GAAG,OAAO;CAC5D,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;ACZA,SAAgB,QAAQ,KAAsB;CAC5C,KAAK,MAAM,UAAU,SAAS,GAAG,GAC/B,IAAI,WAAA,WAA2B,OAAO;CAExC,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../helpers/license/_unknownFamily.ts","../../../helpers/license/families.ts","../../../helpers/license/agree.ts","../../../helpers/license/isKnown.ts"],"sourcesContent":["/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\n/**\n * Sentinel family for a license token that carries no comparable content — `custom`, a bare\n * vendor name inside `custom:<...>`/`LicenseRef-<...>`, or an explicit \"we don't know\". Two\n * unknown tokens are never treated as either agreeing or conflicting with each other, since\n * neither is a real claim to compare against the other.\n *\n * Not exported from the package — `families()`, `agree()` and `isKnown()` already fully\n * encapsulate this concept; a consumer never needs the sentinel's actual value.\n * @ignore\n */\nexport const UNKNOWN_FAMILY = 'unknown';\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\n\n// Longest/most specific alias keys first within a family so a substring match never lets a\n// shorter, less specific alias shadow a longer one that also matches the same input.\nconst FAMILY_ALIASES: Record<string, readonly string[]> = {\n mit: ['mit-0', 'mit'],\n gpl: [\n 'gpl-3.0-or-later', 'gpl-3.0-only', 'gpl-2.0-or-later', 'gpl-2.0-only',\n 'gpl-1.0-or-later', 'gpl-3.0+', 'gpl-2.0+', 'gpl-3.0', 'gpl-2.0',\n 'gplv3', 'gplv2', 'gpl3+', 'gpl3', 'gpl2', 'gpl-3', 'gpl-2', 'gpl',\n ],\n lgpl: [\n 'lgpl-3.0-or-later', 'lgpl-3.0-only', 'lgpl-2.1-or-later', 'lgpl-2.1-only',\n 'lgpl-2.0-or-later', 'lgpl-2.0-only', 'lgpl-3.0+', 'lgpl-2.1+', 'lgpl-3.0', 'lgpl-2.1',\n 'lgplv3', 'lgplv2.1', 'lgpl3', 'lgpl2.1', 'lgpl2', 'lgpl',\n ],\n agpl: ['agpl-3.0-or-later', 'agpl-3.0-only', 'agpl-3.0', 'agplv3', 'agpl3', 'agpl'],\n bsd: [\n 'bsd-3-clause', 'bsd-2-clause', '0bsd', 'bsd3', 'bsd 3-clause',\n 'bsd 2-clause', 'bsd-3', 'bsd',\n ],\n apache: ['apache-2.0', 'apache license 2.0', 'apache license, version 2.0', 'apache2', 'apache 2.0', 'apache'],\n mpl: ['mpl-2.0', 'mpl2', 'mpl'],\n artistic: ['artistic-2.0', 'artistic2.0', 'perlartistic', 'artistic'],\n isc: ['isc'],\n unlicense: ['unlicense'],\n zlib: ['zlib'],\n wtfpl: ['wtfpl'],\n php: ['php'],\n epl: ['epl'],\n cc: ['cc0-1.0', 'cc0', 'cc-by-sa-4.0', 'cc-by-nc-sa-4.0', 'cc-by-sa', 'ccpl'],\n 'public-domain': ['public domain'],\n boost: ['bsl-1.0', 'boost'],\n eupl: ['eupl-1.2', 'eupl'],\n postgresql: ['postgresql'],\n psf: ['psf-2.0', 'psf'],\n gfdl: ['gfdl-1.3', 'gfdl'],\n sspl: ['sspl-1.0', 'sspl'],\n busl: ['busl-1.1', 'busl'],\n};\n\n// Non-informative tokens — a real license claim was made, but it carries no comparable content\n// (\"custom\", a bare vendor name inside `custom:<...>`/`LicenseRef-<...>`, or an explicit \"we\n// don't know\"). Checked first, before the alias table, so e.g. \"custom:MIT\" reads as\n// UNKNOWN_FAMILY rather than incorrectly matching MIT's alias substring — a `custom:<...>`\n// convention names the *vendor's own license text*, not necessarily the SPDX license the name\n// resembles.\nconst UNKNOWN_PATTERNS = [/^custom\\b/, /^licenseref-/, /unknown/, /^none$/, /^various$/, /^unknow$/];\n\nfunction matchAlias(normalized: string): string | undefined {\n for (const [family, aliases] of Object.entries(FAMILY_ALIASES)) {\n if (aliases.includes(normalized)) return family;\n }\n return undefined;\n}\n\n// Splits an SPDX-ish compound expression (\"GPL-3.0+ AND LGPL-3.0+\", or a lowercase \"GPL-2.0+ and\n// GFDL-1.3\") into its individual license tokens. `WITH` exceptions (\"Apache-2.0 WITH\n// LLVM-exception\") are dropped entirely — the exception clause never itself resembles a distinct\n// license family, so it would otherwise either land in UNKNOWN_FAMILY for no reason or dilute the\n// comparison with a token that isn't really a separate license claim.\nfunction splitTokens(raw: string): string[] {\n // Trimmed first: otherwise a padded bare operator (\" or \") would split into empty tokens\n // while the unpadded one (\"or\") stays a single token.\n return raw\n .trim()\n .split(/\\s+(?:and|or)\\s+/i)\n .map((token) => token.split(/\\s+with\\s+/i)[0].trim())\n .filter((token) => token.length > 0);\n}\n\n/**\n * Groups a raw, possibly compound license string into its coarse family set — e.g.\n * `\"GPL-3.0-or-later AND LGPL-3.0-or-later\"` yields `{\"gpl\", \"lgpl\"}`. Two sources reporting the\n * same real license under different notation (`\"GPL3\"` vs `\"GPL-3.0-or-later\"`, `\"GPL\"` vs\n * `\"GPL2\"`) yield the same family, so they read as agreeing rather than conflicting.\n *\n * Proprietary/custom/unknown tokens all collapse to a single shared unknown-family sentinel\n * rather than each becoming their own one-off family, so a batch of otherwise-identical\n * `\"custom:<vendor>\"` strings don't look like dozens of distinct disagreeing licenses. Use\n * {@link isKnown} to check whether any real (non-sentinel) family was found.\n * @param raw - A raw license string, single (`\"MIT\"`) or compound (`\"GPL-3.0+ AND LGPL-3.0+\"`)\n * @returns The set of families found; empty only when `raw` has no tokens at all (e.g. an empty string)\n * @example\n * families('GPL3')\n * // => Set(1) { 'gpl' }\n * @example\n * families('GPL-3.0-or-later AND LGPL-3.0-or-later')\n * // => Set(2) { 'gpl', 'lgpl' }\n * @example\n * families('custom:Acme End User License')\n * // => Set(1) { 'unknown' }\n * @since 3.1.2\n */\nexport function families(raw: string): Set<string> {\n const result = new Set<string>();\n for (const token of splitTokens(raw)) {\n const normalized = token.toLowerCase();\n if (UNKNOWN_PATTERNS.some((pattern) => pattern.test(normalized))) {\n result.add(UNKNOWN_FAMILY);\n continue;\n }\n result.add(matchAlias(normalized) ?? UNKNOWN_FAMILY);\n }\n return result;\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\nimport { families } from './families';\n\n/**\n * Whether two raw license strings agree closely enough to count as \"no real conflict\" — true\n * when their family sets share at least one real (known) family, or when either side is entirely\n * unknown (e.g. `\"custom\"`/`\"unknown\"`) — a vague claim is never itself evidence of disagreement.\n * Only two *different*, both-known family sets (e.g. `bsd` vs `apache`) count as a real conflict.\n * @param a - The first raw license string\n * @param b - The second raw license string\n * @returns `true` when the two strings can be treated as the same license (or too vague to tell), `false` on a real family conflict\n * @example\n * agree('GPL3', 'GPL-3.0-or-later')\n * // => true\n * @example\n * agree('BSD-2-Clause', 'Apache-2.0')\n * // => false\n * @example\n * agree('custom', 'MIT')\n * // => true (a vague claim is never itself a conflict)\n * @since 3.1.2\n */\nexport function agree(a: string, b: string): boolean {\n const knownA = new Set([...families(a)].filter((f) => f !== UNKNOWN_FAMILY));\n const knownB = new Set([...families(b)].filter((f) => f !== UNKNOWN_FAMILY));\n\n if (knownA.size === 0 || knownB.size === 0) return true;\n for (const family of knownA) if (knownB.has(family)) return true;\n return false;\n}\n","/**\n * This file is part of helpers4.\n * Copyright (C) 2025 baxyz\n * SPDX-License-Identifier: LGPL-3.0-or-later\n */\n\nimport { UNKNOWN_FAMILY } from './_unknownFamily';\nimport { families } from './families';\n\n/**\n * Whether a raw license string resolves to at least one recognized family — `false` for an\n * empty string, a purely non-informative claim (`\"custom\"`, `\"unknown\"`, `\"LicenseRef-EULA\"`,\n * ...), or a compound expression where every token is non-informative.\n * @param raw - The raw license string to check\n * @returns `true` if at least one token in `raw` resolves to a real family\n * @example\n * isKnown('GPL-3.0-or-later')\n * // => true\n * @example\n * isKnown('custom:Acme End User License')\n * // => false\n * @since 3.1.2\n */\nexport function isKnown(raw: string): boolean {\n for (const family of families(raw)) {\n if (family !== UNKNOWN_FAMILY) return true;\n }\n return false;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAgBA,IAAa,iBAAiB;;;;;;;;ACN9B,IAAM,iBAAoD;CACxD,KAAK,CAAC,SAAS,KAAK;CACpB,KAAK;EACH;EAAoB;EAAgB;EAAoB;EACxD;EAAoB;EAAY;EAAY;EAAW;EACvD;EAAS;EAAS;EAAS;EAAQ;EAAQ;EAAS;EAAS;CAC/D;CACA,MAAM;EACJ;EAAqB;EAAiB;EAAqB;EAC3D;EAAqB;EAAiB;EAAa;EAAa;EAAY;EAC5E;EAAU;EAAY;EAAS;EAAW;EAAS;CACrD;CACA,MAAM;EAAC;EAAqB;EAAiB;EAAY;EAAU;EAAS;CAAM;CAClF,KAAK;EACH;EAAgB;EAAgB;EAAQ;EAAQ;EAChD;EAAgB;EAAS;CAC3B;CACA,QAAQ;EAAC;EAAc;EAAsB;EAA+B;EAAW;EAAc;CAAQ;CAC7G,KAAK;EAAC;EAAW;EAAQ;CAAK;CAC9B,UAAU;EAAC;EAAgB;EAAe;EAAgB;CAAU;CACpE,KAAK,CAAC,KAAK;CACX,WAAW,CAAC,WAAW;CACvB,MAAM,CAAC,MAAM;CACb,OAAO,CAAC,OAAO;CACf,KAAK,CAAC,KAAK;CACX,KAAK,CAAC,KAAK;CACX,IAAI;EAAC;EAAW;EAAO;EAAgB;EAAmB;EAAY;CAAM;CAC5E,iBAAiB,CAAC,eAAe;CACjC,OAAO,CAAC,WAAW,OAAO;CAC1B,MAAM,CAAC,YAAY,MAAM;CACzB,YAAY,CAAC,YAAY;CACzB,KAAK,CAAC,WAAW,KAAK;CACtB,MAAM,CAAC,YAAY,MAAM;CACzB,MAAM,CAAC,YAAY,MAAM;CACzB,MAAM,CAAC,YAAY,MAAM;AAC3B;AAQA,IAAM,mBAAmB;CAAC;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