@raydeck/id-components
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

id-components

Utility library for composing compound identifiers that survive url-encoding

Note components of compound identifiers are lowercase.

@raydeck/id-components - v1.0.3

Index

Functions

Functions

cleanComponent

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

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

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

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

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

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

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

undefinedIfErrorT›(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›

Readme

Keywords

none

Package Sidebar

Install

npm i @raydeck/id-components

Weekly Downloads

3

Version

1.0.3

License

MIT

Unpacked Size

15.6 kB

Total Files

7

Last publish

Collaborators

  • raydeck