Several functions with different scopes and small in nature
npm i @vyke/fns -D
Filter out an item from an array
const arr = [1, 2, 3, 4, 5]
const filtered = arr.filter(outItem(3))
console.log(filtered) // [1, 2, 4, 5]
Sorts an array of objects by a property.
const arr = [
{ name: 'John', age: 25 },
{ name: 'Jane', age: 22 },
{ name: 'Doe', age: 30 }
]
const sorted = arr.sort(compareBy('age'))
console.log(sorted)
// [
// { name: 'Jane', age: 22 },
// { name: 'John', age: 25 },
// { name: 'Doe', age: 30 }
// ]
Re-maps a number from one range to 0-1 and constrains the value.
const mapped = mapToUnit(50, 0, 100)
console.log(mapped) // 0.5
Re-maps a number from one range to another.
const mapped = map(50, 0, 100, 0, 200)
console.log(mapped) // 100
Constrains a value to not exceed a maximum and minimum value.
const constrained = constrain(150, 0, 100)
console.log(constrained) // 100
A function that does nothing.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.
Easing function that accelerates quickly and then slows down.
Easing function that decelerates quickly and then slows down.
Easing function that accelerates quickly, slows down, and then accelerates again.