{"_id":"set-query-string","_rev":"8-a2760210ce9892c7f8adfa2535190197","name":"set-query-string","description":"Updates/sets the browser's query string in place without adding to browser history.","dist-tags":{"latest":"2.2.0"},"versions":{"1.0.0":{"name":"set-query-string","description":"Updates/sets the browser's query string in place without adding to browser history.","version":"1.0.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/HenrikJoreteg/set-query-string/issues"},"homepage":"https://github.com/HenrikJoreteg/set-query-string#readme","keywords":["browser","pushstate","querystring","replacestate"],"license":"MIT","main":"set-query-string.js","repository":{"type":"git","url":"git+https://github.com/HenrikJoreteg/set-query-string.git"},"scripts":{"test":"standard","prepublish":"npm test"},"dependencies":{"qs":"^3.1.0"},"gitHead":"77c44d34f1105eac75953eada0f5f89f85856cd0","_id":"set-query-string@1.0.0","_shasum":"c38b0bc19c77ce5022f123e1a56560abdff24036","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"henrikjoreteg","email":"henrik@andyet.net"},"dist":{"shasum":"c38b0bc19c77ce5022f123e1a56560abdff24036","tarball":"https://registry.npmjs.org/set-query-string/-/set-query-string-1.0.0.tgz","integrity":"sha512-a6/tXNXa6yqMB9q3Kw+MEKz+AMweIHns7vxKrwDHjllPeh5L2/ui//OHJNmaDZxNEkf6jUWeznlH50ZdoyStOQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDlY6DPEKqd+GAzHgMYwVOeSDMsVwDQ9yZEZ0aVYOZDiwIgSQbxwG7QWaszodpWYNVAHTYcHqBvTMFTF9mbSrYfBSg="}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@andyet.net"}]},"2.0.0":{"name":"set-query-string","description":"Updates/sets the browser's query string in place without adding to browser history.","version":"2.0.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/HenrikJoreteg/set-query-string/issues"},"homepage":"https://github.com/HenrikJoreteg/set-query-string#readme","keywords":["browser","pushstate","querystring","replacestate"],"license":"MIT","main":"set-query-string.js","repository":{"type":"git","url":"git+https://github.com/HenrikJoreteg/set-query-string.git"},"scripts":{"test":"standard","prepublish":"npm test"},"dependencies":{"query-string":"^2.3.0"},"gitHead":"c5bbae995e3ab54f2d049ede2829d9abada8f620","_id":"set-query-string@2.0.0","_shasum":"89cd5cac097bae69b4502639f9351310318638ce","_from":".","_npmVersion":"2.10.1","_nodeVersion":"0.12.4","_npmUser":{"name":"henrikjoreteg","email":"henrik@andyet.net"},"dist":{"shasum":"89cd5cac097bae69b4502639f9351310318638ce","tarball":"https://registry.npmjs.org/set-query-string/-/set-query-string-2.0.0.tgz","integrity":"sha512-y5Go7beC7D+c+zc8N1WPW3BwjsxDtL2xtQZNs20TlicK2yvDt7Ku+LM9p5IavBo6T+Avwu1b9Gtxlm0Qy8atcw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDw28WKwCPGoReG4rQ894hEuBHZ0x7Whxz5SycS3WJkwQIhANLbur0zlrHJjZmbaJ0Ywc05750Fje1vqbuVzMWliRpX"}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@andyet.net"}]},"2.1.0":{"name":"set-query-string","description":"Updates/sets the browser's query string in place without adding to browser history.","version":"2.1.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/HenrikJoreteg/set-query-string/issues"},"homepage":"https://github.com/HenrikJoreteg/set-query-string#readme","keywords":["browser","pushstate","querystring","replacestate"],"license":"MIT","main":"set-query-string.js","repository":{"type":"git","url":"git+https://github.com/HenrikJoreteg/set-query-string.git"},"scripts":{"test":"standard","prepublish":"npm test"},"dependencies":{"query-string":"^2.3.0"},"gitHead":"0759210392a9ad3b124b68d462e5a0b0de40567b","_id":"set-query-string@2.1.0","_shasum":"c4eeef3142c140d55cf8920eb875f7b25b4607f7","_from":".","_npmVersion":"2.12.0","_nodeVersion":"0.12.4","_npmUser":{"name":"henrikjoreteg","email":"henrik@andyet.net"},"dist":{"shasum":"c4eeef3142c140d55cf8920eb875f7b25b4607f7","tarball":"https://registry.npmjs.org/set-query-string/-/set-query-string-2.1.0.tgz","integrity":"sha512-wL5KrnVncfoIIKUOjflUJQvOdE/5ge7yZW2XbDdm77z4XbpRgWCXZJ+EpQswQ1RM8MQbzzDlxXpCcyiQz5yVMg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAKfHV23auhoVD23Ddj/irzqfMcHMlYydNM2Pgx/GJKKAiEAgoCkQ5TYBgoqMdeReUQH3AowX+QwnlLTHGqNcSN9Wag="}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@andyet.net"}]},"2.2.0":{"name":"set-query-string","description":"Updates/sets the browser's query string in place without adding to browser history.","version":"2.2.0","author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/HenrikJoreteg/set-query-string/issues"},"homepage":"https://github.com/HenrikJoreteg/set-query-string#readme","keywords":["browser","pushstate","querystring","replacestate"],"license":"MIT","main":"set-query-string.js","repository":{"type":"git","url":"git+https://github.com/HenrikJoreteg/set-query-string.git"},"scripts":{"test":"standard","prepublish":"npm test"},"dependencies":{"query-string":"^2.3.0"},"gitHead":"cd9e3224d83c1cfaa4cebf25682e2b1794fe6ded","_id":"set-query-string@2.2.0","_npmVersion":"5.3.0","_nodeVersion":"6.9.5","_npmUser":{"name":"henrikjoreteg","email":"henrik@joreteg.com"},"dist":{"integrity":"sha512-p1v6HNQzKxH76fKg7b/n0Rp350sfeRm2czRuhNewmQao1scRleTRv96ObdGD7aIj4wFtmUTGxUO3UbR6Vd31RQ==","shasum":"452521ea97ca965114d764b7bd20939ed0715fe7","tarball":"https://registry.npmjs.org/set-query-string/-/set-query-string-2.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDyUQe0RHSYd3CfpAGuD5le7wFlMNA0Fzdt3mbnDkf00gIhANiwEIZ2898V4Tq155yCLPa0Kga5pOAcTBq5YP+Fysk2"}]},"maintainers":[{"name":"henrikjoreteg","email":"henrik@andyet.net"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/set-query-string-2.2.0.tgz_1503443418078_0.9308191305026412"}}},"readme":"# set-query-string\n\nUpdates/sets the browser's query string in-place without adding to browser history (unless you want to, of course).\n\nThis module uses HTML5's [`history.replaceState`](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history#The_replaceState()_method) to manipulate the query string on the page without refreshing the page.  \n\nIf not supported in your browser it's just a no-op.\n\nThis is just a thin wrapper on top of the awesome and tiny [`query-string`](https://www.npmjs.com/package/query-string) module.\n\n## Why would you want this?\n\nSometimes you want to let the user apply filters to data in your Native Web App (a.k.a. Single Page App) and still make those filters deep-linkable. So what do you do?\n\nSerialize your filter description into the URL: `awesome-app.com?color=blue&search=hair`\n\nNow the user can deep link or bookmark specific filtered views.\n\nIn browsers that don't support `replaceState` using this simply does nothing so your app still works, users simply can't deep-link your filtered views ¯\\_(ツ)_/¯.\n\n## Why bother making it a module?\n\nBecause it's nice to just be able to set an object and have it Just Work™ without having to think about installing a query string parser, etc.\n\nAlso, this automatically URI encodes/decodes values so you can use spaces and whatnot without having to think about it.\n\n## install\n\n```\nnpm install set-query-string\n```\n\n## example\n\n```javascript\nvar setQuery = require('set-query-string');\n\n// the browser's URL will be updated\n// in place without a page refresh:\n\n// before: `example.com`\nsetQuery({something: 'else'})\n// after: `example.com?something=else`\n\n// by default any other query strings are left in place\n// before: `example.com?something=else`\nsetQuery({other: 'value'})\n// after: `example.com?something=else&other=value`\n\n// you can optionally clear other values too\n// before: `example.com?something=else`\nsetQuery({other: 'value'}, {clear: true})\n// after: `example.com?other=value`\n\n// by default it uses `history.replaceState` so\n// the changed URL doesn't end up being part of the\n// \"back\" button history. If you *do* want to add\n// to it, just pass a `pushState: true` option\nsetQuery({other: 'value'}, {pushState: true})\n\n// setting values to anything falsy other than `0` removes that key\n// from the query entirely.\n// if there's no keys left, the `?` is removed too\n// before: `example.com?other=something`\n// these are all the same\nsetQuery({other: ''})\nsetQuery({other: undefined})\nsetQuery({other: null})\n// after: `example.com`\n\n// if for some reason you want to encode the string yourself\n// go for it, just pass it a string instead of an object\nvar myQueryString = '?im-special=yup'\n// this works too, if you really want it (always replaces the entire query string)\n// it ignores leading `?` if you include it, so it's safe to do it either way\nsetQuery(myQueryString)\n\n// setting query string and adding to history state\nsetQuery({other: 'value'}, {pushState: true, state: {other: 'value'}})\n\n```\n\n## binding to model property\n\nIf you happen to be using something like [ampersand-state](http://ampersandjs.com/docs#ampersand-state) you can use this module to easily bind a model property to a certain query paramater quite easily:\n\n```javascript\nimport State from 'ampersand-state'\nimport setQuery from 'set-query-string'\n\nexport default State.extend({\n  initialize () {\n    // bind `query` property to browser URL query\n    this.on('change:query', (model) => setQuery({query: model.query}))\n  },\n\n  session: {\n    query: 'string'\n  }\n})\n\n```\n\n## tests?\n\nWorks well in the apps I use it in. I'd happily take a PR that added some but it's simple enough and don't have the time right now ¯\\_(ツ)_/¯\n\n## credits\n\nIf you like this follow [@HenrikJoreteg](http://twitter.com/henrikjoreteg) on twitter.\n\n## changelog\n\n- `2.1.0`: now inert if required in non browser environment\n- `2.0.0`: use smaller, simpler `query-string` instead of `qs`\n- `1.0.0`: initial release\n\n## license\n\nMIT\n","maintainers":[{"name":"henrikjoreteg","email":"henrik@andyet.net"}],"time":{"modified":"2022-06-26T18:19:47.231Z","created":"2015-06-20T04:35:58.283Z","1.0.0":"2015-06-20T04:35:58.283Z","2.0.0":"2015-06-20T05:07:02.928Z","2.1.0":"2015-06-30T03:52:15.727Z","2.2.0":"2017-08-22T23:10:18.177Z"},"homepage":"https://github.com/HenrikJoreteg/set-query-string#readme","keywords":["browser","pushstate","querystring","replacestate"],"repository":{"type":"git","url":"git+https://github.com/HenrikJoreteg/set-query-string.git"},"author":{"name":"Henrik Joreteg","email":"henrik@joreteg.com"},"bugs":{"url":"https://github.com/HenrikJoreteg/set-query-string/issues"},"license":"MIT","readmeFilename":"README.md","users":{"adamyonk":true}}