summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-13 09:07:24 +0100
committerJoe Carstairs <65492573+Sycamost@users.noreply.github.com>2023-08-13 09:07:24 +0100
commitc3f119d332dea3fc33494a44e077f00f6ad05eec (patch)
treef699eb6e4cc36d541dcae3ec3fff5485182546ab /src/lib
parentc1c9f9a9f3004460787ca23d55ffdacec95c0aad (diff)
Adds breadcrumbs
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/findAllIndicesOf.ts14
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;
+}