Comparing version 0.1.0 to 1.0.0
28
index.js
@@ -1,22 +0,16 @@ | ||
const createHistory = require('history').createBrowserHistory; | ||
const queryString = require('query-string'); | ||
const objectAssign = require('object-assign'); | ||
const history = createHistory(); | ||
function gString(obj, hash) { | ||
const newHash = hash || location.hash; | ||
const query = Object.assign({}, queryString.parse(location.search), obj); | ||
const newQuery = queryString.stringify(query); | ||
history.push(`${location.pathname}?${newQuery}`); | ||
module.exports = function (obj, hash) { | ||
let query = queryString.stringify( | ||
objectAssign( | ||
{}, | ||
queryString.parse(global.window.location.search), | ||
obj | ||
) | ||
); | ||
if (hash) { | ||
location.hash = newHash; | ||
query = query + '#' + hash || ''; | ||
} | ||
} | ||
module.exports = { | ||
gString, | ||
hListen: history.listen, | ||
qParse: queryString.parse | ||
return query; | ||
}; |
{ | ||
"name": "g-string", | ||
"version": "0.1.0", | ||
"version": "1.0.0", | ||
"description": "Manages query string", | ||
@@ -12,3 +12,4 @@ "main": "index.js", | ||
"query", | ||
"string" | ||
"string", | ||
"url" | ||
], | ||
@@ -25,7 +26,16 @@ "author": { | ||
"homepage": "https://github.com/gyfchong/g-string#readme", | ||
"scripts": { | ||
"test": "xo && ava" | ||
}, | ||
"dependencies": { | ||
"history": "^4.6.3", | ||
"object-assign": "^4.1.1", | ||
"query-string": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.22.0", | ||
"xo": "^0.18.2" | ||
}, | ||
"globals": { | ||
"window": true | ||
} | ||
} |
# g-string | ||
> Manage your query string parameters | ||
## Why? | ||
Because React Router v4 doesn't manage query strings anymore, so I built my own :) | ||
## Install | ||
@@ -5,0 +8,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
124730
2
7
28
1
24
2
- Removedhistory@^4.6.3
- Removed@babel/runtime@7.26.0(transitive)
- Removedhistory@4.10.1(transitive)
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedresolve-pathname@3.0.0(transitive)
- Removedtiny-invariant@1.3.3(transitive)
- Removedtiny-warning@1.0.3(transitive)
- Removedvalue-equal@1.0.1(transitive)