-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi wildcard support finalization #40
Multi wildcard support finalization #40
Conversation
target[key] = value | ||
} | ||
/* istanbul ignore else */ | ||
if (typeof target === 'object') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible that target is not an object? It's not covered by tests anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its possible, applies for the example below:
const redact = fastRedact({
paths: ['a[*].x.d[*].i.*.i']
})
const o = {
a: [
{ x: { d: [ { i: undefined, j: 'NR' } ] } }
]
}
Only applies when the given path expects a deeper nested object but is undefined somewhere.
I`am not sure if this should be a case to be considered.
const targetKeys = Object.keys(target) | ||
for (var j = 0; j < targetKeys.length; j++) { | ||
const tKey = targetKeys[j] | ||
const subTarget = target[tKey] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if subtarget is also an object?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you pls explain your point here - I dont get it right now
subTarget
can be an object, and it works imho
For the example, which is also in the tests (https://github.com/lrecknagel/fast-redact/blob/multi-wildcard-support-finalization/test/index.js#L1228)
const redactOut = fastRedact({
paths: ['a[*].x.d[*].p.*.i'],
})
const obj = {
a: [
{ x: { d: [ { i: undefined, j: 'NR' } ] }},
]
}
redactOut(obj)
we get the following state for subtarget:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exceptional work, thank you!
couple of points, also would you mind posting benchmarks of main branch vs your branch, and also adding benchmarks that cover this new code (if it's not covered already that is)
Can you also rebase on top of main so we get some CI running? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm on passing CI
Thanks for the hints and comments! I´ve working on the benchmark part and will push it asap. |
001_fast-redact-bench-main.txt Depending on |
I'm good with the benchmarks I'm seeing |
thanks @lrecknagel - it all seems good to me, I think let's get this merged, any extra benchmarks that could be PR'd after are always welcome but not demanded |
First - thanks for all the efforts already put in this project and also the PR with I`am picking up!
2nd - I hope I have picked up the prior work correctly, please tell me if I take a wrong path here.
(Followed the suggested manual: https://gist.github.com/jsumners/461ef7a64545108635cc437fde112721)
I´ve worked on finishing the multi-wildcard feature #36 with the missing test-coverage.
Also added handling for a
undefined / null
case which I`ve found.Following checks have been made:
npm run cov-ui
npm run test
npm run bench
(see attached report)fast-redact-bench-wc_finalization.txt
Please give me ping if I forgot something - hope we can bring this feature to life!
Best Lucas