Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/knowledgecode/jquery-param

equivalent function to jQuery.param
https://github.com/knowledgecode/jquery-param

equivalent javascript jquery param post serialize

Last synced: 5 days ago
JSON representation

equivalent function to jQuery.param

Awesome Lists containing this project

README

        

# jquery-param

[![Circle CI](https://circleci.com/gh/knowledgecode/jquery-param.svg?style=shield)](https://circleci.com/gh/knowledgecode/jquery-param)

## Features

- Equivalent to jQuery.param (based on jQuery 3.x)
- No dependencies
- Universal (Isomorphic)
- ES Modules Support

## Installation

via npm:

```shell
npm i jquery-param
```

## Usage

```javascript
import param from 'jquery-param';

const obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
const str = param(obj);
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
```

CommonJS:

```javascript
const param = require('jquery-param');

const obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
const str = param(obj);
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"
```

ES Modules (Browser):

```html

import param from '/path/to/jquery-param.js';

const obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
const str = param(obj);
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"

```

Traditional (Browser):

```html

<script>
var obj = { key1: { value1: [10, 20, 30] }, key2: '?a=b&c=d' };
var str = window.param(obj);
// => "key1[value1][]=10&key1[value1][]=20&key1[value1][]=30&key2=?a=b&c=d"

```

## Browser Support

Chrome, Firefox, Safari, Edge, and IE9+.

## License

MIT