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

qhistory

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qhistory - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

52

es/index.js

@@ -15,4 +15,14 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

if ((typeof location === 'undefined' ? 'undefined' : _typeof(location)) === 'object') {
location.search = location.query ? stringify(location.query) : location.search || '';
var search = location.search || '';
if (location.query) {
search = stringify(location.query);
// Ensure leading "?" for non-empty search
if (search.length > 0 && search.charAt(0) !== '?') {
search = '?' + search;
}
}
return _extends({}, location, { search: search });
}
return location;
};

@@ -23,11 +33,9 @@

if (search) {
location.query = parse(search.charAt(0) === '?' ? search.substring(1) : search);
} else {
location.query = {};
}
return _extends({}, location, {
query: search ? parse(search.charAt(0) === '?' ? search.substring(1) : search) : {}
});
};
var updateProperties = function updateProperties(history) {
var properties = ['location', 'length', 'entries', 'index', 'action'];
var properties = ['length', 'entries', 'index', 'action'];
properties.forEach(function (prop) {

@@ -47,24 +55,34 @@ if (history.hasOwnProperty(prop)) {

history.listen(function (location) {
addQuery(location);
updateProperties(history);
});
// make sure that the initial location has query support
addQuery(history.location);
var queryHistory = _extends({}, history, {
listen: function listen(listener) {
return history.listen(function (location, action) {
var isV5 = location.location != null;
if (isV5) {
action = location.action;
location = location.location;
}
var queryLocation = addQuery(location);
isV5 ? listener({ location: queryLocation, action: action }) : listener(queryLocation, action);
});
},
push: function push(location, state) {
addSearch(location);
history.push(location, state);
return history.push(addSearch(location), state);
},
replace: function replace(location, state) {
addSearch(location);
history.replace(location, state);
return history.replace(addSearch(location), state);
},
createHref: function createHref(location) {
addSearch(location);
return history.createHref(location);
return history.createHref(addSearch(location));
}
});
Object.defineProperty(queryHistory, 'location', {
get: function get() {
return addQuery(history.location);
}
});
return queryHistory;

@@ -71,0 +89,0 @@ };

@@ -23,4 +23,14 @@ 'use strict';

if ((typeof location === 'undefined' ? 'undefined' : _typeof(location)) === 'object') {
location.search = location.query ? stringify(location.query) : location.search || '';
var search = location.search || '';
if (location.query) {
search = stringify(location.query);
// Ensure leading "?" for non-empty search
if (search.length > 0 && search.charAt(0) !== '?') {
search = '?' + search;
}
}
return _extends({}, location, { search: search });
}
return location;
};

@@ -31,11 +41,9 @@

if (search) {
location.query = parse(search.charAt(0) === '?' ? search.substring(1) : search);
} else {
location.query = {};
}
return _extends({}, location, {
query: search ? parse(search.charAt(0) === '?' ? search.substring(1) : search) : {}
});
};
var updateProperties = function updateProperties(history) {
var properties = ['location', 'length', 'entries', 'index', 'action'];
var properties = ['length', 'entries', 'index', 'action'];
properties.forEach(function (prop) {

@@ -55,24 +63,34 @@ if (history.hasOwnProperty(prop)) {

history.listen(function (location) {
addQuery(location);
updateProperties(history);
});
// make sure that the initial location has query support
addQuery(history.location);
var queryHistory = _extends({}, history, {
listen: function listen(listener) {
return history.listen(function (location, action) {
var isV5 = location.location != null;
if (isV5) {
action = location.action;
location = location.location;
}
var queryLocation = addQuery(location);
isV5 ? listener({ location: queryLocation, action: action }) : listener(queryLocation, action);
});
},
push: function push(location, state) {
addSearch(location);
history.push(location, state);
return history.push(addSearch(location), state);
},
replace: function replace(location, state) {
addSearch(location);
history.replace(location, state);
return history.replace(addSearch(location), state);
},
createHref: function createHref(location) {
addSearch(location);
return history.createHref(location);
return history.createHref(addSearch(location));
}
});
Object.defineProperty(queryHistory, 'location', {
get: function get() {
return addQuery(history.location);
}
});
return queryHistory;

@@ -79,0 +97,0 @@ };

{
"name": "qhistory",
"version": "1.0.3",
"version": "1.1.0",
"description": "Wrap history with query support",

@@ -55,3 +55,3 @@ "main": "lib/index.js",

"cross-env": "^3.1.4",
"history": "^4.5.1",
"history": "^5.0.0",
"jest": "^18.1.0",

@@ -58,0 +58,0 @@ "qs": "^6.3.0",

@@ -162,4 +162,14 @@ (function webpackUniversalModuleDefinition(root, factory) {

if ((typeof location === 'undefined' ? 'undefined' : _typeof(location)) === 'object') {
location.search = location.query ? stringify(location.query) : location.search || '';
var search = location.search || '';
if (location.query) {
search = stringify(location.query);
// Ensure leading "?" for non-empty search
if (search.length > 0 && search.charAt(0) !== '?') {
search = '?' + search;
}
}
return _extends({}, location, { search: search });
}
return location;
};

@@ -170,11 +180,9 @@

if (search) {
location.query = parse(search.charAt(0) === '?' ? search.substring(1) : search);
} else {
location.query = {};
}
return _extends({}, location, {
query: search ? parse(search.charAt(0) === '?' ? search.substring(1) : search) : {}
});
};
var updateProperties = function updateProperties(history) {
var properties = ['location', 'length', 'entries', 'index', 'action'];
var properties = ['length', 'entries', 'index', 'action'];
properties.forEach(function (prop) {

@@ -194,24 +202,34 @@ if (history.hasOwnProperty(prop)) {

history.listen(function (location) {
addQuery(location);
updateProperties(history);
});
// make sure that the initial location has query support
addQuery(history.location);
var queryHistory = _extends({}, history, {
listen: function listen(listener) {
return history.listen(function (location, action) {
var isV5 = location.location != null;
if (isV5) {
action = location.action;
location = location.location;
}
var queryLocation = addQuery(location);
isV5 ? listener({ location: queryLocation, action: action }) : listener(queryLocation, action);
});
},
push: function push(location, state) {
addSearch(location);
history.push(location, state);
return history.push(addSearch(location), state);
},
replace: function replace(location, state) {
addSearch(location);
history.replace(location, state);
return history.replace(addSearch(location), state);
},
createHref: function createHref(location) {
addSearch(location);
return history.createHref(location);
return history.createHref(addSearch(location));
}
});
Object.defineProperty(queryHistory, 'location', {
get: function get() {
return addQuery(history.location);
}
});
return queryHistory;

@@ -218,0 +236,0 @@ };

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.qhistory=t():e.qhistory=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=1)}([function(e,t,n){"use strict";var r=function(e,t,n,r,o,i,u,f){if(!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var s=[n,r,o,i,u,f],a=0;c=new Error(t.replace(/%s/g,function(){return s[a++]})),c.name="Invariant Violation"}throw c.framesToPop=1,c}};e.exports=r},function(e,t,n){"use strict";t.__esModule=!0;var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},i=n(0),u=function(e){return e&&e.__esModule?e:{default:e}}(i),f=function(e,t,n){(0,u.default)("function"==typeof t,"A stringify function is required in order to transform query objects into search strings."),(0,u.default)("function"==typeof n,"A parse function is required in order to transform search strings into query objects.");var i=function(e){"object"===(void 0===e?"undefined":o(e))&&(e.search=e.query?t(e.query):e.search||"")},f=function(e){var t=e.search;e.query=t?n("?"===t.charAt(0)?t.substring(1):t):{}},c=function(e){["location","length","entries","index","action"].forEach(function(t){e.hasOwnProperty(t)&&(s[t]=e[t])})};e.listen(function(t){f(t),c(e)}),f(e.location);var s=r({},e,{push:function(t,n){i(t),e.push(t,n)},replace:function(t,n){i(t),e.replace(t,n)},createHref:function(t){return i(t),e.createHref(t)}});return s};t.default=f}])});
!function(n,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.qhistory=t():n.qhistory=t()}(this,function(){return function(n){function t(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return n[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var e={};return t.m=n,t.c=e,t.i=function(n){return n},t.d=function(n,e,r){t.o(n,e)||Object.defineProperty(n,e,{configurable:!1,enumerable:!0,get:r})},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=1)}([function(n,t,e){"use strict";var r=function(n,t,e,r,o,i,u,c){if(!n){var f;if(void 0===t)f=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var a=[e,r,o,i,u,c],s=0;f=new Error(t.replace(/%s/g,function(){return a[s++]})),f.name="Invariant Violation"}throw f.framesToPop=1,f}};n.exports=r},function(n,t,e){"use strict";t.__esModule=!0;var r=Object.assign||function(n){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r])}return n},o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(n){return typeof n}:function(n){return n&&"function"==typeof Symbol&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},i=e(0),u=function(n){return n&&n.__esModule?n:{default:n}}(i),c=function(n,t,e){(0,u.default)("function"==typeof t,"A stringify function is required in order to transform query objects into search strings."),(0,u.default)("function"==typeof e,"A parse function is required in order to transform search strings into query objects.");var i=function(n){if("object"===(void 0===n?"undefined":o(n))){var e=n.search||"";return n.query&&(e=t(n.query),e.length>0&&"?"!==e.charAt(0)&&(e="?"+e)),r({},n,{search:e})}return n},c=function(n){var t=n.search;return r({},n,{query:t?e("?"===t.charAt(0)?t.substring(1):t):{}})},f=function(n){["length","entries","index","action"].forEach(function(t){n.hasOwnProperty(t)&&(a[t]=n[t])})};n.listen(function(t){f(n)});var a=r({},n,{listen:function(t){return n.listen(function(n,e){var r=null!=n.location;r&&(e=n.action,n=n.location);var o=c(n);r?t({location:o,action:e}):t(o,e)})},push:function(t,e){return n.push(i(t),e)},replace:function(t,e){return n.replace(i(t),e)},createHref:function(t){return n.createHref(i(t))}});return Object.defineProperty(a,"location",{get:function(){return c(n.location)}}),a};t.default=c}])});
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