Skip to content

Commit 4bd01a5

Browse files
committed
AMD and CommonJs support - Universal Module Definition pattern
1 parent 71044f7 commit 4bd01a5

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

naturalSort.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22
* Natural Sort algorithm for Javascript - Version 0.8 - Released under MIT license
33
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
44
*/
5+
;(function (name, global, undefined) {
6+
var UNDEFINED = undefined + ''
7+
, FUNCTION = 'function'
8+
;
9+
(
10+
typeof define !== FUNCTION || !define.amd ? typeof module != UNDEFINED && module.exports
11+
// CommonJS
12+
? function (deps, factory) { module.exports = factory(); }
13+
// Browser
14+
: function (deps, factory) { global[name] = factory(); }
15+
// AMD
16+
: define
17+
)
18+
/*define*/([], function factory() {
19+
520
function naturalSort (a, b) {
621
var re = /(^([+\-]?(?:\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[\da-fA-F]+$|\d+)/g,
722
sre = /^\s+|\s+$/g, // trim pre-post whitespace
@@ -47,3 +62,8 @@ function naturalSort (a, b) {
4762
}
4863
return 0;
4964
}
65+
66+
return naturalSort;
67+
});
68+
}
69+
('naturalSort', typeof self == 'undefined' ? typeof global == 'undefined' ? this : global : self));

0 commit comments

Comments
 (0)