JSPM

extra-array

2.1.72
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1577
  • Score
    100M100P100Q102808F
  • License MIT

An array is a collection of values, stored contiguously.

Package Exports

  • extra-array

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 (extra-array) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

An array is a collection of values, stored contiguously. Methods that modify any argument end in $. All other methods are functional, and do not modify any parameters.

Stability: Experimental.
Unavilable array methods will be added here as its necessity is noticed.

const array = require('extra-array');

array.last([1, 2, 3]);
// 3

var a = [1, 2, 3, 4];
array.swap(a, 0, 1);
// [2, 1, 3, 4]

array.linspace(0, -1, 5);
// [0, -0.25, -0.5, -0.75, -1]

var a = [1, 2, 3, 4];
array.rotate(a, 1);
// [4, 1, 2, 3]

array.bsearchl([1, 3, 5, 7], 5);
// 2                  ^ found

[...array.permutations([1, 2, 3])];
// [
//   [ 1, 2, 3 ],
//   [ 2, 1, 3 ],
//   [ 1, 3, 2 ],
//   [ 3, 1, 2 ],
//   [ 2, 3, 1 ],
//   [ 3, 2, 1 ]
// ]

reference

Method Action
is Checks if value is array.
head Gets first value.
tail Gets values except first.
init Gets values except last.
last Gets last value.
get Gets value at index (+ve, -ve).
set Sets value at index (+ve, -ve).
set$ Sets value at index (+ve, -ve).
swap Exchanges two values.
swap$ Exchanges two values.
compare Compares two arrays.
isEqual Checks if two arrays are equal.
range Returns evenly spaced values within given interval.
linspace Returns evenly spaced values within given interval.
push Adds values to the end.
pop Removes last value.
shift Removes first value.
unshift Adds values to the start.
copy Copies part of array to another.
copy$ Copies part of array to another.
rotate Rotates values in array.
rotate$ Rotates values in array.
slice$ Keeps only the selected region.
filter$ Keeps the values which pass the test.
map$ Updates values based on map function.
concat$ Appends arrays to the end.
reverse Reverses the values.
chunk Splits array into chunks of given size.
zip Combines values from n arrays, with a function.
splice Removes or replaces existing values.
insert Inserts a value to an ordered array.
insert$ Inserts a value to an ordered array.
repeat Repeats an array gives times.
bsearch Binary searches value in sorted array.
bsearchc Binary searches closest value in sorted array.
bsearchl Binary searches leftmost value in sorted array.
bsearchr Binary searches rightmost value in sorted array.
sort Sorts based on compare function (optional).
prefixes Lists all possible prefixes.
infixes Lists all possible infixes.
suffixes Lists all possible suffixes.
subsequences Lists all possible partial sequences.
permutations Lists all possible arrangements.
isPrefix Checks if array starts with a prefix.
isInfix Checks if array contains an infix.
isSuffix Checks if array ends with a suffix.
isSubsequence Checks if array has a subsequence.
isPermutation Checks if array has a permutation.

nodef

Browserified, minified version of this package is extra-array.min.