From 6cca6281c4bc6b482e77ba34a9c11f75baf95f7f Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Wed, 23 May 2018 18:36:11 +0300 Subject: [PATCH 1/4] is-svg: Allow Buffer input --- types/is-svg/index.d.ts | 4 +++- types/is-svg/is-svg-tests.ts | 6 +++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/types/is-svg/index.d.ts b/types/is-svg/index.d.ts index 21e85cd2e2..568810f94b 100644 --- a/types/is-svg/index.d.ts +++ b/types/is-svg/index.d.ts @@ -3,6 +3,8 @@ // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +/// + export = isSvg; -declare function isSvg(input: string): boolean; +declare function isSvg(input: string | Buffer): boolean; diff --git a/types/is-svg/is-svg-tests.ts b/types/is-svg/is-svg-tests.ts index d556a944f9..d9ccb6f3db 100644 --- a/types/is-svg/is-svg-tests.ts +++ b/types/is-svg/is-svg-tests.ts @@ -1,3 +1,7 @@ import isSvg = require('is-svg'); -const result: boolean = isSvg(''); +const dataString = ''; +const dataBuffer = Buffer.from(dataString); + +const resultString: boolean = isSvg(dataString); +const resultBuffer: boolean = isSvg(dataBuffer); From 512616ac65e48a695af085529a5705b02c5b2f38 Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Wed, 23 May 2018 18:47:33 +0300 Subject: [PATCH 2/4] is-svg: Allow falsy input --- types/is-svg/index.d.ts | 2 +- types/is-svg/is-svg-tests.ts | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/types/is-svg/index.d.ts b/types/is-svg/index.d.ts index 568810f94b..9e36b57b45 100644 --- a/types/is-svg/index.d.ts +++ b/types/is-svg/index.d.ts @@ -7,4 +7,4 @@ export = isSvg; -declare function isSvg(input: string | Buffer): boolean; +declare function isSvg(input?: string | Buffer | false | null): boolean; diff --git a/types/is-svg/is-svg-tests.ts b/types/is-svg/is-svg-tests.ts index d9ccb6f3db..fe68014630 100644 --- a/types/is-svg/is-svg-tests.ts +++ b/types/is-svg/is-svg-tests.ts @@ -1,7 +1,11 @@ import isSvg = require('is-svg'); -const dataString = ''; -const dataBuffer = Buffer.from(dataString); +const data = ''; +let result = false; -const resultString: boolean = isSvg(dataString); -const resultBuffer: boolean = isSvg(dataBuffer); +result = isSvg(data); +result = isSvg(Buffer.from(data)); +result = isSvg(false); +result = isSvg(null); +result = isSvg(undefined); +result = isSvg(); From 4a7b434868f8ad87e539c54266fb15c9e85f4022 Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Wed, 23 May 2018 18:54:24 +0300 Subject: [PATCH 3/4] is-svg: Bump to 3.0 --- types/is-svg/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/is-svg/index.d.ts b/types/is-svg/index.d.ts index 9e36b57b45..1fbdc486ad 100644 --- a/types/is-svg/index.d.ts +++ b/types/is-svg/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for is-svg 2.1 +// Type definitions for is-svg 3.0 // Project: https://github.com/sindresorhus/is-svg#readme // Definitions by: BendingBender // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 5f80843518a77463eb23e6b5e9618e0c375f0729 Mon Sep 17 00:00:00 2001 From: Olegs Jeremejevs Date: Wed, 23 May 2018 19:07:28 +0300 Subject: [PATCH 4/4] is-svg: Export namespace --- types/is-svg/index.d.ts | 7 +++++-- types/is-svg/is-svg-tests.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/types/is-svg/index.d.ts b/types/is-svg/index.d.ts index 1fbdc486ad..54ebb84457 100644 --- a/types/is-svg/index.d.ts +++ b/types/is-svg/index.d.ts @@ -5,6 +5,9 @@ /// -export = isSvg; - declare function isSvg(input?: string | Buffer | false | null): boolean; + +// So that `import * as X` is possible +declare namespace isSvg {} + +export = isSvg; diff --git a/types/is-svg/is-svg-tests.ts b/types/is-svg/is-svg-tests.ts index fe68014630..73ba29062c 100644 --- a/types/is-svg/is-svg-tests.ts +++ b/types/is-svg/is-svg-tests.ts @@ -1,4 +1,4 @@ -import isSvg = require('is-svg'); +import * as isSvg from 'is-svg'; const data = ''; let result = false;