Skip to content

Commit

Permalink
fix mock: support math functions with arity greater than 1 (#640)
Browse files Browse the repository at this point in the history
  • Loading branch information
wcandillon committed Mar 13, 2020
1 parent 9f5f224 commit 383d2b5
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions mock.js
Expand Up @@ -91,11 +91,17 @@ const Reanimated = {
IDENTITY: 'identity',
},

add: (a, b) => new AnimatedValue(getValue(a) + getValue(b)),
sub: (a, b) => new AnimatedValue(getValue(a) - getValue(b)),
multiply: (a, b) => new AnimatedValue(getValue(a) * getValue(b)),
divide: (a, b) => new AnimatedValue(getValue(a) / getValue(b)),
pow: (a, b) => new AnimatedValue(getValue(a) ** getValue(b)),

add: (...vals) =>
new AnimatedValue(vals.map(v => getValue(v)).reduce((acc, v) => acc + v)),
sub: (...vals) =>
new AnimatedValue(vals.map(v => getValue(v)).reduce((acc, v) => acc - v)),
divide: (...vals) =>
new AnimatedValue(vals.map(v => getValue(v)).reduce((acc, v) => acc / v)),
multiply: (...vals) =>
new AnimatedValue(vals.map(v => getValue(v)).reduce((acc, v) => acc * v)),
pow: (...vals) =>
new AnimatedValue(vals.map(v => getValue(v)).reduce((acc, v) => acc ** v)),
modulo: (a, b) => new AnimatedValue(getValue(a) % getValue(b)),
sqrt: a => new AnimatedValue(Math.sqrt(getValue(a))),
log: a => new AnimatedValue(Math.log(getValue(a))),
Expand Down

0 comments on commit 383d2b5

Please sign in to comment.