{"id":19547318,"url":"https://github.com/emilamaj/js-circuit-solver","last_synced_at":"2026-06-13T12:04:10.405Z","repository":{"id":94443507,"uuid":"608134966","full_name":"emilamaj/js-circuit-solver","owner":"emilamaj","description":"Electric circuit solving library in Javascript","archived":false,"fork":false,"pushed_at":"2023-04-20T15:09:51.000Z","size":59,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-10-05T19:52:51.068Z","etag":null,"topics":["circuit-simulation","electric-circuit","electrical-engineering","equation-solver","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emilamaj.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-01T11:51:21.000Z","updated_at":"2023-11-22T22:57:43.000Z","dependencies_parsed_at":null,"dependency_job_id":"70633ae2-0450-47b6-8ab9-c40a4a37e1b7","html_url":"https://github.com/emilamaj/js-circuit-solver","commit_stats":{"total_commits":28,"total_committers":2,"mean_commits":14.0,"dds":0.3214285714285714,"last_synced_commit":"0da26ad2f57ae183b240f2112fc1f3a8b15df318"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/emilamaj/js-circuit-solver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilamaj%2Fjs-circuit-solver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilamaj%2Fjs-circuit-solver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilamaj%2Fjs-circuit-solver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilamaj%2Fjs-circuit-solver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emilamaj","download_url":"https://codeload.github.com/emilamaj/js-circuit-solver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emilamaj%2Fjs-circuit-solver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34283400,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-13T02:00:06.617Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["circuit-simulation","electric-circuit","electrical-engineering","equation-solver","javascript"],"created_at":"2024-11-11T03:49:18.362Z","updated_at":"2026-06-13T12:04:10.368Z","avatar_url":"https://github.com/emilamaj.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# js-circuit-solver\r\nLightweight library aimed at solving/simulating simple electrical circuits\r\n\r\n# Install\r\n\r\nAvailable as [js-circuit-solver](https://www.npmjs.com/package/js-circuit-solver) on npm. \\\r\nRun:\r\n`npm install js-circuit-solver`\r\n\r\n# Functions\r\n\r\nThis library currently provides a single function to solve simple resistive circuits. It takes in a circuit object and returns a solved circuit object. \\\r\n\r\n## solveResistiveCircuit\r\n\r\n`function solveResistiveCircuit(circuit, groundNode, sourceNode, sourceVoltage)`\r\nUsage:\r\n- circuit: Object containing circuit information. Array where element at index i is the array of the connections that node i has with other nodes.\r\n- groundNode: Node to be considered as ground\r\n- sourceNode: Node to be considered as source\r\n- sourceVoltage: Voltage of the source node\r\n\r\n_circuit_ Object\r\n\r\nThe following is an example circuit consisting of the source and ground nodes connected by 3 parallel branches each having 2 resistors.\r\nExample circuit diagram:\r\n```\r\n        |---R1---R2---|\r\n        |             |\r\n        S---R3---R4---G\r\n        |             |\r\n        |---R5---R6---|\r\n```\r\nSince the circuit only contains resistors, we can solve it using the function `solveResistiveCircuit(circuit, groundNode, sourceNode, sourceVoltage)`.\r\nWe want to set the source node (node 0) at 1V and ground node (node 1) at 0V. We can represent this circuit as the following circuit object:\r\n\r\n```\r\n[\r\n    [\r\n        {\r\n            to: 2,\r\n            resistance: 1\r\n        },\r\n        {\r\n            to: 3,\r\n            resistance: 1\r\n        },\r\n        {\r\n            to: 4,\r\n            resistance: 1\r\n        }\r\n    ],\r\n    [\r\n        {\r\n            to: 2,\r\n            resistance: 1\r\n        },\r\n        {\r\n            to: 3,\r\n            resistance: 1\r\n        },\r\n        {\r\n            to: 4,\r\n            resistance: 1\r\n        }\r\n    ],\r\n    [\r\n        {\r\n            to: 0,\r\n            resistance: 1\r\n        },\r\n        {\r\n            to: 1,\r\n            resistance: 1\r\n        }\r\n    ],\r\n    [\r\n        {\r\n            to: 0,\r\n            resistance: 1\r\n        },\r\n        {\r\n            to: 1,\r\n            resistance: 1\r\n        }\r\n    ],\r\n    [\r\n        {\r\n            to: 0,\r\n            resistance: 1\r\n        },\r\n        {\r\n            to: 1,\r\n            resistance: 1\r\n        }\r\n    ]\r\n]\r\n```\r\n\r\nWe get in return the following result, which is an array of objects specifying the *i-th* node's voltage and current flowing to each connected node:\r\n\r\n```\r\n[\r\n    {\r\n        voltage: 1,\r\n        connections: [\r\n            {\r\n                to: 2,\r\n                current: 0.5\r\n            },\r\n            {\r\n                to: 3,\r\n                current: 0.5\r\n            },\r\n            {\r\n                to: 4,\r\n                current: 0.5\r\n            }\r\n        ]\r\n    },\r\n    {\r\n        voltage: 0,\r\n        connections: [\r\n            {\r\n                to: 2,\r\n                current: -0.5\r\n            },\r\n            {\r\n                to: 3,\r\n                current: -0.5\r\n            },\r\n            {\r\n                to: 4,\r\n                current: -0.5\r\n            }\r\n        ]\r\n    },\r\n    {\r\n        voltage: 0.5,\r\n        connections: [\r\n            {\r\n                to: 0,\r\n                current: -0.5\r\n            },\r\n            {\r\n                to: 1,\r\n                current: 0.5\r\n            }\r\n        ]\r\n    },\r\n    {\r\n        voltage: 0.5,\r\n        connections: [\r\n            {\r\n                to: 0,\r\n                current: -0.5\r\n            },\r\n            {\r\n                to: 1,\r\n                current: 0.5\r\n            }\r\n        ]\r\n    },\r\n    {\r\n        voltage: 0.5,\r\n        connections: [\r\n            {\r\n                to: 0,\r\n                current: -0.5\r\n            },\r\n            {\r\n                to: 1,\r\n                current: 0.5\r\n            }\r\n        ]\r\n    }\r\n]\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilamaj%2Fjs-circuit-solver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femilamaj%2Fjs-circuit-solver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femilamaj%2Fjs-circuit-solver/lists"}