File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11. *
2- bower.json
3- compile.js
2+ rollup.config.js
3+ src
44test
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ /**
2+ * @preserve jquery-param (c) KNOWLEDGECODE | MIT
3+ */
4+
5+ /**
6+ * serialize any object
7+ * @param {Object } a - any object to serialize
8+ * @returns {string } a serialized string
9+ */
10+ var param = function ( a ) {
11+ var s = [ ] ;
12+ var add = function ( k , v ) {
13+ v = typeof v === 'function' ? v ( ) : v ;
14+ v = v === null ? '' : v === undefined ? '' : v ;
15+ s [ s . length ] = encodeURIComponent ( k ) + '=' + encodeURIComponent ( v ) ;
16+ } ;
17+ var buildParams = function ( prefix , obj ) {
18+ var i , len , key ;
19+
20+ if ( prefix ) {
21+ if ( Array . isArray ( obj ) ) {
22+ for ( i = 0 , len = obj . length ; i < len ; i ++ ) {
23+ buildParams (
24+ prefix + '[' + ( typeof obj [ i ] === 'object' && obj [ i ] ? i : '' ) + ']' ,
25+ obj [ i ]
26+ ) ;
27+ }
28+ } else if ( String ( obj ) === '[object Object]' ) {
29+ for ( key in obj ) {
30+ buildParams ( prefix + '[' + key + ']' , obj [ key ] ) ;
31+ }
32+ } else {
33+ add ( prefix , obj ) ;
34+ }
35+ } else if ( Array . isArray ( obj ) ) {
36+ for ( i = 0 , len = obj . length ; i < len ; i ++ ) {
37+ add ( obj [ i ] . name , obj [ i ] . value ) ;
38+ }
39+ } else {
40+ for ( key in obj ) {
41+ buildParams ( key , obj [ key ] ) ;
42+ }
43+ }
44+ return s ;
45+ } ;
46+
47+ return buildParams ( '' , a ) . join ( '&' ) ;
48+ } ;
49+
50+ export { param } ;
Original file line number Diff line number Diff line change 1- /**
2- * @preserve jquery-param (c) 2015 KNOWLEDGECODE | MIT
3- */
4- ( function ( global ) {
5- 'use strict' ;
1+ ( function ( global , factory ) {
2+ typeof exports === 'object' && typeof module !== 'undefined' ? module . exports = factory ( ) :
3+ typeof define === 'function' && define . amd ? define ( factory ) :
4+ ( global = global || self , global . param = factory ( ) ) ;
5+ } ( this , ( function ( ) { 'use strict' ;
66
7+ /**
8+ * @preserve jquery-param (c) KNOWLEDGECODE | MIT
9+ */
10+
11+ /**
12+ * serialize any object
13+ * @param {Object } a - any object to serialize
14+ * @returns {string } a serialized string
15+ */
716 var param = function ( a ) {
817 var s = [ ] ;
918 var add = function ( k , v ) {
4453 return buildParams ( '' , a ) . join ( '&' ) ;
4554 } ;
4655
47- if ( typeof module === 'object' && typeof module . exports === 'object' ) {
48- module . exports = param ;
49- } else if ( typeof define === 'function' && define . amd ) {
50- define ( [ ] , function ( ) {
51- return param ;
52- } ) ;
53- } else {
54- global . param = param ;
55- }
56+ return param ;
5657
57- } ( this ) ) ;
58+ } ) ) ) ;
Original file line number Diff line number Diff line change 1+ import { terser } from 'rollup-plugin-terser' ;
2+
3+ export default [
4+ {
5+ input : 'src/index.js' ,
6+ output : [
7+ {
8+ file : 'jquery-param.js' ,
9+ format : 'umd' ,
10+ name : 'param' ,
11+ esModule : false
12+ } ,
13+ {
14+ file : 'jquery-param.min.js' ,
15+ format : 'umd' ,
16+ name : 'param' ,
17+ esModule : false ,
18+ plugins : [ terser ( ) ]
19+ }
20+ ]
21+ } ,
22+ {
23+ input : 'src/esm.js' ,
24+ output : [
25+ {
26+ file : 'esm/jquery-param.es.js' ,
27+ format : 'es'
28+ } ,
29+ {
30+ file : 'esm/jquery-param.es.min.js' ,
31+ format : 'es' ,
32+ plugins : [ terser ( ) ]
33+ }
34+ ]
35+ }
36+ ] ;
Original file line number Diff line number Diff line change 1+ import param from './index.js' ;
2+ export { param } ;
Original file line number Diff line number Diff line change 1+ /**
2+ * @preserve jquery-param (c) KNOWLEDGECODE | MIT
3+ */
4+
5+ /**
6+ * serialize any object
7+ * @param {Object } a - any object to serialize
8+ * @returns {string } a serialized string
9+ */
10+ var param = function ( a ) {
11+ var s = [ ] ;
12+ var add = function ( k , v ) {
13+ v = typeof v === 'function' ? v ( ) : v ;
14+ v = v === null ? '' : v === undefined ? '' : v ;
15+ s [ s . length ] = encodeURIComponent ( k ) + '=' + encodeURIComponent ( v ) ;
16+ } ;
17+ var buildParams = function ( prefix , obj ) {
18+ var i , len , key ;
19+
20+ if ( prefix ) {
21+ if ( Array . isArray ( obj ) ) {
22+ for ( i = 0 , len = obj . length ; i < len ; i ++ ) {
23+ buildParams (
24+ prefix + '[' + ( typeof obj [ i ] === 'object' && obj [ i ] ? i : '' ) + ']' ,
25+ obj [ i ]
26+ ) ;
27+ }
28+ } else if ( String ( obj ) === '[object Object]' ) {
29+ for ( key in obj ) {
30+ buildParams ( prefix + '[' + key + ']' , obj [ key ] ) ;
31+ }
32+ } else {
33+ add ( prefix , obj ) ;
34+ }
35+ } else if ( Array . isArray ( obj ) ) {
36+ for ( i = 0 , len = obj . length ; i < len ; i ++ ) {
37+ add ( obj [ i ] . name , obj [ i ] . value ) ;
38+ }
39+ } else {
40+ for ( key in obj ) {
41+ buildParams ( key , obj [ key ] ) ;
42+ }
43+ }
44+ return s ;
45+ } ;
46+
47+ return buildParams ( '' , a ) . join ( '&' ) ;
48+ } ;
49+
50+ export default param ;
You can’t perform that action at this time.
0 commit comments