Socket
Socket
Sign inDemoInstall

tiny-params

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tiny-params

A tiny URL param parser, suitable for server or browser


Version published
Weekly downloads
204
increased by2%
Maintainers
1
Install size
5.56 kB
Created
Weekly downloads
 

Readme

Source
SCRUD
NPM version js-standard-style

tiny-params

A tiny URL param parser, suitable for server or browser

highlights

  • it's tiny (< 25 sloc)
  • it's highly browser compatible (IE6 and everything else)
  • it ships with both ES6 and CommonJS modules
  • it makes repeated keys an array ?a=1&a=2 -> { a: [1, 2] }
  • it handles explicit arrays ?a[]=1 -> { a: [1] }
  • it handles flags (key with no value) ?a=b&flag -> { a: 'b', flag: true }
  • it decodes encodeURIComponent encoded items
  • it converts booleans and numbers from strings
  • it converts the values 'null' and 'undefined' to null
  • it respects the hash (as per RFC 3986)
  • it's competitively fast (not the fastest, not far from it)

lowlights

  • it looks like code golf, kind of is
  • it uses decodeURIComponent (sparingly) which is slow (but highly compatible)

install

$ npm install --save tiny-params

usage

const tinyParams = require('tiny-params')
const url = 'http://localhost:80/base/res?name=andrew&zip=37615&zip=37601'
const params = tinyParams(url)
// params === { name: 'andrew', zip: [37615, 37601] }

License

MIT © Andrew Carpenter

Keywords

FAQs

Last updated on 13 Mar 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