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

@contentstech/stackflow-plugin-history-sync

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contentstech/stackflow-plugin-history-sync - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

dist/ActivityRoute.d.ts

19

dist/react/index.js

@@ -238,5 +238,22 @@ "use strict";

// src/common/sortActivityRoutes.ts
var paramRe = /^:[\w-]+$/;
var dynamicSegmentValue = 3;
var emptySegmentValue = 1;
var staticSegmentValue = 10;
var splatPenalty = -2;
var isSplat = (s) => s === "*";
function computeScore(path) {
const segments = path.split("/");
let initialScore = segments.length;
if (segments.some(isSplat)) {
initialScore += splatPenalty;
}
return segments.filter((s) => !isSplat(s)).reduce(
(score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
initialScore
);
}
function sortActivityRoutes(routes) {
return [...routes].sort(
(a, b) => makeTemplate(a).variableCount - makeTemplate(b).variableCount
(a, b) => computeScore(b.path) - computeScore(a.path)
);

@@ -243,0 +260,0 @@ }

@@ -238,5 +238,22 @@ "use strict";

// src/common/sortActivityRoutes.ts
var paramRe = /^:[\w-]+$/;
var dynamicSegmentValue = 3;
var emptySegmentValue = 1;
var staticSegmentValue = 10;
var splatPenalty = -2;
var isSplat = (s) => s === "*";
function computeScore(path) {
const segments = path.split("/");
let initialScore = segments.length;
if (segments.some(isSplat)) {
initialScore += splatPenalty;
}
return segments.filter((s) => !isSplat(s)).reduce(
(score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
initialScore
);
}
function sortActivityRoutes(routes) {
return [...routes].sort(
(a, b) => makeTemplate(a).variableCount - makeTemplate(b).variableCount
(a, b) => computeScore(b.path) - computeScore(a.path)
);

@@ -243,0 +260,0 @@ }

@@ -238,5 +238,22 @@ "use strict";

// src/common/sortActivityRoutes.ts
var paramRe = /^:[\w-]+$/;
var dynamicSegmentValue = 3;
var emptySegmentValue = 1;
var staticSegmentValue = 10;
var splatPenalty = -2;
var isSplat = (s) => s === "*";
function computeScore(path) {
const segments = path.split("/");
let initialScore = segments.length;
if (segments.some(isSplat)) {
initialScore += splatPenalty;
}
return segments.filter((s) => !isSplat(s)).reduce(
(score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
initialScore
);
}
function sortActivityRoutes(routes) {
return [...routes].sort(
(a, b) => makeTemplate(a).variableCount - makeTemplate(b).variableCount
(a, b) => computeScore(b.path) - computeScore(a.path)
);

@@ -243,0 +260,0 @@ }

@@ -231,5 +231,22 @@ "use strict";

// src/common/sortActivityRoutes.ts
var paramRe = /^:[\w-]+$/;
var dynamicSegmentValue = 3;
var emptySegmentValue = 1;
var staticSegmentValue = 10;
var splatPenalty = -2;
var isSplat = (s) => s === "*";
function computeScore(path) {
const segments = path.split("/");
let initialScore = segments.length;
if (segments.some(isSplat)) {
initialScore += splatPenalty;
}
return segments.filter((s) => !isSplat(s)).reduce(
(score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue),
initialScore
);
}
function sortActivityRoutes(routes) {
return [...routes].sort(
(a, b) => makeTemplate(a).variableCount - makeTemplate(b).variableCount
(a, b) => computeScore(b.path) - computeScore(a.path)
);

@@ -236,0 +253,0 @@ }

2

package.json
{
"name": "@contentstech/stackflow-plugin-history-sync",
"version": "0.1.0",
"version": "0.2.0",
"repository": {

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

@@ -38,7 +38,7 @@ import { sortActivityRoutes } from "./sortActivityRoutes";

expect(routes).toStrictEqual([
{ activityName: "C", path: "/:hello/:world/:foo/:bar" },
{ activityName: "A", path: "/detailed/*" },
{ activityName: "B", path: "/:hello/:world" },
{ activityName: "C", path: "/:hello/:world/:foo/:bar" },
{ activityName: "A", path: "*" },
]);
});
import type { ActivityRoute } from "./ActivityRoute";
import { makeTemplate } from "./makeTemplate";
const paramRe = /^:[\w-]+$/;
const dynamicSegmentValue = 3;
const emptySegmentValue = 1;
const staticSegmentValue = 10;
const splatPenalty = -2;
const isSplat = (s: string) => s === "*";
/**
* https://github.com/remix-run/react-router/blob/0f2b167e9b862d5e6b3425438787c8e7b39197f4/packages/router/utils.ts#L742-L773
*/
function computeScore(path: string): number {
const segments = path.split("/");
let initialScore = segments.length;
if (segments.some(isSplat)) {
initialScore += splatPenalty;
}
return segments
.filter((s) => !isSplat(s))
.reduce(
(score, segment) =>
score +
(paramRe.test(segment)
? dynamicSegmentValue
: segment === ""
? emptySegmentValue
: staticSegmentValue),
initialScore,
);
}
export function sortActivityRoutes<T>(

@@ -8,4 +38,4 @@ routes: ActivityRoute<T>[],

return [...routes].sort(
(a, b) => makeTemplate(a).variableCount - makeTemplate(b).variableCount,
(a, b) => computeScore(b.path) - computeScore(a.path),
);
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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