Skip to content

Commit 8fdec47

Browse files
committed
moved findLast util
1 parent d7db138 commit 8fdec47

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

packages/rrweb/src/plugins/network/record/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { IWindow, listenerHandler, RecordPlugin } from '@rrweb/types';
2-
import { findLast, patch } from '../../../utils';
2+
import { patch } from '../../../utils';
33
import { stringify, StringifyOptions } from '../../utils/stringify';
4+
import { findLast } from '../../utils/find-last';
45

56
export type InitiatorType =
67
| 'audio'
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
export function findLast<T>(
2+
array: Array<T>,
3+
predicate: (value: T) => boolean,
4+
): T | undefined {
5+
const length = array.length;
6+
for (let i = length - 1; i >= 0; i -= 1) {
7+
if (predicate(array[i])) {
8+
return array[i];
9+
}
10+
}
11+
}

packages/rrweb/src/utils.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -545,15 +545,3 @@ export function inDom(n: Node): boolean {
545545
if (!doc) return false;
546546
return doc.contains(n) || shadowHostInDom(n);
547547
}
548-
549-
export function findLast<T>(
550-
array: Array<T>,
551-
predicate: (value: T) => boolean,
552-
): T | undefined {
553-
const length = array.length;
554-
for (let i = length - 1; i >= 0; i -= 1) {
555-
if (predicate(array[i])) {
556-
return array[i];
557-
}
558-
}
559-
}

0 commit comments

Comments
 (0)