Skip to content

Commit 4eefdc9

Browse files
authored
Merge pull request #25 from objectwow/dev
fix: wrong from param and asMap interface
2 parents 75d3b09 + b7bd34c commit 4eefdc9

3 files changed

Lines changed: 11 additions & 7 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@objectwow/join",
3-
"version": "0.3.5",
3+
"version": "0.3.6",
44
"license": "MIT",
55
"description": "Perform a deep join of arrays of objects using UIDs.",
66
"publishConfig": {

src/type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ export type LocalParam = object | object[];
66

77
export type FromParam =
88
| ((localFieldValues: Primitive[], metadata: any) => object[])
9+
| ((localFieldValues: Primitive[], metadata: any) => Promise<object[]>)
910
| object[];
1011

1112
export type AsMap =
1213
| ((currentFrom: any, currentLocal: any, metadata: any) => any)
14+
| ((currentFrom: any, currentLocal: any, metadata: any) => Promise<any>)
1315
| { [key: string]: string }
1416
| string;
1517

tests/core.spec.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ describe("JoinData - execute method full coverage", () => {
6464
});
6565

6666
it("should merge entire from objects into each local array element when as and asMap are undefined", async () => {
67-
const fromFn = async () => [
68-
{ id: 1, name: "Alice", age: 25 },
69-
{ id: 2, name: "Bob", age: 30 },
70-
];
71-
7267
const param: JoinDataParam = {
73-
from: await fromFn(),
68+
from: async () => {
69+
const result = [
70+
{ id: 1, name: "Alice", age: 25 },
71+
{ id: 2, name: "Bob", age: 30 },
72+
] as unknown as Promise<object[]>;
73+
74+
return result;
75+
},
7476
local: [{ id: 1 }, { id: 2 }],
7577
localField: "id",
7678
fromField: "id",

0 commit comments

Comments
 (0)