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 🙏

© 2025 – Pkg Stats / Ryan Hefner

gremlin-console

v0.9.9

Published

Console for gremlin-server

Readme

gremlin-console is a frontend library that generates a console to query gremlin-server (or gremlin-server enabled graph databases like Titan). It is compatible with Apache TinkerPop3. It can be extended via plugins to support visualization and output format (amongst other things)

Build Status Coverage Status npm GitHub license

Introduction

This is the gremlin-console library used for www.gremlinbin.com. gremlin-console can :

  • Execute gremlin queries against gremlin-server
  • Display query results (with syntax highlighting)
  • Maintain a query + result history (for easy re-runs using up/down arrows as well as any manipulation of the history that could be required)
  • Be extended via plugins

App Screenshot

Installation

npm install gremlin-console

Getting started

Using ES2015/2016
import GremlinConsole from 'gremlin-console';

//create a console + input combo by passing css selectors to GremlinConsole
const gc = GremlinConsole('#console-window', '#console-input', {host: "localhost", port: 8182});
In browser
<head>
  <!-- ... -->
  <link rel="stylesheet" type="text/css" href="umd/css/default.css">
  <script src="umd/gremlin-console.min.js"></script>
</head>
//create a console + input combo by passing css selectors to GremlinConsole
var gc = GremlinConsole.create('#console-window', '#console-input', {host: "localhost", port: 8182});

The available options are :

  • host: The host gremlin-server can be reached on (defaults to localhost)
  • port: The port to connect to gremlin-server on (defaults to 8182)
  • driverOptions: An map of all the configuration options for the console's client. See jbmusso/gremlin-javascript for the default client.

Security

--WARNING-- Due to the nature of gremlin-console being executed locally in the browser and communicating directly with gremlin-server, there are some security implications. If you can't trust your users or are using gremlin-console-js outside of the scope of a secure network (ie : public network) you will need to enable sandboxing (amongst other things) on gremlin-server. This configuration is required to ensure that people running queries in the console don't get access to secure server side information.

Another option (though not a replacement to sandboxing) is to use gc-ajax-plugin which will allow you not to expose the gremlin-server websocket. This has more overhead but it will provid the added benefit that you can handle Authentication and Authorization on your server app level. (see plugin section)

Populating the console on init

You can prepare the state of the graph as well as the queries and results display in the console upon initializing by providing a history object in the options:

// Start an instance of gremlin-console
var gc = GremlinConsole('#console-window', '#console-input');
// Provide a history array to populate the graph
// In this case we create a modern graph "graph", with a traversal object "g".
gc.populateDbFromHistory([
  {query: "graph = TinkerFactory.createModern();", error: undefined, results: [null]},
  {query: "g = graph.traversal();", error: undefined, results: [null]}
]);

What happens under the hood : gremlin-console will concatenate the n-1 queries from the provided history and submit them to the server. Essentially setting the graph's state. Then it will rerun the last query so as to trigger the proper events.

Events

You can register lambdas against events as follows :

const gc = GremlinConsole('#console-window', '#console-input', {host: "localhost", port: 8182});
gc.on('results', (err, result) => {});

There are currently only two supported events :

  • results is triggered when the client receives a response from the server. It provides the following params:
    • err : An object with an err.message property.
    • result : A Parser object.
  • error is triggered when a structural error occurs (different from a query error). It provides the following params:
    • err : An Error object.

Plugins

The following plugins are currently available for gremlin-console :

  • gc-graphson-text-plugin : Modifies the output display. Makes the console show the results in the same way the Apache TinkerPop terminal console displays it's results.
  • gc-ajax-plugin : Makes gremlin-console run it's queries against an http web page instead of directly against the gremlin-server's websocket. This can help provide more control over Authentication and Authorization of users on your website.
  • gc-cytoscape-plugin : highly experimental A graph visualization tool for gremlin-console. This is only useful for very small data sets.

If you're interested in developping plugins check the plugin documentation.

API

You can find the API here.

misc

  • Build libs : npm run build and find file lib/index.js
  • Build web js : npm run build:umd and find file umd/gremlin-console.js
  • Build web min.js : npm run build:min and find file umd/gremlin-console.min.js
  • Run tests : npm run test will run mocha coverage (firefox required)
  • Build api : npm run build:docs will generate an api folder.