Skip to content

parObj

parObj(str, base?, sep?): Record<string, string | undefined>

Defined in: core/utils/parse.ts:18

Parses a key:value:key:value string (the format used by data-* option attributes such as data-modal="width:700") into an object.

Values are always strings. An empty string gives {}. If there is an odd number of segments the last key maps to undefined.

string

String to parse.

string

Text to strip from the front of the string before parsing.

string

Separator between each key and value. Defaults to :.

Record<string, string | undefined>

parObj('width:700:align:left'); // { width: '700', align: 'left' }
parObj(''); // {}