Skip to content

Latest commit

ย 

History

History
73 lines (49 loc) ยท 1.82 KB

File metadata and controls

73 lines (49 loc) ยท 1.82 KB

@wecandobetter/node

npm GitHub

A versatile Node-based system with activation functions, middleware processing, and sinks. Empower your applications with flexible node interactions and context management!

Features ๐ŸŽข

  • ๐Ÿ”Œ Define and link nodes to create complex workflows and data flows.
  • โ™ป Implement activation functions to control when nodes are triggered.
  • ๐Ÿ”ง Utilize middleware processing for fine-tuned data transformation.
  • ๐Ÿ“ค Output context to external systems with ease using sinks.
  • ๐Ÿ”ฎ Debug and visualize node relationships with the explore method.
  • ๐Ÿ“ฅ Asynchronous processing for outputs and sinks to optimize performance.

Installation ๐Ÿ“ฆ

Install the package via npm:

npm install @wecandobetter/node

Usage ๐Ÿ“˜

import Node from "@wecandobetter/node";

// Create nodes and define their behavior
const nodeA = new Node<{ n: number }>({
  id: "A",
  activate: (node, ctx) => ctx.n > 0,
});

const nodeB = new Node<{ n: number }>({ id: "B" });

// Link nodes together
nodeA.link(nodeB);

// Add middleware to process context
nodeA.use(async (ctx, next) => {
  ctx.n += 10;
  await next();
});

// Define sinks for output
nodeB.sink((ctx) => console.log(`Sink output: ${ctx.n}`));

// Touch the nodes with context
const context = { n: 5 };
await nodeA.touch(context);

// Output: Sink output: 15

API Documentation ๐Ÿ“œ

For detailed API documentation, please refer to the API Documentation.

License ๐Ÿ“œ

This project is licensed under the MIT License.

Contributing ๐Ÿ™‹โ€โ™‚๏ธ

Contributions are welcome! Feel free to open issues and submit pull requests.

Credits ๐Ÿ‘

Made with โค๏ธโ€๐Ÿ”ฅ by We Can Do Better.