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

fungsi-maju

v0.1.21

Published

Library javascript untuk memproses fungsi berantai yang modular dengan format JSON

Downloads

9

Readme

⭐️ Feature

  • Engine untuk proses fungsi
  • Validator skema json
  • Editor visual
  • Server-side processing
  • Custom component

📦 Getting Started

NOTE: LIBRARY INI MASIH BERSIFAT EKPERIMEN


$ npm install fungsi-maju

npm

import { Engine } from 'fungsi-maju';
import 'fungsi-maju/build/index.css' // If you import a css file in your library

let libraryInstance = new Engine("0.1.0");
...

self-host/cdn

<link href="https://unpkg.com/fungsi-maju@latest/build/index.css" rel="stylesheet">
<script src="https://unpkg.com/fungsi-maju@latest/build/index.js"></script>

<script>
  let FungsiMaju = window.Engine.default;
  let libraryInstance = new FungsiMaju.Engine("0.1.0");
  ...
</script>

Example

import { Editor, Node, Component } from "fungsi-maju";

class Basic extends Component {
  constructor() {
    super("Basic");
  }
  builder(nodeView) {
    nodeView.addSocket("output", 0, "Output");
    return nodeView;
  }
  worker(node, input) {
    const output = input * 2;
    return output;
  }
}

class Debug extends Component {
  constructor() {
    super("Debug");
  }
  builder(nodeView) {
    nodeView.addSocket("input", 0, "Output");
    return nodeView;
  }
  worker(node, input) {
    console.log(input);
  }
}

let container = document.getElementById("editor");

let editor = new Editor("0.1.0", container);

editor.register(new Basic());
editor.register(new Debug());

let node = [
  new Node(Editor.generateId(), "Basic"),
  new Node(Editor.generateId(), "Debug"),
];

editor.addNode(node[0]);
editor.addNode(node[1]);

editor.connect(node[0], 0, node[1]);

const inputValue = 1;

editor.process(inputValue, node[0]);

editor.on("process", () => {
  console.log("process")
});

Tanpa View

import { Editor, Node, Component } from "fungsi-maju";

class MyComponent extends Component{
  constructor(name) {
    super(name);
  }
  worker(node, input) {
    const output = input + 1;
    return output;
  }
}

let editor = new Editor("0.1.0");

editor.register(new MyComponent("CustomComponent"));

let node = [
  new Node(Editor.generateId(), "CustomComponent"),
  new Node(Editor.generateId(), "CustomComponent"),
]

editor.addNode(node[0]);
editor.addNode(node[1]);

editor.connect(node[0], 0, node[1]);

const inputValue = 1;

editor.process(inputValue, node[0]);

editor.on("process", () => {
  console.log("process")
});

Interaction

Move canvas
[Press + Hold] Space key then [Drag] Click on canvas.
Move Canvas

Move node
[Drag] Mouse Click on node.
Move Node

Connect node socket
Click on node socket source, then Click on target socket.
Connect Node Socket

Remove connection
[Hover]Mouse on connection wire, [Press] Backspace key. [Hold] Shift to select multiple connection.
Remove connection

API

Schema

{
  "version": "1.0.0",
  "nodes": [
    {
      "id": "string",
      "type": "string",
      "metadata": {},
      "outputs": [
        [ "string" ]
      ]
    },
    ...
  ]
}

Events

  • process
  • nodeselected
  • nodecreate
  • nodecreated
  • noderemove
  • noderemoved
  • connectionselected
  • connectioncreated
  • connectionremoved

Engine

export { Engine } from "fungsi-maju";

properties

  • extends Emitter
  • version = string
  • components = [Connection]
  • nodes = [Node]

| method | arguments | return | | ----------------------------- | --------------------------- | ------------------- | | register(component) | Component | Engine | | validate(data) | json | boolean | | process(input, startId, json) | value, Node.id, json? | boolean |

Editor

export { Editor } from "fungsi-maju";

properties

| method | arguments | return | | ------------------------- | ------------------------------------------ | --------------- | | static generateId() | - | string | | addNode(node) | Node | Node | | removeNode(node) | Node | boolean | | getNode(node) | Node | boolean | | connect(from, branch, to) | Node, number, Node | boolean | | toJSON() | - | json | | fromJSON(json) | json | json |

Node

export { Node } from "fungsi-maju";

properties

  • id = string
  • metadata = object
  • position = object
  • type = string
  • outputs = [ [Node.id] ]

| method | arguments | return | | ------------------------ | ----------------------------- | --------------- | | getData(key) | any | any | | setData(key, value) | any, value | metadata | | removeData(key) | any | metadata | | addOutput(branch, id) | number, Node.id | Node | | removeOutput(id, branch) | Node.id, number? | Node | | toJSON() | - | json |

View

properties

  • emitter = Editor
  • area = Area
  • picker = Picker
  • selection = Selection
  • container = HTMLElement
  • connection = {Connection}
  • selected = {NodeView}
  • nodes = {NodeView}

| method | arguments | return | | ---------------- | ------------------ | ----------------------- | | addNode(node) | Node | NodeView | | getNode(id) | Node.id | NodeView | | removeNode(node) | Node | Node |

NodeView

properties

  • id = Node.id
  • view = View
  • node = Node
  • sockets = {Socket}
  • component = {Component}
  • container = HTMLElement
  • element = Element

| method | arguments | return | | -------- | --------- | ------ | | update() | - | - | | render() | - | - | | toJSON() | - | json |

Credit

Konsep prosesnya mirip Node Red.
Editor visual adopsi dari vvvv.
Library ini diekstrak dari library ReteJS.
Emitter yang dipakai yaitu nanoevents.
Template library menggunkan js-library-boilerplate.