New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@alloc/path-types

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@alloc/path-types

TypeScript utility types for URL pathnames

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

@alloc/path-types

A simple package for type-level manipulation of route paths (i.e. /foo/:bar)

Usage

The two types included are InferParams and PathTemplate.

The InferParams type expects a route path string literal. It tells the type checker how to parse route paths in order to extract “route parameter names” (the :bar part in /foo/:bar) from them. It returns an object type whose keys are the route parameters. By default, the property values are a string type, but this can be customized with the 2nd type parameter.

type Params = InferParams<'/foo/:bar'>
// => { bar: string }

The PathTemplate type also expects a route path string literal. It returns a template string type where the route parameters are replaced with ${string}, so the type is useful for pathname construction.

type Pathname = PathTemplate<'/foo/:bar'>
// => `/foo/${string}`

Keywords

url

FAQs

Package last updated on 09 Oct 2024

Did you know?

Socket

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.

Install

Related posts