Skip to content

Commit 06b2add

Browse files
committed
fix #183: Default function parameters are ECMAScript 2015
1 parent 1495360 commit 06b2add

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/newton.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ export function solve(f, y, x) {
1717

1818
// Approximate Newton-Raphson in 2D
1919
// Solve f(a,b) = [x,y]
20-
export function solve2d(f, MAX_ITERATIONS = 40, eps = epsilon2) {
21-
return function(x, y, a = 0, b = 0) {
20+
export function solve2d(f, MAX_ITERATIONS, eps) {
21+
if (MAX_ITERATIONS === undefined) MAX_ITERATIONS = 40;
22+
if (eps === undefined) eps = epsilon2;
23+
return function(x, y, a, b) {
2224
var err2, da, db;
25+
a = a === undefined ? 0 : +a;
26+
b = b === undefined ? 0 : +b;
2327
for (var i = 0; i < MAX_ITERATIONS; i++) {
2428
var p = f(a, b),
2529
// diffs

0 commit comments

Comments
 (0)