New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

j-light-router

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

j-light-router - npm Package Compare versions

Comparing version 0.0.2 to 0.1.0

4

lib/index.d.ts

@@ -6,4 +6,5 @@ export interface RouterOptions {

extended?: (RegExp | string)[];
disableHistory?: boolean;
}
export declare function createRouter({ routes, fallback, mappings, extended, }?: RouterOptions): {
export declare function createRouter({ routes, fallback, mappings, extended, disableHistory, }?: RouterOptions): {
interceptHref: (event: MouseEvent) => void;

@@ -13,2 +14,3 @@ push: (href: string) => void;

getRoute: () => string[];
destroy: () => void;
};
import { createRouteTree } from "./routeTree";
import * as util from "./util";
export function createRouter({ routes, fallback, mappings, extended, } = {}) {
export function createRouter({ routes, fallback, mappings, extended, disableHistory, } = {}) {
const props = {

@@ -70,2 +70,13 @@ routes: (routes || ["*"]).map(util.toRegExp),

}
function handlePopState(event) {
const levels = event.state?.levels;
if (!levels)
return;
event.preventDefault();
setRoute(levels);
}
!disableHistory && window.addEventListener("popstate", handlePopState);
function destroy() {
!disableHistory && window.removeEventListener("popstate", handlePopState);
}
const initialHref = new URL(window.location.toString()).pathname;

@@ -80,3 +91,4 @@ const inititalLevels = interpretHref(initialHref);

getRoute,
destroy,
};
}
{
"name": "j-light-router",
"version": "0.0.2",
"version": "0.1.0",
"description": "",

@@ -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