mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-07-10 04:00:10 +00:00
Merge pull request #33496 from adamzerella/types/mumath
[mumath] Update typing for mumath
This commit is contained in:
6
types/mumath/clamp.d.ts
vendored
Normal file
6
types/mumath/clamp.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Detects proper clamp min/max.
|
||||
*/
|
||||
declare function clamp(value: number, left: number, right: number): number;
|
||||
|
||||
export = clamp;
|
||||
6
types/mumath/closest.d.ts
vendored
Normal file
6
types/mumath/closest.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Get closest value out of a set.
|
||||
*/
|
||||
declare function closest(value: number, list: number[]): number;
|
||||
|
||||
export = closest;
|
||||
69
types/mumath/index.d.ts
vendored
69
types/mumath/index.d.ts
vendored
@@ -2,62 +2,17 @@
|
||||
// Project: https://github.com/dfcreative/mumath
|
||||
// Definitions by: Adam Zerella <https://github.com/adamzerella>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.3
|
||||
|
||||
/**
|
||||
* Detects proper clamp min/max.
|
||||
*/
|
||||
export function clamp(value: number, left: number, right: number): number;
|
||||
import clamp = require('./clamp');
|
||||
import closest = require('./closest');
|
||||
import isMultiple = require('./isMultiple');
|
||||
import len = require('./len');
|
||||
import lerp = require('./lerp');
|
||||
import mod = require('./mod');
|
||||
import order = require('./order');
|
||||
import precision = require('./precision');
|
||||
import round = require('./round');
|
||||
import scale = require('./scale');
|
||||
import within = require('./within');
|
||||
|
||||
/**
|
||||
* Get closest value out of a set.
|
||||
*/
|
||||
export function closest(value: number, list: number[]): number;
|
||||
|
||||
/**
|
||||
* Check if one number is multiple of other
|
||||
* Same as a % b === 0, but with precision check.
|
||||
*/
|
||||
export function isMultiple(a: number, b: number, eps?: number): boolean;
|
||||
|
||||
/**
|
||||
* Return quadratic length of a vector.
|
||||
*/
|
||||
export function len(a: number, b: number): number;
|
||||
|
||||
/**
|
||||
* Return value interpolated between x and y.
|
||||
*/
|
||||
export function lerp(x: number, y: number, ratio: number): number;
|
||||
|
||||
/**
|
||||
* An enhanced mod-loop, like fmod — loops value within a frame.
|
||||
*/
|
||||
export function mod(value: number, max: number, min?: number): number;
|
||||
|
||||
/**
|
||||
* Get order of magnitude for a number.
|
||||
*/
|
||||
export function order(value: number): number;
|
||||
|
||||
/**
|
||||
* Get precision from float:
|
||||
*/
|
||||
export function precision(value: number): number;
|
||||
|
||||
/**
|
||||
* Rounds value to optional step.
|
||||
*/
|
||||
export function round(value: number, step?: number): number;
|
||||
|
||||
/**
|
||||
* Get first scale out of a list of basic scales, aligned to the power. E. g.
|
||||
* step(.37, [1, 2, 5]) → .5 step(456, [1, 2]) → 1000
|
||||
* Similar to closest, but takes all possible powers of scales.
|
||||
*/
|
||||
export function scale(value: number, list: number[]): number;
|
||||
|
||||
/**
|
||||
* Whether element is between left & right, including.
|
||||
*/
|
||||
export function within(value: number, left: number, right: number): number;
|
||||
export { clamp, closest, isMultiple, len, lerp, mod, order, precision, round, scale, within };
|
||||
|
||||
7
types/mumath/isMultiple.d.ts
vendored
Normal file
7
types/mumath/isMultiple.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Check if one number is multiple of other
|
||||
* Same as a % b === 0, but with precision check.
|
||||
*/
|
||||
declare function isMultiple(a: number, b: number, eps?: number): boolean;
|
||||
|
||||
export = isMultiple;
|
||||
6
types/mumath/len.d.ts
vendored
Normal file
6
types/mumath/len.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Return quadratic length of a vector.
|
||||
*/
|
||||
declare function len(a: number, b: number): number;
|
||||
|
||||
export = len;
|
||||
6
types/mumath/lerp.d.ts
vendored
Normal file
6
types/mumath/lerp.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Return value interpolated between x and y.
|
||||
*/
|
||||
declare function lerp(x: number, y: number, ratio: number): number;
|
||||
|
||||
export = lerp;
|
||||
6
types/mumath/mod.d.ts
vendored
Normal file
6
types/mumath/mod.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* An enhanced mod-loop, like fmod — loops value within a frame.
|
||||
*/
|
||||
declare function mod(value: number, max: number, min?: number): number;
|
||||
|
||||
export = mod;
|
||||
@@ -1,25 +1,48 @@
|
||||
import * as mumath from "mumath";
|
||||
import mumath = require("mumath");
|
||||
|
||||
import mumathClamp = require("mumath/clamp");
|
||||
import mumathClosest = require("mumath/closest");
|
||||
import mumathIsMultiple = require("mumath/isMultiple");
|
||||
import mumathLen = require("mumath/len");
|
||||
import mumathLerp = require("mumath/lerp");
|
||||
import mumathMod = require("mumath/mod");
|
||||
import mumathOrder = require("mumath/order");
|
||||
import mumathPrecision = require("mumath/precision");
|
||||
import mumathRound = require("mumath/round");
|
||||
import mumathScale = require("mumath/scale");
|
||||
import mumathWithin = require("mumath/within");
|
||||
|
||||
mumath.clamp(1, 2, 3);
|
||||
mumathClamp(1, 2, 3);
|
||||
|
||||
mumath.closest(5, [1, 7, 3, 6, 10]);
|
||||
mumathClosest(5, [1, 7, 3, 6, 10]);
|
||||
|
||||
mumath.isMultiple(5, 10, 1.000074);
|
||||
mumath.isMultiple(5, 10);
|
||||
mumathIsMultiple(5, 10, 1.000074);
|
||||
|
||||
mumath.len(15, 1.0);
|
||||
mumathLen(15, 1.0);
|
||||
|
||||
mumath.lerp(1, 2, 3);
|
||||
mumathLerp(1, 2, 3);
|
||||
|
||||
mumath.mod(1, 2, 3);
|
||||
mumath.mod(1, 2);
|
||||
mumathMod(1, 2, 3);
|
||||
|
||||
mumath.order(5);
|
||||
mumathOrder(5);
|
||||
|
||||
mumath.precision(5.0000001);
|
||||
mumathPrecision(5.0000001);
|
||||
|
||||
mumath.round(0.3, 0.5);
|
||||
mumathRound(0.3, 0.5);
|
||||
|
||||
mumath.scale(5.93, [1.0, 35, 10, 7.135]);
|
||||
mumathScale(5.93, [1.0, 35, 10, 7.135]);
|
||||
|
||||
mumath.within(5, 1, 10);
|
||||
mumathWithin(5, 1, 10);
|
||||
|
||||
6
types/mumath/order.d.ts
vendored
Normal file
6
types/mumath/order.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Get order of magnitude for a number.
|
||||
*/
|
||||
declare function order(value: number): number;
|
||||
|
||||
export = order;
|
||||
6
types/mumath/precision.d.ts
vendored
Normal file
6
types/mumath/precision.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Get precision from float:
|
||||
*/
|
||||
declare function precision(value: number): number;
|
||||
|
||||
export = precision;
|
||||
6
types/mumath/round.d.ts
vendored
Normal file
6
types/mumath/round.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Rounds value to optional step.
|
||||
*/
|
||||
declare function round(value: number, step?: number): number;
|
||||
|
||||
export = round;
|
||||
8
types/mumath/scale.d.ts
vendored
Normal file
8
types/mumath/scale.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Get first scale out of a list of basic scales, aligned to the power. E. g.
|
||||
* step(.37, [1, 2, 5]) → .5 step(456, [1, 2]) → 1000
|
||||
* Similar to closest, but takes all possible powers of scales.
|
||||
*/
|
||||
declare function scale(value: number, list: number[]): number;
|
||||
|
||||
export = scale;
|
||||
@@ -20,6 +20,17 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"clamp.d.ts",
|
||||
"closest.d.ts",
|
||||
"isMultiple.d.ts",
|
||||
"len.d.ts",
|
||||
"lerp.d.ts",
|
||||
"mod.d.ts",
|
||||
"order.d.ts",
|
||||
"precision.d.ts",
|
||||
"round.d.ts",
|
||||
"scale.d.ts",
|
||||
"within.d.ts",
|
||||
"mumath-tests.ts"
|
||||
]
|
||||
}
|
||||
|
||||
6
types/mumath/within.d.ts
vendored
Normal file
6
types/mumath/within.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/**
|
||||
* Whether element is between left & right, including.
|
||||
*/
|
||||
declare function within(value: number, left: number, right: number): number;
|
||||
|
||||
export = within;
|
||||
Reference in New Issue
Block a user