mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 19:07:08 +00:00
Added declarations for content-disposition (#13191)
* Added declarations for content-disposition * Fixed missing semicolon * Added empty function * Made ContentDisposition an interface instead of a class * Filename may be undefined but not void
This commit is contained in:
parent
f599b18306
commit
edfee9d9ee
10
content-disposition/content-disposition-tests.ts
Normal file
10
content-disposition/content-disposition-tests.ts
Normal file
@ -0,0 +1,10 @@
|
||||
import contentDisposition = require("content-disposition");
|
||||
|
||||
const noParams = contentDisposition();
|
||||
const withFilenameNoOptions = contentDisposition("EURO rates.txt");
|
||||
const withFilenameAndOptions = contentDisposition("€ rates.txt", { type: "attachment", fallback: "EURO rates.txt" });
|
||||
const noFilename = contentDisposition(undefined, { type: "attachment", fallback: true });
|
||||
|
||||
const res = contentDisposition.parse('attachment; filename="EURO rates.txt"');
|
||||
const type = res.type;
|
||||
const parameters = res.parameters;
|
||||
24
content-disposition/index.d.ts
vendored
Normal file
24
content-disposition/index.d.ts
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
// Type definitions for content-disposition 0.5
|
||||
// Project: https://github.com/jshttp/content-disposition
|
||||
// Definitions by: Stefan Reichel <https://github.com/bomret>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare namespace contentDisposition {
|
||||
export interface ContentDisposition {
|
||||
type: string;
|
||||
parameters: any;
|
||||
}
|
||||
|
||||
export interface Options {
|
||||
type?: string;
|
||||
fallback?: string | boolean;
|
||||
}
|
||||
|
||||
export function parse(contentDispositionHeader: string): ContentDisposition;
|
||||
}
|
||||
|
||||
declare function contentDisposition(): string;
|
||||
declare function contentDisposition(filename: undefined, options: contentDisposition.Options): string;
|
||||
declare function contentDisposition(filename: string, options?: contentDisposition.Options): string;
|
||||
|
||||
export = contentDisposition;
|
||||
19
content-disposition/tsconfig.json
Normal file
19
content-disposition/tsconfig.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"noImplicitAny": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"content-disposition-tests.ts"
|
||||
]
|
||||
}
|
||||
1
content-disposition/tslint.json
Normal file
1
content-disposition/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "../tslint.json" }
|
||||
Loading…
Reference in New Issue
Block a user