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

chore(Create class for constants) #213

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

mohsinayaz
Copy link
Collaborator

Issue #187
1:- create a class for device contants because we want to destroy regexes after it checked
2:- apply the condition when user check its device first time it will work but when same useragent and device check another time we return the store data which is stored when user check is first time

mohsinayaz and others added 2 commits May 7, 2021 03:59
#187
1:- create a class for device contants because we want to destroy regexes after it checked
2:- apply the condition when user check its device first time it will work but when same useragent and device check another time we return the store data which is stored when user check is first time
@AhsanAyaz AhsanAyaz force-pushed the issue/187-memory-leak-and-performance branch from f1df8a9 to ad9a31f Compare May 7, 2021 22:25
@AhsanAyaz AhsanAyaz self-requested a review May 11, 2021 01:14
@rvalitov
Copy link

Any updates on this?

@AhsanAyaz AhsanAyaz force-pushed the master branch 2 times, most recently from 34de892 to 6423208 Compare November 30, 2021 01:38
if (this.isTablet(userAgent)) {
return false;
}
const match = Object.keys(Constants.MOBILES_RE).find(mobile => {
return this.reTree.test(userAgent, Constants.MOBILES_RE[mobile]);
const match = Object.keys(parser.MOBILES_RE).find(mobile => {
Copy link

@srnec srnec Dec 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about using array.some instead of array.find?
Since you only care if there is some item matching your condition it and not looking for that item itself.
const match = Object.keys(parser.MOBILES_RE).some(mobile => this.reTree.test(userAgent, parser.MOBILES_RE[mobile]));
The same change can be applied for all occurances of this pattern in this file

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

Successfully merging this pull request may close these issues.

4 participants