@extra-array/is-permutation-on
v2.7.8
Published
Checks if array has a permutation.
Downloads
240
Maintainers
Readme
Checks if array has a permutation. :running: :vhs: :package: :moon:
Alternatives: compare, map. Similar: permutation, permutations, isPermutation. This is part of package extra-array.
array.isPermutationOn(x, y, [fn], [ths]);
// x: an array
// y: permutation?
// fn: map function (v, i, x)
// ths: this argument
const array = require('extra-array');
var x = [1, 2, 3, 4];
array.isPermutationOn(x, [4, 3, 2, 1]);
// true
array.isPermutationOn(x, [3, -1, -2, 4]);
// false
array.isPermutationOn(x, [3, -1, -2, 4], v => Math.abs(v));
// true