email-misspelled
Advanced tools
Comparing version 1.0.4 to 2.0.0
@@ -0,3 +1,4 @@ | ||
import { ResultInterface } from "Result.interface"; | ||
interface EmailCheckerInterface { | ||
(email: string): string | null; | ||
(email: string): ResultInterface[] | null; | ||
} | ||
@@ -4,0 +5,0 @@ interface EmailCheckerConfigInterface { |
@@ -1,1 +0,1 @@ | ||
!function(e,n){if("object"==typeof exports&&"object"==typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t=n();for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(window,(function(){return function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";t.r(n),t.d(n,"emailChecker",(function(){return f}));var r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return 1===e.replace(/[^@]/g,"").length},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.includes("@")?e.replace(/.*@/,""):""},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return function(t){var r=e.length-t.length;return r<=n&&r>=-n}},l=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return function(){for(var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",r=Array(e.length+1).fill(null).map((function(){return Array(t.length+1).fill(null)})),o=0;o<=t.length;o+=1)r[0][o]=o;for(var i=0;i<=e.length;i+=1)r[i][0]=i;for(var l=1;l<=e.length;l+=1)for(var u=1;u<=t.length;u+=1){var f=t[u-1]===e[l-1]?0:1;r[l][u]=Math.min(r[l][u-1]+1,r[l-1][u]+1,r[l-1][u-1]+f)}return r[e.length][t.length]<=n}},u=["outlook.com","gmail.com","hotmail.com","hotmail.fr","live.fr","live.com","laposte.fr","wanadoo.fr"],f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.lengthDiffMax,t=void 0===n?2:n,f=e.maxMisspelled,a=void 0===f?2:f,c=e.domainList,d=void 0===c?u:c;return function(e){if(r(e)&&(null==d?void 0:d.length)){var n=o(e);if(!d.includes(n)){var u=i(n,t),f=l(n,a);return d.filter(u).filter(f)[0]}}}};n.default=f}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t),n.d(t,"emailChecker",(function(){return s}));var r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return 1===e.replace(/[^@]/g,"").length},o=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.includes("@")?e.replace(/.*@/,""):""},u=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return function(n){var r=e.length-n.length;return r<=t&&r>=-t}},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return function(){for(var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{suggest:""},r=Array(e.length+1).fill(null).map((function(){return Array(n.suggest.length+1).fill(null)})),o=0;o<=n.suggest.length;o+=1)r[0][o]=o;for(var u=0;u<=e.length;u+=1)r[u][0]=u;for(var i=1;i<=e.length;i+=1)for(var l=1;l<=n.suggest.length;l+=1){var f=n.suggest[l-1]===e[i-1]?0:1;r[i][l]=Math.min(r[i][l-1]+1,r[i-1][l]+1,r[i-1][l-1]+f)}return n.misspelledCount=r[e.length][n.suggest.length],n.misspelledCount<=t}},l=["outlook.com","gmail.com","hotmail.com","hotmail.fr","live.fr","live.com","laposte.fr","wanadoo.fr"],f=function(e){return{suggest:e}},a=function(e){return function(t){return e&&(null==t?void 0:t.suggest)?(t.corrected=e.replace(/@.*$/,"@".concat(t.suggest)),t):t}},c=function(e,t){return e.misspelledCount-t.misspelledCount},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.lengthDiffMax,n=void 0===t?2:t,s=e.maxMisspelled,d=void 0===s?2:s,g=e.domainList,v=void 0===g?l:g;return function(e){if(r(e)&&(null==v?void 0:v.length)){var t=o(e);if(!v.includes(t)){var l=u(t,n),s=i(t,d),g=a(e),p=v.filter(l).map(f).filter(s).map(g).sort(c);return p.length?p:void 0}}}};t.default=s}])})); |
@@ -0,3 +1,4 @@ | ||
import { ResultInterface } from "./Result.interface"; | ||
export interface LettersComparisonInterface { | ||
(ref: string): boolean; | ||
(ref: ResultInterface): boolean; | ||
} | ||
@@ -4,0 +5,0 @@ interface LettersComparisonConfigInterface { |
@@ -68,3 +68,3 @@ { | ||
}, | ||
"version": "1.0.4" | ||
"version": "2.0.0" | ||
} |
@@ -9,3 +9,3 @@ # email-misspelled | ||
> Check misspell email domain and return a matching domain suggestion | ||
> Check misspell email's domain and return a list of matching domain suggestions | ||
@@ -31,3 +31,3 @@ String comparison is based on [this](https://github.com/trekhleb/javascript-algorithms/tree/master/src/algorithms/string/levenshtein-distance) | ||
### Importing <a id="importing"></a> | ||
## Importing <a id="importing"></a> | ||
@@ -39,3 +39,7 @@ ```js | ||
emailChecker("user@otmail.com") // hotmail.com | ||
emailChecker("user@otmail.com") | ||
/** | ||
* return : | ||
* [{ suggest: "hotmail.com", misspelledCount: 1, corrected:"user@hotmail.com"}] | ||
**/ | ||
@@ -58,9 +62,24 @@ ``` | ||
emailChecker1("user@otmail.com") // hotmail.com | ||
emailChecker1("user@tmail.com") // undefined | ||
emailChecker1("user@otmail.com") | ||
/** | ||
* return : | ||
* [{ suggest: "hotmail.com", misspelledCount: 1, corrected:"user@hotmail.com"}] | ||
**/ | ||
emailChecker1("user@tmail.com") // undefined | ||
const emailChecker1 = emailMisspelled({ lengthDiffMax: 2 }) | ||
const emailChecker2 = emailMisspelled({ lengthDiffMax: 2 }) | ||
emailChecker1("user@otmail.com") // hotmail.com | ||
emailChecker1("user@tmail.com") // hotmail.com | ||
emailChecker2("user@otmail.com") | ||
/** | ||
* return : | ||
* [{ suggest: "hotmail.com", misspelledCount: 1, corrected:"user@hotmail.com"}] | ||
**/ | ||
emailChecker2("user@tmail.com") | ||
/** | ||
* return : | ||
* [ | ||
* { suggest: "gmail.com", misspelledCount: 1, corrected:"user@gmail.com"} | ||
* { suggest: "hotmail.com", misspelledCount: 2, corrected:"user@hotmail.com"}, | ||
* ] | ||
**/ | ||
``` | ||
@@ -80,9 +99,22 @@ | ||
emailChecker1("user@hotmial.com") // hotmail.com | ||
emailChecker1("user@hotmial.com") | ||
/** | ||
* return : | ||
* [{ suggest: "hotmail.com", misspelledCount: 2, corrected:"user@hotmail.com"}] | ||
**/ | ||
emailChecker1("user@hotmia.com") // undefined | ||
const emailChecker1 = emailMisspelled({ maxMisspelled: 2 }) | ||
const emailChecker2 = emailMisspelled({ maxMisspelled: 3 }) | ||
emailChecker1("user@hotmial.com") // hotmail.com | ||
emailChecker1("user@hotmia.com") // hotmail.com | ||
emailChecker2("user@hotmial.com") | ||
/** | ||
* return : | ||
* [{ suggest: "hotmail.com", misspelledCount: 2, corrected:"user@hotmail.com"}] | ||
**/ | ||
emailChecker2("user@hotmia.com") | ||
/** | ||
* return : | ||
* [{ suggest: "hotmail.com", misspelledCount: 3, corrected:"user@hotmail.com"}] | ||
**/ | ||
emailChecker2("user@otmia.com") //4 misspelled, return undefined | ||
``` | ||
@@ -103,3 +135,7 @@ | ||
emailChecker1("user@hotmial.com") // undefined | ||
emailChecker1("user@randmo.org") // random.org | ||
emailChecker1("user@randmo.org") | ||
/** | ||
* return : | ||
* [{ suggest: "random.org", misspelledCount: 1, corrected:"user@random.org"}] | ||
**/ | ||
``` | ||
@@ -106,0 +142,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12547
14
61
158