UNPKG

@extra-array/is-permutation

Version:

Checks if array has a permutation.

11 lines (6 loc) 283 B
const array = require('extra-array'); var x = [1, 2, 3, 4]; array.isPermutation(x, [4, 3, 2, 1]); array.isPermutation(x, [3, -1, -2, 4]); array.isPermutation(x, [3, -1, -2, 4], (a, b) => Math.abs(a) - Math.abs(b)); array.isPermutation(x, [3, -1, -2, 4], null, v => Math.abs(v));