You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: base.d.ts
+34-5Lines changed: 34 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -184,7 +184,7 @@ export type ParseOptions = {
184
184
185
185
You can also provide a custom function to transform the value. The function will receive the raw string and should return the desired parsed result (see Example 4).
186
186
187
-
NOTE: Array types (`string[]`, `number[]`) are ignored if `arrayFormat` is set to `'none'`. (See Example 5.)
187
+
NOTE: Array types (`string[]`, `number[]`) are ignored if `arrayFormat` is set to `'none'`.
188
188
189
189
@default {}
190
190
@@ -325,9 +325,10 @@ export type ParsedUrl = {
325
325
/**
326
326
Extract the URL and the query string as an object.
327
327
328
-
If the `parseFragmentIdentifier` option is `true`, the object will also contain a `fragmentIdentifier` property.
329
-
330
328
@param url - The URL to parse.
329
+
@returns An object with a `url` and `query` property.
330
+
331
+
If the `parseFragmentIdentifier` option is `true`, the object will also contain a `fragmentIdentifier` property.
331
332
332
333
@example
333
334
```
@@ -536,15 +537,33 @@ export type StringifyOptions = {
536
537
readonlyskipEmptyString?: boolean;
537
538
};
538
539
540
+
/**
541
+
Supported value types for query string parameters.
542
+
543
+
Note: `Symbol`, functions, and objects (except arrays) are not supported and will throw an error when stringified.
Stringify an object into a query string and sort the keys.
556
+
Stringify an object into a query string and sorting the keys.
557
+
558
+
@param object - Object to stringify. Supported value types are: `string`, `number`, `bigint`, `boolean`, `null`, `undefined`, and arrays of these types. Other types like `Symbol`, functions, or objects (except arrays) will throw an error.
// TODO: Use the below instead when the following TS issues are fixed:
@@ -559,7 +578,13 @@ export function stringify(
559
578
/**
560
579
Extract a query string from a URL that can be passed into `.parse()`.
561
580
562
-
Note: This behaviour can be changed with the `skipNull` option.
581
+
@example
582
+
```
583
+
import queryString from 'query-string';
584
+
585
+
queryString.extract('https://foo.bar?foo=bar');
586
+
//=> 'foo=bar'
587
+
```
563
588
*/
564
589
exportfunctionextract(url: string): string;
565
590
@@ -580,6 +605,10 @@ export type UrlObject = {
580
605
/**
581
606
Stringify an object into a URL with a query string and sorting the keys. The inverse of [`.parseUrl()`](https://github.com/sindresorhus/query-string#parseurlstring-options)
582
607
608
+
The `options` are the same as for `.stringify()`.
609
+
610
+
@returns A string with the URL and a query string.
611
+
583
612
Query items in the `query` property overrides queries in the `url` property.
584
613
585
614
The `fragmentIdentifier` property overrides the fragment identifier in the `url` property.
Copy file name to clipboardExpand all lines: readme.md
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,6 +52,14 @@ Parse a query string into an object. Leading `?` or `#` are ignored, so you can
52
52
53
53
The returned object is created with [`Object.create(null)`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/create) and thus does not have a `prototype`.
54
54
55
+
```js
56
+
queryString.parse('?foo=bar');
57
+
//=> {foo: 'bar'}
58
+
59
+
queryString.parse('#token=secret&name=jhon');
60
+
//=> {token: 'secret', name: 'jhon'}
61
+
```
62
+
55
63
#### options
56
64
57
65
Type: `object`
@@ -318,6 +326,8 @@ Parse the value as a boolean type instead of string type if it's a boolean.
318
326
319
327
Stringify an object into a query string and sorting the keys.
320
328
329
+
**Supported value types:** `string`, `number`, `bigint`, `boolean`, `null`, `undefined`, and arrays of these types. Other types like `Symbol`, functions, or objects (except arrays) will throw an error.
0 commit comments