-
Notifications
You must be signed in to change notification settings - Fork 5
hasSuffix
Subhajit Sahu edited this page May 3, 2023
·
14 revisions
Examine if array ends with a suffix.
Similar: randomSuffix, suffixes, hasSuffix.
Similar: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPermutation, hasPath.
function hasSuffix(x, y, fc, fm)
// x: an array
// y: search suffix
// fc: compare function (a, b)
// fm: map function (v, i, x)
const xarray = require('extra-array');
var x = [1, 2, 3, 4];
xarray.hasSuffix(x, [3, 4]);
// → true
xarray.hasSuffix(x, [-3, -4]);
// → false
xarray.hasSuffix(x, [-3, -4], (a, b) => Math.abs(a) - Math.abs(b));
// → true
xarray.hasSuffix(x, [-3, -4], null, v => Math.abs(v));
// → true