
Security News
rv Is a New Rust-Powered Ruby Version Manager Inspired by Python's uv
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
⚡️ A Toy Complex Number Library in Javascript ⚡️
toString()
methodconst complex = require('imaginejs');
// Make a new Complex number, 4 + 2i
const num = complex(4, 2)
// Add another complex Number
const newNum = num.add(complex(6,3)) // returns 10 + 5i
// Test some Equality
newNum.equals(num) // False
// find the absolute value and print
console.log(newNum.abs().toString) // "10 + 5i"
// Do a random sum
complex.multiply(Complex(21, 4), Complex(76, 2)) // returns 1588 + 346i
All methods require a complex object to be used, and the library includes the following methods:
abs()
add(y)
subtract(y)
multiply(y)
divide(y)
sqrt()
toString
equals(x)
The methods can be used on the complex
object like Complex(3, 2).abs()
or as static methods, Complex.abs(Complex(3, 2))
Even though this is a toy library, its all tested! (Cause thats whats good)
Heres the results of the tests and the coverage:
PASS tests/signum.test.js
PASS tests/index.test.js
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Lines |
---|---|---|---|---|---|
All files | 100 | 94.44 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
signum.js | 100 | 83.33 | 100 | 100 |
Test Suites: 2 passed, 2 total
Tests: 10 passed, 10 total
Snapshots: 0 total
Time: 1.362s
Ran all test suites matching "tests".
FAQs
A Toy Complex Number Library in Javascript
The npm package imaginejs receives a total of 0 weekly downloads. As such, imaginejs popularity was classified as not popular.
We found that imaginejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.
Security News
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.