Skip to content

Commit

Permalink
parse-prefer-header: More specific typings (#42642)
Browse files Browse the repository at this point in the history
* 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
marcelltoth committed Feb 26, 2020
1 parent 92a3a40 commit cd414cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions types/parse-prefer-header/index.d.ts
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;
9 changes: 8 additions & 1 deletion types/parse-prefer-header/parse-prefer-header-tests.ts
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);

0 comments on commit cd414cb

Please sign in to comment.