-
-
Notifications
You must be signed in to change notification settings - Fork 103
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
base: master
Are you sure you want to change the base?
Conversation
#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
f1df8a9
to
ad9a31f
Compare
projects/ngx-device-detector/src/lib/device-detector.service.ts
Outdated
Show resolved
Hide resolved
projects/ngx-device-detector/src/lib/device-detector.service.ts
Outdated
Show resolved
Hide resolved
projects/ngx-device-detector/src/lib/device-detector.service.ts
Outdated
Show resolved
Hide resolved
projects/ngx-device-detector/src/lib/device-detector.service.ts
Outdated
Show resolved
Hide resolved
projects/ngx-device-detector/src/lib/device-detector.service.ts
Outdated
Show resolved
Hide resolved
projects/ngx-device-detector/src/lib/device-detector.service.ts
Outdated
Show resolved
Hide resolved
projects/ngx-device-detector/src/lib/device-detector.service.ts
Outdated
Show resolved
Hide resolved
projects/ngx-device-detector/src/lib/device-detector.service.ts
Outdated
Show resolved
Hide resolved
Any updates on this? |
34de892
to
6423208
Compare
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 => { |
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 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
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