Skip to content

jackall3n/query-parsed

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

query-parsed 🔎

NPM Version Package License NPM Downloads

Blurb

A library for query string type coercion

Installation

npm install query-parsed
yarn add query-parsed

Usage

Parsed

import queryparse from 'query-parsed';

// Return Type = { test: number }
const parsed = queryparse.parse("test=1", { test: Number });

Arrays

import queryparse from 'query-parsed';

// Return Type = { test: number[] }
const parsed = queryparse.parse("test=1,2", { test: [Number] }, { arrayFormat: "comma" });

Typed

import queryparse from 'query-parsed';

// Return Type = { test: string }
const parsed = queryparse.parse<{ test: string }>("test=1");

Default

import queryparse from 'query-parsed';

// Return Type = Record<string, string | string[]>
const parsed = queryparse.parse("test=1");

API

Supported Parse Types

String | Boolean | Number

About

A library for query string type coercion

Resources

Stars

Watchers

Forks