| 30 | }; |
| 31 | |
| 32 | function paramGenerator(paramType) { |
| 33 | const valueKeys = Object.keys(values); |
| 34 | switch (paramType) { |
| 35 | case 'string': |
| 36 | // Return the values object with all values as strings |
| 37 | return valueKeys.reduce((acc, key) => { |
| 38 | acc[key] = Object.keys(values[key]).reduce((acc, k, i) => { |
| 39 | acc += `${k}=${values[key][k]}${i < valueKeys.length - 1 ? '&' : ''}`; |
| 40 | return acc; |
| 41 | }, ''); |
| 42 | return acc; |
| 43 | }, {}); |
| 44 | case 'iterable': |
| 45 | // Return the values object with all values as iterable |
| 46 | return valueKeys.reduce((acc, key) => { |
| 47 | acc[key] = Object.keys(values[key]).reduce((acc, k) => { |
| 48 | acc.push([k, values[key][k]]); |
| 49 | return acc; |
| 50 | }, []); |
| 51 | return acc; |
| 52 | }, {}); |
| 53 | case 'object': |
| 54 | // Return the values object with all values as objects |
| 55 | return values; |
| 56 | default: |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | const bench = common.createBenchmark(main, { |
| 61 | type: ['noencode', 'encodemany', 'encodelast', 'array', 'multiprimitives'], |