JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 9563
  • Score
    100M100P100Q126267F
  • License ISC

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

Package Exports

  • object-query-string

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (object-query-string) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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!