3.0.16 • Published 11 months ago

deparam.js v3.0.16

Weekly downloads
41
License
MIT
Repository
github
Last release
11 months ago

GitHub package.json version GitHub Build Status

Deparam.js

Deparam.js is a lightweight query string to object converter

Install

npm i deparam.js

Usage

ES6

import deparam from 'deparam.js';
deparam(...);

CommonJS

const deparam = require('deparam.js');
deparam(...);

Browser

<script src="deparam.js"></script>
<script>
  deparam(...);
</script>

How it works?

Deparam can convert simple as well as complex query strings to regular JavaScript objects. Examples are shown below:

Simple string

deparam('?a=10&b=helloworld'); // --> { a: '10', b: 'helloworld'}

Complex string

deparam('a=10&a=20&b=test&c=test2&x[]=45&x[]=99&y[a]=22&y[b]=33');

// --> { a: ['10', '20'], b: 'test', c: 'test2', x: ['99', '22'], y: { a: '22', b: '33' } }

Enable type coercion

Deparam disables type coercion by default for performance reasons. To enable it you can pass an additional flag.

deparam('a=10&b=20&c=hello', true); // --> { a: 10, b: 20, c: 'hello' }
3.0.9

11 months ago

3.0.12

11 months ago

3.0.13

11 months ago

3.0.10

11 months ago

3.0.11

11 months ago

3.0.16

11 months ago

3.0.8

11 months ago

3.0.14

11 months ago

3.0.15

11 months ago

3.0.7

1 year ago

3.0.6

2 years ago

3.0.5

3 years ago

3.0.4

3 years ago

3.0.3

3 years ago

3.0.2

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.11

5 years ago

2.0.10

5 years ago

2.0.9

5 years ago

2.0.8

5 years ago

2.0.7

5 years ago

2.0.6

5 years ago

2.0.5

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago