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

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

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

browser equivalent form-data javascript jquery nodejs param post query-string serialize url-encoding

Last synced: 24 days ago
JSON representation

Equivalent function to jQuery.param

Awesome Lists containing this project

README

          

# jquery-param

[![CI](https://github.com/knowledgecode/jquery-param/actions/workflows/ci.yml/badge.svg)](https://github.com/knowledgecode/jquery-param/actions/workflows/ci.yml)
[![npm](https://img.shields.io/npm/v/jquery-param)](https://www.npmjs.com/package/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