Permalink
Browse files

rename distance to sift3, fix docs and tests

  • Loading branch information...
1 parent 4955f35 commit 549885dcb6f977d285371b01ab6095a5b1e80c0d @DimitarChristoff committed Mar 24, 2012
Showing with 13 additions and 13 deletions.
  1. +2 −2 README.md
  2. +3 −3 src/String.distance.js
  3. +1 −1 src/mootools.mailcheck.js
  4. +7 −7 test/tests/mootools.mailcheck-test.js
View
@@ -44,10 +44,10 @@ else {
```javascript
// it can create an instance on the fly for you
-var mailcheck = new Mailcheck(, {
+var mailcheck = new Mailcheck(document.id('email', {
domains: ["hotmail.com", "gmail.com", "aol.com"],
threshold: 2,
- method: 'distance' // sift3 or 'levenstein' (default)
+ method: 'sift3' // sift3 or 'levenstein' (default)
});
document.id("email").addEvent("change", function() {
View
@@ -14,7 +14,7 @@
requires:
- Core/String
- provides: String.distance
+ provides: String.sift3, String.levenstein
...
*/
@@ -23,8 +23,8 @@
'use strict'
String.implement({
- distance: function(s2) {
- // sift3, returns crap in IE7
+ sift3: function(s2) {
+ // sift3 - http://siderite.blogspot.com/2007/04/super-fast-and-accurate-string-distance.html
var s1 = String(this),
c = 0,
offset1 = 0,
@@ -86,7 +86,7 @@
'ymail.com'
],
threshold: 2,
- // check String.distance.js - supported: 'distance' (sift3, issues in IE6/7), 'levenstein' (slower but consistent)
+ // check String.distance.js - supported: 'sift3', 'levenstein'
method: 'levenstein'
},
@@ -3,7 +3,7 @@ if (typeof require == "function" && typeof module == "object") {
}
-buster.testCase("String.distance tests", {
+buster.testCase("String.sift3 tests", {
setUp: function() {
this.string = "gmail";
this.distance1 = "gnail";
@@ -12,19 +12,19 @@ buster.testCase("String.distance tests", {
},
"Expect distance between two equal strings to be 0": function() {
- buster.assert.equals(String.distance(this.string, this.string), 0);
+ buster.assert.equals(String.sift3(this.string, this.string), 0);
},
"Expect distance between two strings with 1 typo to be 1": function() {
- buster.assert.equals(String.distance(this.string, this.distance1), 1);
+ buster.assert.equals(String.sift3(this.string, this.distance1), 1);
},
"Expect distance between two strings with 1 typo and 1 char difference to be 1.5": function() {
- buster.assert.equals(String.distance(this.string, this.distance2), 1.5);
+ buster.assert.equals(String.sift3(this.string, this.distance2), 1.5);
},
"Expect distance between two unrelated strings to be length of base string": function() {
- buster.assert.equals(String.distance(this.string, this.toofar), this.string.length);
+ buster.assert.equals(String.sift3(this.string, this.toofar), this.string.length);
}
});
@@ -57,7 +57,7 @@ buster.testCase("String.levenstein tests", {
buster.testCase("mootools.mailcheck distance tests", {
setUp: function () {
this.mailcheck = new Mailcheck(new Element("input#email"), {
- method: "distance"
+ method: "sift3"
});
},
@@ -126,7 +126,7 @@ buster.testCase("mootools.mailcheck distance tests", {
buster.testCase("mootools.mailcheck cache tests", {
setUp: function () {
this.mailcheck = new Mailcheck(new Element("input#email"), {
- method: "distance"
+ method: "sift3"
});
},

0 comments on commit 549885d

Please sign in to comment.