advent-of-code-2023/src/utils.ts

7 lines
281 B
TypeScript
Raw Normal View History

2023-12-03 12:17:08 +00:00
export const matchAllAndThen = (input: string, pattern: RegExp, callback: (value: string, index: number) => void) => {
[...input.matchAll(pattern)].map(match => {
if (match && match.index !== undefined) {
callback(match[0], match.index);
}
});
}