UNPKG

895 BJavaScriptView Raw
1var _curry2 =
2/*#__PURE__*/
3require("./internal/_curry2");
4
5var equals =
6/*#__PURE__*/
7require("./equals");
8
9var takeLast =
10/*#__PURE__*/
11require("./takeLast");
12/**
13 * Checks if a list ends with the provided sublist.
14 *
15 * Similarly, checks if a string ends with the provided substring.
16 *
17 * @func
18 * @memberOf R
19 * @since v0.24.0
20 * @category List
21 * @sig [a] -> [a] -> Boolean
22 * @sig String -> String -> Boolean
23 * @param {*} suffix
24 * @param {*} list
25 * @return {Boolean}
26 * @see R.startsWith
27 * @example
28 *
29 * R.endsWith('c', 'abc') //=> true
30 * R.endsWith('b', 'abc') //=> false
31 * R.endsWith(['c'], ['a', 'b', 'c']) //=> true
32 * R.endsWith(['b'], ['a', 'b', 'c']) //=> false
33 */
34
35
36var endsWith =
37/*#__PURE__*/
38_curry2(function (suffix, list) {
39 return equals(takeLast(suffix.length, list), suffix);
40});
41
42module.exports = endsWith;
\No newline at end of file