mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
Add types for append-query (#35997)
This commit is contained in:
parent
8d45842583
commit
695e81c90d
13
types/append-query/append-query-tests.ts
Normal file
13
types/append-query/append-query-tests.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import appendQuery = require('append-query');
|
||||
|
||||
appendQuery('http://example.com/foo', 'bar=baz&beep=boop');
|
||||
|
||||
appendQuery('http://example.com/?foo=bar', 'hello=world');
|
||||
|
||||
appendQuery('http://example.com/', { beep: 'boop' });
|
||||
|
||||
appendQuery('http://example.com/', { nothing: null });
|
||||
|
||||
appendQuery('http://example.com/', { preEncoded: '%22hello%2C%20world!%22' }, { encodeComponents: false });
|
||||
|
||||
appendQuery('http://example.com/?test=1', { test: null }, { removeNull: true });
|
||||
31
types/append-query/index.d.ts
vendored
Normal file
31
types/append-query/index.d.ts
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Type definitions for append-query 2.0
|
||||
// Project: https://github.com/lakenen/node-append-query
|
||||
// Definitions by: Florian Keller <https://github.com/ffflorian>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace appendQuery {
|
||||
interface Query {
|
||||
[index: string]: string | null;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
/**
|
||||
* whether or not to encode appended passed params using `encodeURIComponent`.
|
||||
* Default: `true`.
|
||||
*/
|
||||
encodeComponents?: boolean;
|
||||
/**
|
||||
* whether or not to remove params for `null` properties in the query object.
|
||||
* Default: `false` (properties will be preserved with no value).
|
||||
*/
|
||||
removeNull?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url a string URL to append to
|
||||
* @param query a string or object containing query params to append
|
||||
*/
|
||||
declare function appendQuery(url: string, query: string | appendQuery.Query, options?: appendQuery.Options): string;
|
||||
|
||||
export = appendQuery;
|
||||
23
types/append-query/tsconfig.json
Normal file
23
types/append-query/tsconfig.json
Normal file
@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"append-query-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/append-query/tslint.json
Normal file
1
types/append-query/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Loading…
Reference in New Issue
Block a user