• Parse a String into an Object using basic key value syntax

    Parameters

    • input: string
    • Optional decode: null | ((input) => string)
    • Optional seperator: null | string
    • Optional equals: null | string

    Returns Record<string, string>

    Example

    import { string } from "@rjweb/utils"

    string.kv('K=12') // {K:'12'}
    string.kv('E="400"') // {E:'"400"'}
    string.kv('sofhjjsihgai') // {sofhjjsihgai:''}
    string.kv('hi=ok&eeee=%20') // {hi:'ok', eeee:'%20'}
    string.kv('hi=ok&eeee=%20', decodeURIComponent) // {hi:'ok', eeee:' '}
    string.kv('aaa&bbb') // {aaa:'', bbb:''}
    string.kv('aaa#g.1', null, '#', '.') // {aaa:'', g: '1'}

    Since

    1.12.19

    Supports

    nodejs, browser