@writetome51/array-get-and-remove-head-tail
TypeScript icon, indicating that this package has built-in type declarations

3.0.0 • Public • Published

getAndRemoveHead<T>(
      numItems,
      array: T[]
): T[]

Removes and returns numItems from beginning of array.

getAndRemoveTail<T>(
      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

import {getAndRemoveHead, getAndRemoveTail} 
    from '@writetome51/array-get-and-remove-head-tail';

Package Sidebar

Install

npm i @writetome51/array-get-and-remove-head-tail

Weekly Downloads

1

Version

3.0.0

License

MIT

Unpacked Size

3.5 kB

Total Files

5

Last publish

Collaborators

  • writetome51