MCPcopy
hub / github.com/darkreader/darkreader / forEach

Function forEach

src/utils/array.ts:7–17  ·  view source on GitHub ↗
(items: Iterable<T> | ArrayLike<T> | Set<T>, iterator: (item: T) => void)

Source from the content-addressed store, hash-verified

5// NOTE: Iterating Array-like items using `for .. of` is 3x slower in Firefox
6// https://jsben.ch/kidOp
7export function forEach<T>(items: Iterable<T> | ArrayLike<T> | Set<T>, iterator: (item: T) => void): void {
8 if (isArrayLike(items)) {
9 for (let i = 0, len = items.length; i < len; i++) {
10 iterator(items[i]);
11 }
12 } else {
13 for (const item of items) {
14 iterator(item);
15 }
16 }
17}
18
19// NOTE: Pushing items like `arr.push(...items)` is 3x slower in Firefox
20// https://jsben.ch/nr9OF

Callers 14

collectCSSFunction · 0.90
handleAdoptedStyleSheetsFunction · 0.90
watchForUpdatesFunction · 0.90
removeDynamicThemeFunction · 0.90
iterateCSSRulesFunction · 0.90
iterateCSSDeclarationsFunction · 0.90
iterateSourceSheetsFunction · 0.90
getManageableStylesFunction · 0.90
overrideInlineStyleFunction · 0.90
collectUndefinedElementsFunction · 0.90

Calls 1

isArrayLikeFunction · 0.85

Tested by

no test coverage detected