Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jackall3n/query-parsed

A library for query string type coercion
https://github.com/jackall3n/query-parsed

Last synced: 4 days ago
JSON representation

A library for query string type coercion

Awesome Lists containing this project

README

        

# query-parsed 🔎


NPM Version
Package License
NPM Downloads

## Blurb

A library for query string type coercion

## Installation

```shell
npm install query-parsed
```

```shell
yarn add query-parsed
```

## Usage

### Parsed

```typescript
import queryparse from 'query-parsed';

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

### Arrays

```typescript
import queryparse from 'query-parsed';

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

### Typed

```typescript
import queryparse from 'query-parsed';

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

### Default

```typescript
import queryparse from 'query-parsed';

// Return Type = Record
const parsed = queryparse.parse("test=1");
```

## API

### Supported Parse Types

```typescript
String | Boolean | Number
```