https://github.com/writetome51/array-remove-between
Function removes chunk of adjacent items from the middle of the array
https://github.com/writetome51/array-remove-between
array-manipulations javascript middle remove typescript
Last synced: about 2 months ago
JSON representation
Function removes chunk of adjacent items from the middle of the array
- Host: GitHub
- URL: https://github.com/writetome51/array-remove-between
- Owner: writetome51
- License: mit
- Created: 2018-12-07T00:26:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-02-28T23:59:09.000Z (over 7 years ago)
- Last Synced: 2025-07-05T18:47:25.032Z (11 months ago)
- Topics: array-manipulations, javascript, middle, remove, typescript
- Language: TypeScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# removeBetween(
numItemsToKeepAtEachEnd,
array
): void
Removes everything in `array` between `numItemsToKeepAtEachEnd`.
## Example
```
let arr = [1,2,3,4,5,6,7,8,9,10];
removeBetween(3, arr); // Keeps first 3 items and last 3 items.
// arr is now [1, 2, 3, 8, 9, 10]
let arr = ['t', 'h', 20, 100, true, false];
removeBetween(1, arr); // Keeps first item and last item.
// arr is now ['t', false]
```
## Installation
`npm i @writetome51/array-remove-between`
## Loading
```
// if using TypeScript:
import {removeBetween} from '@writetome51/array-remove-between';
// if using ES5 JavaScript:
var removeBetween = require('@writetome51/array-remove-between').removeBetween;
```