UNPKG

rambdax

Version:

Extended version of Rambda - a lightweight, faster alternative to Ramda

17 lines (12 loc) 405 B
import { cloneList } from './_internals/cloneList.js' import { curry } from './curry.js' function adjustFn( index, replaceFn, list ){ const actualIndex = index < 0 ? list.length + index : index if (index >= list.length || actualIndex < 0) return list const clone = cloneList(list) clone[ actualIndex ] = replaceFn(clone[ actualIndex ]) return clone } export const adjust = curry(adjustFn)