Start sharing components as a team!Share components as a team!Join Bit to build your applications faster.Get Started Free

adjust

v0.26.1arrow_drop_down
v0.26.1
STATUS
Passing
DOWNLOADS
85
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
SIZE
1 KB
Applies a function to the value at the given index of an array, returning a
1 contributor
Install adjust as a package?
Copied
npm i @bit/ramda.ramda.adjust
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
React
React
Vue
Angular
React Native
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
toggle layout
  "a",
  "b",
  "c",
  "d",
]);
modifieddraft
chevron_left
chevron_right
adjust (
idx:Number,
fn:Function,
list:(Array | Arguments)
) : Array

Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.

Example
R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']);      //=> ['a', 'B', 'c', 'd']
     R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']);     //=> ['a', 'b', 'c', 'D']
Arguments
idx: Number

The index.

fn: Function

The function to apply.

list: (Array | Arguments)

An array-like object whose value at the supplied index will be replaced.

Returns
Array

A copy of the supplied array-like object with the element at index `idx` replaced with the value returned by applying `fn` to the existing element.