Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

qstring

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

qstring

Comprehensive lightweight query string parser and stringifier + free parsing/output of process.argv.

  • 0.0.9
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

qstring

Comprehensive lightweight query string parser and stringifier + free parsing/output of process.argv.

Features:

  • import { stringify, parse, parseProcessArgs } from 'qstring' (or qstring/dist/ for es2015)
  • stringify(object); -> string
  • parse(queryString); -> object
  • parseProcessArgs(process.argv); -> object
  • toProcessArgs(object) -> string
  • 164 SLOC (3.5KiB built vs 1.5KiB GZipped)
  • Dependency free.
  • Performant, less than 1ms for below object on a Dell D430 (2 cores, 1.2Gz, 2GB of RAM)
const object = {
  '': 'defaultParamValue',
  example: [123.5, 252.23, 3, 'gaben'],
  level1Name: 'name',
  level1: {
    title: 'level1',
    '@$^strange~)*': '@:~)',
    level2: {
      level3Args: [1, 2, 'c'],
      level3: [{
        level4: 'foo'
      }, , {
        level4: 'bar'
      }]
    }
  }
};

// Output below.

//for readability purposes, using a multiline
const queryString = `
  ?defaultParamValue
  &example[0]=123.5
  &example[1]=252.23
  &example[2]=3
  &example[3]=gaben
  &level1Name=name
  &level1.title=level1
  &level1.%40%24%5Estrange~)*=%40%3A~)
  &level1.level2.level3Args=1
  &level1.level2.level3Args=2
  &level1.level2.level3Args=c
  &level1.level2.level3[].level4=foo
  &level1.level2.level3[2].level4=bar
`.replace(/[\n\t ]/g, ''); //strip all newlines and tabs

const processArgs = `
  --defaultParam 
  --example[0]=123.5 
  --example[1]=252.23 
  --example[2]=3 
  --example[3]=gaben 
  --level1Name=name 
  --level1.title=level1 
  --level1.@$^strange~)*=@:~) 
  --level1.level2.level3Args[0]=1 
  --level1.level2.level3Args[1]=2 
  --level1.level2.level3Args[2]=c --level1.level2.level3[0].level4=foo --level1.level2.level3[2].level4=bar'

Thanks, and have fun. You can email:dev@rob.pw, I sometimes take project requests/commissions.

FAQs

Package last updated on 25 Aug 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc