Skip to content

Commit d7ef932

Browse files
authored
Merge pull request #54 from ferflores507/dev
Dev
2 parents 0b3fe51 + 5dc1c82 commit d7ef932

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ferflores507/object-builder",
3-
"version": "9.4.0",
3+
"version": "9.5.0",
44
"main": "index.js",
55
"scripts": {
66
"test": "vitest"

src/builders/PropiedadesBuilder.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@ export class PropiedadesBuilder {
77
const allEntries = Object.entries(propiedades)
88
const { entries = [], computedEntries = [] } = this.groupByComputed(allEntries)
99

10-
this.entries = entries
10+
this.entries = entries.filter(([key]) => key !== "$bind")
1111
this.result = assignAll({}, ...this.getGetters(computedEntries))
1212
this.builder = builder.with({ siblings: this.result })
13+
14+
const bindEntry = entries.find(([key]) => key === "$bind")
15+
16+
if(bindEntry) {
17+
const [key, val] = bindEntry
18+
19+
Object.assign(this.result, this.builder.with({ schema: val }).build())
20+
}
1321
}
1422

1523
private readonly result: Record<string, any>

tests/schema/mixed.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@ import { Queue } from '../../src/helpers/Queue'
99
import { TaskBuilder } from '../../src/builders/TaskBuilder'
1010
import { Propiedades } from '../../src/models'
1111

12+
test("propiedades $bind", async () => {
13+
await expectToEqualAsync({
14+
store: {
15+
details: {
16+
id: 1,
17+
en: "one"
18+
}
19+
},
20+
schema: {
21+
propiedades: {
22+
$bind: {
23+
path: "details"
24+
}
25+
}
26+
},
27+
expected: {
28+
id: 1,
29+
en: "one"
30+
}
31+
})
32+
})
33+
1234
test("map object", async () => {
1335
await expectToEqualAsync({
1436
store: {

0 commit comments

Comments
 (0)