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

panzer

v0.3.13

Published

A comprehensive node-tree solution, for smart data.

Downloads

129

Readme

Panzer

Build Status

version 0.3.13 by Bemi Faison

A comprehensive node-tree solution, for smart data.*

DESCRIPTION

Panzer is a JavaScript class factory that implements tree parsing, traversal and monitoring. Panzer separates node behavior, structure, and navigation concerns, so you can design classes that do just what you need.

The procedural consumption of "structure" allows data to inform your code's execution, for easier coding. As well, Panzer provides nodal meta-data, like parent-child relationships, depth, child order, etc. - which can be used to solve various problem domains.

The purpose and function of your Panzer is given by it's packages - modules of code that access and extend classes. The package architecture allows several treatments of an instance, with fewer resource collisions and greater interoperability than traditional plug-in schemes.

* Read The Cathedral and the Bazaar, to understand why "Smart data structures and dumb code works a lot better than the other way around."

INSTALL

Web Browsers

Use a <SCRIPT> tag to reference panzer.min.js, as you would any external JavaScript file. The "Panzer" namespace will be added to the global scope.

  <script type="text/javascript" src="somepath/panzer.min.js"></script>
  <script type="text/javascript">
    // ... Panzer dependent code ...
  </script>

Node.js

  • npm install panzer if you're using npm
  • component install bemson/panzer if you're using component
  • bower install panzer if you're using Bower

Dependencies

Panzer requires genData v3.1.0. (The minified file includes this dependency.)

USAGE

First, create a Panzer class.

var BasicTree = Panzer.create();

In order to access and extend Panzer's functionality, we need to define a package. (Otherwise, our instances won't do much.) Let's register a new package by name.

var myPkgDef = BasicTree.pkg('my first package');

The returned value is the package-definition, a function with special members that hook into our class. Many hooks are available, but we'll prototype an instance method now.

myPkgDef.proxy.onward = function () {
    var
        // get the corresponding package-instance
        tree = myPkgDef(this),
        // alias the tank that controls our tree's "pointer"
        tank = tree.tank,
        // reference the current node
        currentNode = tree.nodes[tank.currentIndex],
        // reference a sibling or child node, if available
        nextNode = tree.nodes[currentNode.nextIndex || currentNode.firstChildIndex];
    // if there is a nextNode and we've successfully navigated to it...
    if (nextNode && tank.go(nextNode.index)) {
        // return the value of (what is now) the current node
        return nextNode.value;
    }
    // (otherwise) flag that no node is next
    return false;
};

Though simple enough, there is a lot going on in our method. Nevertheless, we can now "walk" the left-branch of any data structure.

var
    myTree = new BasicTree({hello: 'world'}),
    nodeValue, lefties = [];
while (nodeValue = myTree.onward()) {
    lefties.push(nodeValue);
}
//
// lefties[0] -> {hello: 'world'}
// lefties[1] -> 'world'
//

Understanding the package api is key to getting the most from your class. However, in lieu of full documentation, please see the test suite for greater insight. Thanks for your patience!

FILES

  • src/ - Directory containing the source code
  • test/ - Mocha test suite
  • README.md - This readme file
  • LICENSE - The legal terms and conditions under which this software may be used
  • panzer.min.js - The Panzer platform, including dependencies, minified for browser environments

Source files minified with both UglifyJS and Yahoo! Compressor.

LICENSE

Panzer is available under the terms of the MIT-License.

Copyright 2014, Bemi Faison