Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.

Commit 948f8b2

Browse files
author
Bassem Dghaidi
authored
Merge pull request #17 from mena-devs/develop
Releasing 0.1.13
2 parents fa10629 + af437f7 commit 948f8b2

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

index.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,15 @@ const match = (payload, pattern, callback) => {
6262
*/
6363
} else if (element instanceof Object) {
6464
currentNode[key][index] = {}
65-
tester(payload[key][index], element, currentNode[key][index])
65+
66+
payload[key].forEach((payloadItem, payloadIndex) => {
67+
if (payloadItem instanceof Object) {
68+
const payloadItemMatch = match(payloadItem, element)
69+
if (payloadItemMatch.match) {
70+
tester(payload[key][payloadIndex], element, currentNode[key][index])
71+
}
72+
}
73+
})
6674
} else if (payload[key].includes(element)) {
6775
currentNode[key][index] = element
6876
result.total += 1

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@menadevs/objectron",
3-
"version": "0.1.12",
3+
"version": "0.1.13",
44
"description": "Compares a set of match rules contained with an object to determine if the latter conforms to the matching rules",
55
"main": "index.js",
66
"devDependencies": {

test/test_objectron.js

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,15 @@ suite('Objectron Core Tests', () => {
564564
{
565565
type: 'markdown',
566566
text: '*This must be it*'
567-
}
567+
},
568+
{
569+
type: 'html',
570+
text: '<b>Hello world</b>'
571+
},
572+
{
573+
type: 'yaml',
574+
text: 'Another text!'
575+
},
568576
]
569577
}
570578
}
@@ -578,14 +586,22 @@ suite('Objectron Core Tests', () => {
578586
{
579587
type: 'markdown',
580588
text: /.*/
581-
}
589+
},
590+
{
591+
type: 'html',
592+
text: /<b>(.*?)<\/b>/
593+
},
594+
{
595+
type: 'yaml',
596+
text: /(?<yamlText>.*)/,
597+
},
582598
]
583599
}
584600
})
585601

586602
const expected = {
587603
match: true,
588-
total: 8,
604+
total: 11,
589605
matches: {
590606
api: 13,
591607
ids: [12, 130, 45],
@@ -595,13 +611,24 @@ suite('Objectron Core Tests', () => {
595611
{
596612
type: 'markdown',
597613
text: '*This must be it*'
598-
}
614+
},
615+
{
616+
type: 'html',
617+
text: '<b>Hello world</b>'
618+
},
619+
{
620+
type: 'yaml',
621+
text: 'Another text!'
622+
},
599623
]
600624
}
601625
},
602-
groups: {}
626+
groups: {
627+
yamlText: 'Another text!'
628+
}
603629
}
604630

605-
assert.isFalse(result.match)
631+
assert.isTrue(result.match)
632+
assert.deepEqual(result, expected)
606633
})
607634
})

0 commit comments

Comments
 (0)