@extra-array/is-suffix
Version:
Checks if array ends with a suffix.
53 lines (42 loc) • 2.04 kB
Markdown
Checks if array ends with a suffix. [:running:] [:vhs:] [:package:] [:moon:] [:ledger:]
> Similar: [suffix], [suffixes], [isSuffix].<br>
> Similar: [isValue], [isPrefix], [isInfix], [isSuffix], [isSubsequence], [isPermutation].<br>
> This is part of package [extra-array].
[extra-array]: https://www.npmjs.com/package/extra-array
```javascript
array.isSuffix(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.isSuffix(x, [3, 4]);
// true
array.isSuffix(x, [-3, -4]);
// false
array.isSuffix(x, [-3, -4], (a, b) => Math.abs(a) - Math.abs(b));
// true
array.isSuffix(x, [-3, -4], null, v => Math.abs(v));
// true
```
### 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)
[:running:]: https://npm.runkit.com/@extra-array/is-suffix
[:package:]: https://www.npmjs.com/package/@extra-array/is-suffix
[:moon:]: https://www.npmjs.com/package/@extra-array/is-suffix.min
[suffix]: https://github.com/nodef/extra-array/wiki/suffix
[suffixes]: https://github.com/nodef/extra-array/wiki/suffixes
[isSuffix]: https://github.com/nodef/extra-array/wiki/isSuffix
[:ledger:]: https://unpkg.com/@extra-array/is-suffix/
[:vhs:]: https://asciinema.org/a/332083
[isValue]: https://github.com/nodef/extra-array/wiki/isValue
[isPrefix]: https://github.com/nodef/extra-array/wiki/isPrefix
[isInfix]: https://github.com/nodef/extra-array/wiki/isInfix
[isSubsequence]: https://github.com/nodef/extra-array/wiki/isSubsequence
[isPermutation]: https://github.com/nodef/extra-array/wiki/isPermutation