Socket
Socket
Sign inDemoInstall

awesome-querystring

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    awesome-querystring

Awesome and robust querystring


Version published
Weekly downloads
7
increased by133.33%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

logo

Awesome Querystring

Querystring that is robust in its working yet remains awesome to TypeScript users

DepfuLicenseBuild Status

NPM bundle size (minified)NPM bundle size (minified + gzip)NPM VersionNPM Weekly DownloadsNPM Total Downloads

Follow me on TwitterDonate with PayPalBecome a Patron

Join Discord Server
NPM Stats


Created out of a frustration with the node default querystring as well as for TypeScript based projects that do not require @types/node

Install

Install with yarn:

$ yarn add awesome-querystring

Usage

Stringify

Create a querystring from a JS object

const { stringify } = require('awesome-querystring');
// or for TypeScript:
// import { stringify } from 'awesome-querystring';

console.log(stringify({prop: 'value', prop2: 'value2'}));
//=> '?prop=value&prop2=value2'

// supply options
console.log(stringify({prop: 'value', prop2: 'value2'}, {separator: '&', equals: '=', includeQuestion: true}));
//=> '?prop=value&prop2=value2'

// customize options
console.log(stringify({prop: 'value', prop2: 'value2'}, {separator: '&&', equals: '=', includeQuestion: false}));
//=> 'prop=value&&prop2=value2'

Parse

Create a JS object from a querystring

const { parse } = require('awesome-querystring');
// or for TypeScript:
// import { parse } from 'awesome-querystring';

console.log(parse('?prop=value&prop2=value2'));
//=> {prop: 'value', prop2: 'value2'}

// supply options
console.log(parse('?prop=value&prop2=value2', {separator: '&', equals: '='}));
//=> {prop: 'value', prop2: 'value2'}

// customize options
console.log(parse('prop=value&&prop2=value2', {separator: '&&', equals: '='}));
//=> {prop: 'value', prop2: 'value2'}

Documentation

Functions

stringify(obj, [options])string

Stringifies an object

parse(qs, [options])IAwesomeQuerystringObject

Parses a querystring back to an object

Typedefs

IStringifyOptions : IStringifyOptions

Options for the Stringify function

IParseOptions : IParseOptions

Options for the Parse function

stringify(obj, [options]) ⇒ string

Stringifies an object

Kind: global function

ParamTypeDescription
objIAwesomeQuerystringObject

Object to stringify

[options]IStringifyOptions

Options for the stringify, see IStringifyOptions

parse(qs, [options]) ⇒ IAwesomeQuerystringObject

Parses a querystring back to an object

Kind: global function

ParamTypeDescription
qsstring

Querystring to parse

[options]IParseOptions

Options for the parse, see IParseOptions

IStringifyOptions : IStringifyOptions

Options for the Stringify function

Kind: global typedef
Properties

NameTypeDescription
separatorstring

separator the querystring should get

equalsstring

equals sign the querystring should use

includeQuestionboolean

whether the querystring should be prefixed with a ?

IParseOptions : IParseOptions

Options for the Parse function

Kind: global typedef
Properties

NameTypeDescription
separatorstring

separator the querystring has

equalsstring

equals sign the querystring has


About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

License

Copyright © 2018-2019, Favna. Released under the MIT License.

Buy me a donut

This project is open source and always will be, even if I don't get donations. That said, I know there are people out there that may still want to donate just to show their appreciation so this is for you guys. Thanks in advance!

I accept donations through PayPal, BitCoin, Ethereum and LiteCoin. You can use the buttons below to donate through your method of choice

Donate WithQRAddress
Donate with PayPal
1E643TNif2MTh75rugepmXuq35Tck4TnE5
0xF653F666903cd8739030D2721bF01095896F5D6E
LZHvBkaJqKJRa8N7Dyu41Jd1PDBAofCik6

Keywords

FAQs

Last updated on 26 Feb 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc