https://github.com/writetome51/array-get-and-remove-head-tail
These functions remove and return items from the beginning and end of the array, respectively
https://github.com/writetome51/array-get-and-remove-head-tail
array-manipulation elements javascript remove typescript
Last synced: 11 months ago
JSON representation
These functions remove and return items from the beginning and end of the array, respectively
- Host: GitHub
- URL: https://github.com/writetome51/array-get-and-remove-head-tail
- Owner: writetome51
- License: mit
- Created: 2018-10-13T00:45:04.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2021-05-02T21:06:18.000Z (over 4 years ago)
- Last Synced: 2025-02-18T08:07:34.705Z (11 months ago)
- Topics: array-manipulation, elements, javascript, remove, typescript
- Language: JavaScript
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# getAndRemoveHead\(
numItems,
array: T[]
): T[]
Removes and returns `numItems` from beginning of `array`.
# getAndRemoveTail\(
numItems,
array: T[]
): T[]
Removes and returns `numItems` from end of `array`.
## Examples
```
let arr = ['jim', 'todd', 'tony', 'barry', 'jill'];
let firstTwo = getAndRemoveHead(2, arr);
// firstTwo is ['jim', 'todd'] .
// arr is now ['tony', 'barry', 'jill'] .
let arr = ['jim', 'todd', 'tony', 'barry', 'jill'];
let lastThree = getAndRemoveTail(3, arr);
// lastThree is [ 'tony', 'barry', 'jill'] .
// arr is now ['jim', 'todd'] .
```
## Installation
`npm i @writetome51/array-get-and-remove-head-tail`
## Loading
```js
import {getAndRemoveHead, getAndRemoveTail}
from '@writetome51/array-get-and-remove-head-tail';
```