Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

complexjs

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

complexjs - npm Package Compare versions

Comparing version 1.1.0 to 2.1.0

.eslintignore

21

package.json
{
"name": "complexjs",
"version": "1.1.0",
"version": "2.1.0",
"description": "This is a library for complex numbers calculations in javascript using plain objects immutably",
"main": "./src/complex.js",
"main": "dist/complex-es5.js",
"babel": {

@@ -13,6 +13,12 @@ "presets": [

"scripts": {
"pretest": "eslint .",
"test": "mocha --compilers js:babel-core/register --require ./test/test_helper.js 'test/**/*.@(js|jsx)'",
"test:watch": "npm run test -- --watch"
"test:watch": "npm run test -- --watch",
"build": "babel src/complex.js > dist/complex-es5.js"
},
"keywords": ["complex numbers", "geometry", "maths"],
"keywords": [
"complex numbers",
"geometry",
"maths"
],
"author": "Gerard Moreno-Torres Bertran",

@@ -30,2 +36,3 @@ "license": "ISC",

"mocha": "^2.3.4",
"pre-commit": "^1.1.2",
"webpack": "^1.12.12",

@@ -38,3 +45,7 @@ "webpack-dev-server": "^1.14.1"

"url": "https://github.com/germtb/complexjs"
}
},
"pre-commit": [
"test",
"build"
]
}

@@ -14,3 +14,3 @@ # complexjs

| `csum(c0 : complex, c1: complex)` | Returns `c0` plus `c1` |
| `csub(c0 : complex, c1: complex)` | Returns the c0 minus `c1` |
| `csub(c0 : complex, c1: complex)` | Returns the `c0` minus `c1` |
| `cmul(c0 : complex, c1: complex)` | Returns `c0` times `c1` |

@@ -59,2 +59,3 @@ | `cdiv(c0 : complex, c1: complex)` | Returns `c0` over `c1` |

```javascript
import {csum} from 'complexjs';
csum(c_cartesian, c_polar); // => {re: 1, im: 1}

@@ -67,2 +68,9 @@ csum(c_polar, c_cartesian); // => {r: 1.414, arg: 0.785}

```javascript
import {
cmul,
cdiv,
cmod,
conjugate
} from 'complexjs';
cmul(c_cartesian, c_polar); // => {re: 0, im: 1}

@@ -69,0 +77,0 @@ cdiv(c_cartesian, c_polar); // => {re: 0, im: -1}

export function isCartesian(c) {
return ('re' in c || 'im' in c);
return 're' in c || 'im' in c;
}
export function isPolar(c) {
return ('r' in c && 'arg' in c);
return 'r' in c && 'arg' in c;
}

@@ -43,3 +43,3 @@

im: im(c1) + im(c2)
}
};
}

@@ -51,3 +51,3 @@

...toPolar({re: re(c1) + re(c2), im: im(c1) + im(c2)})
}
};
}

@@ -64,3 +64,3 @@

im: im(c1) - im(c2)
}
};
}

@@ -74,3 +74,3 @@

im: im(c1) - im(c2)})
}
};
}

@@ -87,3 +87,3 @@

im: re(c1) * im(c2) + re(c2) * im(c1)
}
};
}

@@ -96,3 +96,3 @@

arg: normalize(c1.arg + c2.arg)
}
};
}

@@ -111,3 +111,3 @@

im: mul.im / mod2
}
};
}

@@ -120,3 +120,3 @@

arg: normalize(c1.arg - c2.arg)
}
};
}

@@ -248,3 +248,3 @@

im: -im(c)
}
};
}

@@ -257,3 +257,3 @@

arg: -c.arg
}
};
}

@@ -272,1 +272,28 @@

}
export function translate(c, translation) {
return csum(c, translation);
}
export function scale(c, factor, pivot = undefined) {
return pivot ?
csum(cmul(csub(c, pivot), {re: factor}), pivot) :
cmul(c, {re: factor});
}
export function rotate(c, delta, pivot = undefined) {
return pivot ?
csum(cmul(csub(c, pivot), {r: 1, arg: delta }), pivot) :
cmul(c, {r: 1, arg: delta });
}
export function distance(c1, c2) {
return cmod(csub(c1, c2));
}
export function vector(x, y) {
return {
re: x,
im: y
};
}

@@ -7,5 +7,3 @@ import {expect} from 'chai';

scale,
distance
} from '../src/geometry';
import {
distance,
csum,

@@ -12,0 +10,0 @@ cmul,

@@ -8,3 +8,3 @@ import {expect} from 'chai';

distance
} from '../src/geometry';
} from '../src/complex';

@@ -11,0 +11,0 @@ describe('cartesian form', () => {

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