UNPKG

urns

Version:

An RFC 8141 compliant URN library with some interesting type related functionality

24 lines (23 loc) 1.06 kB
/** * A full URN is one that (potentially) includes an r-component, q-component or fragment. */ export declare type FullURN<NID extends string, NSS extends string, X extends string = ""> = `urn:${NID}:${NSS}${X}`; /** * A "base" URN is one that includes _only_ the NID and the NSS (no r-component, q-component or fragment) * * The distinction can be important when trying to exploit TypeScript's "template literal types" where * we want to carefully control the possible strings that can be formulated. Removing all the optional * components minimizes the possible combinations into something easier for the type system to reason about. */ export declare type BaseURN<NID extends string, NSS extends string = string> = FullURN<NID, NSS, "">; /** * This is the information returned when a string is parsed as a URN. */ export interface ParsedURN<NID extends string = string, NSS extends string = string> { nid: NID; nss: NSS; nss_encoded: string; rcomponent: string | null; qcomponent: string | null; fragment: string | null; }