You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

object-query-string

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

object-query-string

Stringify objects as URL Query Strings, a lightweight mock of jQuery.param without any dependencies!

1.2.0
latest
Source
npm
Version published
Weekly downloads
21K
-0.49%
Maintainers
1
Weekly downloads
 
Created
Source

Object Query String

Stringify objects as URL Query Strings.

A lightweight mock of jQuery.param function without any dependencies!

Example

// TypeScript
import { queryString } from 'object-query-string';

// Node.js
const { queryString } = require("object-query-string");

const query = queryString({
    filter: {
        brands: ["Audi"],
        models: ["A4", "A6", "A8"],
        accidentFree: true
    },
    sort: 'mileage'
});

returns

filter[brands][]=Audi&filter[models][]=A4&filter[models][]=A6&filter[models][]=A8&filter[accidentFree]=true&sort=milage

Options

// queryString(params : string, options : object|undefined)

// default options
queryString(params, {
    separator: '&', // string 
    encode: encodeURIComponent, // function(string) : string
    encodeBrackets: false, // foo[baz]=1 or foo%5Bbaz%5D=1
});

Inspired by jQuery's param!

Keywords

node

FAQs

Package last updated on 06 Nov 2021

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