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

protopipe

v2.2.10

Published

Graph-driven data processor

Downloads

344

Readme

protopipe

Graph-driven data processor. qiwi.github.io/protopipe

stability-experimental CI npm (tag) Maintainability Test Coverage CodeStyle

Idea

We often come across the problem of atomic data processing (logwrap, uniconfig, cyclone, etc), and it seems to be useful to make the one pipeline to rule them all. Not universal, not high-performance. But dumb and clear.

TL;DR

Install

  yarn add protopipe

Usage

import {Graph, IAny, ISpace, NetProcessor} from 'protopipe'

const graph = new Graph({
  edges: ['AB', 'BC'],
  vertexes: ['A', 'B', 'C'],
  incidentor: {
    type: 'EDGE_LIST_INCDR',
    value: {
      'AB': ['A', 'B'],
      'BC': ['B', 'C'],
    },
  },
})
const handler = {
  // Default handler
  graph: (space: ISpace): IAny => (NetProcessor.getData(space) || {value: 0}).value * 2,
  // Vertex specific handlers
  vertexes: {
    'B': (space: ISpace): IAny => (NetProcessor.getData(space, 'A') || {value: 10}).value * 3,
  },
}
const protopipe = new NetProcessor({
  graph,
  handler,
})
const space = protopipe.impact(true, ['A', 1]) as ISpace

console.log(NetProcessor.getData(space, 'C').value) // 6
Features
  • Sync / async execution modes.
  • Stateful and stateless contracts.
  • Deep customization.
  • Typings for both worlds — TS and flow.
Limitations (of default executor, traverser, etc)
  • Protopipe supports digraphs only.
  • The lib does not solve the declaration problem (you know, adjacency/incidence matrix, adjacency list, DSL).
  • No consistency checks out of box: graph is being processed as is. But you're able to add custom assertions (for example, BFS-based check).

Definitions and contracts

  • Space is a set with some added structure.
  • Vertex is a graph atom.
  • Edge — bond.
  • Incidentor — the rule of connecting vertexes and edges.
  • Graph — a class that implements IGraph — stores vertexes and edges collections, features and incidentor.
  • Sequence — any possible transition.
    • Walk: vertices may repeat, edges may repeat (closed / open)
    • Trail: vertices may repeat, edges cannot repeat (open)
    • Circuit: vertices may repeat, edges cannot repeat (closed)
    • Path: vertices cannot repeat, edges cannot repeat (open)
    • Cycle : vertices cannot repeat, edges cannot repeat (closed)
  • Pipe is an executable segment of pipeline, any directed sequence with attached handler(s)
  • Handler — lambda-function, which implements IHandler iface.

IGraph

export type IGraph = {
  vertexes: Array<IVertex>,
  edges: Array<IEdge>,
  incidentor: IGraphIncidentor
}

export type IGraphRepresentation = any

export type IGraphIncidentor = {
  type: IGraphIncidentorType,
  value: IGraphRepresentation
}

Sync / async

Pass mode flag as the first .impact() argument to get result or promise.

const graph = new Graph({
  edges: ['AB', 'AC', 'BC', 'BD', 'CD', 'AD'],
  vertexes: ['A', 'B', 'C', 'D'],
  incidentor: {
    type: 'EDGE_LIST_INCDR',
    value: {
      'AB': ['A', 'B'],
      'AC': ['A', 'C'],
      'BC': ['B', 'C'],
      'BD': ['B', 'D'],
      'CD': ['C', 'D'],
      'AD': ['A', 'D'],
    },
  },
})
const handler = (space: ISpace) => NetProcessor.requireElt('ANCHOR', space).value.vertex
const netProcessor = new NetProcessor({graph, handler})

// SYNC
const res1 = netProcessor.impact(true,'A') as ISpace 
NetProcessor.getData(res1, 'D') // 'D'

// ASYNC
netProcessor.impact(false,'A').then((res) => {
  NetProcessor.getData(res, 'D') // 'D'
})

Bundles

The lib exposes its inners as ES5, ES6 and TS formats.

Customization

You're able to override everything.