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

gremlin-piper

v1.0.9

Published

## TODO: 0. fix exports 1. properly integrate typescript types 2. implement the gremlin pipes missed in the initial pass 3. Add a clone generator function that returns a clone of the specific type everytime it is called 4. Make sure the repo is

Downloads

8

Readme

gremlin-piper

TODO:

  1. fix exports
  2. properly integrate typescript types
  3. implement the gremlin pipes missed in the initial pass
  4. Add a clone generator function that returns a clone of the specific type everytime it is called
  5. Make sure the repo is consistant with what is explained in the readme.md
  6. Add character escaping to default_primitiveValueTransform
  7. Add a default_aliasPipe, which can take multiple pipes, and chooses which to print when toString is called based on input args
  8. Figure out why some objects need to be cast with as in order to shut typescript up
  9. Add init function, which returns a pipeBuilder, but doesnt add anything to the callstack

usage example:

import { createPipeBuilderLib } from 'pipeBuilder';
const { g, inE } = createPipeBuilderLib();

// 1
const pipe = g.V().outE();
console.log(pipe.toString());
// console: g.V().outE()

const pipe2 = inE('latest').inV();
pipe.union(pipe2, out('latest'));
console.log(pipe.toString());
// console: g.V().outE().union(inE('latest').inV(),out('latest'));

let pipe3 = __;
pipe3 = pipe3.inE('test').outV().values('test').is(1);
pipe.where(pipe);
console.log(pipe3.toString());
// console: g.V().outE().union(inE('latest').inV(),out('latest')).where(inE('test').outV().values('test').is(1))

let appendTest = outE('append').inV();
pipe.append(appendTest);
console.log(pipe.toString());
// console: g.V().outE().union(inE('latest').inV(),out('latest')).where(inE('test').outV().values('test').is(1)).outE('append').inV()

let cloneTest = outE('test').inV();
const cloned = cloneTest.clone();
cloneTest.where(cloned.append(label().is(eq('test'))));
cloneTest.log()
// console: outE('test').inV().where(outE('test').inV().label().is(eq('test'))));

glossary:

Builder

The main object returned by createdBuilder and any given pipe.

pipe

A term used to describe any function or property that mutates the Builder internal state and returns the Builder the pipe is a member of.

pipeNames

pipeNames are a generic term used for any property that will be accessable at any point in the created pipeBuilder.

override defaults:

out-of-the-box, pipeBuilder is set up with gremlin traversal scripts in mind, but createPipeBuilder takes several arguments to override or extend this functionality.

aliasPipeNames?: string[]

Pipes with custom functionality

aliasPipes?: {[pipeName: string]: AliasPipe};

A map of functions, which return a string, and will be called once toString is called.

langReservedWordPipeNames?: string[];

Pipes that are also reserved words in the output programming language. When these pipes are stringified, if they are at the head of the pipeStream, they will be prepended with __.

nonFunctionPipeNames?: string[];

Pipes that are not functions, but merely properties. toString will not look for arguments for these pipes, and will not append them with paraentheses.

primitiveArgumentTransform?: PrimitiveArgumentTransform;

A function that is used to stringify the pipe arguments. PipeName: string and the argument be processed: any are passed into this function when its called.

regularPipeNames?: string[];

A list of generic pipes.

langReservedWordHandler?: string;

A function that takes a pipeName as its input, and returns a string which will be appended to the output script, if the given reserved word is a head of a pipeStream default: appended __. to the script;

gotchas:

Infinite toString recursion when passing a destructured nonFunctionProp in as an argument of its own pipeStream.

import { createPipeBuilderLib } from 'pipe-builder-to-string';
const __ = createPipeBuilderLib();
const { g } = __;
const pipe = g.V().where(g.V().inE().label().is(eq('one')));

...will result in a stack overflow upon calling toString.

When properties are deconstructed from createPipeBuilder, its get function constructs a new pipeBuilder. So, if one were to construct a pipe with g, then pass g into a g pipe call, upon running toString, the toString function will attempt to stringify the nested g, and since they're the same builder, will also contain said g

...you get the picture.

A potential work around might look like...

const pipe = g.V().where(__.g.V().inE().label().is(eq('one')));

This way, g.get() is called a second time, and a new pipeBuilder is created

If there are any suggestions, which maintain the syntax, I'm all open. Personally, I don't really see this as a huge deal breaker, since, with keeping Gremlin in mind, calling g isn't something you're going to do more than once.

primitiveValueTransform throwing an error, saying it cannot handle [object Object] type

import { createPipeBuilder } from 'pipe-builder-to-string';
const __ = createPipeBuilder();
const pipe = __;
pipe.g.V().inE().outV();
pipe.toString();
// error

Hopefully, there is a decent solution for this, but currently, createPipeBuilder does not return a Builder object , but returns an object in which each property is a pipeName and upon being called: inits a Builder, calls the property name's function, and returns the Builder

current work around

  let pipe = __;
  pipe = pipe.g.V().inE().outV();

Pretty fucking poor; no bueno.

So, perhaps we can create a Builder when createPipeBuilder is called, then said Builder is passed into the first function call.

or shit, what if this is one of those situations where .this is actually fucking desirable. if the call comes from __., then pass the builder into the first function call, if not don't pass it

...later

yep, this doesn't work renamed createPipeBuilder to createPipeBuilderLib, to indicate that createPipeBuilderLib returns a lib of pipeBuilders rather than a pipeBuilder