Skip to content

Commit

Permalink
optimize, node usage
Browse files Browse the repository at this point in the history
  • Loading branch information
billybonks committed Oct 25, 2015
1 parent 21c4860 commit 450096d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 6 additions & 3 deletions index.js
Expand Up @@ -10,7 +10,7 @@
*/


;(this.String || this).naturalCompare = function(a, b) {
var naturalCompare = function(a, b) {
var i, codeA
, codeB = 1
, posA = 0
Expand Down Expand Up @@ -50,5 +50,8 @@
return 0
}



try {
module.exports = naturalCompare;
} catch (e) {
String.naturalCompare = naturalCompare;
}
3 changes: 1 addition & 2 deletions tests/index.js
@@ -1,5 +1,5 @@

var naturalCompare = require("../").naturalCompare
var naturalCompare = require("../")

var arr1 = [1.001, 1.002, 1.010, 1.02, 1.1, 1.3]
, arr2 = [-1.001, -1.002, -1.010, -1.02, -1.1, -1.3]
Expand Down Expand Up @@ -72,4 +72,3 @@ describe ("naturalCompare").
}).
equal(["a", "ä", "B", "Š", "X", "A", "õ", "z", "1", "2", "9", "10"].sort(naturalCompare).join(""), "12910ABŠXazõä").
done()

1 comment on commit 450096d

@jlutzhbo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a backwards incompatible change. Probably should have been a new major version

Please sign in to comment.