Enable Flow for bezier

Reviewed By: sahrens

Differential Revision: D8346102

fbshipit-source-id: bb1a2eccb5472bf6f3fe113303ad96cf3f386cab
This commit is contained in:
Eli White 2018-06-10 15:09:41 -07:00 committed by Facebook Github Bot
parent f50ce0850d
commit 6b1bb01804
2 changed files with 10 additions and 6 deletions

View File

@ -3,8 +3,8 @@
* https://github.com/gre/bezier-easing
*
* @copyright 2014-2015 Gaetan Renaudeau. MIT License.
* @noflow
* @emails oncall+react_native
* @flow
* @format
*/
@ -39,7 +39,7 @@ function allEquals(be1, be2, samples, assertion) {
function repeat(n) {
return function(f) {
for (let i = 0; i < n; ++i) {
f(i);
f();
}
};
}

View File

@ -2,9 +2,9 @@
* BezierEasing - use bezier curve for transition easing function
* https://github.com/gre/bezier-easing
*
* @flow
* @format
* @copyright 2014-2015 Gaëtan Renaudeau. MIT License.
* @noflow
*/
'use strict';
@ -71,9 +71,13 @@ function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
return aGuessT;
}
module.exports = function bezier(mX1, mY1, mX2, mY2) {
module.exports = function bezier(
mX1: number,
mY1: number,
mX2: number,
mY2: number,
) {
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) {
// eslint-disable-line yoda
throw new Error('bezier x values must be in [0, 1] range');
}
@ -123,7 +127,7 @@ module.exports = function bezier(mX1, mY1, mX2, mY2) {
}
}
return function BezierEasing(x) {
return function BezierEasing(x: number): number {
if (mX1 === mY1 && mX2 === mY2) {
return x; // linear
}