mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-23 21:00:01 +08:00
Add query-string
This commit is contained in:
13
query-string/query-string-tests.ts
Normal file
13
query-string/query-string-tests.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/// <reference path="./query-string.d.ts" />
|
||||
|
||||
import qs = require('query-string');
|
||||
|
||||
qs.stringify({ foo: 'bar' });
|
||||
qs.stringify({ foo: 'bar', bar: 'baz' });
|
||||
|
||||
qs.parse('?foo=bar');
|
||||
qs.parse('#foo=bar');
|
||||
qs.parse('&foo=bar&foo=baz');
|
||||
|
||||
qs.extract('http://foo.bar/?abc=def&hij=klm');
|
||||
qs.extract('http://foo.bar/?foo=bar');
|
||||
27
query-string/query-string.d.ts
vendored
Normal file
27
query-string/query-string.d.ts
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
// Type definitions for query-string v3.0.0
|
||||
// Project: https://github.com/sindresorhus/query-string
|
||||
// Definitions by: Sam Verschueren <https://github.com/SamVerschueren>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare module "query-string" {
|
||||
/**
|
||||
* Parse a query string into an object.
|
||||
* Leading ? or # are ignored, so you can pass location.search or location.hash directly.
|
||||
* @param str
|
||||
*/
|
||||
export function parse(str: string): any;
|
||||
|
||||
/**
|
||||
* Stringify an object into a query string, sorting the keys.
|
||||
*
|
||||
* @param obj
|
||||
*/
|
||||
export function stringify(obj: any): string;
|
||||
|
||||
/**
|
||||
* Extract a query string from a URL that can be passed into .parse().
|
||||
*
|
||||
* @param str
|
||||
*/
|
||||
export function extract(str: string): string;
|
||||
}
|
||||
Reference in New Issue
Block a user