package
JavaScript library to parse and build "purl" aka. package URLs. This is a microlibrary implementing the purl spec at https://github.com/package-url
npm install packageurl-jsGitHub-flavored package documentation.
Across all versions, last 30 days.
11,825,121 in 30 days
Runtime metadata.
Tagged topics.
To install packageurl-js in your project, simply run:
npm install packageurl-jsThis command will download the packageurl-js npm package for use in your application.
Clone the packageurl-js repo and cd into the directory.
Then run:
npm installTo run the test suite:
npm testAs an ES6 module
import { PackageURL } from 'packageurl-js'As a CommonJS module
const { PackageURL } = require('packageurl-js')const purlStr = 'pkg:maven/org.springframework.integration/spring-integration-jms@5.5.5'
console.log(PackageURL.fromString(purlStr))
console.log(new PackageURL(...PackageURL.parseString(purlStr)))will both log
PackageURL {
type: 'maven',
name: 'spring-integration-jms',
namespace: 'org.springframework.integration',
version: '5.5.5',
qualifiers: undefined,
subpath: undefined
}const pkg = new PackageURL(
'maven',
'org.springframework.integration',
'spring-integration-jms',
'5.5.5'
)
console.log(pkg.toString())=>
pkg:maven/org.springframework.integration/spring-integration-jms@5.5.5try {
PackageURL.fromString('not-a-purl')
} catch (e) {
console.error(e.message)
}=>
Invalid purl: missing required "pkg" scheme componentHelpers for encoding, normalizing, and validating purl components and types can be imported directly from the module or found on the PackageURL class as static properties.
import {
PackageURL,
PurlComponent,
PurlType
} from 'packageurl-js'
PurlComponent === PackageURL.Component // => true
PurlType === PackageURL.Type // => trueContains the following properties each with their own encode, normalize,
and validate methods, e.g. PurlComponent.name.validate(nameStr):
Contains the following properties each with their own normalize, and validate
methods, e.g. PurlType.npm.validate(purlObj):
Estimated unpacked size across 1 packages.
55.8 kB
Includes dependencies.
majurg
me@stevenesser.com