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

use-query-params

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

use-query-params - npm Package Compare versions

Comparing version 1.1.4 to 1.1.5

6

esm/shallowEqual.d.ts

@@ -11,8 +11,6 @@ /**

* Returns true when the values of all keys are strictly equal.
*/
export default function shallowEqual(objA: any, objB: any): boolean;
/**
* @pbeshai modification of shallowEqual to take into consideration a map providing
* equals functions
*/
export declare function shallowEqualMap(objA: any, objB: any, equalMap: any): boolean;
export default function shallowEqual(objA: any, objB: any, equalMap?: any): boolean;

@@ -30,33 +30,8 @@ /**

* Returns true when the values of all keys are strictly equal.
*/
export default function shallowEqual(objA, objB) {
if (is(objA, objB)) {
return true;
}
if (typeof objA !== 'object' ||
objA === null ||
typeof objB !== 'object' ||
objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
for (var i = 0; i < keysA.length; i++) {
if (!hasOwnProperty.call(objB, keysA[i]) ||
!is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
/**
* @pbeshai modification of shallowEqual to take into consideration a map providing
* equals functions
*/
export function shallowEqualMap(objA, objB, equalMap) {
var _a;
export default function shallowEqual(objA, objB, equalMap) {
var _a, _b;
if (is(objA, objB)) {

@@ -78,3 +53,3 @@ return true;

for (var i = 0; i < keysA.length; i++) {
var isEqual = (_a = equalMap[keysA[i]].equals) !== null && _a !== void 0 ? _a : is;
var isEqual = (_b = (_a = equalMap === null || equalMap === void 0 ? void 0 : equalMap[keysA[i]]) === null || _a === void 0 ? void 0 : _a.equals) !== null && _b !== void 0 ? _b : is;
if (!hasOwnProperty.call(objB, keysA[i]) ||

@@ -81,0 +56,0 @@ !isEqual(objA[keysA[i]], objB[keysA[i]])) {

@@ -6,3 +6,3 @@ import * as React from 'react';

import { sharedMemoizedQueryParser } from './memoizedQueryParser';
import shallowEqual, { shallowEqualMap } from './shallowEqual';
import shallowEqual from './shallowEqual';
/**

@@ -57,3 +57,3 @@ * Helper to get the latest decoded values with smart caching.

// keep referential equality for decoded valus if we didn't actually change anything
var hasNewDecodedValues = !shallowEqualMap(decodedValuesCacheRef.current, decodedValues, paramConfigMap);
var hasNewDecodedValues = !shallowEqual(decodedValuesCacheRef.current, decodedValues, paramConfigMap);
return {

@@ -91,3 +91,3 @@ encodedValues: encodedValues,

useUpdateRefIfShallowNew(decodedValuesCacheRef, decodedValues, function (a, b) {
return shallowEqualMap(a, b, paramConfigMap);
return shallowEqual(a, b, paramConfigMap);
});

@@ -94,0 +94,0 @@ // create a setter for updating multiple query params at once

@@ -11,8 +11,6 @@ /**

* Returns true when the values of all keys are strictly equal.
*/
export default function shallowEqual(objA: any, objB: any): boolean;
/**
* @pbeshai modification of shallowEqual to take into consideration a map providing
* equals functions
*/
export declare function shallowEqualMap(objA: any, objB: any, equalMap: any): boolean;
export default function shallowEqual(objA: any, objB: any, equalMap?: any): boolean;

@@ -32,34 +32,8 @@ "use strict";

* Returns true when the values of all keys are strictly equal.
*/
function shallowEqual(objA, objB) {
if (is(objA, objB)) {
return true;
}
if (typeof objA !== 'object' ||
objA === null ||
typeof objB !== 'object' ||
objB === null) {
return false;
}
var keysA = Object.keys(objA);
var keysB = Object.keys(objB);
if (keysA.length !== keysB.length) {
return false;
}
// Test for A's keys different from B.
for (var i = 0; i < keysA.length; i++) {
if (!hasOwnProperty.call(objB, keysA[i]) ||
!is(objA[keysA[i]], objB[keysA[i]])) {
return false;
}
}
return true;
}
exports.default = shallowEqual;
/**
* @pbeshai modification of shallowEqual to take into consideration a map providing
* equals functions
*/
function shallowEqualMap(objA, objB, equalMap) {
var _a;
function shallowEqual(objA, objB, equalMap) {
var _a, _b;
if (is(objA, objB)) {

@@ -81,3 +55,3 @@ return true;

for (var i = 0; i < keysA.length; i++) {
var isEqual = (_a = equalMap[keysA[i]].equals) !== null && _a !== void 0 ? _a : is;
var isEqual = (_b = (_a = equalMap === null || equalMap === void 0 ? void 0 : equalMap[keysA[i]]) === null || _a === void 0 ? void 0 : _a.equals) !== null && _b !== void 0 ? _b : is;
if (!hasOwnProperty.call(objB, keysA[i]) ||

@@ -90,2 +64,2 @@ !isEqual(objA[keysA[i]], objB[keysA[i]])) {

}
exports.shallowEqualMap = shallowEqualMap;
exports.default = shallowEqual;

@@ -58,3 +58,3 @@ "use strict";

// keep referential equality for decoded valus if we didn't actually change anything
var hasNewDecodedValues = !shallowEqual_1.shallowEqualMap(decodedValuesCacheRef.current, decodedValues, paramConfigMap);
var hasNewDecodedValues = !shallowEqual_1.default(decodedValuesCacheRef.current, decodedValues, paramConfigMap);
return {

@@ -92,3 +92,3 @@ encodedValues: encodedValues,

helpers_1.useUpdateRefIfShallowNew(decodedValuesCacheRef, decodedValues, function (a, b) {
return shallowEqual_1.shallowEqualMap(a, b, paramConfigMap);
return shallowEqual_1.default(a, b, paramConfigMap);
});

@@ -95,0 +95,0 @@ // create a setter for updating multiple query params at once

{
"name": "use-query-params",
"version": "1.1.4",
"version": "1.1.5",
"description": "React Hook for managing state in URL query parameters with easy serialization.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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