UNPKG

@extra-array/search-infix-all

Version:
72 lines (55 loc) 2.16 kB
Finds indices of an infix. [:package:](https://www.npmjs.com/package/@extra-array/search-infix-all) [:smiley_cat:](https://github.com/orgs/nodef/packages?repo_name=extra-array) [:running:](https://npm.runkit.com/@extra-array/search-infix-all) [:vhs:](https://asciinema.org/a/342306) [:moon:](https://www.npmjs.com/package/@extra-array/search-infix-all.min) [:scroll:](https://unpkg.com/@extra-array/search-infix-all/) [:newspaper:](https://nodef.github.io/extra-array/) [:blue_book:](https://github.com/nodef/extra-array/wiki/) > Alternatives: [searchInfix], [searchInfixRight], [searchInfixAll].<br> > Similar: [hasInfix], [searchInfix].<br> > Similar: [search], [scan], [find]. > This is part of package [extra-array]. [extra-array]: https://www.npmjs.com/package/extra-array <br> ```javascript array.searchInfixAll(x, y, [fc], [fm]); // x: an array // y: search infix // fc: compare function (a, b) // fm: map function (v, i, x) ``` ```javascript iterable.searchInfixAll(x, y, fc, [fm]); // x: an iterable // y: search infix // fc: compare function (a, b) // fm: map function (v, i, x) ``` ```javascript const array = require("extra-array"); var x = [1, 2, 3, 4, -2, -3]; var y = [2, 3]; array.searchInfixAll(x, y); // [ 1 ] var y = [-2, -3]; array.searchInfixAll(x, y); // [ 4 ] array.searchInfixAll(x, y, (a, b) => Math.abs(a) - Math.abs(b)); // [ 1, 4 ] array.searchInfixAll(x, y, null, v => Math.abs(v)); // [ 1, 4 ] ``` <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) [searchInfix]: https://github.com/nodef/extra-array/wiki/searchInfix [searchInfixRight]: https://github.com/nodef/extra-array/wiki/searchInfixRight [searchInfixAll]: https://github.com/nodef/extra-array/wiki/searchInfixAll [hasInfix]: https://github.com/nodef/extra-array/wiki/hasInfix [search]: https://github.com/nodef/extra-array/wiki/search [scan]: https://github.com/nodef/extra-array/wiki/scan [find]: https://github.com/nodef/extra-array/wiki/find