Skip to content
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

regex index problem #47

Closed
kenyipp opened this issue Nov 6, 2019 · 0 comments
Closed

regex index problem #47

kenyipp opened this issue Nov 6, 2019 · 0 comments

Comments

@kenyipp
Copy link

kenyipp commented Nov 6, 2019

I would like to exclude key with start of "_"
camelcaseKeys(object, { deep: true, exclude: [/^\_/ig] });
However, I found that some of keys has not follow that rule because the lastIndex of the regex has changed when it test the keys one by one and make it fail to test.
I have rewrite the "has" function to solve this problemfunction has(array, key) { return array.some(x => { if (typeof x === 'string') return x === key; else { x.lastIndex = 0; return x.test(key) } }); }
I am wondering if there has any better solution and if it can fix it in next version. thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant