@ce1pers/use-array
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

@ce1pers/use-array

Collection of utility functions for Array.

Installation

npm

npm i @ce1pers/use-array

yarn

yarn add @ce1pers/use-array

Usage

import {
  getCombinations,
  getPermutations,
  getPermutationsWithSelf,
} from "@ce1pers/use-array";

const combinations = getCombinations([1, 2, 3], 2);
console.log("combinations", combinations);
// [ [ 1, 2 ], [ 1, 3 ], [ 2, 3 ] ]

const permutations = getPermutations([1, 2, 3], 2);
console.log("permutations", permutations);
// [ [ 1, 2 ], [ 1, 3 ], [ 2, 1 ], [ 2, 3 ], [ 3, 1 ], [ 3, 2 ] ]

const permutationsWithSelf = getPermutationsWithSelf([1, 2, 3], 2);
console.log("permutationsWithSelf", permutationsWithSelf);
// [ [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 2, 1 ], [ 2, 2 ], [ 2, 3 ], [ 3, 1 ], [ 3, 2 ], [ 3, 3 ] ]

Package Sidebar

Install

npm i @ce1pers/use-array

Weekly Downloads

1

Version

1.0.1

License

MIT

Unpacked Size

15.8 kB

Total Files

5

Last publish

Collaborators

  • __coma__