{"id":15355959,"url":"https://github.com/fibo/dflow","last_synced_at":"2025-04-13T21:32:49.251Z","repository":{"id":5038507,"uuid":"6198183","full_name":"fibo/dflow","owner":"fibo","description":"is a minimal Dataflow programming engine","archived":false,"fork":false,"pushed_at":"2024-02-15T18:49:02.000Z","size":6166,"stargazers_count":72,"open_issues_count":0,"forks_count":8,"subscribers_count":10,"default_branch":"main","last_synced_at":"2024-04-14T16:14:24.953Z","etag":null,"topics":["dataflow","dataflow-programming"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"CyanogenMod/android_external_arduino","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fibo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-10-13T00:23:45.000Z","updated_at":"2024-08-26T18:38:17.225Z","dependencies_parsed_at":"2022-08-30T14:51:36.005Z","dependency_job_id":"ed123cc7-945a-46e3-97cb-bc81d89ae74e","html_url":"https://github.com/fibo/dflow","commit_stats":{"total_commits":1212,"total_committers":4,"mean_commits":303.0,"dds":"0.028877887788778867","last_synced_commit":"a4da5570e325bb9a9e7ff4ad7d0555568b90fd1e"},"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Fdflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Fdflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Fdflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fibo%2Fdflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fibo","download_url":"https://codeload.github.com/fibo/dflow/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248786907,"owners_count":21161511,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dataflow","dataflow-programming"],"created_at":"2024-10-01T12:26:23.438Z","updated_at":"2025-04-13T21:32:44.217Z","avatar_url":"https://github.com/fibo.png","language":"TypeScript","readme":"# Dflow\n\n\u003e is a minimal [Dataflow programming][dataflow-wikipedia] engine\n\n## Installation\n\nWith [npm](https://npmjs.org/) do\n\n```sh\nnpm install dflow\n```\n\n## How it works\n\nA **node** represents a block of code: it can have **inputs** and **outputs**.\n\nAn **edge** connects an input to an output.\n\nA **graph** represents a program.\nIt can contain nodes and edges. Nodes are executed, sorted by their connections.\n\n## Features\n\n- Implemented in TypeScript.\n- Expressive and simple API.\n- A graph can be saved as a JSON file. It can be then loaded and executed.\n- It is easy to create nodes: just extend `DflowNode` class, define its inputs and outputs and the `run()` function.\n- Minimal internal type system: it is possible to connect an output of type `T` to an input of type `U`, if and only if `U` includes `T`.\n- It is possible to define functions represented by nodes and edges.\n\n**NOTA BENE**: it is supposed that you implement your own nodes, for example node `addition` could be implemented using bigint or some floating point library, according to your needs.\nHowever an example nodes catalog with basic JavaScript features can be imported from `dflow/nodes`.\n\n## Usage\n\nThis is a graph that will compute `sin(π / 2) = 1` and print the result.\n\n```\n   ----------------\n  | number = π / 2 |\n   ----------------\n   |\n   |\n   ---------\n  | mathSin |\n   ---------\n    \\\n     \\\n     ------------\n    | consoleLog |\n     ------------\n```\n\nYou can run the following code with any of the following by cloning this repo and launching `npm run example:usage`.\n\nYou should see a number `1` printed on output.\n\n```javascript\nimport { Dflow, DflowNode } from \"dflow\";\n\nconst { input, output } = Dflow;\n\nclass DflowMathSin extends DflowNode {\n  static kind = \"mathSin\";\n  static inputs = [input(\"number\")];\n  static outputs = [output(\"number\")];\n  run() {\n    this.output(0).data = Math.sin(this.input(0).data);\n  }\n}\n\nclass DflowConsoleLog extends DflowNode {\n  static kind = \"consoleLog\";\n  static inputs = [input()];\n  run() {\n    console.log(this.input(0).data);\n  }\n}\n\nconst nodesCatalog = {\n  [DflowMathSin.kind]: DflowMathSin,\n  [DflowConsoleLog.kind]: DflowConsoleLog,\n  // DflowNodeData is a core node\n};\n\nfunction rungraph() {\n  const dflow = new Dflow(nodesCatalog);\n  const catalog = dflow.nodesCatalog;\n\n  // create nodes\n  const numNode = dflow.newNode({\n    kind: catalog.data.kind,\n    // set numNode output to π / 2\n    outputs: [{ data: Math.PI / 2 }],\n  });\n  const sinNode = dflow.newNode({ kind: catalog.mathSin.kind });\n  const consoleLogNode = dflow.newNode({ kind: catalog.consoleLog.kind });\n\n  // connect numNode to sinNode and sinNode to consoleLog\n  dflow.connect(numNode).to(sinNode);\n  dflow.connect(sinNode).to(consoleLogNode);\n\n  // run graph\n  dflow.run();\n}\n\nrungraph();\n```\n\nA graph can be executed asynchronously with `await dflow.run()`: see [custom nodes example](https://github.com/fibo/dflow/blob/main/examples/custom-nodes.js).\n\nAvailable examples are listed [here](https://github.com/fibo/dflow/blob/main/examples).\n\n## License\n\n[MIT](https://fibo.github.io/mit-license)\n\n[dataflow-wikipedia]: http://en.wikipedia.org/wiki/Dataflow_programming \"Dataflow programming\"\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibo%2Fdflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffibo%2Fdflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffibo%2Fdflow/lists"}