npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pathway-commons

v1.5.4

Published

Library to facilitate access to the Pathway Commons web service

Downloads

6

Readme

Pathway Commons JS Library Build Status

Description

This library is an interface for accessing the Pathway Commons web API, which is designed to make Pathway Commons easier to work with. In addition, it contains useful optimisations to improve efficiency, and various tools which may be useful when working with Pathway Commons data.

The library makes use of promises in order to keep the API clean. Therefore, if you must support browsers which do not natively support promises, please include a polyfill in your project.

We also have a Pathway Commons (cPath2) java client library.

Getting Started

This library can be included directly using a script tag, or it can be imported using several methods. This library is available on NPM.

CommonJS:

var pathwayCommons = require('pathway-commons');

ES6 Imports:

// The entire library can be imported
import pathwayCommons from 'pathway-commons';
// Or only the necessary functions
import {utilities, search} from 'pathway-commons';

Setting a username

We request that our users set a username (or app name), which allows us to analyse how and what kind of different clients use the Pathway Commons web services. If no username is set, then the default username (ID) will be used.

Usage Example

var pathwayCommons = require('pathway-commons'); // Import library

pathwayCommons.utilities.user('my-demo-app'); // Set your user/app name

pathwayCommons.search() // Initialise a new Pathway Commons search request
  .q("insulin") // Set the q parameter
  .datasource(["inoh", "reactome"]) // filter by data source
  .type("pathway") // filter by BioPAX class (includes sub-classes)
  .organism("homo sapiens") // filter by orgamism (currently, Pathway Commons aims to integrate human data only)
  .format("json") // Set the output format
  .fetch() // Send the request to the Pathway Commons service
  .then((obj) => { // Receive the response asynchronously
    console.log(obj);
  });

pathwayCommons.search() // Or use an object containing all request parameters
  .query({
    q: "insulin",
    datasource: [
      "inoh",
      "reactome"
    ],
    type: "pathway",
    organism: "homo sapiens"
  })
  .format("json")
  .fetch()
  .then((obj) => {
    console.log(obj);
  });

See unit tests or documentation for more examples on how the library can be used.

Build

Required Software

  • Node.js >=4.0.0. In order to support earlier versions, compile for node and add polyfills for missing features (etc. Promises).

Configuration

The following environment variables can be used to configure the server:

  • NODE_ENV : the environment mode, either production or development (default)
  • PORT : the port on which the server runs (default 3000)

Run targets

  • npm run build : build project
  • npm run build-prod : build the project for production
  • npm run clean : clean the project
  • npm run watch : watch mode (debug mode enabled, auto rebuild, livereload)
  • npm test : run tests
  • npm run lint : lint the project
  • npm run docs : Generate documentation and place resulting HTML files in the docs folder

Testing

All files /test will be run by Mocha. You can npm test to run all tests, or you can run mocha -g specific-test-name (prerequisite: npm install -g mocha) to run specific tests.

Chai is included to make the tests easier to read and write.