🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

array-update-item

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array-update-item

Update an item of an array

0.1.2
latest
Source
npm
Version published
Weekly downloads
4
100%
Maintainers
1
Weekly downloads
 
Created
Source

update an item of an array

XO code style

Just a simple function to update an item of an Array. Works well in both, the browser & node.

install

npm i -S array-update-item

and use it

import updateItemInArray from 'array-update-item'
// OR
const updateItemInArray = require('array-update-item')

const abcde = updateItemInArray(['a', 'b', 'b', 'd'], 'c', 2)
console.log(abcde) // ['a', 'b', 'c', 'd']

behavior

  • updateItemInArray is a pure function, it does not mutate the provided array.
  • the item is not updated if:
    • the index is out of the range of the array (grater than arr.length or less than 0)
    • the index is not a number or is a float number.

FAQ

Keywords

array

FAQs

Package last updated on 07 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts