replace-array
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

replace-array

Utility to replace items in arrays at specified index

NPM

Install

yarn add replace-array

Usage

replaceAtIndex

import { replaceAtIndex } from 'replace-array';
 
const replaced = replaceAtIndex([1, 2, 3], 1, 5); // -> [1, 5, 3]
 
const replacedFn = replaceAtIndex([1, 2, 3], 1, value => value * 3); // -> [1, 6, 3]
 
const replacedPadded = replaceAtIndex([1, 2], 3, 10, 0); // -> [1, 2, 0, 10]

removeAtIndex

import { removeAtIndex } from 'replace-array';
 
const removed = removeAtIndex([1, 2, 3], 1); // -> [1, 3]

License

MIT © felamaslen

Package Sidebar

Install

npm i replace-array

Weekly Downloads

2

Version

0.2.0

License

MIT

Unpacked Size

5.2 kB

Total Files

9

Last publish

Collaborators

  • felamaslen