If you want the order of boundary values to not matter, clamp can be implemented in the following way: const clamp = (num, a, b) => Math.min(Math.max(num, Math.min(a, b)), Math.max(a, b))
@@syntaxfm a lot of projects use lodash and it maybe. dependancy already and you can now cherrypick lodash functions. var clamp = require('lodash.clamp');
If you want the order of boundary values to not matter, clamp can be implemented in the following way:
const clamp = (num, a, b) => Math.min(Math.max(num, Math.min(a, b)), Math.max(a, b))
Scott, have you tried svelte-trpc?
I've never used tRPC in general. Looks interesting though.
If you are using lodash in your project they already have a clamp function. console.log(_.clamp(2, 3, 5));
I'd argue that lodash isn't a dependency you need in 2022, at the very least, you shouldn't be loading the entire lodash library.
@@syntaxfm a lot of projects use lodash and it maybe. dependancy already and you can now cherrypick lodash functions. var clamp = require('lodash.clamp');