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

Commit

Permalink
Merge pull request #17 from mena-devs/develop
Browse files Browse the repository at this point in the history
Releasing 0.1.13
  • Loading branch information
Bassem Dghaidi authored May 24, 2020
2 parents fa10629 + af437f7 commit 948f8b2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 8 deletions.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ const match = (payload, pattern, callback) => {
*/
} else if (element instanceof Object) {
currentNode[key][index] = {}
tester(payload[key][index], element, currentNode[key][index])

payload[key].forEach((payloadItem, payloadIndex) => {
if (payloadItem instanceof Object) {
const payloadItemMatch = match(payloadItem, element)
if (payloadItemMatch.match) {
tester(payload[key][payloadIndex], element, currentNode[key][index])
}
}
})
} else if (payload[key].includes(element)) {
currentNode[key][index] = element
result.total += 1
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@menadevs/objectron",
"version": "0.1.12",
"version": "0.1.13",
"description": "Compares a set of match rules contained with an object to determine if the latter conforms to the matching rules",
"main": "index.js",
"devDependencies": {
Expand Down
39 changes: 33 additions & 6 deletions test/test_objectron.js
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,15 @@ suite('Objectron Core Tests', () => {
{
type: 'markdown',
text: '*This must be it*'
}
},
{
type: 'html',
text: '<b>Hello world</b>'
},
{
type: 'yaml',
text: 'Another text!'
},
]
}
}
Expand All @@ -578,14 +586,22 @@ suite('Objectron Core Tests', () => {
{
type: 'markdown',
text: /.*/
}
},
{
type: 'html',
text: /<b>(.*?)<\/b>/
},
{
type: 'yaml',
text: /(?<yamlText>.*)/,
},
]
}
})

const expected = {
match: true,
total: 8,
total: 11,
matches: {
api: 13,
ids: [12, 130, 45],
Expand All @@ -595,13 +611,24 @@ suite('Objectron Core Tests', () => {
{
type: 'markdown',
text: '*This must be it*'
}
},
{
type: 'html',
text: '<b>Hello world</b>'
},
{
type: 'yaml',
text: 'Another text!'
},
]
}
},
groups: {}
groups: {
yamlText: 'Another text!'
}
}

assert.isFalse(result.match)
assert.isTrue(result.match)
assert.deepEqual(result, expected)
})
})

0 comments on commit 948f8b2

Please sign in to comment.