UNPKG

@extra-array/is-permutation

Version:

Checks if array has a permutation.

15 lines 466 B
import isSubsequence from './isSubsequence'; /** * Checks if array has a permutation. * @param x an array * @param y permutation? * @param fc map function (v, i, x) * @param fm compare function (a, b) */ function isPermutation(x, y, fc = null, fm = null) { var x1 = fm ? x.map(fm) : x.slice(); var y1 = fm ? y.map(fm) : y.slice(); return isSubsequence(x1.sort(), y1.sort(), fc, fm); } export default isPermutation; //# sourceMappingURL=index.js.map