Options
All
  • Public
  • Public/Protected
  • All
Menu

Module "queries"

Queries

Parse url query to JSON object or stringify JSON object to url query.

import { queries } from '@mochen/yuumi';

Index

Functions

Functions

Const parse

  • parse<T>(query: string): T
  • Parse url query to JSON object.

    example
    interface Query {
     u?: string;
     x?: string;
    }
    const parsedQuery = queries.parse<Query>("u=123");

    Type parameters

    • T = Record<string, any>

    Parameters

    • query: string

    Returns T

Const stringify

  • stringify(query: Record<string, any>): string
  • Stringify JSON object to url query.

    example
    queries.stringify({
      a: '1',
      b: '2',
    });
    // a=1&b=2

    Parameters

    • query: Record<string, any>

      JSON object

    Returns string

Generated using TypeDoc