mirror of
https://github.com/chanzuckerberg/cellxgene.git
synced 2026-10-02 04:58:11 +08:00
934cc5c69b
* Added TS. Updated build and linting config. Added types. * [ts-migrate][.] Rename files from JS/JSX to TS/TSX Co-authored-by: ts-migrate <> * [ts-migrate][.] Run TS Migrate Co-authored-by: ts-migrate <> * Corrected files mangled by ts-migrate. * Updated lint config, minor linting. * Re-enabled Husky. * Updated tests and config. * Reverted webpack devtool config. * Removed obsolete snapshots. * Added annotations snap. * Updated tsconfig includes wrt linting. * Removed ts-migrate. Co-authored-by: Timmy Huang <tihuan@users.noreply.github.com>
14 lines
450 B
TypeScript
14 lines
450 B
TypeScript
/**
|
|
* The function will ensure a number is above or below given thresholds
|
|
* @param val - a number
|
|
* @param rng - an array of two numbers, a min and a max
|
|
* Ie., in the case of a histogram brush selection:
|
|
* const x0 = x(clamp(selectionRange[0], [min, max]));
|
|
* const x1 = x(clamp(selectionRange[1], [min, max]));
|
|
* @returns a number
|
|
*/
|
|
|
|
export default function clamp(val: any, rng: any) {
|
|
return Math.max(Math.min(val, rng[1]), rng[0]);
|
|
}
|