UNPKG

@extra-array/has-infix

Version:

Checks if array contains an infix.

64 lines (48 loc) 2.14 kB
Checks if array contains an infix. [:package:](https://www.npmjs.com/package/@extra-array/has-infix) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/has-infix) [:vhs:](https://asciinema.org/a/343738) [:moon:](https://www.npmjs.com/package/@extra-array/has-infix.min) [:scroll:](https://unpkg.com/@extra-array/has-infix/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Similar: [infix], [infixes], [hasInfix], [searchInfix].<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.hasInfix(x, y, [fc], [fm]); // x: an array // y: infix? // fc: compare function (a, b) // fm: map function (v, i, x) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4]; array.hasInfix(x, [2, 3]); // true array.hasInfix(x, [-2, -3]); // false array.hasInfix(x, [-2, -3], (a, b) => Math.abs(a) - Math.abs(b)); // true array.hasInfix(x, [-2, -3], null, v => Math.abs(v)); // true ``` <br> <br> ## References - [Data.List.isInfixOf: Haskell](https://hackage.haskell.org/package/base-4.12.0.0/docs/Data-List.html#v:isInfixOf) - [List-Extra.isInfixOf: elm](https://package.elm-lang.org/packages/elm-community/list-extra/7.1.0/List-Extra#isInfixOf) [infix]: https://github.com/nodef/extra-array/wiki/infix [infixes]: https://github.com/nodef/extra-array/wiki/infixes [hasInfix]: https://github.com/nodef/extra-array/wiki/hasInfix [searchInfix]: https://github.com/nodef/extra-array/wiki/searchInfix [hasValue]: https://github.com/nodef/extra-array/wiki/hasValue [hasPrefix]: https://github.com/nodef/extra-array/wiki/hasPrefix [hasSuffix]: https://github.com/nodef/extra-array/wiki/hasSuffix [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