{
"_from": "query-string@6.8.2",
"_id": "query-string@6.8.2",
"_inBundle": false,
"_integrity": "sha512-J3Qi8XZJXh93t2FiKyd/7Ec6GNifsjKXUsVFkSBj/kjLsDylWhnCz4NT1bkPcKotttPW+QbKGqqPH8OoI2pdqw==",
"_location": "/npm/query-string",
"_phantomChildren": {},
"_requested": {
"escapedName": "query-string",
"fetchSpec": "6.8.2",
"name": "query-string",
"raw": "query-string@6.8.2",
"rawSpec": "6.8.2",
"registry": true,
"saveSpec": null,
"type": "version"
},
"_requiredBy": [
"#USER",
"/npm"
],
"_resolved": "https://registry.npmjs.org/query-string/-/query-string-6.8.2.tgz",
"_shasum": "36cb7e452ae11a4b5e9efee83375e0954407b2f6",
"_shrinkwrap": null,
"_spec": "query-string@6.8.2",
"_where": "/Users/isaacs/dev/npm/cli",
"author": {
"email": "sindresorhus@gmail.com",
"name": "Sindre Sorhus",
"url": "sindresorhus.com"
},
"bugs": {
"url": "https://github.com/sindresorhus/query-string/issues"
},
"bundleDependencies": false,
"dependencies": {
"decode-uri-component": "^0.2.0",
"split-on-first": "^1.0.0",
"strict-uri-encode": "^2.0.0"
},
"deprecated": false,
"description": "Parse and stringify URL query strings",
"devDependencies": {
"ava": "^1.4.1",
"deep-equal": "^1.0.1",
"fast-check": "^1.5.0",
"tsd": "^0.7.3",
"xo": "^0.24.0"
},
"engines": {
"node": ">=6"
},
"files": [
"index.d.ts",
"index.js"
],
"homepage": "https://github.com/sindresorhus/query-string#readme",
"keywords": [
"browser",
"decode",
"encode",
"param",
"parameter",
"parse",
"qs",
"query",
"querystring",
"searchparams",
"string",
"stringify",
"url"
],
"license": "MIT",
"name": "query-string",
"optionalDependencies": {},
"readme": "# query-string [](https://travis-ci.org/sindresorhus/query-string)\n\n> Parse and stringify URL [query strings](https://en.wikipedia.org/wiki/Query_string)\n\n\n## Install\n\n```\n$ npm install query-string\n```\n\nThis module targets Node.js 6 or later and the latest version of Chrome, Firefox, and Safari. If you want support for older browsers, or, [if your project is using create-react-app v1](https://github.com/sindresorhus/query-string/pull/148#issuecomment-399656020), use version 5: `npm install query-string@5`.\n\n\n## Usage\n\n```js\nconst queryString = require('query-string');\n\nconsole.log(location.search);\n//=> '?foo=bar'\n\nconst parsed = queryString.parse(location.search);\nconsole.log(parsed);\n//=> {foo: 'bar'}\n\nconsole.log(location.hash);\n//=> '#token=bada55cafe'\n\nconst parsedHash = queryString.parse(location.hash);\nconsole.log(parsedHash);\n//=> {token: 'bada55cafe'}\n\nparsed.foo = 'unicorn';\nparsed.ilike = 'pizza';\n\nconst stringified = queryString.stringify(parsed);\n//=> 'foo=unicorn&ilike=pizza'\n\nlocation.search = stringified;\n// note that `location.search` automatically prepends a question mark\nconsole.log(location.search);\n//=> '?foo=unicorn&ilike=pizza'\n```\n\n\n## API\n\n### .parse(string, options?)\n\nParse a query string into an object. Leading `?` or `#` are ignored, so you can pass `location.search` or `location.hash` directly.\n\nThe 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`.\n\n#### options\n\nType: `object`\n\n##### decode\n\nType: `boolean`<br>\nDefault: `true`\n\nDecode the keys and values. URL components are decoded with [`decode-uri-component`](https://github.com/SamVerschueren/decode-uri-component).\n\n##### arrayFormat\n\nType: `string`<br>\nDefault: `'none'`\n\n- `'bracket'`: Parse arrays with bracket representation:\n\n```js\nqueryString.parse('foo[]=1&foo[]=2&foo[]=3', {arrayFormat: 'bracket'});\n//=> {foo: ['1', '2', '3']}\n```\n\n- `'index'`: Parse arrays with index representation:\n\n```js\nqueryString.parse('foo[0]=1&foo[1]=2&foo[3]=3', {arrayFormat: 'index'});\n//=> {foo: ['1', '2', '3']}\n```\n\n- `'comma'`: Parse arrays with elements separated by comma:\n\n```js\nqueryString.parse('foo=1,2,3', {arrayFormat: 'comma'});\n//=> {foo: ['1', '2', '3']}\n```\n\n- `'none'`: Parse arrays with elements using duplicate keys:\n\n```js\nqueryString.parse('foo=1&foo=2&foo=3');\n//=> {foo: ['1', '2', '3']}\n```\n\n##### sort\n\nType: `Function | boolean`<br>\nDefault: `true`\n\nSupports both `Function` as a custom sorting function or `false` to disable sorting.\n\n##### parseNumbers\n\nType: `boolean`<br>\nDefault: `false`\n\n```js\nqueryString.parse('foo=1', {parseNumbers: true});\n//=> {foo: 1}\n```\n\nParse the value as a number type instead of string type if it's a number.\n\n##### parseBooleans\n\nType: `boolean`<br>\nDefault: `false`\n\n```js\nqueryString.parse('foo=true', {parseBooleans: true});\n//=> {foo: true}\n```\n\nParse the value as a boolean type instead of string type if it's a boolean.\n\n### .stringify(object, [options])\n\nStringify an object into a query string and sorting the keys.\n\n#### options\n\nType: `object`\n\n##### strict\n\nType: `boolean`<br>\nDefault: `true`\n\nStrictly encode URI components with [strict-uri-encode](https://github.com/kevva/strict-uri-encode). It uses [encodeURIComponent](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) if set to false. You probably [don't care](https://github.com/sindresorhus/query-string/issues/42) about this option.\n\n##### encode\n\nType: `boolean`<br>\nDefault: `true`\n\n[URL encode](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) the keys and values.\n\n##### arrayFormat\n\nType: `string`<br>\nDefault: `'none'`\n\n- `'bracket'`: Serialize arrays using bracket representation:\n\n```js\nqueryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'bracket'});\n//=> 'foo[]=1&foo[]=2&foo[]=3'\n```\n\n- `'index'`: Serialize arrays using index representation:\n\n```js\nqueryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'index'});\n//=> 'foo[0]=1&foo[1]=2&foo[2]=3'\n```\n\n- `'comma'`: Serialize arrays by separating elements with comma:\n\n```js\nqueryString.stringify({foo: [1, 2, 3]}, {arrayFormat: 'comma'});\n//=> 'foo=1,2,3'\n```\n\n- `'none'`: Serialize arrays by using duplicate keys:\n\n```js\nqueryString.stringify({foo: [1, 2, 3]});\n//=> 'foo=1&foo=2&foo=3'\n```\n\n##### sort\n\nType: `Function | boolean`\n\nSupports both `Function` as a custom sorting function or `false` to disable sorting.\n\n```js\nconst order = ['c', 'a', 'b'];\n\nqueryString.stringify({a: 1, b: 2, c: 3}, {\n\tsort: (a, b) => order.indexOf(a) - order.indexOf(b)\n});\n//=> 'c=3&a=1&b=2'\n```\n\n```js\nqueryString.stringify({b: 1, c: 2, a: 3}, {sort: false});\n//=> 'b=1&c=2&a=3'\n```\n\nIf omitted, keys are sorted using `Array#sort()`, which means, converting them to strings and comparing strings in Unicode code point order.\n\n### .extract(string)\n\nExtract a query string from a URL that can be passed into `.parse()`.\n\n### .parseUrl(string, options?)\n\nExtract the URL and the query string as an object.\n\nThe `options` are the same as for `.parse()`.\n\nReturns an object with a `url` and `query` property.\n\n```js\nqueryString.parseUrl('https://foo.bar?foo=bar');\n//=> {url: 'https://foo.bar', query: {foo: 'bar'}}\n```\n\n\n## Nesting\n\nThis module intentionally doesn't support nesting as it's not spec'd and varies between implementations, which causes a lot of [edge cases](https://github.com/visionmedia/node-querystring/issues).\n\nYou're much better off just converting the object to a JSON string:\n\n```js\nqueryString.stringify({\n\tfoo: 'bar',\n\tnested: JSON.stringify({\n\t\tunicorn: 'cake'\n\t})\n});\n//=> 'foo=bar&nested=%7B%22unicorn%22%3A%22cake%22%7D'\n```\n\nHowever, there is support for multiple instances of the same key:\n\n```js\nqueryString.parse('likes=cake&name=bob&likes=icecream');\n//=> {likes: ['cake', 'icecream'], name: 'bob'}\n\nqueryString.stringify({color: ['taupe', 'chartreuse'], id: '515'});\n//=> 'color=taupe&color=chartreuse&id=515'\n```\n\n\n## Falsy values\n\nSometimes you want to unset a key, or maybe just make it present without assigning a value to it. Here is how falsy values are stringified:\n\n```js\nqueryString.stringify({foo: false});\n//=> 'foo=false'\n\nqueryString.stringify({foo: null});\n//=> 'foo'\n\nqueryString.stringify({foo: undefined});\n//=> ''\n```\n\n\n---\n\n<div align=\"center\">\n\t<b>\n\t\t<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>\n\t</b>\n\t<br>\n\t<sub>\n\t\tTidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.\n\t</sub>\n</div>\n",
"readmeFilename": "readme.md",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/query-string.git"
},
"scripts": {
"test": "xo && ava && tsd"
},
"version": "6.8.2"
}