MCPcopy Index your code
hub / github.com/mitmproxy/mitmproxy / insertViewItem

Function insertViewItem

web/src/js/ducks/flows/_utils.ts:79–95  ·  view source on GitHub ↗
(
    prevView: T[],
    prevViewIndex: Map<string, number>,
    item: T,
    sort: Comparer<T>,
)

Source from the content-addressed store, hash-verified

77}
78
79export function insertViewItem<T extends Item>(
80 prevView: T[],
81 prevViewIndex: Map<string, number>,
82 item: T,
83 sort: Comparer<T>,
84): { view: T[]; _viewIndex: Map<string, number> } {
85 const pos = findInsertPos(prevView, item, sort);
86
87 const view = toSpliced(prevView, pos, 0, item);
88
89 const _viewIndex = new Map(prevViewIndex);
90 for (let i = view.length - 1; i >= pos; i--) {
91 _viewIndex.set(view[i].id, i);
92 }
93
94 return { view, _viewIndex };
95}
96
97/// Find the insertion position in a sorted array.
98export function findInsertPos<T>(

Callers 2

flowsReducerFunction · 0.90
_utilsSpec.tsFile · 0.90

Calls 3

toSplicedFunction · 0.90
findInsertPosFunction · 0.85
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…