New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

query-string-utils

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

query-string-utils - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

12

package.json
{
"name": "query-string-utils",
"version": "0.1.0",
"description": "A small collection of helper functions for working with query strings.",
"version": "0.2.0",
"description": "A small collection of utility functions for working with query strings.",
"main": "lib/index.js",

@@ -11,7 +11,7 @@ "types": "lib/index.d.ts",

"lint": "tslint -p tsconfig.json",
"postversion" : "git push && git push --tags",
"prepublishOnly" : "npm test && npm run lint",
"preversion" : "npm run lint",
"postversion": "git push && git push --tags",
"prepublishOnly": "npm test && npm run lint",
"preversion": "npm run lint",
"test": "jest --config jestconfig.json",
"version" : "npm run format && git add -A src"
"version": "npm run format && git add -A src"
},

@@ -18,0 +18,0 @@ "files": [

@@ -14,3 +14,3 @@ # Query string utils

```js
import { getQsNumber, getQsNumbers, getQsString, getQsStrings } from 'query-string-utils';
import { getQsDate, getQsDates, getQsNumber, getQsNumbers, getQsString, getQsStrings } from 'query-string-utils';

@@ -20,3 +20,3 @@ const searchParams = new URLSearchParams(window.location.search);

// ?id=42
const id = getQsNumber(searchParams, 'id', 0);
const [ id = 0 ] = getQsNumber(searchParams, 'id');
console.log(id);

@@ -26,3 +26,3 @@ //=> 42

// ?id=13&id=30&id=7
const ids = getQsNumbers(searchParams, 'id', []);
const ids = getQsNumber(searchParams, 'id');
console.log(ids);

@@ -32,3 +32,3 @@ //=> [13, 30, 7]

// ?key=foo
const key = getQsString(searchParams, 'key', '');
const [ key = '' ] = getQsString(searchParams, 'key');
console.log(key);

@@ -38,5 +38,25 @@ //=> 'foo'

// ?key=foo&key=bar&key=baz
const keys = getQsStrings(searchParams, 'key', []);
const keys = getQsString(searchParams, 'key');
console.log(keys);
//=> ['foo', 'bar', 'baz']
// ?key=1970-01-01T13:30:07
const [ date = new Date() ] = getQsDate(searchParams, 'date');
console.log(date);
//=> Date Thu Jan 01 1970 13:30:07 GMT+0100 (Central European Standard Time)
// ?date=1962-10-16&date=1962-10-28
const dates = getQsDate(searchParams, 'date');
console.log(dates);
//=> [ Date Tue Oct 16 1962 01:00:00 GMT+0100 (Central European Standard Time), Date Sun Oct 28 1962 01:00:00 GMT+0100 (Central European Standard Time) ]
// ?status=true
const [ status = false ] = getQsBoolean(searchParams, 'status');
console.log(active);
//=> true
// ?status=true&status=yes&status=false&status=on
const statuses = getQsBoolean(searchParams, 'status');
console.log(statuses);
//=> true, true, false, true
```
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