diff options
| author | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-13 09:07:24 +0100 |
|---|---|---|
| committer | Joe Carstairs <65492573+Sycamost@users.noreply.github.com> | 2023-08-13 09:07:24 +0100 |
| commit | c3f119d332dea3fc33494a44e077f00f6ad05eec (patch) | |
| tree | f699eb6e4cc36d541dcae3ec3fff5485182546ab /src/lib | |
| parent | c1c9f9a9f3004460787ca23d55ffdacec95c0aad (diff) | |
Adds breadcrumbs
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/findAllIndicesOf.ts | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/lib/findAllIndicesOf.ts b/src/lib/findAllIndicesOf.ts new file mode 100644 index 0000000..8f1a100 --- /dev/null +++ b/src/lib/findAllIndicesOf.ts @@ -0,0 +1,14 @@ +export default function (searchFor: string, searchIn: string): number[] { + const indices: number[] = []; + + let index = -1; + while (index !== searchIn.length - 1) { + index = searchIn.slice(index + 1).indexOf(searchFor) + index + 1; + if (index === -1) { + break; + } + indices.push(index); + } + + return indices; +} |
