rambdax
Version:
Extended version of Rambda - a lightweight, faster alternative to Ramda
16 lines (11 loc) • 345 B
JavaScript
import { curry } from './curry'
function adjustFn(
index, replaceFn, list
){
const actualIndex = index < 0 ? list.length + index : index
if (index >= list.length || actualIndex < 0) return list
const clone = list.slice()
clone[ actualIndex ] = replaceFn(clone[ actualIndex ])
return clone
}
export const adjust = curry(adjustFn)