Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

query-string

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-string - npm Package Compare versions

Comparing version 6.5.0 to 6.6.0

25

index.d.ts

@@ -37,2 +37,23 @@ export interface ParseOptions {

readonly arrayFormat?: 'bracket' | 'index' | 'comma' | 'none';
/**
* Supports both `Function` as a custom sorting function or `false` to disable sorting.
*
* If omitted, keys are sorted using `Array#sort`, which means, converting them to strings and comparing strings in Unicode code point order.
*
* @default true
*
* @example
*
* const order = ['c', 'a', 'b'];
* queryString.parse('?a=one&b=two&c=three', {
* sort: (itemLeft, itemRight) => order.indexOf(itemLeft) - order.indexOf(itemRight)
* });
* // => {c: 'three', a: 'one', b: 'two'}
*
* queryString.parse('?a=one&c=three&b=two', {sort: false});
* // => {a: 'one', c: 'three', b: 'two'}
*/
readonly sort?: ((itemLeft: string, itemRight: string) => number) | false;
}

@@ -119,2 +140,4 @@

*
* @default true
*
* @example

@@ -138,3 +161,3 @@ *

export function stringify(
object: {[key: string]: unknown},
object: {[key: string]: any},
options?: StringifyOptions

@@ -141,0 +164,0 @@ ): string;

@@ -177,2 +177,3 @@ 'use strict';

decode: true,
sort: true,
arrayFormat: 'none'

@@ -206,3 +207,7 @@ }, options);

return Object.keys(ret).sort().reduce((result, key) => {
if (options.sort === false) {
return ret;
}
return (options.sort === true ? Object.keys(ret).sort() : Object.keys(ret).sort(options.sort)).reduce((result, key) => {
const value = ret[key];

@@ -209,0 +214,0 @@ if (Boolean(value) && typeof value === 'object' && !Array.isArray(value)) {

6

package.json
{
"name": "query-string",
"version": "6.5.0",
"version": "6.6.0",
"description": "Parse and stringify URL query strings",

@@ -43,8 +43,8 @@ "license": "MIT",

"devDependencies": {
"ava": "^1.3.1",
"ava": "^2.0.0",
"deep-equal": "^1.0.1",
"fast-check": "^1.5.0",
"tsd": "^0.7.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
}
}

@@ -14,7 +14,3 @@ # query-string [![Build Status](https://travis-ci.org/sindresorhus/query-string.svg?branch=master)](https://travis-ci.org/sindresorhus/query-string)

<a href="https://www.patreon.com/sindresorhus">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
</a>
## Usage

@@ -54,3 +50,3 @@

### .parse(string, [options])
### .parse(string, options?)

@@ -63,3 +59,3 @@ Parse a query string into an object. Leading `?` or `#` are ignored, so you can pass `location.search` or `location.hash` directly.

Type: `Object`
Type: `object`

@@ -76,5 +72,5 @@ ##### decode

Type: `string`<br>
Default: `none`
Default: `'none'`
- `bracket`: Parse arrays with bracket representation:
- `'bracket'`: Parse arrays with bracket representation:

@@ -86,3 +82,3 @@ ```js

- `index`: Parse arrays with index representation:
- `'index'`: Parse arrays with index representation:

@@ -94,3 +90,3 @@ ```js

- `comma`: Parse arrays with elements separated by comma:
- `'comma'`: Parse arrays with elements separated by comma:

@@ -102,3 +98,3 @@ ```js

- `none`: Parse arrays with elements using duplicate keys:
- `'none'`: Parse arrays with elements using duplicate keys:

@@ -110,2 +106,9 @@ ```js

##### sort
Type: `Function | boolean`<br>
Default: `true`
Supports both `Function` as a custom sorting function or `false` to disable sorting.
### .stringify(object, [options])

@@ -117,3 +120,3 @@

Type: `Object`
Type: `object`

@@ -137,5 +140,5 @@ ##### strict

Type: `string`<br>
Default: `none`
Default: `'none'`
- `bracket`: Serialize arrays using bracket representation:
- `'bracket'`: Serialize arrays using bracket representation:

@@ -147,3 +150,3 @@ ```js

- `index`: Serialize arrays using index representation:
- `'index'`: Serialize arrays using index representation:

@@ -155,3 +158,3 @@ ```js

- `comma`: Serialize arrays by separating elements with comma:
- `'comma'`: Serialize arrays by separating elements with comma:

@@ -163,3 +166,3 @@ ```js

- `none`: Serialize arrays by using duplicate keys:
- `'none'`: Serialize arrays by using duplicate keys:

@@ -197,3 +200,3 @@ ```js

### .parseUrl(string, [options])
### .parseUrl(string, options?)

@@ -255,4 +258,12 @@ Extract the URL and the query string as an object.

## License
---
MIT © [Sindre Sorhus](https://sindresorhus.com)
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-query-string?utm_source=npm-query-string&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc