es-toolkit 1.52.0-dev.2137 → 1.52.0-dev.2138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -24,9 +24,15 @@ function intersectionBy(secondArray, mapper) {
|
|
|
24
24
|
function intersectionByEager(array) {
|
|
25
25
|
return require_intersectionBy.intersectionBy(array, secondArray, mapper);
|
|
26
26
|
}
|
|
27
|
-
const intersectionByLazy =
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const intersectionByLazy = (emit) => {
|
|
28
|
+
const unmatched = new Set(mappedSecondSet);
|
|
29
|
+
return (value) => {
|
|
30
|
+
const mappedValue = mapper(value);
|
|
31
|
+
if (!unmatched.has(mappedValue)) return true;
|
|
32
|
+
unmatched.delete(mappedValue);
|
|
33
|
+
return emit(value);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
30
36
|
return require_lazy.combineEagerAndLazyFunctions(intersectionByEager, intersectionByLazy);
|
|
31
37
|
}
|
|
32
38
|
//#endregion
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { intersectionBy as intersectionBy$1 } from "../../array/intersectionBy.mjs";
|
|
2
|
-
import { combineEagerAndLazyFunctions
|
|
2
|
+
import { combineEagerAndLazyFunctions } from "../_internal/lazy.mjs";
|
|
3
3
|
//#region src/fp/array/intersectionBy.ts
|
|
4
4
|
/**
|
|
5
5
|
* Creates a function that keeps values whose mapped identity appears in another array.
|
|
@@ -24,9 +24,16 @@ function intersectionBy(secondArray, mapper) {
|
|
|
24
24
|
function intersectionByEager(array) {
|
|
25
25
|
return intersectionBy$1(array, secondArray, mapper);
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const intersectionByLazy = (emit) => {
|
|
28
|
+
const unmatched = new Set(mappedSecondSet);
|
|
29
|
+
return (value) => {
|
|
30
|
+
const mappedValue = mapper(value);
|
|
31
|
+
if (!unmatched.has(mappedValue)) return true;
|
|
32
|
+
unmatched.delete(mappedValue);
|
|
33
|
+
return emit(value);
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
return combineEagerAndLazyFunctions(intersectionByEager, intersectionByLazy);
|
|
30
37
|
}
|
|
31
38
|
//#endregion
|
|
32
39
|
export { intersectionBy };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"version": "1.52.0-dev.
|
|
3
|
+
"version": "1.52.0-dev.2138+678c655c",
|
|
4
4
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|