New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

imaginejs

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

imaginejs

A Toy Complex Number Library in Javascript

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Imagine

⚡️ A Toy Complex Number Library in Javascript ⚡️

GitHub issues Travis npm Codacy Badge

Features

  • Complex Numbers!!!i!!!i!!!i!!!!
  • Addition, Subtraction
  • Multiplication, Division
  • Square Roots
  • Absolute Values
  • A lovely formatted toString() method

Usage

const 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))

Tests

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% LinesUncovered Lines
All files10094.44100100
index.js100100100100
signum.js10083.33100100
Test Suites: 2 passed, 2 total
Tests:       10 passed, 10 total
Snapshots:   0 total
Time:        1.362s
Ran all test suites matching "tests".

FAQs

Package last updated on 12 Mar 2017

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc