-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat(isISO6391): add isISO6391() functionality #1103
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
Conversation
ezkemboi
commented
Sep 9, 2019
- closes Add isISO6391() method #989
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.
isISO6391('xx') will return true even if xx is not a valid ISO 639-1 code
Don't you think that having a regex with all possibilities is more accurate since ISO 639-1 is a standardized list?
|
@tux-tn, good suggestion. Let me check how long is the list of the codes. |
|
@tux-tn let me work on this today evening or tomorrow and update it. |
I think this will help. Thanks. |
|
@ezkemboi take your time! Thank you for working on this |
598d6bc to
9ef2dfb
Compare
|
@tux-tn, I have fixed the code, though after running the test, it has changed many more files. |
|
Ping @profnandaa @tux-tn |
profnandaa
left a comment
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.
See my minor suggestion, and also remove the unrelated changes.
src/lib/isISO6391.js
Outdated
| @@ -0,0 +1,8 @@ | |||
| import assertString from './util/assertString'; | |||
|
|
|||
| const isISO6391Reg = /^(aa|ab|ae|af|ak|am|an|ar|as|av|ay|az|az|ba|be|bg|bh|bi|bm|bn|bo|br|bs|ca|ce|ch|co|cr|cs|cu|cv|cy|da|de|dv|dz|ee|el|en|eo|es|et|eu|fa|ff|fi|fj|fo|fr|fy|ga|gd|gl|gn|gu|gv|ha|he|hi|ho|hr|ht|hu|hy|hz|ia|id|ie|ig|ii|ik|io|is|it|iu|ja|jv|ka|kg|ki|kj|kk|kl|km|kn|ko|kr|ks|ku|kv|kw|ky|la|lb|lg|li|ln|lo|lt|lu|lv|mg|mh|mi|mk|ml|mn|mr|ms|mt|my|na|nb|nd|ne|ng|nl|nn|no|nr|nv|ny|oc|oj|om|or|os|pa|pi|pl|ps|pt|qu|rm|rn|ro|ru|rw|sa|sc|sd|se|sg|si|sk|sl|sm|sn|so|sq|sr|ss|st|su|sv|sw|ta|te|tg|th|ti|tk|tl|tn|to|tr|ts|tt|tw|ty|ug|uk|ur|uz|ve|vi|vo|wa|wo|xh|yi|yo|za|zh|zu)$/i; | |||
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.
Instead of a regex, could we just use a set instead? Listing the items on each line for better readability:
const isoSet = new Set([
'aa',
'ab',
//...
]);and return isoSet.has(str).
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.
Alright, thanks, looking at making the requested changes.
|
@profnandaa I have tried to fix them. |
|
@ezkemboi -- make sure you rebase with the latest |
|
@ezkemboi -- could you also check my comments here, let's check if there's any demand for this... The idea here to try as much as possible (unless compelled by demand), to have the checking-against-db-ish sort of features, and strictly stick to regex. I'd prefer that we put this PR on hold until a sizable number of vote is met; like what I saw with -na |
|
That is awesome @profnandaa. |