
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
@e22m4u/js-path-trie
Advanced tools
Маршрутизатор для Node.js на основе префиксного дерева (trie).
Требуется Node.js 16 и выше.
npm install @e22m4u/js-path-trie
Модуль поддерживает ESM и CommonJS стандарты.
ESM
import {PathTrie} from '@e22m4u/js-path-trie';
CommonJS
const {PathTrie} = require('@e22m4u/js-path-trie');
Класс PathTrie
имеет следующие методы:
add(pathTemplate: string, value: unknown)
добавить значение к новому маршрутуmatch(path: string)
поиск значения по заданному маршрутуПример:
import {PathTrie} from '@e22m4u/js-path-trie';
const trie = new PathTrie();
// добавление маршрутов выполняется
// методом "add", который принимает
// шаблон маршрута и его значение
trie.add('/foo/bar', yourValue1);
trie.add('/foo/:p1/bar/:p2', yourValue2);
// для поиска значения используется
// метод "match", который возвращает
// значение маршрута и его параметры
trie.match('/foo/bar');
// {
// value: yourValue1,
// params: {}
// }
// если маршрут имеет параметры,
// то их значения вернуться
// в результате поиска
trie.match('/foo/10/bar/20');
// {
// value: yourValue2,
// params: {p1: 10, p2: 20}
// }
// если маршрут не найден,
// то возвращается "undefined"
trie.match('/foo/bar/baz');
// undefined
Установка переменной DEBUG
включает вывод логов.
DEBUG=jsPathTrie* npm run test
npm run test
MIT
FAQs
Маршрутизатор для Node.js на основе префиксного дерева
We found that @e22m4u/js-path-trie demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.