From 031c56a34d8a85d8847d21fb7a50d0485890a154 Mon Sep 17 00:00:00 2001 From: Michael Wolbert Date: Thu, 4 Aug 2016 10:09:54 +0200 Subject: [PATCH 1/3] Create bower.json --- bower.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..6767e7b --- /dev/null +++ b/bower.json @@ -0,0 +1,17 @@ +{ + "name": "javascript-natural-sort", + "version": "0.7.1", + "description": "Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license", + "main": "naturalSort.js", + "keywords": [ + "natural", + "sort", + "javascript", + "array", + "sort", + "sorting" + ], + "author": "Jim Palmer (based on chunking idea from Dave Koelle, packaged by @khous of Bill4Time)", + "license": "MIT", + "homepage": "https://github.com/Bill4Time/javascript-natural-sort" +} From 09fc032ad8d9a3ad662fe4368482f3ef272bcc7e Mon Sep 17 00:00:00 2001 From: Michael Wolbert Date: Thu, 4 Aug 2016 10:46:37 +0200 Subject: [PATCH 2/3] CommonJS it only if exists --- naturalSort.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/naturalSort.js b/naturalSort.js index 28dd64d..8e85869 100644 --- a/naturalSort.js +++ b/naturalSort.js @@ -3,7 +3,7 @@ * Author: Jim Palmer (based on chunking idea from Dave Koelle) */ /*jshint unused:false */ -module.exports = function naturalSort (a, b) { +function naturalSort (a, b) { "use strict"; var re = /(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi, sre = /(^[ ]*|[ ]*$)/g, @@ -43,3 +43,7 @@ module.exports = function naturalSort (a, b) { } return 0; }; + +if (module && module.exports) { + module.exports = naturalSort; +} From 36f8185dc55de8799bd3592c9d71412ab1202319 Mon Sep 17 00:00:00 2001 From: Michael Wolbert Date: Thu, 4 Aug 2016 12:25:16 +0200 Subject: [PATCH 3/3] CommonJS it only if exists --- naturalSort.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/naturalSort.js b/naturalSort.js index 8e85869..b9a6810 100644 --- a/naturalSort.js +++ b/naturalSort.js @@ -44,6 +44,9 @@ function naturalSort (a, b) { return 0; }; -if (module && module.exports) { - module.exports = naturalSort; +if(typeof exports !== 'undefined') { + if (typeof module !== 'undefined' && module.exports) { + exports = module.exports = moduleName; + } + exports = moduleName; }