-
Notifications
You must be signed in to change notification settings - Fork 29.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse-prefer-header: More specific typings (#42642)
* parse-prefer-header: Allow null or undefined input * parse-prefer-header: More explicit return value typing * parse-prefer-header: amend contributor list * parse-prefer-header: Support ReadonlyArray argument * parse-prefer-header: Add separate tests for Array and ReadonlyArray
- Loading branch information
1 parent
92a3a40
commit cd414cb
Showing
2 changed files
with
10 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
// Type definitions for parse-prefer-header 1.0 | ||
// Project: https://github.com/ppaskaris/node-parse-prefer-header | ||
// Definitions by: Vincenzo Chianese <https://github.com/XVincentX> | ||
// Definitions by: Vincenzo Chianese <https://github.com/XVincentX>, Marcell Toth <https://github.com/marcelltoth> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
|
||
declare function parsePreferHeader(preferHeader: string | string[]): { [key: string]: string | boolean }; | ||
declare function parsePreferHeader(preferHeader: string | ReadonlyArray<string> | null | undefined): { [key: string]: string | true }; | ||
|
||
export = parsePreferHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
import parsePreferHeader = require('parse-prefer-header'); | ||
|
||
parsePreferHeader(['respond-async, wait=100', 'handling=lenient']); | ||
const testArray = ['respond-async, wait=100', 'handling=lenient']; | ||
|
||
const readonlyTestArray: ReadonlyArray<string> = testArray; | ||
|
||
parsePreferHeader(testArray); | ||
parsePreferHeader(readonlyTestArray); | ||
parsePreferHeader(''); | ||
parsePreferHeader(null); | ||
parsePreferHeader(undefined); |