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

@pown/graph

v2.0.0

Published

Pownage guaranteed

Downloads

2

Readme

License GitHub Release Follow on Twitter NPM Fury default workflow SecApps

Graph

Graph is a library and a command-line utility for the PownJS toolkit, that works with graphs. It can be used stand-alone, in script or in other tools which require graph-based data model. It powers other tools such as PownJS Recon.

Credits

This tool is part of secapps.com open-source initiative.

  ___ ___ ___   _   ___ ___  ___
 / __| __/ __| /_\ | _ \ _ \/ __|
 \__ \ _| (__ / _ \|  _/  _/\__ \
 |___/___\___/_/ \_\_| |_|  |___/
  https://secapps.com

NB: Graph is the result of an almost direct copy of SecApps' excellent Recon tool.

Quickstart

This tool is meant to be used as part of Pown.js but it can be invoked separately as an independent tool.

Install Pown first as usual:

$ npm install -g pown@latest

Invoke directly from Pown:

$ pown graph

Otherwise, install this module locally from the root of your project:

$ npm install @pown/graph --save

Once done, invoke pown cli:

$ POWN_ROOT=. ./node_modules/.bin/pown-cli graph

You can also use the global pown to invoke the tool locally:

$ POWN_ROOT=. pown graph

Usage

WARNING: This pown command is currently under development and as a result will be subject to breaking changes.

pown-cli graph <command>

Target graph

Commands:
  pown-cli graph template <command>             Graph template commands  [aliases: p, templates]
  pown-cli graph select <expressions...>        Select nodes  [aliases: s]
  pown-cli graph traverse <expressions...>      Traverse nodes  [aliases: v]
  pown-cli graph add <nodes...>                 Add nodes  [aliases: a]
  pown-cli graph remove <expressions...>        Remove nodes  [aliases: r]
  pown-cli graph edit <expressions...>          Edit nodes  [aliases: e]
  pown-cli graph merge <files...>               Perform a merge between at least two graph files  [aliases: m]
  pown-cli graph diff <fileA> <fileB>           Perform a diff between two graph files  [aliases: d]
  pown-cli graph group <name> <expressions...>  Group nodes  [aliases: g]
  pown-cli graph ungroup <expressions...>       Ungroup nodes  [aliases: u]
  pown-cli graph load <file>                    Load a file  [aliases: l]
  pown-cli graph save <file>                    Save to file  [aliases: o]
  pown-cli graph import <file>                  Import file  [aliases: i]
  pown-cli graph export <file>                  Export to file  [aliases: x]
  pown-cli graph layout <name>                  Layout the graph  [aliases: k]
  pown-cli graph summary                        Create a summary  [aliases: y]
  pown-cli graph exec <files...>                Execute js file  [aliases: c]

Options:
  --version  Show version number  [boolean]
  --help     Show help  [boolean]

Selectors

Some commands expect graph selectors. The rest of the documentation is copy of cytoscape.js selectors manual with some minor differences.

A selector functions similar to a CSS selector on DOM elements, but selectors in Graph instead work on collections of graph elements. This mechanism is provided by the powerful cytoscape.js.

The selectors can be combined together to make powerful queries, for example:

pown graph select 'node[weight >= 50][height < 180]'

Selectors can be joined together (effectively creating a logical OR) with commas:

pown graph select 'node#j, edge[source = "j"]'

It is important to note that strings need to be enclosed by quotation marks:

pown graph select 'node[type = "domain"]'

Note that metacharacters ( ^ $ \ / ( ) | ? + * [ ] { } , . ) need to be escaped:

pown graph select '#some\$funky\@id'

Group, class, & ID

  • node, edge, or * (group selector) Matches elements based on group (node for nodes, edge for edges, * for all).
  • .className Matches elements that have the specified class (e.g. use .foo for a class named "foo").
  • The #id Matches element with the matching ID (e.g. #foo is the same as [id = 'foo'])

Data

  • [name] Matches elements if they have the specified data attribute defined, i.e. not undefined (e.g. [foo] for an attribute named “foo”). Here, null is considered a defined value.
  • [^name] Matches elements if the specified data attribute is not defined, i.e. undefined (e.g [^foo]). Here, null is considered a defined value.
  • [?name] Matches elements if the specified data attribute is a truthy value (e.g. [?foo]).
  • [!name] Matches elements if the specified data attribute is a falsey value (e.g. [!foo]).
  • [name = value] Matches elements if their data attribute matches a specified value (e.g. [foo = 'bar'] or [num = 2]).
  • [name != value] Matches elements if their data attribute doesn’t match a specified value (e.g. [foo != 'bar'] or [num != 2]).
  • [name > value] Matches elements if their data attribute is greater than a specified value (e.g. [foo > 'bar'] or [num > 2]).
  • [name >= value] Matches elements if their data attribute is greater than or equal to a specified value (e.g. [foo >= 'bar'] or [num >= 2]).
  • [name < value] Matches elements if their data attribute is less than a specified value (e.g. [foo < 'bar'] or [num < 2]).
  • [name <= value] Matches elements if their data attribute is less than or equal to a specified value (e.g. [foo <= 'bar'] or [num <= 2]).
  • [name *= value] Matches elements if their data attribute contains the specified value as a substring (e.g. [foo *= 'bar']).
  • [name ^= value] Matches elements if their data attribute starts with the specified value (e.g. [foo ^= 'bar']).
  • [name $= value] Matches elements if their data attribute ends with the specified value (e.g. [foo $= 'bar']).
  • @ (data attribute operator modifier) Prepended to an operator so that is case insensitive (e.g. [foo @$= 'ar'], [foo @>= 'a'], [foo @= 'bar'])
  • ! (data attribute operator modifier) Prepended to an operator so that it is negated (e.g. [foo !$= 'ar'], [foo !>= 'a'])
  • [[]] (metadata brackets) Use double square brackets in place of square ones to match against metadata instead of data (e.g. [[degree > 2]] matches elements of degree greater than 2). The properties that are supported include degree, indegree, and outdegree.

Compound nodes

  • > (child selector) Matches direct children of the parent node (e.g. node > node).
  • (descendant selector) Matches descendants of the parent node (e.g. node node).
  • $ (subject selector) Sets the subject of the selector (e.g. $node > node to select the parent nodes instead of the children).