Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ok so worked up some changes to splitString function, plus wrote some corresponding tests, and updated the readme
I see that I could have just wrote my own string split but now these features are incorporated. Nothing has changed per former usage (single delimiter works, don't split string elements by default).
in my use case I needed to split any elements that may contain delimiters when passing a path as an array and use more than one delimeter so I wrote this "pre format path" function. Now it is not necessary. :)
Along the way I came up with another way using regex look behind to find
\\
and not split those, then remove them. Avoids that loop with slices and such :).There is only one thing that bothers me and that is the caching. Some time the
fn()
is not being called cause it thinks the value is in the cacheconst val = setValue.cache.get(key) || fn();
in my test for splitting elements
note the
'z.b'
if you change that to'a.b'
the test will throw error becausefn
is not called.not exactly grokking how this cache is working (it is even a different object so different cache?)
It seems like a testing issue as the example works fine
gone for a few days but able to make updates later in the week per your review.