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

socko-api

v1.1.1

Published

Hierarchical Tree Weaver

Downloads

8

Readme

SOCKO! - Hierarchical Tree Weaver

Build Status Build Status Coverage Status npm

Build Status

Introduction

SOCKO! is an ETL tool for trees. It walks through an input tree, applies various modifications from a hierarchy tree to it and returns the resulting tree.

This is the core SOCKO api. It's currently the base framework for the SOCKO! command line tool and Grunt helper, that use the API to modify a set of directories in the area of configuration file management. The API is heavily based on js-hierarchy.

The current features include:

  • Use the contents of a node in the hierarchy-tree, that has the same name as a node in the input-tree
  • Insert the content of one or multiple cartridge node in the hierarchy tree into the content of a socket node in the input tree at a specific index
  • Collect a bunch of nodes from the hierarchy-tree and put them in a corresponding branch node of the result tree

For details, see the API documentation

Usage

Typescript

The module includes the complete type definitions for Typescript applications. Simply install the module and you're ready to go:

import {RootNodeBuilder} from 'socko-api';

let rootNode: RootNodeInterface = new RootNodeBuilder().build();

Node.js

After installing the module, use it with require():

var sockoApi = require('socko-api');

var rootNode = new sockoApi.RootNodeBuilder().build();

Browser

Install the module and include the browser script:

<script type="text/javascript" src="node_modules/socko-api/browser.min.js"></script>

or use the jsDelivr CDN hosted version:

<script type="text/javascript" src="//cdn.jsdelivr.net/npm/socko.api/browser.min.js"></script>

With this the global namespace will include a "sockoapi" object:

var rootNode = new sockoapi.RootNodeBuilder().build();

After that, everything's right as working in Node.js.

Nodes and processors

The SOCKO! api provides a set of custom js-hierarchy nodes. All nodes implement the interface "SockoNodeInterface", that adds a "type" and a "content" property. The type references the specific node, that was used and is mainly used to identify the nodes at runtime. The content holds the original or generated content of the node.

These nodes are provided by the core API:

  • RootNodeInterface: The root of each tree
  • BranchNodeInterface: A node, that holds children
  • SimpleNodeInterface, OutputNodeInterface: A node, that holds content, but no children. The SimpleNode is used in the input- and hierarchy-trees and the OutputNode in the result tree.
  • SkippedNodeInterface: A node, that was skipped by the current processor

The different features of the SOCKO! api rely on processors, that process specific node types when walking the input tree. So each processor uses additional node types

  • SocketProcessor:
    • SocketNodeInterface: A "skeleton" node, that holds different insertion slots for cartridge nodes or cartridge collectors to insert content at various parts of the SocketNode content
    • CartridgeNodeInterface: A node, that is inserted into one or more slots of SocketNodes
  • BucketProcessor:
    • BucketNodeInterface: A node in the input node producing a branch node in the result tree collecting SimpleNodes from the hierarchy-tree