Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

wouter

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wouter - npm Package Compare versions

Comparing version
3.9.0
to
3.10.0
+1
-1
package.json
{
"name": "wouter",
"version": "3.9.0",
"version": "3.10.0",
"description": "Minimalist-friendly ~1.5KB router for React",

@@ -5,0 +5,0 @@ "type": "module",

@@ -234,3 +234,6 @@ import { parse as parsePattern } from "regexparam";

);
navigate(location + "?" + tempSearchParams, options);
navigate(
location + (tempSearchParams.size ? "?" + tempSearchParams : ""),
options
);
});

@@ -237,0 +240,0 @@

@@ -11,2 +11,3 @@ import mitt from "mitt";

searchPath = "",
state = null,
static: staticLocation,

@@ -16,2 +17,3 @@ record,

let initialPath = path;
const initialState = state;
if (searchPath) {

@@ -24,6 +26,7 @@ // join with & if path contains search query, and ? otherwise

let [currentPath, currentSearch = ""] = initialPath.split("?");
let currentState = initialState;
const history = [initialPath];
const emitter = mitt();
const navigateImplementation = (path, { replace = false } = {}) => {
const navigateImplementation = (path, { replace = false, state } = {}) => {
if (record) {

@@ -38,2 +41,3 @@ if (replace) {

[currentPath, currentSearch = ""] = path.split("?");
if (state !== undefined) currentState = state;
emitter.emit("navigate", path);

@@ -63,7 +67,6 @@ };

history.splice(0, history.length);
navigateImplementation(initialPath);
navigateImplementation(initialPath, { state: initialState });
}
return {
const memoryLocationResult = {
hook: useMemoryLocation,

@@ -75,2 +78,9 @@ searchHook: useMemoryQuery,

};
Object.defineProperty(memoryLocationResult, "state", {
enumerable: true,
get: () => currentState,
});
return memoryLocationResult;
};

@@ -13,20 +13,23 @@ import {

type HookReturnValue = {
type HookReturnValue<S = unknown> = {
hook: BaseLocationHook;
searchHook: BaseSearchHook;
navigate: Navigate;
navigate: Navigate<S>;
readonly state: S | null;
};
type StubHistory = { history: Path[]; reset: () => void };
export function memoryLocation(options?: {
export function memoryLocation<S = unknown>(options?: {
path?: Path;
searchPath?: SearchString;
state?: S;
static?: boolean;
record?: false;
}): HookReturnValue;
export function memoryLocation(options?: {
}): HookReturnValue<S>;
export function memoryLocation<S = unknown>(options?: {
path?: Path;
searchPath?: SearchString;
state?: S;
static?: boolean;
record: true;
}): HookReturnValue & StubHistory;
}): HookReturnValue<S> & StubHistory;