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

fast-querystring

Package Overview
Dependencies
Maintainers
2
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-querystring

A fast alternative to legacy querystring module

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.2M
decreased by-18.45%
Maintainers
2
Weekly downloads
 
Created
Source

fast-querystring

Test codecov NPM version

Fast query-string parser and stringifier to replace the legacy node:querystring module.

Installation

npm i fast-querystring

Features

  • Supports both parse and stringify methods from node:querystring module
  • Parsed object does not have prototype methods
  • Uses & separator as default
  • Supports only input of type string
  • Supports repeating keys in query string
    • foo=bar&foo=baz parses into {foo: ['bar', 'baz']}
  • Supports pairs with missing values
    • foo=bar&hola parses into {foo: 'bar', hola: ''}
  • Stringify does not support nested values (just like node:querystring)

Usage

const qs = require('fast-querystring')

// Parsing a querystring
console.log(qs.parse('hello=world&foo=bar&values=v1&values=v2'))
// {
//   hello: 'world',
//   foo: 'bar',
//   values: ['v1', 'v2']
// }

// Stringifying an object
console.log(qs.stringify({ foo: ['bar', 'baz'] }))
// 'foo=bar&foo=baz'

Benchmark

  • Parsing a query-string
> node benchmark/parse.mjs

╔═════════════════════════════════════════╤═════════╤═══════════════════╤═══════════╗
║ Slower tests                            │ Samples │            Result │ Tolerance ║
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────╢
║ qs                                      │   10000 │  350884.75 op/sec │  ± 1.36 % ║
║ query-string                            │   10000 │  383165.31 op/sec │  ± 1.22 % ║
║ querystringify                          │    1500 │  530280.43 op/sec │  ± 0.90 % ║
║ @aws-sdk/querystring-parser             │    2000 │  556657.27 op/sec │  ± 0.79 % ║
║ URLSearchParams-with-Object.fromEntries │   10000 │  845766.67 op/sec │  ± 2.85 % ║
║ URLSearchParams-with-construct          │   10000 │ 1158368.83 op/sec │  ± 4.28 % ║
║ node:querystring                        │    2000 │ 1460476.58 op/sec │  ± 0.96 % ║
║ querystringparser                       │   10000 │ 1976384.97 op/sec │  ± 4.11 % ║
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────╢
║ Fastest test                            │ Samples │            Result │ Tolerance ║
╟─────────────────────────────────────────┼─────────┼───────────────────┼───────────╢
║ fast-querystring                        │   10000 │ 2123713.08 op/sec │  ± 2.87 % ║
╚═════════════════════════════════════════╧═════════╧═══════════════════╧═══════════╝
  • Stringify a query-string
> node benchmark/stringify.mjs

╔══════════════════════════════╤═════════╤═══════════════════╤═══════════╗
║ Slower tests                 │ Samples │            Result │ Tolerance ║
╟──────────────────────────────┼─────────┼───────────────────┼───────────╢
║ query-string                 │   10000 │  310383.60 op/sec │  ± 1.14 % ║
║ qs                           │   10000 │  354332.59 op/sec │  ± 1.23 % ║
║ @aws-sdk/querystring-builder │   10000 │  411500.38 op/sec │  ± 1.30 % ║
║ http-querystring-stringify   │    1500 │  535883.47 op/sec │  ± 1.00 % ║
║ URLSearchParams              │   10000 │  594068.52 op/sec │  ± 1.61 % ║
║ querystringparser            │   10000 │  766081.64 op/sec │  ± 2.18 % ║
║ querystringify               │   10000 │  914083.38 op/sec │  ± 1.67 % ║
║ node:querystring             │    4000 │ 1822536.85 op/sec │  ± 0.91 % ║
╟──────────────────────────────┼─────────┼───────────────────┼───────────╢
║ Fastest test                 │ Samples │            Result │ Tolerance ║
╟──────────────────────────────┼─────────┼───────────────────┼───────────╢
║ fast-querystring             │   10000 │ 2186435.62 op/sec │  ± 3.48 % ║
╚══════════════════════════════╧═════════╧═══════════════════╧═══════════╝

Keywords

FAQs

Package last updated on 04 Jan 2023

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