JSPM

@writetome51/array-append-prepend-many

0.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q43702F
  • License MIT

Functions appendMany(values, array) and prependMany(values, array), which are alternatives to Array.prototype.push(...values) and Array.prototype.unshift(...values)

Package Exports

  • @writetome51/array-append-prepend-many

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@writetome51/array-append-prepend-many) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

prependMany<T>(values: T[], array: T[]): void

Adds values to beginning of array. Alternative to array.unshift(...values)

appendMany<T>(values: T[], array: T[]): void

Adds values to end of array. Alternative to array.push(...values)

Examples

let arr = [1, 2, 3];  
prependMany([10, 11], arr); 
// arr === [10, 11, 1, 2, 3] 

arr = [1, 2, 3];
appendMany([10, 11], arr); 
// arr === [1, 2, 3, 10, 11]

arr = [ [1, 2, 3] ];
prependMany([ [10,11], [12,13] ], arr);
// arr === [ [10,11], [12,13], [1, 2, 3] ]

arr = [ [1, 2, 3] ];
appendMany([ [10,11], [12,13] ], arr);
// arr === [ [1, 2, 3], [10,11], [12,13] ]

Installation

npm i @writetome51/array-append-prepend-many

Loading

import {prependMany, appendMany} from '@writetome51/array-append-prepend-many';