@extra-array/has-suffix
Version:
Checks if array ends with a suffix.
65 lines (49 loc) • 2.29 kB
Markdown
Checks if array ends with a suffix.
[:package:](https://www.npmjs.com/package/@extra-array/has-suffix)
[:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array)
[:running:](https://npm.runkit.com/@extra-array/has-suffix)
[:vhs:](https://asciinema.org/a/343743)
[:moon:](https://www.npmjs.com/package/@extra-array/has-suffix.min)
[:scroll:](https://unpkg.com/@extra-array/has-suffix/)
[:newspaper:](https://nodef.github.io/extra-array/)
[:blue_book:](https://github.com/nodef/extra-array/wiki/)
> Similar: [suffix], [suffixes], [hasSuffix].<br>
> Similar: [hasValue], [hasPrefix], [hasInfix], [hasSuffix], [hasSubsequence], [hasPermutation], [hasPath].
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
<br>
```javascript
array.hasSuffix(x, y, [fc], [fm]);
// x: an array
// y: suffix?
// fc: compare function (a, b)
// fm: map function (v, i, x)
```
```javascript
const array = require("extra-array");
var x = [1, 2, 3, 4];
array.hasSuffix(x, [3, 4]);
// true
array.hasSuffix(x, [-3, -4]);
// false
array.hasSuffix(x, [-3, -4], (a, b) => Math.abs(a) - Math.abs(b));
// true
array.hasSuffix(x, [-3, -4], null, v => Math.abs(v));
// true
```
<br>
<br>
## References
- [Data.List.isSuffixOf: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:isSuffixOf)
- [List-Extra.isSuffixOf: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#isSuffixOf)
- [String.prototype.endsWith: MDN web docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith)
- [ends-with: @jonschlinkert](https://www.npmjs.com/package/ends-with)
[suffix]: https://github.com/nodef/extra-array/wiki/suffix
[suffixes]: https://github.com/nodef/extra-array/wiki/suffixes
[hasSuffix]: https://github.com/nodef/extra-array/wiki/hasSuffix
[hasValue]: https://github.com/nodef/extra-array/wiki/hasValue
[hasPrefix]: https://github.com/nodef/extra-array/wiki/hasPrefix
[hasInfix]: https://github.com/nodef/extra-array/wiki/hasInfix
[hasSubsequence]: https://github.com/nodef/extra-array/wiki/hasSubsequence
[hasPermutation]: https://github.com/nodef/extra-array/wiki/hasPermutation
[hasPath]: https://github.com/nodef/extra-array/wiki/hasPath