query2string

    1.0.1 • Public • Published

    Parse and stringify URL query strings




    安装

    $ npm install query2string
    

    用法

    import * as queryString from "query2string";
     
    const parsed = queryString.parse(location.search);
    //=> {foo: 'bar'}

    常用 API

    .parse(string, options?)

    options

    Type: object

    import * as queryString from "query2string";
     
    const parsed = queryString.parse(location.search);
    console.log(parsed);

    .stringify(object, options?)

    options

    Type: object

    import * as queryString from "query2string";
     
    queryString.stringify({ foo: [1, 2, 3] });
    //=> 'foo=1&foo=2&foo=3'

    .parseUrl(string, options?)

    import * as queryString from "query2string";
     
    queryString.parseUrl("https://foo.bar?foo=bar");
    //=> {url: 'https://foo.bar', query: {foo: 'bar'}}

    .stringifyUrl(object, options?)

    import * as queryString from "query2string";
     
    queryString.stringifyUrl({
      url: "https://foo.bar?foo=baz",
      query: { foo: "bar" },
    });
    //=> 'https://foo.bar?foo=bar'

    Install

    npm i query2string

    DownloadsWeekly Downloads

    0

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    11.5 kB

    Total Files

    3

    Last publish

    Collaborators

    • dengpeng840