type-is
3.0.0 · 21 Sep 2026MIT211.4M / weekRepositoryHomepagenpmAtom feed
41 stable releases, newest first, by release line. Notes are quoted as the maintainers published them.
- 3.x · latest line
3.0.0
21 Sep 2026Publish the package as ESM and bump to node 22 (#106)
Publishes built-in types using TypeScript (#94)
Refactors the API shape to a class (#103)
This version switches the package to ESM and node >= 22.
Changed:
Publish the package as ESM and bump to node 22 (#106)
Publishes built-in types using TypeScript (#94)
Refactors the API shape to a class (#103)
2-4x faster by initializing the class once (instead of every request)
20% faster by initializing inline (e.g. every request)
Added support for matching parameters too (e.g.
text/html; charset=utf-8)Returns the original input string not the matched MIME type
Previously
text/*would return e.g.text/htmlon match, now it returns the originaltext/*
Returns
undefinedinstead offalseon no matchReturns
undefinedwhen no input types are definedThrows on invalid MIME type used to construct the matcher (e.g.
new TypeIs(["invalid"]), it does not error if the header is invalid)
Matches return the original input string (#109)
Removed:
Removes
mime-typesfrom the package, only has 3 built in "shortcuts" (e.g.json->application/json)Pass
mime-types.lookupas an option to override
Before:
const isText = typeis(req, ['text/*'])
After:
const isText = new TypeIs(['text/*']).request(req);
If you are upgrading an upstream dependency (e.g. express), and want maximum compatibility, something like this can help with compatibility for the extension aliases:
import * as mimeTypes from 'mime-types'; import { TypeIs, DEFAULT_LOOKUP } from 'type-is'; function lookup (value) { return mimeTypes.lookup(value) || DEFAULT_LOOKUP(value); } req.is = function (types) { const matcher = new TypeIs(types, { lookup }); return matcher.request(this); };However the returned string has changed. Backward compatibility with the old string is achievable by mimicking the old behavior -- parse the MIME type yourself (example) and use the
matcher.contentTypemethod. This is not recommended though.- 2.x
2.1.0
13 May 2026Reading the note…
2.0.1
27 Mar 2025Reading the note…
2.0.0
31 Aug 2024Reading the note…
- 1.x
1.6.18
26 Apr 2019Reading the note…
1.6.17
25 Apr 2019Reading the note…
1.6.16
16 Feb 2018Reading the note…
1.6.15
1 Apr 2017Reading the note…
1.6.14
19 Nov 2016Reading the note…
1.6.13
19 May 2016Reading the note…
1.6.12
29 Feb 2016Reading the note…
1.6.11
30 Jan 2016Reading the note…
1.6.10
1 Dec 2015Reading the note…
1.6.9
28 Sep 2015Reading the note…
1.6.8
4 Sep 2015Reading the note…
1.6.7
20 Aug 2015Reading the note…
1.6.6
31 Jul 2015Reading the note…
1.6.5
17 Jul 2015Reading the note…
1.6.4
2 Jul 2015Reading the note…
1.6.3
8 Jun 2015Reading the note…
1.6.2
11 May 2015Reading the note…
1.6.1
14 Mar 2015Reading the note…
1.6.0
13 Feb 2015Reading the note…
1.5.7
10 Feb 2015Reading the note…
1.5.6
30 Jan 2015Reading the note…
1.5.5
31 Dec 2014Reading the note…
1.5.4
11 Dec 2014Reading the note…
1.5.3
9 Nov 2014Reading the note…
1.5.2
29 Sep 2014Reading the note…
1.5.1
8 Sep 2014Reading the note…
1.5.0
5 Sep 2014Reading the note…
1.4.0
2 Sep 2014Reading the note…
1.3.2
25 Jun 2014Reading the note…
1.3.1
20 Jun 2014Reading the note…
1.3.0
20 Jun 2014Reading the note…
1.2.2
20 Jun 2014Reading the note…
1.2.1
4 Jun 2014Reading the note…
1.2.0
12 May 2014Reading the note…
1.1.0
13 Apr 2014Reading the note…
1.0.1
30 Mar 2014Reading the note…
1.0.0
28 Dec 2013Reading the note…