JSPM

@aaronhayes/qstring

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q32609F
  • License MIT

The easiest way to build query strings

Package Exports

  • @aaronhayes/qstring

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 (@aaronhayes/qstring) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

qstring

npm (scoped) Build Codecov npm bundle size (scoped) NPM

The easiest way to build querystrings. I wanted a lightweight, easy to use way to build full urls including the querystring.

The popular query-string only handles the part querystring part, so there is another step of building the final url. The API inspired by JedWatson's Classnames Package.

Install

$ npm install --save @aaronhayes/qstring
$ yarn add @aaronhayes/qstring

Usage

import qstring, { ArrayFormat } from 'qstring';

const qs = qstring('https://myapi.com', {
    foo: 'bar',
    foobar: true,
    foo3: null,
    foo4: undefined
});

console.log(qs);
// https://myapi.com?foo=bar&foobar=true

const qs = qstring(
    'https://myapi.com',
    {
        foo: ['hello', 'world'],
        cat: 'dog'
    }
);

console.log(qs);
// https://myapi.com?foo=hello&foo=world&cat=dog

const qs = qstring(
    'https://myapi.com',
    {
        foo: ['hello', 'world'],
        cat: 'dog'
    },
    ArrayFormat.comma
);

console.log(qs);
// https://myapi.com?foo=hello,world&cat=dog

See Also