Skip to content

hasSuffix

Subhajit Sahu edited this page Feb 3, 2021 · 11 revisions

Checks if iterable ends with a suffix. 🏃 📼 📦 🌔 📒

Alternatives: hasValue, hasPrefix, hasInfix, hasSuffix, hasSubsequence, hasPath.

iterable.hasSuffix(x, y, fc, [fm]);
// x:  an iterable
// y:  suffix?
// fc: compare function (a, b)
// fm: map function (v, i, x)
const iterable = require("extra-iterable");

var x = [1, 2, 3, 4];
iterable.hasSuffix(x, [3, 4]);
// true

iterable.hasSuffix(x, [-3, -4]);
// false

iterable.hasSuffix(x, [-3, -4], (a, b) => Math.abs(a) - Math.abs(b));
// true

iterable.hasSuffix(x, [-3, -4], null, v => Math.abs(v));
// true

references

Clone this wiki locally