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

Use camelCase for JS identifiers #57

Merged
merged 1 commit into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ MailChecker currently supports:
```javascript
var MailChecker = require('mailchecker');

if(!MailChecker.is_valid('myemail@yopmail.com')){
if(!MailChecker.isValid('myemail@yopmail.com')){
console.error('O RLY !');
process.exit(1);
}

if(!MailChecker.is_valid('myemail.com')){
if(!MailChecker.isValid('myemail.com')){
console.error('O RLY !');
process.exit(1);
}
Expand All @@ -52,11 +52,11 @@ if(!MailChecker.is_valid('myemail.com')){
```html
<script type="text/javascript" src="MailChecker/platform/javascript/MailChecker.js"></script>
<script type="text/javascript">
if(!MailChecker.is_valid('myemail@yopmail.com')){
if(!MailChecker.isValid('myemail@yopmail.com')){
console.error('O RLY !');
}

if(!MailChecker.is_valid('myemail.com')){
if(!MailChecker.isValid('myemail.com')){
console.error('O RLY !');
}
</script>
Expand Down
22 changes: 11 additions & 11 deletions platform/javascript/MailChecker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions platform/javascript/MailChecker.tmpl.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* MailChecker.is_valid(String email);
* MailChecker.isValid(String email);
* @return {Boolean} true is the specified email is valid, false otherwise
*
* Usage
*
* <script type="text/javascript" src="mailchecker/platform/javascript/mailchecker.js"></script>
* <script type="text/javascript">
* alert(MailChecker.is_valid("plop@plop.33mail.com"));
* alert(MailChecker.isValid("plop@plop.33mail.com"));
* </script>
*/

Expand All @@ -24,25 +24,25 @@
return arr;
}

function all_domain_suffixes(email) {
var domain_components = email.split('@')[1].split('.');
function allDomainSuffixes(email) {
var domainComponents = email.split('@')[1].split('.');

return mapRange(0, domain_components.length, function (n) {
return domain_components.slice(n).join('.');
return mapRange(0, domainComponents.length, function (n) {
return domainComponents.slice(n).join('.');
});
}

function is_blacklisted(email) {
return all_domain_suffixes(email).some(function (domain_suffix) {
return blacklist.indexOf(domain_suffix) >= 0;
function isBlacklisted(email) {
return allDomainSuffixes(email).some(function (domainSuffix) {
return blacklist.indexOf(domainSuffix) >= 0;
});
};

global.MailChecker = {
is_valid: function (email){
isValid: function (email){
email = email.toLowerCase();
if(!isValidEmail.test(email)){return false;}
return !is_blacklisted(email);
return !isBlacklisted(email);
},
blacklist: function () {
return blacklist;
Expand Down
24 changes: 12 additions & 12 deletions platform/node/index.js

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions platform/node/index.tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Usage
*
* var MailChecker = require('mailchecker/platform/node')
* MailChecker.is_valid(String email);
* MailChecker.isValid(String email);
* @return {Boolean} true is the specified email is valid, false otherwise
*/
'use strict';
Expand All @@ -12,32 +12,32 @@ var range = require('node-range');
var blacklist = [{{& listSTR }}];
var isValidEmail = /{{& regexp }}/;

function all_domain_suffixes(email) {
var domain_components = email.split('@')[1].split('.');
function allDomainSuffixes(email) {
var domainComponents = email.split('@')[1].split('.');

return range(0, domain_components.length).map(function (n) {
return domain_components.slice(n).join('.');
return range(0, domainComponents.length).map(function (n) {
return domainComponents.slice(n).join('.');
});
}

function is_blacklisted(email) {
function suffix_is_blacklisted(domain_suffix) {
return blacklist.indexOf(domain_suffix) >= 0;
function isBlacklisted(email) {
function suffixIsBlacklisted(domainSuffix) {
return blacklist.indexOf(domainSuffix) >= 0;
}

return all_domain_suffixes(email).some(suffix_is_blacklisted);
}
return allDomainSuffixes(email).some(suffixIsBlacklisted);
};

module.exports = {
is_valid: function (email){
isValid: function (email){
if (typeof(email) !== 'string') {
return false;
}
email = email.toLowerCase();
if (!isValidEmail.test(email)) {
return false;
}
return !is_blacklisted(email);
return !isBlacklisted(email);
},
blacklist: function () {
return blacklist;
Expand Down
2 changes: 1 addition & 1 deletion test/platform.node.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ suite('Node', function () {
});

function _is(b, email) {
t.equal(MailChecker.is_valid(email), b, "MailChecker.is_valid(" + email + ") === " + b);
t.equal(MailChecker.isValid(email), b, "MailChecker.isValid(" + email + ") === " + b);
}
var isValid = _is.bind(this, true);
var isInvalid = _is.bind(this, false);
Expand Down