Skip to content

Commit aaa2810

Browse files
committed
Updated README.md
1 parent 729a37b commit aaa2810

File tree

1 file changed

+44
-18
lines changed

1 file changed

+44
-18
lines changed

README.md

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,78 @@
11
# jquery-param
2+
23
[![Circle CI](https://circleci.com/gh/knowledgecode/jquery-param.svg?style=shield)](https://circleci.com/gh/knowledgecode/jquery-param)
34

45
## Features
6+
57
- Equivalent to jQuery.param (based on jQuery 3.x)
68
- No dependencies
79
- Universal (Isomorphic)
8-
- ES5
10+
- ES Modules Support
911

1012
## Installation
13+
1114
Node.js:
15+
1216
```shell
13-
$ npm install jquery-param --save
14-
```
15-
Bower (DEPRECATED):
16-
```shell
17-
$ bower install jquery-param
17+
npm install jquery-param --save
1818
```
19+
1920
the browser:
21+
2022
```html
21-
<script src="jquery-param.min.js"></script>
23+
<script src="/path/to/jquery-param.min.js"></script>
2224
```
2325

2426
## Usage
25-
Node.js:
27+
28+
CommonJS:
29+
2630
```javascript
2731
const param = require('jquery-param');
2832

29-
let obj = { key1: 'value1', key2: [10, 20, 30] };
30-
let str = param(obj);
31-
// => "key1=value1&key2[]=10&key2[]=20&key2[]=30"
33+
const obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
34+
const str = param(obj);
35+
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
3236
```
33-
AMD:
37+
38+
TypeScript:
39+
3440
```javascript
35-
require(['jquery-param'], function (param) {
36-
var obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
37-
var str = param(obj);
38-
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
39-
});
41+
import param from 'jquery-param';
42+
43+
const obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
44+
const str = param(obj);
45+
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
4046
```
41-
directly:
47+
48+
*You will need to add `"esModuleInterop": true` to the `"compilerOptions"` directive in `tsconfig.json`.*
49+
50+
ES Modules:
51+
52+
```html
53+
<script type="module">
54+
import { param } from './esm/jquery-param.es.js';
55+
56+
const obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
57+
const str = param(obj);
58+
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
59+
</script>
60+
```
61+
62+
Older browser:
63+
4264
```javascript
65+
<script>
4366
var obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
4467
var str = window.param(obj); // global object
4568
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
69+
</script>
4670
```
4771

4872
## Browser Support
73+
4974
Chrome, Firefox, Safari, Edge, and IE9+.
5075

5176
## License
77+
5278
MIT

0 commit comments

Comments
 (0)