DefinitelyTyped/types/media-typer/media-typer-tests.ts
Piotr Błażejewicz (Peter Blazejewicz) a08ce5ef58
update(media-typer): version 1.1 (#44279)
* update(media-typer): version 1.1

- add new `test` method
- missing docs comments
- version bump to 1.1
- v0 created for compatibility
- maintainer added

https://github.com/jshttp/media-typer/compare/v0.3.0...v1.1.0
https://github.com/jshttp/media-typer#typerteststring

Thanks!

* Update types/media-typer/index.d.ts

thx to @sandersn

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* Update types/media-typer/index.d.ts

thx to @sandersn

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-05-12 12:55:24 -07:00

19 lines
428 B
TypeScript

import typer = require('media-typer');
const obj = typer.parse('image/svg+xml');
// $ExpectType MediaType
obj;
// $ExpectType string
obj.type;
// $ExpectType string
obj.subtype;
// $ExpectType string | undefined
obj.suffix;
// $ExpectType string
typer.format({ type: 'image', subtype: 'svg', suffix: 'xml' });
typer.format({ type: 'image', subtype: 'svg' });
// $ExpectType boolean
const valid = typer.test('image/svg+xml');