
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
ES2015 Class versions of a Node and Tree
npm install structz or yarn add structz
ES Module
import { Node, Tree } from 'structz';
CJS
const Structz = require('structz'),
Node = Structz.Node,
Tree = Structz.Tree;
After importing the library, you can create as many nodes as you'd like.
let rootSoilNode = new Node('soil');
let fertilizerChildNode = new Node('fertilizer');
let waterChildNode = new Node('h2o');
The new Node() constructor accepts an argument of any Javascript type.
You can append child nodes to a root node like so:
rootSoilNode.append(fertilizerChildNode);
rootSoilNode.append(waterChildNode);
You can detect if a Node is a root or not as well.
rootSoilNode.isRoot(); // -> true
waterChildNode.isRoot(); // -> false
Accessing child nodes is simple.
rootSoilNode.children // returns [fertilizerChildNode, waterChildNode]
You can perform immutable operations on the Node data structure using the Tree class. You instantiate it with a root Node.
let rootNode = new Node(1);
rootNode.append(new Node(2));
let newRootNode = Tree.map(rootNode, (node) => {
return node + 10;
}); // this returns a `new Tree()` with the newly created `Node` as the `.root` value.
newRootNode.root // returns Node of modified type
// in this case, our new structure looks like:
[11] (root)
|
[12] (child)
See docs/index.html for up to date documentation.
Class representing a Node data structure type
Kind: global class
Array*booleanbooleanNodestringArrayReturns an array of child nodes.
Kind: instance property of Node
*Returns the value of the this.attributes.
Kind: instance property of Node
Sets the value of this.attributes.
Kind: instance property of Node
| Param |
|---|
| attribute |
booleanDetects if this Node is a parent node or not.
Kind: instance method of Node
booleanDetects if this node has children or not.
Kind: instance method of Node
NodeAppends a child Node to this Node.
Kind: instance method of Node
| Param |
|---|
| child |
stringReturns a String that represents this Node.
Kind: instance method of Node
Class representing a Tree data structure type that contains a Root node
Class representing a Tree data structure type that contains a Root node
Kind: global class
*Instantiates a Node as a Binary Tree
| Param |
|---|
| root |
*Returns the root of the Node.
Kind: instance property of Tree
*Performs a function on a Node with the provided function and returns the output. Optionally accepts a Tree to perform this otherwise a new Tree is instantiated and returned (breaks immutability).
Kind: static method of Tree
| Param | Default |
|---|---|
| node | |
| func | |
| tree | |
> structz@1.0.0 test ~/github/structz
> nyc mocha
A Node data structure
✓ Can instantiate a new Node
✓ Returns [] children if empty
✓ Returns [] children if not empty
✓ successfully can append a child
✓ returns false if there are no children
✓ returns true if there are children
✓ can return its own value
✓ can set its own value
✓ can output itself as a String
A Tree data structure type that contains a Root node data structure
✓ can instantiate itself
✓ returns the root Node
✓ maps over a Node
12 passing (12ms)
----------|----------|----------|----------|----------|-------------------|
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files | 88.46 | 71.43 | 91.67 | 92 | |
Node.js | 80 | 0 | 87.5 | 85.71 | 23,24 |
Tree.js | 100 | 100 | 100 | 100 | |
----------|----------|----------|----------|----------|-------------------|
FAQs
ES2015 Class versions of a Node and Tree data structure
We found that structz demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.