New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@locustjs/querystring

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@locustjs/querystring

This library provides querystring utilities.

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
2
100%
Maintainers
1
Weekly downloads
 
Created
Source

locustjs-querystring

This library provides querystring utilities.

Installation

npm i @locustjs/querystring

functions

parseQuery: Parses strings in querystring format and returns a json object.

Example 1: basic example

import { parseQuery } from 'locustjs-querystring';

var result = parseQuery('name=John%20Doe&age=23&city=UK&agree=true');

console.log(result);

/*
  {
    age: "23",
    agree: "true",
    city: "UK",
    name: "John Doe",
  }
*/

Example 2: enabling automatic-conversion

import { parseQuery } from 'locustjs-querystring';

var result = parseQuery('name=John%20Doe&age=23&city=UK&agree=true', true);

console.log(result);

/*
  {
    age: 23,
    agree: true,
    city: "UK",
    name: "John Doe",
  }
*/

createQuery: converts a javascript object into querystring.

Example 1: basic example

import { createQuery } from 'locustjs-querystring';

var result = createQuery({ name: 'John Doe', age: 23, city: 'UK', agree: true });

console.log(result);

/*
  name=John%20Doe&age=23&city=UK&agree=true
*/

Example 2: using ignore props

import { createQuery } from 'locustjs-querystring';

var result = createQuery({ name: 'John Doe', age: 23, city: 'UK', agree: true }, 'age,city');

console.log(result);

/*
  name=John%20Doe&agree=true
*/

Helpers

QueryHelper: A helper object with two methods, parse() and stringify() that are maped to parseQuery and createQuery methods. This helper is exported as default object from library.

Example:

import QueryHelper from 'locustjs-querystring'

console.log(QueryHelper.parse('name=John%20Doe&agree=true'));  // { name: 'John Doe', agree: 'true' }
console.log(QueryHelper.stringify({ name: 'John Doe', age: 23 })); // name=John%20Doe&age=23

Keywords

javascript

FAQs

Package last updated on 23 May 2024

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