Skip to content

Commit 5620b81

Browse files
Vladimir Chizhovevanplaice
authored andcommitted
Simplified usage inside nodejs.
jQuery npm package is no longer required. Just: var csv = require('./path/to/jquery.csv.js');
1 parent 6990eea commit 5620b81

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/jquery.csv.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,19 @@ RegExp.escape= function(s) {
3131
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
3232
};
3333

34-
(function( $ ) {
34+
(function (undefined) {
3535
'use strict'
36+
37+
var $;
38+
39+
// to keep backwards compatibility
40+
if (typeof jQuery !== 'undefined' && jQuery) {
41+
$ = jQuery;
42+
} else {
43+
$ = {};
44+
}
45+
46+
3647
/**
3748
* jQuery.csv.defaults
3849
* Encapsulates the method paramater defaults for the CSV plugin module.
@@ -945,4 +956,10 @@ RegExp.escape= function(s) {
945956
$.csv2Array = $.csv.toArrays;
946957
$.csv2Dictionary = $.csv.toObjects;
947958

948-
})( jQuery );
959+
// CommonJS module is defined
960+
if (typeof module !== 'undefined' && module.exports) {
961+
module.exports = $.csv;
962+
}
963+
964+
}).call( this );
965+

0 commit comments

Comments
 (0)