GithubHelp home page GithubHelp logo

jdalton / packageurl-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from package-url/packageurl-js

1.0 0.0 0.0 236 KB

JavaScript implementation of the package url spec

License: MIT License

JavaScript 100.00%

packageurl-js's Introduction

packageurl-js

Installing:

To install packageurl-js in your project, simply run:

npm install packageurl-js

This command will download the packageurl-js npm package for use in your application.

Local Development:

Clone the packageurl-js repo and cd into the directory.

Then run:

npm install

Testing

To run the test suite:

npm test

Usage Examples

Import ES6 Module

import { PackageURL } from 'packageurl-js';

Import CommonJs Module

const { PackageURL } = require('packageurl-js');

Parsing from a string

const pkg = PackageURL.fromString('pkg:maven/org.springframework.integration/[email protected]');
console.log(pkg);

=>

PackageURL {
  type: 'maven',
  name: 'spring-integration-jms',
  namespace: 'org.springframework.integration',
  version: '5.5.5',
  qualifiers: null,
  subpath: null
}

Constructing

const pkg = new PackageURL(
    'maven',
    'org.springframework.integration',
    'spring-integration-jms',
    '5.5.5',
    undefined,
    undefined);

console.log(pkg.toString());

=>

pkg:maven/org.springframework.integration/[email protected]

Error Handling

try {
    PackageURL.fromString('not-a-purl');
} catch(ex) {
    console.error(ex.message);
}

=>

purl is missing the required "pkg" scheme component.

packageurl-js's People

Contributors

steven-esser avatar jdalton avatar mscudlik avatar pombredanne avatar jkowalleck avatar darthhater avatar chriswininger avatar smorimoto avatar topaztee avatar aniruth37 avatar isasmendiagus avatar mcombuechen avatar moullisha avatar declanhunter avatar dependabot[bot] avatar satanshiro avatar

Stargazers

Bret Comnes avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.