Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

zer

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zer

Generate Gremlin queries by chaining JavaScript function calls

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

zer

Zer helps you serialize any JavaScript chains to String representations of any languages by leveraging ES2015 Proxy objects.

Installation

npm install zer

Usage

Zer is currently useful for generating Gremlin-Groovy graph database queries.


import { createChainCreator } from 'zer';

import { toGroovy } from 'zer/src/groovy';
import { STRATEGY } from 'zer/src/chain';

const Objects = createChainCreator(STRATEGY, toGroovy);

const { g, out, has } = Objects;

const chain = g.V().has('name', 'Alice').repeat(out('knows')).until(has('name', 'Bob'));

console.log(chain.__repr__());
// g.V().has('name', 'Alice').repeat(out('knows')).until(has('name', 'Bob'))

Argument escaping

Zer allows you to output Objects, not just Strings. This is especially useful when you wish to escape some arguments from your chain, such as when creating a DSL for a database client (SQL, Gremlin...).

const chain = g.V().has('name', 'Alice').repeat(out('knows')).until(has('name', 'Bob'));

console.log(chain.__repr__())

/*
 { query: 'g.V().has(p0, p1).has(p2, p3).repeat(out(p4, p5))',
  params:
   { p0: 'name',
     p1: 'Alice',
     p2: 'age',
     p3: 30,
     p4: 'firstname',
     p5: 'Bob' }
*/

Keywords

FAQs

Package last updated on 17 May 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc