Converts between PURL strings and ClearlyDefined coordinates.
| PURL type | ClearlyDefined type/provider |
|---|---|
npm |
npm/npmjs |
pypi |
pypi/pypi |
cargo |
crate/cratesio |
gem |
gem/rubygems |
nuget |
nuget/nuget |
cocoapods |
pod/cocoapods |
composer |
composer/packagist |
github |
git/github |
maven |
maven/mavencentral, maven/mavengoogle |
golang |
go/golang |
npm install @clearlydefined/purl-coordinates-converterRequires Node.js >= 22.12.
import { purlToCoordinates, coordinatesToPurl } from '@clearlydefined/purl-coordinates-converter'
// PURL → ClearlyDefined coordinates
const coords = await purlToCoordinates('pkg:npm/%40angular/core@17.0.0')
// { type: 'npm', provider: 'npmjs', namespace: '@angular', name: 'core', revision: '17.0.0' }
// ClearlyDefined coordinates → PURL
const purl = coordinatesToPurl({ type: 'npm', provider: 'npmjs', namespace: '@angular', name: 'core', revision: '17.0.0' })
// 'pkg:npm/%40angular/core@17.0.0'Parses a PURL string and returns ClearlyDefined coordinates. Throws if the PURL type is unsupported or a subpath is present.
Converts ClearlyDefined coordinates to a PURL string. Throws if the type/provider combination is unsupported.
interface CoordinatesSpec {
type: string
provider: string
namespace: string
name: string
revision: string | undefined
}npm install
npm test # run tests
npm run lint # type-check + biome lint
npm run lint:fix