🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

gremlin-script

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gremlin-script

Generate Gremlin scripts with ease

1.0.1
Source
npm
Version published
Weekly downloads
17
1600%
Maintainers
1
Weekly downloads
 
Created
Source

gremlin-script

Generate Gremlin scripts with ease.

Works in Node.js and the browser.

Installation

Node.js

$ npm install gremlin-script -S

Browsers

This module works as a CommonJS, AMD module or standalone module (exported globally as GremlinScript).

API

Instantiate a script object:

var GremlinScript = require('gremlin-script').GremlinScript;
var gremlin = new GremlinScript();

Get a reference to the graph:

var Graph = require('gremlin-script').Structure.Graph;
var g = new Graph('g'); // pass graph identifier/name to the constructor

gremlin.line(String|Helper[, ...parameters])

Adding a raw String line

var gremlin = new GremlinScript();

gremlin.line('g.v(1)');
gremlin.script.should.equal('g.v(1)\n');

Adding a raw String line with a bound parameter (printf style)

var gremlin = new GremlinScript();

gremlin.line('g.v(%s)', 1);
gremlin.script.should.equal('g.v(p0)\n');
gremlin.params.p0.should.equal(1);

Adding a raw String line with multiple parameters (printf style)

var gremlin = new GremlinScript();

gremlin.line('g.V(%s, %s)', 'name', 'Alice');
gremlin.script.should.equal('g.V(p0, p1)\n');
gremlin.params.p0.should.equal('name');
gremlin.params.p1.should.equal('Alice');

Adding a line with Graph and Element helpers

var gremlin = new GremlinScript();
var g = new Graph('g');

gremlin.line(g.v(1));
gremlin.script.should.equal('g.v(1)\n');

Binding parameters is currently not supported when using helpers.

Author

Jean-Baptiste Musso - @jbmusso.

This library was heavily inspired by the great work started by Frank Panetta on gRex. Thanks!

Contributors

https://github.com/gulthor/gremlin-script/graphs/contributors

License

MIT (c) 2014 Jean-Baptiste Musso

Keywords

Gremlin

FAQs

Package last updated on 01 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts