{"id":26552101,"url":"https://github.com/iamsquare/complex.js","last_synced_at":"2026-04-08T16:32:16.650Z","repository":{"id":40952968,"uuid":"146816064","full_name":"iamsquare/complex.js","owner":"iamsquare","description":"A simple complex numbers library written in Typescript.","archived":false,"fork":false,"pushed_at":"2025-11-11T03:13:05.000Z","size":1013,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-11-23T07:29:52.150Z","etag":null,"topics":["complex-numbers","javascript","library","math","node","typescript"],"latest_commit_sha":null,"homepage":"https://complex-js.iamsquare.it/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamsquare.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}},"created_at":"2018-08-30T23:10:01.000Z","updated_at":"2025-11-09T13:42:39.000Z","dependencies_parsed_at":"2023-02-06T11:16:36.289Z","dependency_job_id":null,"html_url":"https://github.com/iamsquare/complex.js","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/iamsquare/complex.js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamsquare%2Fcomplex.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamsquare%2Fcomplex.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamsquare%2Fcomplex.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamsquare%2Fcomplex.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamsquare","download_url":"https://codeload.github.com/iamsquare/complex.js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamsquare%2Fcomplex.js/sbom","scorecard":{"id":478048,"data":{"date":"2025-08-11","repo":{"name":"github.com/iamsquare/complex.js","commit":"345f59ed9f0d17d2075aa0c98bde1e3ee20631f7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.5,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/18 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v1.0.4 not signed: https://api.github.com/repos/iamsquare/complex.js/releases/44008677","Warn: release artifact v1.0.3 not signed: https://api.github.com/repos/iamsquare/complex.js/releases/17928114","Warn: release artifact v1.0.2 not signed: https://api.github.com/repos/iamsquare/complex.js/releases/15599327","Warn: release artifact v1.0.1 not signed: https://api.github.com/repos/iamsquare/complex.js/releases/15571231","Warn: release artifact v1.0.0 not signed: https://api.github.com/repos/iamsquare/complex.js/releases/15466115","Warn: release artifact v1.0.4 does not have provenance: https://api.github.com/repos/iamsquare/complex.js/releases/44008677","Warn: release artifact v1.0.3 does not have provenance: https://api.github.com/repos/iamsquare/complex.js/releases/17928114","Warn: release artifact v1.0.2 does not have provenance: https://api.github.com/repos/iamsquare/complex.js/releases/15599327","Warn: release artifact v1.0.1 does not have provenance: https://api.github.com/repos/iamsquare/complex.js/releases/15571231","Warn: release artifact v1.0.0 does not have provenance: https://api.github.com/repos/iamsquare/complex.js/releases/15466115"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 13 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"17 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-76c9-3jph-rj3q","Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7","Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-19T15:50:40.389Z","repository_id":40952968,"created_at":"2025-08-19T15:50:40.390Z","updated_at":"2025-08-19T15:50:40.390Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31564899,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["complex-numbers","javascript","library","math","node","typescript"],"created_at":"2025-03-22T08:23:46.863Z","updated_at":"2026-04-08T16:32:16.636Z","avatar_url":"https://github.com/iamsquare.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Logo](https://raw.githubusercontent.com/iamsquare/complex.js/master/logo.png)\n\n# [ℂomplex.js](https://complex-js.iamsquare.it)\n\n[![NPM](https://img.shields.io/npm/v/@iamsquare/complex.js.svg?style=flat-square)](https://www.npmjs.com/package/@iamsquare/complex.js)\n[![GitHub issues](https://img.shields.io/github/issues-raw/iamsquare/complex.js.svg?style=flat-square)](https://github.com/iamsquare/complex.js/issues)\n[![GitHub License](https://img.shields.io/github/license/mashape/apistatus.svg?style=flat-square)](https://github.com/iamsquare/complex.js/blob/master/LICENSE)\n[![NPM](https://nodei.co/npm/@iamsquare/complex.js.png?mini=true)](https://nodei.co/npm/@iamsquare/complex.js)\n\n\u003e A powerful, type-safe complex numbers library for JavaScript and TypeScript. Works seamlessly in browsers and Node.js.\n\n**Complex.js** provides a comprehensive set of operations and functions for complex number arithmetic, trigonometry, hyperbolic functions, and more. Built with TypeScript, it includes full type definitions out of the box.\n\n## Features\n\n- **Complete Complex Number Operations** - Addition, subtraction, multiplication, division, and more\n- **Trigonometric Functions** - sin, cos, tan, sec, csc, cot and their inverses\n- **Hyperbolic Functions** - sinh, cosh, tanh, sech, csch, coth and their inverses\n- **Mathematical Functions** - Exponentiation, logarithms, powers, square roots, principal values (n-th roots)\n- **Numerically Stable** - Uses robust floating-point comparisons (combining absolute and relative error) and stable algorithms to handle precision errors\n- **TypeScript Support** - Full type definitions included, no `@types` package needed\n- **Universal** - Works in both browsers and Node.js\n- **Zero Dependencies** - Lightweight and fast\n- **Multiple Representations** - Create from Cartesian, polar, or numeric coordinates\n\n## Installation\n\nInstall Complex.js using [npm](https://www.npmjs.com/package/@iamsquare/complex.js) or [pnpm](https://pnpm.io/):\n\n```bash\nnpm i @iamsquare/complex.js\n# or\npnpm i @iamsquare/complex.js\n```\n\n## Quick Start\n\n```typescript\nimport { Complex, add, sum, multiply, sin, exp } from '@iamsquare/complex.js';\n\n// Create complex numbers\nconst z = new Complex(1, -1);\nconst w = new Complex({ x: 1, y: -3 });\nconst k = new Complex({ r: 1, p: Math.PI / 2 });\n\n// Perform operations\nconst addition = add(z, w);\nconst total = sum(z, w, k);\nconst product = multiply(z, w);\nconst sine = sin(z);\nconst exponential = exp(z);\n\nconsole.log(addition.toString()); // =\u003e \"2 - 4i\"\n```\n\n## Usage\n\n### Creating Complex Numbers\n\nComplex numbers can be created in several ways:\n\n```typescript\n// Numeric arguments (real, imaginary)\nconst z = new Complex(1, -1);\n\n// Cartesian coordinates\nconst w = new Complex({ x: 1, y: -3 });\n\n// Polar coordinates (radius, phase in radians)\nconst k = new Complex({ r: 1, p: Math.PI / 2 });\n\n// From another Complex number\nconst zz = new Complex(z);\n```\n\n### Accessing Parts\n\n```typescript\nconst z = new Complex(3, 4);\n\n// Get real and imaginary parts\nconst realPart = z.getRe(); // 3\nconst imagPart = z.getIm(); // 4\n\n// Convert to different representations\nconst cartesian = z.toCartesian(); // { x: 3, y: 4 }\nconst polar = z.toPolar(); // { r: 5, p: 0.9272952180016122 }\n```\n\n### Basic Arithmetic Operations\n\n```typescript\nimport { Complex, add, sum, subtract, multiply, divide, negate } from '@iamsquare/complex.js';\n\nconst z = new Complex(1, -1);\nconst w = new Complex(1, -3);\n\n// Addition\nconst addition = add(z, w);\nconsole.log(addition.toString()); // =\u003e \"2 - 4i\"\n\n// Sum multiple numbers\nconst z1 = new Complex(1, 2);\nconst z2 = new Complex(3, 4);\nconst z3 = new Complex(5, 6);\nconst total = sum(z1, z2, z3);\nconsole.log(total.toString()); // =\u003e \"9 + 12i\"\n\n// Subtraction\nconst diff = subtract(z, w);\nconsole.log(diff.toString()); // =\u003e \"0 + 2i\"\n\n// Multiplication\nconst product = multiply(z, w);\nconsole.log(product.toString()); // =\u003e \"-2 - 4i\"\n\n// Division\nconst quotient = divide(z, w);\nconsole.log(quotient.toString()); // =\u003e \"0.4 + 0.2i\"\n\n// Negation\nconst negated = negate(z);\nconsole.log(negated.toString()); // =\u003e \"-1 + 1i\"\n```\n\n### Mathematical Functions\n\n```typescript\nimport {\n  Complex,\n  exp,\n  log,\n  pow,\n  sqrt,\n  principal,\n  sin,\n  cos,\n  tan,\n  sinh,\n  cosh,\n  tanh,\n  asin,\n  asinh,\n} from '@iamsquare/complex.js';\n\nconst z = new Complex(1, 1);\n\n// Exponential and logarithmic functions\nconst e = exp(z);\nconst ln = log(z);\nconst power = pow(z, new Complex(2, 0));\nconst root = sqrt(z);\nconst cubeRoot = principal(z, 3);\n\n// Trigonometric functions\nconst sine = sin(z);\nconst cosine = cos(z);\nconst tangent = tan(z);\n\n// Hyperbolic functions\nconst hypSine = sinh(z);\nconst hypCosine = cosh(z);\nconst hypTangent = tanh(z);\n\n// Inverse functions\nconst arcSine = asin(z);\nconst arcHyperSine = asinh(z);\n```\n\n### Utility Operations\n\n```typescript\nimport {\n  Complex,\n  modulus,\n  argument,\n  conjugate,\n  unit,\n  equals,\n  isApproximatelyEqual,\n  isReal,\n  isZero,\n} from '@iamsquare/complex.js';\n\nconst z = new Complex(3, 4);\n\n// Modulus (absolute value)\nconst mod = modulus(z); // 5\n\n// Argument (phase)\nconst arg = argument(z); // 0.9272952180016122\n\n// Complex conjugate\nconst conj = conjugate(z); // 3 - 4i\n\n// Unit vector\nconst unitVec = unit(z); // 0.6 + 0.8i\n\n// Equality checks (uses epsilon-based comparison for floating-point precision)\nconst isEqual = equals(z, new Complex(3, 4)); // true\nconst isRealNum = isReal(z); // false\nconst isZeroNum = isZero(z); // false\n\n// Compare floating-point numbers\nconst approxEqual = isApproximatelyEqual(0.1 + 0.2, 0.3); // true\n```\n\n### Predefined Constants\n\n```typescript\nComplex.ZERO; // 0\nComplex.ONE; // 1\nComplex.I; // i (imaginary unit)\nComplex.PI; // π\nComplex.HALFPI; // π/2\nComplex.E; // e (Euler's number)\nComplex.INFINITY; // ∞\nComplex.NAN; // NaN\nComplex.EPSILON; // Machine epsilon\n```\n\n## 📖 Documentation\n\nComprehensive documentation is available at **[https://complex-js.iamsquare.it](https://complex-js.iamsquare.it)**.\n\nThe documentation includes:\n\n- Complete API reference\n- Detailed examples\n- Mathematical background\n- Usage guides\n\n### Local Documentation Development\n\nThe documentation website is built using [Docusaurus](https://docusaurus.io/). To work with the documentation locally:\n\n```bash\ncd docusaurus\npnpm install\npnpm start\n```\n\nThis starts a local development server. Most changes are reflected live without restarting the server.\n\nTo build the documentation:\n\n```bash\ncd docusaurus\npnpm build\n```\n\n## Development\n\n### Building from Source\n\nClone the repository and build the library:\n\n```bash\ngit clone https://github.com/iamsquare/complex.js.git\ncd complex.js\npnpm install\npnpm run prod\n```\n\n`pnpm run prod` runs tests with coverage and builds the library only if all tests pass. To build without testing:\n\n```bash\npnpm run build\n```\n\n\u003e **Note**: This project uses [pnpm](https://pnpm.io/) as its package manager. The `preinstall` script will enforce this.\n\n### Available Scripts\n\n- `pnpm test` - Run tests\n- `pnpm test:watch` - Run tests in watch mode\n- `pnpm test:coverage` - Run tests with coverage\n- `pnpm build` - Build the library\n- `pnpm lint` - Run ESLint\n- `pnpm lint:fix` - Fix ESLint issues\n- `pnpm prod` - Clean, test with coverage, and build\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease read our [Contributing Guide](.github/CONTRIBUTING.md) for details on our development process and how to submit pull requests.\n\n## License\n\nThis project is licensed under the [MIT License](LICENSE).\n\n## Built With\n\n- [TypeScript](https://www.typescriptlang.org/) - Main language\n- [Vitest](https://vitest.dev/) - Testing framework\n- [Rollup](https://rollupjs.org/) - Module bundler\n- [Docusaurus](https://docusaurus.io/) - Documentation website framework\n- [pnpm](https://pnpm.io/) - Fast, disk space efficient package manager\n\n---\n\nMade with ❤️ by [iamsquare](https://iamsquare.it)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamsquare%2Fcomplex.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamsquare%2Fcomplex.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamsquare%2Fcomplex.js/lists"}