From 383d2b5874d98416a30d3ca957ebae88c214cd86 Mon Sep 17 00:00:00 2001 From: William Candillon Date: Fri, 13 Mar 2020 16:21:39 +0100 Subject: [PATCH] fix mock: support math functions with arity greater than 1 (#640) --- mock.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mock.js b/mock.js index 67c81820471..3e4a3b364fa 100644 --- a/mock.js +++ b/mock.js @@ -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))),