MCPcopy
hub / github.com/jestjs/jest / findCommonItems

Function findCommonItems

packages/diff-sequences/src/__tests__/index.property.test.ts:15–28  ·  view source on GitHub ↗
(a: Array<string>, b: Array<string>)

Source from the content-addressed store, hash-verified

13 fc.string({maxLength: 1, minLength: 1, unit: 'grapheme-ascii'});
14
15const findCommonItems = (a: Array<string>, b: Array<string>): Array<string> => {
16 const array: Array<string> = [];
17 diff(
18 a.length,
19 b.length,
20 (aIndex: number, bIndex: number) => a[aIndex] === b[bIndex],
21 (nCommon: number, aCommon: number) => {
22 for (; nCommon !== 0; nCommon -= 1, aCommon += 1) {
23 array.push(a[aCommon]);
24 }
25 },
26 );
27 return array;
28};
29
30const extractCount = (data: Array<string>): Map<string, number> => {
31 const countPerChar = new Map<string, number>();

Callers 1

Calls 1

diffFunction · 0.50

Tested by

no test coverage detected