Utility library for composing compound identifiers that survive url-encoding
Note components of compound identifiers are lowercase.
- cleanComponent
- decodeComponent
- encodeComponent
- isCompoundId
- makeCompoundId
- parseCompoundId
- parseUri
- undefinedIfError
▸ cleanComponent(component
: string): string
Defined in index.ts:68
Clean a component for use (lower-case)
Parameters:
Name | Type | Description |
---|---|---|
component |
string | component string to clean up |
Returns: string
▸ decodeComponent(component
: string): string
Defined in index.ts:61
Decode a component previously wrapped by encodeCOmponent (and should be the same if it was not encoded previously)
Parameters:
Name | Type | Description |
---|---|---|
component |
string | string to decode |
Returns: string
▸ encodeComponent(component
: string): string
Defined in index.ts:53
Encode a component in an un-wrappable way
Parameters:
Name | Type | Description |
---|---|---|
component |
string | string to encode |
Returns: string
▸ isCompoundId(id
: string): boolean
Defined in index.ts:38
Determine whether the string is a compound id
Parameters:
Name | Type | Description |
---|---|---|
id |
string | string to test |
Returns: boolean
▸ makeCompoundId(primaryId
: string, secondaryId
: string): string
Defined in index.ts:46
Create a compound ID from two other ids
Parameters:
Name | Type | Description |
---|---|---|
primaryId |
string | Primary id (goes first in the list) |
secondaryId |
string | Secondary id (goes second - usually locally unique to the primary) |
Returns: string
▸ parseCompoundId(id
: string): string[]
Defined in index.ts:25
Parse a compound id (e.g. url-encoded and joined with slashses) into its constituent components
Parameters:
Name | Type | Description |
---|---|---|
id |
string |
Returns: string[]
▸ parseUri(uri
: string): string[]
Defined in index.ts:75
Parse a URI into scheme and host components for uri-ization
Parameters:
Name | Type | Description |
---|---|---|
uri |
string | URI to parse |
Returns: string[]
▸ undefinedIfError‹T›(fnc
: function, defaultValue
: T | undefined): Promise‹T | undefined›
Defined in index.ts:10
Check a function and return the defaultValue
in the event it returns an error (rather than throwing)
Type parameters:
▪ T
Type of expected return
Parameters:
▪ fnc: function
Asynchronous (promise-returning) function
▸ (): Promise‹T›
▪Default value
defaultValue: T | undefined= undefined
Value to return in the event of an error
Returns: Promise‹T | undefined›